Completed
Branch master (44537d)
by
unknown
14:30 queued 10:03
created
admin/extend/events/espresso_events_Events_Hooks_Extend.class.php 2 patches
Indentation   +2324 added lines, -2324 removed lines patch added patch discarded remove patch
@@ -15,2342 +15,2342 @@
 block discarded – undo
15 15
  */
16 16
 class espresso_events_Events_Hooks_Extend extends EE_Admin_Hooks
17 17
 {
18
-    /**
19
-     * This property is just used to hold the status of whether an event is currently being
20
-     * created (true) or edited (false)
21
-     *
22
-     * @access protected
23
-     * @var bool
24
-     */
25
-    protected $_is_creating_event;
26
-
27
-    /**
28
-     * Used to contain the format strings for date and time that will be used for php date and
29
-     * time.
30
-     * Is set in the _set_hooks_properties() method.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $_date_format_strings;
35
-
36
-    /**
37
-     * @var string $_date_time_format
38
-     */
39
-    protected $_date_time_format;
40
-
41
-
42
-    /**
43
-     * @throws InvalidArgumentException
44
-     * @throws InvalidInterfaceException
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    protected function _set_hooks_properties()
48
-    {
49
-        $this->_name = 'events';
50
-        // capability check
51
-        if (
52
-            $this->_adminpage_obj->adminConfig()->useAdvancedEditor()
53
-            || ! EE_Registry::instance()->CAP->current_user_can(
54
-                'ee_read_default_prices',
55
-                'advanced_ticket_datetime_metabox'
56
-            )
57
-        ) {
58
-            $this->_metaboxes      = [];
59
-            $this->_scripts_styles = [];
60
-            return;
61
-        }
62
-        $this->_setup_metaboxes();
63
-        $this->_set_date_time_formats();
64
-        $this->_validate_format_strings();
65
-        $this->_set_scripts_styles();
66
-        add_filter(
67
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
68
-            [$this, 'caf_updates']
69
-        );
70
-    }
71
-
72
-
73
-    /**
74
-     * @return void
75
-     */
76
-    protected function _setup_metaboxes()
77
-    {
78
-        // if we were going to add our own metaboxes we'd use the below.
79
-        $this->_metaboxes        = [
80
-            0 => [
81
-                'page_route' => ['edit', 'create_new'],
82
-                'func'       => [$this, 'pricing_metabox'],
83
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
84
-                'priority'   => 'high',
85
-                'context'    => 'normal',
86
-            ],
87
-        ];
88
-        $this->_remove_metaboxes = [
89
-            0 => [
90
-                'page_route' => ['edit', 'create_new'],
91
-                'id'         => 'espresso_event_editor_tickets',
92
-                'context'    => 'normal',
93
-            ],
94
-        ];
95
-    }
96
-
97
-
98
-    /**
99
-     * @return void
100
-     */
101
-    protected function _set_date_time_formats()
102
-    {
103
-        /**
104
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
105
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
106
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
107
-         *
108
-         * @since 4.6.7
109
-         * @var array  Expected an array returned with 'date' and 'time' keys.
110
-         */
111
-        $this->_date_format_strings = apply_filters(
112
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
113
-            [
114
-                'date' => 'Y-m-d',
115
-                'time' => 'h:i a',
116
-            ]
117
-        );
118
-        // validate
119
-        $this->_date_format_strings['date'] = $this->_date_format_strings['date'] ?? '';
120
-        $this->_date_format_strings['time'] = $this->_date_format_strings['time'] ?? '';
121
-
122
-        $this->_date_time_format = $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'];
123
-    }
124
-
125
-
126
-    /**
127
-     * @return void
128
-     */
129
-    protected function _validate_format_strings()
130
-    {
131
-        // validate format strings
132
-        $format_validation = EEH_DTT_Helper::validate_format_string(
133
-            $this->_date_time_format
134
-        );
135
-        if (is_array($format_validation)) {
136
-            $msg = '<p>';
137
-            $msg .= sprintf(
138
-                esc_html__(
139
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
140
-                    'event_espresso'
141
-                ),
142
-                $this->_date_time_format
143
-            );
144
-            $msg .= '</p><ul>';
145
-            foreach ($format_validation as $error) {
146
-                $msg .= '<li>' . $error . '</li>';
147
-            }
148
-            $msg .= '</ul><p>';
149
-            $msg .= sprintf(
150
-                esc_html__(
151
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
152
-                    'event_espresso'
153
-                ),
154
-                '<span style="color:#D54E21;">',
155
-                '</span>'
156
-            );
157
-            $msg .= '</p>';
158
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
159
-            $this->_date_format_strings = [
160
-                'date' => 'Y-m-d',
161
-                'time' => 'h:i a',
162
-            ];
163
-        }
164
-    }
165
-
166
-
167
-    /**
168
-     * @return void
169
-     */
170
-    protected function _set_scripts_styles()
171
-    {
172
-        $this->_scripts_styles = [
173
-            'registers'   => [
174
-                'ee-tickets-datetimes-css' => [
175
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
176
-                    'type' => 'css',
177
-                ],
178
-                'ee-dtt-ticket-metabox'    => [
179
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
180
-                    'depends' => ['ee-datepicker', 'ee-dialog', 'underscore'],
181
-                ],
182
-            ],
183
-            'deregisters' => [
184
-                'event-editor-css'       => ['type' => 'css'],
185
-                'event-datetime-metabox' => ['type' => 'js'],
186
-            ],
187
-            'enqueues'    => [
188
-                'ee-tickets-datetimes-css' => ['edit', 'create_new'],
189
-                'ee-dtt-ticket-metabox'    => ['edit', 'create_new'],
190
-            ],
191
-            'localize'    => [
192
-                'ee-dtt-ticket-metabox' => [
193
-                    'DTT_TRASH_BLOCK'       => [
194
-                        'main_warning'            => esc_html__(
195
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
196
-                            'event_espresso'
197
-                        ),
198
-                        'after_warning'           => esc_html__(
199
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
200
-                            'event_espresso'
201
-                        ),
202
-                        'cancel_button'           => '
18
+	/**
19
+	 * This property is just used to hold the status of whether an event is currently being
20
+	 * created (true) or edited (false)
21
+	 *
22
+	 * @access protected
23
+	 * @var bool
24
+	 */
25
+	protected $_is_creating_event;
26
+
27
+	/**
28
+	 * Used to contain the format strings for date and time that will be used for php date and
29
+	 * time.
30
+	 * Is set in the _set_hooks_properties() method.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $_date_format_strings;
35
+
36
+	/**
37
+	 * @var string $_date_time_format
38
+	 */
39
+	protected $_date_time_format;
40
+
41
+
42
+	/**
43
+	 * @throws InvalidArgumentException
44
+	 * @throws InvalidInterfaceException
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	protected function _set_hooks_properties()
48
+	{
49
+		$this->_name = 'events';
50
+		// capability check
51
+		if (
52
+			$this->_adminpage_obj->adminConfig()->useAdvancedEditor()
53
+			|| ! EE_Registry::instance()->CAP->current_user_can(
54
+				'ee_read_default_prices',
55
+				'advanced_ticket_datetime_metabox'
56
+			)
57
+		) {
58
+			$this->_metaboxes      = [];
59
+			$this->_scripts_styles = [];
60
+			return;
61
+		}
62
+		$this->_setup_metaboxes();
63
+		$this->_set_date_time_formats();
64
+		$this->_validate_format_strings();
65
+		$this->_set_scripts_styles();
66
+		add_filter(
67
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
68
+			[$this, 'caf_updates']
69
+		);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return void
75
+	 */
76
+	protected function _setup_metaboxes()
77
+	{
78
+		// if we were going to add our own metaboxes we'd use the below.
79
+		$this->_metaboxes        = [
80
+			0 => [
81
+				'page_route' => ['edit', 'create_new'],
82
+				'func'       => [$this, 'pricing_metabox'],
83
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
84
+				'priority'   => 'high',
85
+				'context'    => 'normal',
86
+			],
87
+		];
88
+		$this->_remove_metaboxes = [
89
+			0 => [
90
+				'page_route' => ['edit', 'create_new'],
91
+				'id'         => 'espresso_event_editor_tickets',
92
+				'context'    => 'normal',
93
+			],
94
+		];
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return void
100
+	 */
101
+	protected function _set_date_time_formats()
102
+	{
103
+		/**
104
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
105
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
106
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
107
+		 *
108
+		 * @since 4.6.7
109
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
110
+		 */
111
+		$this->_date_format_strings = apply_filters(
112
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
113
+			[
114
+				'date' => 'Y-m-d',
115
+				'time' => 'h:i a',
116
+			]
117
+		);
118
+		// validate
119
+		$this->_date_format_strings['date'] = $this->_date_format_strings['date'] ?? '';
120
+		$this->_date_format_strings['time'] = $this->_date_format_strings['time'] ?? '';
121
+
122
+		$this->_date_time_format = $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'];
123
+	}
124
+
125
+
126
+	/**
127
+	 * @return void
128
+	 */
129
+	protected function _validate_format_strings()
130
+	{
131
+		// validate format strings
132
+		$format_validation = EEH_DTT_Helper::validate_format_string(
133
+			$this->_date_time_format
134
+		);
135
+		if (is_array($format_validation)) {
136
+			$msg = '<p>';
137
+			$msg .= sprintf(
138
+				esc_html__(
139
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
140
+					'event_espresso'
141
+				),
142
+				$this->_date_time_format
143
+			);
144
+			$msg .= '</p><ul>';
145
+			foreach ($format_validation as $error) {
146
+				$msg .= '<li>' . $error . '</li>';
147
+			}
148
+			$msg .= '</ul><p>';
149
+			$msg .= sprintf(
150
+				esc_html__(
151
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
152
+					'event_espresso'
153
+				),
154
+				'<span style="color:#D54E21;">',
155
+				'</span>'
156
+			);
157
+			$msg .= '</p>';
158
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
159
+			$this->_date_format_strings = [
160
+				'date' => 'Y-m-d',
161
+				'time' => 'h:i a',
162
+			];
163
+		}
164
+	}
165
+
166
+
167
+	/**
168
+	 * @return void
169
+	 */
170
+	protected function _set_scripts_styles()
171
+	{
172
+		$this->_scripts_styles = [
173
+			'registers'   => [
174
+				'ee-tickets-datetimes-css' => [
175
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
176
+					'type' => 'css',
177
+				],
178
+				'ee-dtt-ticket-metabox'    => [
179
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
180
+					'depends' => ['ee-datepicker', 'ee-dialog', 'underscore'],
181
+				],
182
+			],
183
+			'deregisters' => [
184
+				'event-editor-css'       => ['type' => 'css'],
185
+				'event-datetime-metabox' => ['type' => 'js'],
186
+			],
187
+			'enqueues'    => [
188
+				'ee-tickets-datetimes-css' => ['edit', 'create_new'],
189
+				'ee-dtt-ticket-metabox'    => ['edit', 'create_new'],
190
+			],
191
+			'localize'    => [
192
+				'ee-dtt-ticket-metabox' => [
193
+					'DTT_TRASH_BLOCK'       => [
194
+						'main_warning'            => esc_html__(
195
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
196
+							'event_espresso'
197
+						),
198
+						'after_warning'           => esc_html__(
199
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
200
+							'event_espresso'
201
+						),
202
+						'cancel_button'           => '
203 203
                             <button class="button--secondary ee-modal-cancel">
204 204
                                 ' . esc_html__('Cancel', 'event_espresso') . '
205 205
                             </button>',
206
-                        'close_button'            => '
206
+						'close_button'            => '
207 207
                             <button class="button--secondary ee-modal-cancel">
208 208
                                 ' . esc_html__('Close', 'event_espresso') . '
209 209
                             </button>',
210
-                        'single_warning_from_tkt' => esc_html__(
211
-                            'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
212
-                            'event_espresso'
213
-                        ),
214
-                        'single_warning_from_dtt' => esc_html__(
215
-                            'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
216
-                            'event_espresso'
217
-                        ),
218
-                        'dismiss_button'          => '
210
+						'single_warning_from_tkt' => esc_html__(
211
+							'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
212
+							'event_espresso'
213
+						),
214
+						'single_warning_from_dtt' => esc_html__(
215
+							'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
216
+							'event_espresso'
217
+						),
218
+						'dismiss_button'          => '
219 219
                             <button class="button--secondary ee-modal-cancel">
220 220
                                 ' . esc_html__('Dismiss', 'event_espresso') . '
221 221
                             </button>',
222
-                    ],
223
-                    'DTT_ERROR_MSG'         => [
224
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
225
-                        'dismiss_button' => '
222
+					],
223
+					'DTT_ERROR_MSG'         => [
224
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
225
+						'dismiss_button' => '
226 226
                             <div class="save-cancel-button-container">
227 227
                                 <button class="button--secondary ee-modal-cancel">
228 228
                                     ' . esc_html__('Dismiss', 'event_espresso') . '
229 229
                                 </button>
230 230
                             </div>',
231
-                    ],
232
-                    'DTT_OVERSELL_WARNING'  => [
233
-                        'datetime_ticket' => esc_html__(
234
-                            'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
235
-                            'event_espresso'
236
-                        ),
237
-                        'ticket_datetime' => esc_html__(
238
-                            'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
239
-                            'event_espresso'
240
-                        ),
241
-                    ],
242
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
243
-                        $this->_date_format_strings['date'],
244
-                        $this->_date_format_strings['time']
245
-                    ),
246
-                    'DTT_START_OF_WEEK'     => ['dayValue' => (int) get_option('start_of_week')],
247
-                ],
248
-            ],
249
-        ];
250
-    }
251
-
252
-
253
-    /**
254
-     * @param array $update_callbacks
255
-     * @return array
256
-     */
257
-    public function caf_updates(array $update_callbacks): array
258
-    {
259
-        unset($update_callbacks['_default_tickets_update']);
260
-        $update_callbacks['datetime_and_tickets_caf_update'] = [$this, 'datetime_and_tickets_caf_update'];
261
-        return $update_callbacks;
262
-    }
263
-
264
-
265
-    /**
266
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
267
-     *
268
-     * @param EE_Event $event The Event object we're attaching data to
269
-     * @param array    $data  The request data from the form
270
-     * @throws ReflectionException
271
-     * @throws Exception
272
-     * @throws InvalidInterfaceException
273
-     * @throws InvalidDataTypeException
274
-     * @throws EE_Error
275
-     * @throws InvalidArgumentException
276
-     */
277
-    public function datetime_and_tickets_caf_update(EE_Event $event, array $data)
278
-    {
279
-        // first we need to start with datetimes cause they are the "root" items attached to events.
280
-        $saved_datetimes = $this->_update_datetimes($event, $data);
281
-        // next tackle the tickets (and prices?)
282
-        $this->_update_tickets($event, $saved_datetimes, $data);
283
-    }
284
-
285
-
286
-    /**
287
-     * update event_datetimes
288
-     *
289
-     * @param EE_Event $event Event being updated
290
-     * @param array    $data  the request data from the form
291
-     * @return EE_Datetime[]
292
-     * @throws Exception
293
-     * @throws ReflectionException
294
-     * @throws InvalidInterfaceException
295
-     * @throws InvalidDataTypeException
296
-     * @throws InvalidArgumentException
297
-     * @throws EE_Error
298
-     */
299
-    protected function _update_datetimes(EE_Event $event, array $data): array
300
-    {
301
-        $saved_datetime_ids  = [];
302
-        $saved_datetime_objs = [];
303
-        $timezone            = $data['timezone_string'] ?? null;
304
-        $datetime_model      = EEM_Datetime::instance($timezone);
305
-
306
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
307
-            throw new InvalidArgumentException(
308
-                esc_html__(
309
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
310
-                    'event_espresso'
311
-                )
312
-            );
313
-        }
314
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
315
-            // trim all values to ensure any excess whitespace is removed.
316
-            $datetime_data = array_map(
317
-                function ($datetime_data) {
318
-                    return is_array($datetime_data)
319
-                        ? $datetime_data
320
-                        : trim($datetime_data);
321
-                },
322
-                $datetime_data
323
-            );
324
-
325
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
326
-                                            && ! empty($datetime_data['DTT_EVT_end'])
327
-                ? $datetime_data['DTT_EVT_end']
328
-                : $datetime_data['DTT_EVT_start'];
329
-            $datetime_values              = [
330
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
331
-                    ? $datetime_data['DTT_ID']
332
-                    : null,
333
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
334
-                    ? $datetime_data['DTT_name']
335
-                    : '',
336
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
337
-                    ? $datetime_data['DTT_description']
338
-                    : '',
339
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
340
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
341
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
342
-                    ? EE_INF
343
-                    : $datetime_data['DTT_reg_limit'],
344
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
345
-                    ? $row
346
-                    : $datetime_data['DTT_order'],
347
-            ];
348
-
349
-            // if we have an id then let's get existing object first and then set the new values.
350
-            // Otherwise we instantiate a new object for save.
351
-            if (! empty($datetime_data['DTT_ID'])) {
352
-                $datetime = EE_Registry::instance()
353
-                                       ->load_model('Datetime', [$timezone])
354
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
355
-                // set date and time format according to what is set in this class.
356
-                $datetime->set_date_format($this->_date_format_strings['date']);
357
-                $datetime->set_time_format($this->_date_format_strings['time']);
358
-                foreach ($datetime_values as $field => $value) {
359
-                    $datetime->set($field, $value);
360
-                }
361
-
362
-                // make sure the $datetime_id here is saved just in case
363
-                // after the add_relation_to() the autosave replaces it.
364
-                // We need to do this so we dont' TRASH the parent DTT.
365
-                // (save the ID for both key and value to avoid duplications)
366
-                $saved_datetime_ids[ $datetime->ID() ] = $datetime->ID();
367
-            } else {
368
-                $datetime = EE_Datetime::new_instance(
369
-                    $datetime_values,
370
-                    $timezone,
371
-                    [$this->_date_format_strings['date'], $this->_date_format_strings['time']]
372
-                );
373
-                foreach ($datetime_values as $field => $value) {
374
-                    $datetime->set($field, $value);
375
-                }
376
-            }
377
-            $datetime->save();
378
-            do_action(
379
-                'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
380
-                $datetime,
381
-                $row,
382
-                $datetime_data,
383
-                $data
384
-            );
385
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
386
-            // before going any further make sure our dates are setup correctly
387
-            // so that the end date is always equal or greater than the start date.
388
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
389
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
390
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
391
-                $datetime->save();
392
-            }
393
-            // now we have to make sure we add the new DTT_ID to the $saved_datetime_ids array
394
-            // because it is possible there was a new one created for the autosave.
395
-            // (save the ID for both key and value to avoid duplications)
396
-            $DTT_ID                        = $datetime->ID();
397
-            $saved_datetime_ids[ $DTT_ID ] = $DTT_ID;
398
-            $saved_datetime_objs[ $row ]   = $datetime;
399
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
400
-        }
401
-        $event->save();
402
-        // now we need to REMOVE any datetimes that got deleted.
403
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
404
-        // So its safe to permanently delete at this point.
405
-        $old_datetimes = explode(',', $data['datetime_IDs']);
406
-        $old_datetimes = $old_datetimes[0] === ''
407
-            ? []
408
-            : $old_datetimes;
409
-        if (is_array($old_datetimes)) {
410
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_datetime_ids);
411
-            foreach ($datetimes_to_delete as $id) {
412
-                $id = absint($id);
413
-                if (empty($id)) {
414
-                    continue;
415
-                }
416
-                $dtt_to_remove = $datetime_model->get_one_by_ID($id);
417
-                // remove tkt relationships.
418
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
419
-                foreach ($related_tickets as $ticket) {
420
-                    $dtt_to_remove->_remove_relation_to($ticket, 'Ticket');
421
-                }
422
-                $event->_remove_relation_to($id, 'Datetime');
423
-                $dtt_to_remove->refresh_cache_of_related_objects();
424
-            }
425
-        }
426
-        return $saved_datetime_objs;
427
-    }
428
-
429
-
430
-    /**
431
-     * update tickets
432
-     *
433
-     * @param EE_Event      $event           Event object being updated
434
-     * @param EE_Datetime[] $saved_datetimes an array of datetime ids being updated
435
-     * @param array         $data            incoming request data
436
-     * @return EE_Ticket[]
437
-     * @throws Exception
438
-     * @throws ReflectionException
439
-     * @throws InvalidInterfaceException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidArgumentException
442
-     * @throws EE_Error
443
-     */
444
-    protected function _update_tickets(EE_Event $event, array $saved_datetimes, array $data): array
445
-    {
446
-        $new_ticket = null;
447
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
448
-        $data         = stripslashes_deep($data);
449
-        $timezone     = $data['timezone_string'] ?? null;
450
-        $ticket_model = EEM_Ticket::instance($timezone);
451
-
452
-        $saved_tickets = [];
453
-        $old_tickets   = isset($data['ticket_IDs'])
454
-            ? explode(',', $data['ticket_IDs'])
455
-            : [];
456
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
457
-            throw new InvalidArgumentException(
458
-                esc_html__(
459
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
460
-                    'event_espresso'
461
-                )
462
-            );
463
-        }
464
-        foreach ($data['edit_tickets'] as $row => $ticket_data) {
465
-            $update_prices = $create_new_TKT = false;
466
-            // figure out what datetimes were added to the ticket
467
-            // and what datetimes were removed from the ticket in the session.
468
-            $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
469
-            $ticket_datetime_rows          = explode(',', $data['ticket_datetime_rows'][ $row ]);
470
-            $datetimes_added               = array_diff($ticket_datetime_rows, $starting_ticket_datetime_rows);
471
-            $datetimes_removed             = array_diff($starting_ticket_datetime_rows, $ticket_datetime_rows);
472
-            // trim inputs to ensure any excess whitespace is removed.
473
-            $ticket_data = array_map(
474
-                function ($ticket_data) {
475
-                    return is_array($ticket_data)
476
-                        ? $ticket_data
477
-                        : trim($ticket_data);
478
-                },
479
-                $ticket_data
480
-            );
481
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
482
-            // because we're doing calculations prior to using the models.
483
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
484
-            $ticket_price = isset($ticket_data['TKT_price'])
485
-                ? round((float) $ticket_data['TKT_price'], 3)
486
-                : 0;
487
-            // note incoming base price needs converted from localized value.
488
-            $base_price = isset($ticket_data['TKT_base_price'])
489
-                ? EEH_Money::convert_to_float_from_localized_money($ticket_data['TKT_base_price'])
490
-                : 0;
491
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
492
-            $ticket_price  = $ticket_price === 0 && $base_price !== 0
493
-                ? $base_price
494
-                : $ticket_price;
495
-            $base_price_id = $ticket_data['TKT_base_price_ID'] ?? 0;
496
-            $price_rows    = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
497
-                ? $data['edit_prices'][ $row ]
498
-                : [];
499
-            $now           = null;
500
-            if (empty($ticket_data['TKT_start_date'])) {
501
-                // lets' use now in the set timezone.
502
-                $now                           = new DateTime('now', new DateTimeZone($event->get_timezone()));
503
-                $ticket_data['TKT_start_date'] = $now->format($this->_date_time_format);
504
-            }
505
-            if (empty($ticket_data['TKT_end_date'])) {
506
-                /**
507
-                 * set the TKT_end_date to the first datetime attached to the ticket.
508
-                 */
509
-                $first_datetime              = $saved_datetimes[ reset($ticket_datetime_rows) ];
510
-                $ticket_data['TKT_end_date'] = $first_datetime->start_date_and_time($this->_date_time_format);
511
-            }
512
-            $TKT_values = [
513
-                'TKT_ID'          => ! empty($ticket_data['TKT_ID'])
514
-                    ? $ticket_data['TKT_ID']
515
-                    : null,
516
-                'TTM_ID'          => ! empty($ticket_data['TTM_ID'])
517
-                    ? $ticket_data['TTM_ID']
518
-                    : 0,
519
-                'TKT_name'        => ! empty($ticket_data['TKT_name'])
520
-                    ? $ticket_data['TKT_name']
521
-                    : '',
522
-                'TKT_description' => ! empty($ticket_data['TKT_description'])
523
-                                     && $ticket_data['TKT_description'] !== esc_html__(
524
-                    'You can modify this description',
525
-                    'event_espresso'
526
-                )
527
-                    ? $ticket_data['TKT_description']
528
-                    : '',
529
-                'TKT_start_date'  => $ticket_data['TKT_start_date'],
530
-                'TKT_end_date'    => $ticket_data['TKT_end_date'],
531
-                'TKT_qty'         => ! isset($ticket_data['TKT_qty']) || $ticket_data['TKT_qty'] === ''
532
-                    ? EE_INF
533
-                    : $ticket_data['TKT_qty'],
534
-                'TKT_uses'        => ! isset($ticket_data['TKT_uses']) || $ticket_data['TKT_uses'] === ''
535
-                    ? EE_INF
536
-                    : $ticket_data['TKT_uses'],
537
-                'TKT_min'         => empty($ticket_data['TKT_min'])
538
-                    ? 0
539
-                    : $ticket_data['TKT_min'],
540
-                'TKT_max'         => empty($ticket_data['TKT_max'])
541
-                    ? EE_INF
542
-                    : $ticket_data['TKT_max'],
543
-                'TKT_row'         => $row,
544
-                'TKT_order'       => $ticket_data['TKT_order'] ?? 0,
545
-                'TKT_taxable'     => ! empty($ticket_data['TKT_taxable'])
546
-                    ? 1
547
-                    : 0,
548
-                'TKT_required'    => ! empty($ticket_data['TKT_required'])
549
-                    ? 1
550
-                    : 0,
551
-                'TKT_price'       => $ticket_price,
552
-            ];
553
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
554
-            // which means in turn that the prices will become new prices as well.
555
-            if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) {
556
-                $TKT_values['TKT_ID']         = 0;
557
-                $TKT_values['TKT_is_default'] = 0;
558
-                $update_prices                = true;
559
-            }
560
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
561
-            // we actually do our saves ahead of doing any add_relations to
562
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
563
-            // but DID have it's items modified.
564
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
565
-            // then we won't be updating the ticket but instead a new ticket will be created and the old one archived.
566
-            if (absint($TKT_values['TKT_ID'])) {
567
-                $ticket = EE_Registry::instance()
568
-                                     ->load_model('Ticket', [$timezone])
569
-                                     ->get_one_by_ID($TKT_values['TKT_ID']);
570
-                if ($ticket instanceof EE_Ticket) {
571
-                    $ticket = $this->_update_ticket_datetimes(
572
-                        $ticket,
573
-                        $saved_datetimes,
574
-                        $datetimes_added,
575
-                        $datetimes_removed
576
-                    );
577
-                    // are there any registrations using this ticket ?
578
-                    $tickets_sold = $ticket->count_related(
579
-                        'Registration',
580
-                        [
581
-                            [
582
-                                'STS_ID' => ['NOT IN', [EEM_Registration::status_id_incomplete]],
583
-                            ],
584
-                        ]
585
-                    );
586
-                    // set ticket formats
587
-                    $ticket->set_date_format($this->_date_format_strings['date']);
588
-                    $ticket->set_time_format($this->_date_format_strings['time']);
589
-                    // let's just check the total price for the existing ticket
590
-                    // and determine if it matches the new total price.
591
-                    // if they are different then we create a new ticket (if tickets sold)
592
-                    // if they aren't different then we go ahead and modify existing ticket.
593
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
594
-                    // set new values
595
-                    foreach ($TKT_values as $field => $value) {
596
-                        if ($field === 'TKT_qty') {
597
-                            $ticket->set_qty($value);
598
-                        } else {
599
-                            $ticket->set($field, $value);
600
-                        }
601
-                    }
602
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
603
-                    // Otherwise we have to create a new ticket.
604
-                    if ($create_new_TKT) {
605
-                        $new_ticket = $this->_duplicate_ticket(
606
-                            $ticket,
607
-                            $price_rows,
608
-                            $ticket_price,
609
-                            $base_price,
610
-                            $base_price_id
611
-                        );
612
-                    }
613
-                }
614
-            } else {
615
-                // no TKT_id so a new TKT
616
-                $ticket = EE_Ticket::new_instance(
617
-                    $TKT_values,
618
-                    $timezone,
619
-                    [$this->_date_format_strings['date'], $this->_date_format_strings['time']]
620
-                );
621
-                if ($ticket instanceof EE_Ticket) {
622
-                    // make sure ticket has an ID of setting relations won't work
623
-                    $ticket->save();
624
-                    $ticket        = $this->_update_ticket_datetimes(
625
-                        $ticket,
626
-                        $saved_datetimes,
627
-                        $datetimes_added,
628
-                        $datetimes_removed
629
-                    );
630
-                    $update_prices = true;
631
-                }
632
-            }
633
-            // make sure any current values have been saved.
634
-            // $ticket->save();
635
-            // before going any further make sure our dates are setup correctly
636
-            // so that the end date is always equal or greater than the start date.
637
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
638
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
639
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
640
-            }
641
-            // let's make sure the base price is handled
642
-            $ticket = ! $create_new_TKT
643
-                ? $this->_add_prices_to_ticket(
644
-                    [],
645
-                    $ticket,
646
-                    $update_prices,
647
-                    $base_price,
648
-                    $base_price_id
649
-                )
650
-                : $ticket;
651
-            // add/update price_modifiers
652
-            $ticket = ! $create_new_TKT
653
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
654
-                : $ticket;
655
-            // need to make sue that the TKT_price is accurate after saving the prices.
656
-            $ticket->ensure_TKT_Price_correct();
657
-            // handle CREATING a default ticket from the incoming ticket but ONLY if this isn't an autosave.
658
-            if (! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) {
659
-                $new_default = clone $ticket;
660
-                $new_default->set('TKT_ID', 0);
661
-                $new_default->set('TKT_is_default', 1);
662
-                $new_default->set('TKT_row', 1);
663
-                $new_default->set('TKT_price', $ticket_price);
664
-                // remove any datetime relations cause we DON'T want datetime relations attached
665
-                // (note this is just removing the cached relations in the object)
666
-                $new_default->_remove_relations('Datetime');
667
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
668
-                $new_default = $this->_add_prices_to_ticket(
669
-                    $price_rows,
670
-                    $new_default,
671
-                    true
672
-                );
673
-                // don't forget the base price!
674
-                $new_default = $this->_add_prices_to_ticket(
675
-                    [],
676
-                    $new_default,
677
-                    true,
678
-                    $base_price,
679
-                    $base_price_id
680
-                );
681
-                $new_default->save();
682
-                do_action(
683
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
684
-                    $new_default,
685
-                    $row,
686
-                    $ticket,
687
-                    $data
688
-                );
689
-            }
690
-            // DO ALL datetime relationships for both current tickets and any archived tickets
691
-            // for the given datetime that are related to the current ticket.
692
-            // TODO... not sure exactly how we're going to do this considering we don't know
693
-            // what current ticket the archived tickets are related to
694
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
695
-            // let's assign any tickets that have been setup to the saved_tickets tracker
696
-            // save existing TKT
697
-            $ticket->save();
698
-            if ($create_new_TKT && $new_ticket instanceof EE_Ticket) {
699
-                // save new TKT
700
-                $new_ticket->save();
701
-                // add new ticket to array
702
-                $saved_tickets[ $new_ticket->ID() ] = $new_ticket;
703
-                do_action(
704
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
705
-                    $new_ticket,
706
-                    $row,
707
-                    $ticket_data,
708
-                    $data
709
-                );
710
-            } else {
711
-                // add ticket to saved tickets
712
-                $saved_tickets[ $ticket->ID() ] = $ticket;
713
-                do_action(
714
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
715
-                    $ticket,
716
-                    $row,
717
-                    $ticket_data,
718
-                    $data
719
-                );
720
-            }
721
-        }
722
-        // now we need to handle tickets actually "deleted permanently".
723
-        // There are cases where we'd want this to happen
724
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
725
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
726
-        // No sense in keeping all the related data in the db!
727
-        $old_tickets     = isset($old_tickets[0]) && $old_tickets[0] === ''
728
-            ? []
729
-            : $old_tickets;
730
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
731
-        foreach ($tickets_removed as $id) {
732
-            $id = absint($id);
733
-            // get the ticket for this id
734
-            $ticket_to_remove = $ticket_model->get_one_by_ID($id);
735
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
736
-            if ($ticket_to_remove->get('TKT_is_default')) {
737
-                continue;
738
-            }
739
-            // if this ticket has any registrations attached so then we just ARCHIVE
740
-            // because we don't actually permanently delete these tickets.
741
-            if ($ticket_to_remove->count_related('Registration') > 0) {
742
-                $ticket_to_remove->delete();
743
-                continue;
744
-            }
745
-            // need to get all the related datetimes on this ticket and remove from every single one of them
746
-            // (remember this process can ONLY kick off if there are NO tickets_sold)
747
-            $datetimes = $ticket_to_remove->get_many_related('Datetime');
748
-            foreach ($datetimes as $datetime) {
749
-                $ticket_to_remove->_remove_relation_to($datetime, 'Datetime');
750
-            }
751
-            // need to do the same for prices (except these prices can also be deleted because again,
752
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
753
-            $ticket_to_remove->delete_related('Price');
754
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $ticket_to_remove);
755
-            // finally let's delete this ticket
756
-            // (which should not be blocked at this point b/c we've removed all our relationships)
757
-            $ticket_to_remove->delete_or_restore();
758
-        }
759
-        return $saved_tickets;
760
-    }
761
-
762
-
763
-    /**
764
-     * @access  protected
765
-     * @param EE_Ticket     $ticket
766
-     * @param EE_Datetime[] $saved_datetimes
767
-     * @param int[]         $added_datetimes
768
-     * @param int[]         $removed_datetimes
769
-     * @return EE_Ticket
770
-     * @throws EE_Error
771
-     * @throws ReflectionException
772
-     */
773
-    protected function _update_ticket_datetimes(
774
-        EE_Ticket $ticket,
775
-        array $saved_datetimes = [],
776
-        array $added_datetimes = [],
777
-        array $removed_datetimes = []
778
-    ): EE_Ticket {
779
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
780
-        // and removing the ticket from datetimes it got removed from.
781
-        // first let's add datetimes
782
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
783
-            foreach ($added_datetimes as $row_id) {
784
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
785
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
786
-                    // Is this an existing ticket (has an ID) and does it have any sold?
787
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
788
-                    if ($ticket->ID() && $ticket->sold() > 0) {
789
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
790
-                    }
791
-                }
792
-            }
793
-        }
794
-        // then remove datetimes
795
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
796
-            foreach ($removed_datetimes as $row_id) {
797
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
798
-                // So make sure we skip over this if the datetime isn't in the $saved_datetimes array)
799
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
800
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
801
-                }
802
-            }
803
-        }
804
-        // cap ticket qty by datetime reg limits
805
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
806
-        return $ticket;
807
-    }
808
-
809
-
810
-    /**
811
-     * @access  protected
812
-     * @param EE_Ticket $ticket
813
-     * @param array     $price_rows
814
-     * @param int|float $ticket_price
815
-     * @param int|float $base_price
816
-     * @param int       $base_price_id
817
-     * @return EE_Ticket
818
-     * @throws ReflectionException
819
-     * @throws InvalidArgumentException
820
-     * @throws InvalidInterfaceException
821
-     * @throws InvalidDataTypeException
822
-     * @throws EE_Error
823
-     */
824
-    protected function _duplicate_ticket(
825
-        EE_Ticket $ticket,
826
-        array $price_rows = [],
827
-        $ticket_price = 0,
828
-        $base_price = 0,
829
-        int $base_price_id = 0
830
-    ): EE_Ticket {
831
-        // create new ticket that's a copy of the existing
832
-        // except a new id of course (and not archived)
833
-        // AND has the new TKT_price associated with it.
834
-        $new_ticket = clone $ticket;
835
-        $new_ticket->set('TKT_ID', 0);
836
-        $new_ticket->set_deleted(0);
837
-        $new_ticket->set_price($ticket_price);
838
-        $new_ticket->set_sold(0);
839
-        // let's get a new ID for this ticket
840
-        $new_ticket->save();
841
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
842
-        $datetimes_on_existing = $ticket->datetimes();
843
-        $new_ticket            = $this->_update_ticket_datetimes(
844
-            $new_ticket,
845
-            $datetimes_on_existing,
846
-            array_keys($datetimes_on_existing)
847
-        );
848
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
849
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
850
-        // available.
851
-        if ($ticket->sold() > 0) {
852
-            $new_qty = $ticket->qty() - $ticket->sold();
853
-            $new_ticket->set_qty($new_qty);
854
-        }
855
-        // now we update the prices just for this ticket
856
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
857
-        // and we update the base price
858
-        return $this->_add_prices_to_ticket(
859
-            [],
860
-            $new_ticket,
861
-            true,
862
-            $base_price,
863
-            $base_price_id
864
-        );
865
-    }
866
-
867
-
868
-    /**
869
-     * This attaches a list of given prices to a ticket.
870
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
871
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
872
-     * price info and prices are automatically "archived" via the ticket.
873
-     *
874
-     * @access  private
875
-     * @param array     $prices        Array of prices from the form.
876
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
877
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
878
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
879
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
880
-     * @return EE_Ticket
881
-     * @throws ReflectionException
882
-     * @throws InvalidArgumentException
883
-     * @throws InvalidInterfaceException
884
-     * @throws InvalidDataTypeException
885
-     * @throws EE_Error
886
-     */
887
-    protected function _add_prices_to_ticket(
888
-        array $prices,
889
-        EE_Ticket $ticket,
890
-        bool $new_prices = false,
891
-        $base_price = false,
892
-        $base_price_id = false
893
-    ): EE_Ticket {
894
-        $price_model = EEM_Price::instance();
895
-        // let's just get any current prices that may exist on the given ticket
896
-        // so we can remove any prices that got trashed in this session.
897
-        $current_prices_on_ticket = $base_price !== false
898
-            ? $ticket->base_price(true)
899
-            : $ticket->price_modifiers();
900
-        $updated_prices           = [];
901
-        // if $base_price ! FALSE then updating a base price.
902
-        if ($base_price !== false) {
903
-            $prices[1] = [
904
-                'PRC_ID'     => $new_prices || $base_price_id === 1
905
-                    ? null
906
-                    : $base_price_id,
907
-                'PRT_ID'     => 1,
908
-                'PRC_amount' => $base_price,
909
-                'PRC_name'   => $ticket->get('TKT_name'),
910
-                'PRC_desc'   => $ticket->get('TKT_description'),
911
-            ];
912
-        }
913
-        // possibly need to save ticket
914
-        if (! $ticket->ID()) {
915
-            $ticket->save();
916
-        }
917
-        foreach ($prices as $row => $prc) {
918
-            $prt_id = ! empty($prc['PRT_ID'])
919
-                ? $prc['PRT_ID']
920
-                : null;
921
-            if (empty($prt_id)) {
922
-                continue;
923
-            } //prices MUST have a price type id.
924
-            $PRC_values = [
925
-                'PRC_ID'         => ! empty($prc['PRC_ID'])
926
-                    ? $prc['PRC_ID']
927
-                    : null,
928
-                'PRT_ID'         => $prt_id,
929
-                'PRC_amount'     => ! empty($prc['PRC_amount'])
930
-                    ? $prc['PRC_amount']
931
-                    : 0,
932
-                'PRC_name'       => ! empty($prc['PRC_name'])
933
-                    ? $prc['PRC_name']
934
-                    : '',
935
-                'PRC_desc'       => ! empty($prc['PRC_desc'])
936
-                    ? $prc['PRC_desc']
937
-                    : '',
938
-                'PRC_is_default' => false,
939
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
940
-                'PRC_order'      => $row,
941
-            ];
942
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
943
-                $PRC_values['PRC_ID'] = 0;
944
-                $price                = EE_Registry::instance()->load_class(
945
-                    'Price',
946
-                    [$PRC_values],
947
-                    false,
948
-                    false
949
-                );
950
-            } else {
951
-                $price = $price_model->get_one_by_ID($prc['PRC_ID']);
952
-                // update this price with new values
953
-                foreach ($PRC_values as $field => $value) {
954
-                    $price->set($field, $value);
955
-                }
956
-            }
957
-            $price->save();
958
-            $updated_prices[ $price->ID() ] = $price;
959
-            $ticket->_add_relation_to($price, 'Price');
960
-        }
961
-        // now let's remove any prices that got removed from the ticket
962
-        if (! empty($current_prices_on_ticket)) {
963
-            $current          = array_keys($current_prices_on_ticket);
964
-            $updated          = array_keys($updated_prices);
965
-            $prices_to_remove = array_diff($current, $updated);
966
-            if (! empty($prices_to_remove)) {
967
-                foreach ($prices_to_remove as $prc_id) {
968
-                    $p = $current_prices_on_ticket[ $prc_id ];
969
-                    $ticket->_remove_relation_to($p, 'Price');
970
-                    // delete permanently the price
971
-                    $p->delete_or_restore();
972
-                }
973
-            }
974
-        }
975
-        return $ticket;
976
-    }
977
-
978
-
979
-    /**
980
-     * @throws ReflectionException
981
-     * @throws InvalidArgumentException
982
-     * @throws InvalidInterfaceException
983
-     * @throws InvalidDataTypeException
984
-     * @throws DomainException
985
-     * @throws EE_Error
986
-     */
987
-    public function pricing_metabox()
988
-    {
989
-        $event          = $this->_adminpage_obj->get_cpt_model_obj();
990
-        $timezone       = $event instanceof EE_Event
991
-            ? $event->timezone_string()
992
-            : null;
993
-        $price_model    = EEM_Price::instance($timezone);
994
-        $ticket_model   = EEM_Ticket::instance($timezone);
995
-        $datetime_model = EEM_Datetime::instance($timezone);
996
-        $all_tickets    = [];
997
-
998
-        // set is_creating_event property.
999
-        $EVT_ID                   = $event->ID();
1000
-        $this->_is_creating_event = empty($this->_req_data['post']);
1001
-        $existing_datetime_ids    = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = [];
1002
-
1003
-        // default main template args
1004
-        $main_template_args = [
1005
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1006
-                'event_editor_event_datetimes_help_tab',
1007
-                $this->_adminpage_obj->page_slug,
1008
-                $this->_adminpage_obj->get_req_action()
1009
-            ),
1010
-
1011
-            // todo need to add a filter to the template for the help text
1012
-            // in the Events_Admin_Page core file so we can add further help
1013
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1014
-                'add_new_dtt_info',
1015
-                $this->_adminpage_obj->page_slug,
1016
-                $this->_adminpage_obj->get_req_action()
1017
-            ),
1018
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1019
-            'datetime_rows'            => '',
1020
-            'show_tickets_container'   => '',
1021
-            'ticket_rows'              => '',
1022
-            'ee_collapsible_status'    => ' ee-collapsible-open',
1023
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1024
-        ];
1025
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1026
-
1027
-        /**
1028
-         * 1. Start with retrieving Datetimes
1029
-         * 2. For each datetime get related tickets
1030
-         * 3. For each ticket get related prices
1031
-         */
1032
-        $datetimes                            = $datetime_model->get_all_event_dates($EVT_ID);
1033
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1034
-
1035
-        /**
1036
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1037
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1038
-         */
1039
-        $datetime_row = 1;
1040
-        foreach ($datetimes as $datetime) {
1041
-            $DTT_ID = $datetime->get('DTT_ID');
1042
-            $datetime->set('DTT_order', $datetime_row);
1043
-            $existing_datetime_ids[] = $DTT_ID;
1044
-            // tickets attached
1045
-            $related_tickets = $datetime->ID() > 0
1046
-                ? $datetime->get_many_related(
1047
-                    'Ticket',
1048
-                    [
1049
-                        [
1050
-                            'OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0],
1051
-                        ],
1052
-                        'default_where_conditions' => 'none',
1053
-                        'order_by'                 => ['TKT_order' => 'ASC'],
1054
-                    ]
1055
-                )
1056
-                : [];
1057
-            // if there are no related tickets this is likely a new event OR auto-draft
1058
-            // event so we need to generate the default tickets because datetimes
1059
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1060
-            // datetime on the event.
1061
-            if (empty($related_tickets) && count($datetimes) < 2) {
1062
-                $related_tickets = $ticket_model->get_all_default_tickets();
1063
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1064
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1065
-                $default_prices      = $price_model->get_all_default_prices();
1066
-                $main_default_ticket = reset($related_tickets);
1067
-                if ($main_default_ticket instanceof EE_Ticket) {
1068
-                    foreach ($default_prices as $default_price) {
1069
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1070
-                            continue;
1071
-                        }
1072
-                        $main_default_ticket->cache('Price', $default_price);
1073
-                    }
1074
-                }
1075
-            }
1076
-            // we can't actually setup rows in this loop yet cause we don't know all
1077
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1078
-            // So we're going to temporarily cache some of that information.
1079
-            // loop through and setup the ticket rows and make sure the order is set.
1080
-            foreach ($related_tickets as $ticket) {
1081
-                $TKT_ID     = $ticket->get('TKT_ID');
1082
-                $ticket_row = $ticket->get('TKT_row');
1083
-                // we only want unique tickets in our final display!!
1084
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1085
-                    $existing_ticket_ids[] = $TKT_ID;
1086
-                    $all_tickets[]         = $ticket;
1087
-                }
1088
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1089
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1090
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1091
-                if (
1092
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1093
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1094
-                ) {
1095
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1096
-                }
1097
-            }
1098
-            $datetime_row++;
1099
-        }
1100
-        $main_template_args['total_ticket_rows']     = count($existing_ticket_ids);
1101
-        $main_template_args['existing_ticket_ids']   = implode(',', $existing_ticket_ids);
1102
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1103
-        // sort $all_tickets by order
1104
-        usort(
1105
-            $all_tickets,
1106
-            function (EE_Ticket $a, EE_Ticket $b) {
1107
-                $a_order = (int) $a->get('TKT_order');
1108
-                $b_order = (int) $b->get('TKT_order');
1109
-                if ($a_order === $b_order) {
1110
-                    return 0;
1111
-                }
1112
-                return ($a_order < $b_order)
1113
-                    ? -1
1114
-                    : 1;
1115
-            }
1116
-        );
1117
-        // k NOW we have all the data we need for setting up the datetime rows
1118
-        // and ticket rows so we start our datetime loop again.
1119
-        $datetime_row = 1;
1120
-        foreach ($datetimes as $datetime) {
1121
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1122
-                $datetime_row,
1123
-                $datetime,
1124
-                $datetime_tickets,
1125
-                $all_tickets,
1126
-                false,
1127
-                $datetimes
1128
-            );
1129
-            $datetime_row++;
1130
-        }
1131
-        // then loop through all tickets for the ticket rows.
1132
-        $ticket_row = 1;
1133
-        foreach ($all_tickets as $ticket) {
1134
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1135
-                $ticket_row,
1136
-                $ticket,
1137
-                $ticket_datetimes,
1138
-                $datetimes,
1139
-                false,
1140
-                $all_tickets
1141
-            );
1142
-            $ticket_row++;
1143
-        }
1144
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1145
-
1146
-        $status_change_notice = LoaderFactory::getLoader()->getShared(
1147
-            'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
1148
-        );
1149
-
1150
-        $main_template_args['status_change_notice'] = $status_change_notice->display(
1151
-            '__event-editor',
1152
-            'espresso-events'
1153
-        );
1154
-
1155
-        EEH_Template::display_template(
1156
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1157
-            $main_template_args
1158
-        );
1159
-    }
1160
-
1161
-
1162
-    /**
1163
-     * @param int|string  $datetime_row
1164
-     * @param EE_Datetime $datetime
1165
-     * @param array       $datetime_tickets
1166
-     * @param array       $all_tickets
1167
-     * @param bool        $default
1168
-     * @param array       $all_datetimes
1169
-     * @return string
1170
-     * @throws DomainException
1171
-     * @throws EE_Error
1172
-     * @throws ReflectionException
1173
-     */
1174
-    protected function _get_datetime_row(
1175
-        $datetime_row,
1176
-        EE_Datetime $datetime,
1177
-        array $datetime_tickets = [],
1178
-        array $all_tickets = [],
1179
-        bool $default = false,
1180
-        array $all_datetimes = []
1181
-    ): string {
1182
-        return EEH_Template::display_template(
1183
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1184
-            [
1185
-                'dtt_edit_row'             => $this->_get_dtt_edit_row(
1186
-                    $datetime_row,
1187
-                    $datetime,
1188
-                    $default,
1189
-                    $all_datetimes
1190
-                ),
1191
-                'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1192
-                    $datetime_row,
1193
-                    $datetime,
1194
-                    $datetime_tickets,
1195
-                    $all_tickets,
1196
-                    $default
1197
-                ),
1198
-                'dtt_row'                  => $default
1199
-                    ? 'DTTNUM'
1200
-                    : $datetime_row,
1201
-            ],
1202
-            true
1203
-        );
1204
-    }
1205
-
1206
-
1207
-    /**
1208
-     * This method is used to generate a datetime fields  edit row.
1209
-     * The same row is used to generate a row with valid DTT objects
1210
-     * and the default row that is used as the skeleton by the js.
1211
-     *
1212
-     * @param int|string       $datetime_row  The row number for the row being generated.
1213
-     * @param EE_Datetime|null $datetime
1214
-     * @param bool             $default       Whether a default row is being generated or not.
1215
-     * @param EE_Datetime[]    $all_datetimes This is the array of all datetimes used in the editor.
1216
-     * @return string
1217
-     * @throws EE_Error
1218
-     * @throws ReflectionException
1219
-     */
1220
-    protected function _get_dtt_edit_row(
1221
-        $datetime_row,
1222
-        ?EE_Datetime $datetime,
1223
-        bool $default,
1224
-        array $all_datetimes
1225
-    ): string {
1226
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1227
-        $default                     = ! $datetime instanceof EE_Datetime
1228
-            ? true
1229
-            : $default;
1230
-        $template_args               = [
1231
-            'dtt_row'              => $default
1232
-                ? 'DTTNUM'
1233
-                : $datetime_row,
1234
-            'event_datetimes_name' => $default
1235
-                ? 'DTTNAMEATTR'
1236
-                : 'edit_event_datetimes',
1237
-            'edit_dtt_expanded'    => '',
1238
-            'DTT_ID'               => $default
1239
-                ? ''
1240
-                : $datetime->ID(),
1241
-            'DTT_name'             => $default
1242
-                ? ''
1243
-                : $datetime->get_f('DTT_name'),
1244
-            'DTT_description'      => $default
1245
-                ? ''
1246
-                : $datetime->get_raw('DTT_description'),
1247
-            'DTT_EVT_start'        => $default
1248
-                ? ''
1249
-                : $datetime->start_date($this->_date_time_format),
1250
-            'DTT_EVT_end'          => $default
1251
-                ? ''
1252
-                : $datetime->end_date($this->_date_time_format),
1253
-            'DTT_reg_limit'        => $default
1254
-                ? ''
1255
-                : $datetime->get_pretty(
1256
-                    'DTT_reg_limit',
1257
-                    'input'
1258
-                ),
1259
-            'DTT_order'            => $default
1260
-                ? 'DTTNUM'
1261
-                : $datetime_row,
1262
-            'dtt_sold'             => $default
1263
-                ? '0'
1264
-                : $datetime->get('DTT_sold'),
1265
-            'dtt_reserved'         => $default
1266
-                ? '0'
1267
-                : $datetime->reserved(),
1268
-            'can_clone'            => $datetime instanceof EE_Datetime,
1269
-            'can_trash'            => count($all_datetimes) > 1
1270
-                                      && $datetime instanceof EE_Datetime
1271
-                                      && ! $datetime->get('DTT_sold'),
1272
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1273
-                ? 'trash-entity dashicons dashicons-lock'
1274
-                : 'trash-entity dashicons dashicons-post-trash clickable',
1275
-            'reg_list_url'         => $default || ! $datetime->event() instanceof EE_Event
1276
-                ? ''
1277
-                : EE_Admin_Page::add_query_args_and_nonce(
1278
-                    [
1279
-                        'event_id'    => $datetime->event()->ID(),
1280
-                        'datetime_id' => $datetime->ID(),
1281
-                        'use_filters' => true,
1282
-                    ],
1283
-                    REG_ADMIN_URL
1284
-                ),
1285
-        ];
1286
-        $template_args['show_trash'] = count($all_datetimes) === 1
1287
-                                       && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1288
-            ? 'display:none'
1289
-            : '';
1290
-        // allow filtering of template args at this point.
1291
-        $template_args = apply_filters(
1292
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1293
-            $template_args,
1294
-            $datetime_row,
1295
-            $datetime,
1296
-            $default,
1297
-            $all_datetimes,
1298
-            $this->_is_creating_event
1299
-        );
1300
-        return EEH_Template::display_template(
1301
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1302
-            $template_args,
1303
-            true
1304
-        );
1305
-    }
1306
-
1307
-
1308
-    /**
1309
-     * @param int|string       $datetime_row
1310
-     * @param EE_Datetime|null $datetime
1311
-     * @param array            $datetime_tickets
1312
-     * @param array            $all_tickets
1313
-     * @param bool             $default
1314
-     * @return string
1315
-     * @throws DomainException
1316
-     * @throws EE_Error
1317
-     * @throws ReflectionException
1318
-     */
1319
-    protected function _get_dtt_attached_tickets_row(
1320
-        $datetime_row,
1321
-        ?EE_Datetime $datetime,
1322
-        array $datetime_tickets = [],
1323
-        array $all_tickets = [],
1324
-        bool $default = false
1325
-    ): string {
1326
-        $template_args = [
1327
-            'dtt_row'                           => $default
1328
-                ? 'DTTNUM'
1329
-                : $datetime_row,
1330
-            'event_datetimes_name'              => $default
1331
-                ? 'DTTNAMEATTR'
1332
-                : 'edit_event_datetimes',
1333
-            'DTT_description'                   => $default
1334
-                ? ''
1335
-                : $datetime->get_raw('DTT_description'),
1336
-            'datetime_tickets_list'             => $default
1337
-                ? '<li class="hidden"></li>'
1338
-                : '',
1339
-            'show_tickets_row'                  => 'display:none;',
1340
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1341
-                'add_new_ticket_via_datetime',
1342
-                $this->_adminpage_obj->page_slug,
1343
-                $this->_adminpage_obj->get_req_action()
1344
-            ),
1345
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1346
-            'DTT_ID'                            => $default
1347
-                ? ''
1348
-                : $datetime->ID(),
1349
-        ];
1350
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1351
-        if (! $default) {
1352
-            $ticket_row = 1;
1353
-            foreach ($all_tickets as $ticket) {
1354
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1355
-                    $datetime_row,
1356
-                    $ticket_row,
1357
-                    $datetime,
1358
-                    $ticket,
1359
-                    $datetime_tickets
1360
-                );
1361
-                $ticket_row++;
1362
-            }
1363
-        }
1364
-        // filter template args at this point
1365
-        $template_args = apply_filters(
1366
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1367
-            $template_args,
1368
-            $datetime_row,
1369
-            $datetime,
1370
-            $datetime_tickets,
1371
-            $all_tickets,
1372
-            $default,
1373
-            $this->_is_creating_event
1374
-        );
1375
-        return EEH_Template::display_template(
1376
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1377
-            $template_args,
1378
-            true
1379
-        );
1380
-    }
1381
-
1382
-
1383
-    /**
1384
-     * @param int|string       $datetime_row
1385
-     * @param int|string       $ticket_row
1386
-     * @param EE_Datetime|null $datetime
1387
-     * @param EE_Ticket|null   $ticket
1388
-     * @param array            $datetime_tickets
1389
-     * @param bool             $default
1390
-     * @return string
1391
-     * @throws EE_Error
1392
-     * @throws ReflectionException
1393
-     */
1394
-    protected function _get_datetime_tickets_list_item(
1395
-        $datetime_row,
1396
-        $ticket_row,
1397
-        ?EE_Datetime $datetime,
1398
-        ?EE_Ticket $ticket,
1399
-        array $datetime_tickets = [],
1400
-        bool $default = false
1401
-    ): string {
1402
-        $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1403
-            ? $datetime_tickets[ $datetime->ID() ]
1404
-            : [];
1405
-        $display_row      = $ticket instanceof EE_Ticket
1406
-            ? $ticket->get('TKT_row')
1407
-            : 0;
1408
-        $no_ticket        = $default && empty($ticket);
1409
-        $template_args    = [
1410
-            'dtt_row'                 => $default
1411
-                ? 'DTTNUM'
1412
-                : $datetime_row,
1413
-            'tkt_row'                 => $no_ticket
1414
-                ? 'TICKETNUM'
1415
-                : $ticket_row,
1416
-            'datetime_ticket_checked' => in_array($display_row, $datetime_tickets, true)
1417
-                ? ' checked'
1418
-                : '',
1419
-            'ticket_selected'         => in_array($display_row, $datetime_tickets, true)
1420
-                ? ' ticket-selected'
1421
-                : '',
1422
-            'TKT_name'                => $no_ticket
1423
-                ? 'TKTNAME'
1424
-                : $ticket->get('TKT_name'),
1425
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1426
-                ? ' tkt-status-' . EE_Ticket::onsale
1427
-                : ' tkt-status-' . $ticket->ticket_status(),
1428
-        ];
1429
-        // filter template args
1430
-        $template_args = apply_filters(
1431
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1432
-            $template_args,
1433
-            $datetime_row,
1434
-            $ticket_row,
1435
-            $datetime,
1436
-            $ticket,
1437
-            $datetime_tickets,
1438
-            $default,
1439
-            $this->_is_creating_event
1440
-        );
1441
-        return EEH_Template::display_template(
1442
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1443
-            $template_args,
1444
-            true
1445
-        );
1446
-    }
1447
-
1448
-
1449
-    /**
1450
-     * This generates the ticket row for tickets.
1451
-     * This same method is used to generate both the actual rows and the js skeleton row
1452
-     * (when default === true)
1453
-     *
1454
-     * @param int|string     $ticket_row       Represents the row number being generated.
1455
-     * @param EE_Ticket|null $ticket
1456
-     * @param EE_Datetime[]  $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1457
-     *                                         or empty for default
1458
-     * @param EE_Datetime[]  $all_datetimes    All Datetimes on the event or empty for default.
1459
-     * @param bool           $default          Whether default row being generated or not.
1460
-     * @param EE_Ticket[]    $all_tickets      This is an array of all tickets attached to the event
1461
-     *                                         (or empty in the case of defaults)
1462
-     * @return string
1463
-     * @throws InvalidArgumentException
1464
-     * @throws InvalidInterfaceException
1465
-     * @throws InvalidDataTypeException
1466
-     * @throws DomainException
1467
-     * @throws EE_Error
1468
-     * @throws ReflectionException
1469
-     */
1470
-    protected function _get_ticket_row(
1471
-        $ticket_row,
1472
-        ?EE_Ticket $ticket,
1473
-        array $ticket_datetimes,
1474
-        array $all_datetimes,
1475
-        bool $default = false,
1476
-        array $all_tickets = []
1477
-    ): string {
1478
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1479
-        $default = ! $ticket instanceof EE_Ticket
1480
-            ? true
1481
-            : $default;
1482
-        $prices  = ! empty($ticket) && ! $default
1483
-            ? $ticket->get_many_related(
1484
-                'Price',
1485
-                ['default_where_conditions' => 'none', 'order_by' => ['PRC_order' => 'ASC']]
1486
-            )
1487
-            : [];
1488
-        // if there is only one price (which would be the base price)
1489
-        // or NO prices and this ticket is a default ticket,
1490
-        // let's just make sure there are no cached default prices on the object.
1491
-        // This is done by not including any query_params.
1492
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1493
-            $prices = $ticket->prices();
1494
-        }
1495
-        // check if we're dealing with a default ticket in which case
1496
-        // we don't want any starting_ticket_datetime_row values set
1497
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1498
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1499
-        $default_datetime = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1500
-        $tkt_datetimes    = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1501
-            ? $ticket_datetimes[ $ticket->ID() ]
1502
-            : [];
1503
-        $ticket_subtotal  = $default
1504
-            ? 0
1505
-            : $ticket->get_ticket_subtotal();
1506
-        $base_price       = $default
1507
-            ? null
1508
-            : $ticket->base_price();
1509
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1510
-        // breaking out complicated condition for ticket_status
1511
-        if ($default) {
1512
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1513
-        } else {
1514
-            $ticket_status_class = $ticket->is_default()
1515
-                ? ' tkt-status-' . EE_Ticket::onsale
1516
-                : ' tkt-status-' . $ticket->ticket_status();
1517
-        }
1518
-        // breaking out complicated condition for TKT_taxable
1519
-        if ($default) {
1520
-            $TKT_taxable = '';
1521
-        } else {
1522
-            $TKT_taxable = $ticket->taxable()
1523
-                ? 'checked'
1524
-                : '';
1525
-        }
1526
-        if ($default) {
1527
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1528
-        } elseif ($ticket->is_default()) {
1529
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1530
-        } else {
1531
-            $TKT_status = $ticket->ticket_status(true);
1532
-        }
1533
-        if ($default) {
1534
-            $TKT_min = '';
1535
-        } else {
1536
-            $TKT_min = $ticket->min();
1537
-            if ($TKT_min === -1 || $TKT_min === 0) {
1538
-                $TKT_min = '';
1539
-            }
1540
-        }
1541
-        $template_args                 = [
1542
-            'tkt_row'                       => $default
1543
-                ? 'TICKETNUM'
1544
-                : $ticket_row,
1545
-            'TKT_order'                     => $default
1546
-                ? 'TICKETNUM'
1547
-                : $ticket_row,
1548
-            // on initial page load this will always be the correct order.
1549
-            'tkt_status_class'              => $ticket_status_class,
1550
-            'display_edit_tkt_row'          => 'display:none;',
1551
-            'edit_tkt_expanded'             => '',
1552
-            'edit_tickets_name'             => $default
1553
-                ? 'TICKETNAMEATTR'
1554
-                : 'edit_tickets',
1555
-            'TKT_name'                      => $default
1556
-                ? ''
1557
-                : $ticket->get_f('TKT_name'),
1558
-            'TKT_start_date'                => $default
1559
-                ? ''
1560
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1561
-            'TKT_end_date'                  => $default
1562
-                ? ''
1563
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1564
-            'TKT_status'                    => $TKT_status,
1565
-            'TKT_price'                     => $default
1566
-                ? ''
1567
-                : EEH_Template::format_currency(
1568
-                    $ticket->get_ticket_total_with_taxes(),
1569
-                    false,
1570
-                    false
1571
-                ),
1572
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1573
-            'TKT_price_amount'              => $default
1574
-                ? 0
1575
-                : $ticket_subtotal,
1576
-            'TKT_qty'                       => $default
1577
-                ? ''
1578
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1579
-            'TKT_qty_for_input'             => $default
1580
-                ? ''
1581
-                : $ticket->get_pretty('TKT_qty', 'input'),
1582
-            'TKT_uses'                      => $default
1583
-                ? ''
1584
-                : $ticket->get_pretty('TKT_uses', 'input'),
1585
-            'TKT_min'                       => $TKT_min,
1586
-            'TKT_max'                       => $default
1587
-                ? ''
1588
-                : $ticket->get_pretty('TKT_max', 'input'),
1589
-            'TKT_sold'                      => $default
1590
-                ? 0
1591
-                : $ticket->tickets_sold(),
1592
-            'TKT_reserved'                  => $default
1593
-                ? 0
1594
-                : $ticket->reserved(),
1595
-            'TKT_registrations'             => $default
1596
-                ? 0
1597
-                : $ticket->count_registrations(
1598
-                    [
1599
-                        [
1600
-                            'STS_ID' => [
1601
-                                '!=',
1602
-                                EEM_Registration::status_id_incomplete,
1603
-                            ],
1604
-                        ],
1605
-                    ]
1606
-                ),
1607
-            'TKT_ID'                        => $default
1608
-                ? 0
1609
-                : $ticket->ID(),
1610
-            'TKT_description'               => $default
1611
-                ? ''
1612
-                : $ticket->get_raw('TKT_description'),
1613
-            'TKT_is_default'                => $default
1614
-                ? 0
1615
-                : $ticket->is_default(),
1616
-            'TKT_required'                  => $default
1617
-                ? 0
1618
-                : $ticket->required(),
1619
-            'TKT_is_default_selector'       => '',
1620
-            'ticket_price_rows'             => '',
1621
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1622
-                ? ''
1623
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1624
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price
1625
-                ? 0
1626
-                : $base_price->ID(),
1627
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1628
-                ? ''
1629
-                : 'display:none;',
1630
-            'show_price_mod_button'         => count($prices) > 1
1631
-                                               || ($default && $count_price_mods > 0)
1632
-                                               || (! $default && $ticket->deleted())
1633
-                ? 'display:none;'
1634
-                : '',
1635
-            'total_price_rows'              => count($prices) > 1
1636
-                ? count($prices)
1637
-                : 1,
1638
-            'ticket_datetimes_list'         => $default
1639
-                ? '<li class="hidden"></li>'
1640
-                : '',
1641
-            'starting_ticket_datetime_rows' => $default || $default_datetime
1642
-                ? ''
1643
-                : implode(',', $tkt_datetimes),
1644
-            'ticket_datetime_rows'          => $default
1645
-                ? ''
1646
-                : implode(',', $tkt_datetimes),
1647
-            'existing_ticket_price_ids'     => $default
1648
-                ? ''
1649
-                : implode(',', array_keys($prices)),
1650
-            'ticket_template_id'            => $default
1651
-                ? 0
1652
-                : $ticket->get('TTM_ID'),
1653
-            'TKT_taxable'                   => $TKT_taxable,
1654
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1655
-                ? ''
1656
-                : 'display:none;',
1657
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1658
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1659
-                $ticket_subtotal,
1660
-                false,
1661
-                false
1662
-            ),
1663
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1664
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1665
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1666
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1667
-                ? ' ticket-archived'
1668
-                : '',
1669
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1670
-                                               && $ticket->deleted()
1671
-                                               && ! $ticket->is_permanently_deleteable()
1672
-                ? 'dashicons dashicons-lock '
1673
-                : 'trash-entity dashicons dashicons-post-trash clickable',
1674
-
1675
-            'can_clone' => $ticket instanceof EE_Ticket && ! $ticket->deleted(),
1676
-            'can_trash' => $ticket instanceof EE_Ticket
1677
-                           && (! $ticket->deleted() && $ticket->is_permanently_deleteable()),
1678
-        ];
1679
-        $template_args['trash_hidden'] = count($all_tickets) === 1
1680
-                                         && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1681
-            ? 'display:none'
1682
-            : '';
1683
-        // handle rows that should NOT be empty
1684
-        if (empty($template_args['TKT_start_date'])) {
1685
-            // if empty then the start date will be now.
1686
-            $template_args['TKT_start_date']   = date(
1687
-                $this->_date_time_format,
1688
-                current_time('timestamp')
1689
-            );
1690
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1691
-        }
1692
-        if (empty($template_args['TKT_end_date'])) {
1693
-            // get the earliest datetime (if present);
1694
-            $earliest_datetime = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1695
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1696
-                    'Datetime',
1697
-                    ['order_by' => ['DTT_EVT_start' => 'ASC']]
1698
-                )
1699
-                : null;
1700
-            if (! empty($earliest_datetime)) {
1701
-                $template_args['TKT_end_date'] = $earliest_datetime->get_datetime(
1702
-                    'DTT_EVT_start',
1703
-                    $this->_date_time_format
1704
-                );
1705
-            } else {
1706
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1707
-                $template_args['TKT_end_date'] = date(
1708
-                    $this->_date_time_format,
1709
-                    mktime(
1710
-                        24,
1711
-                        0,
1712
-                        0,
1713
-                        date('m'),
1714
-                        date('d') + 29,
1715
-                        date('Y')
1716
-                    )
1717
-                );
1718
-            }
1719
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1720
-        }
1721
-        // generate ticket_datetime items
1722
-        if (! $default) {
1723
-            $datetime_row = 1;
1724
-            foreach ($all_datetimes as $datetime) {
1725
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1726
-                    $datetime_row,
1727
-                    $ticket_row,
1728
-                    $datetime,
1729
-                    $ticket,
1730
-                    $ticket_datetimes,
1731
-                    $default
1732
-                );
1733
-                $datetime_row++;
1734
-            }
1735
-        }
1736
-        $price_row = 1;
1737
-        foreach ($prices as $price) {
1738
-            if (! $price instanceof EE_Price) {
1739
-                continue;
1740
-            }
1741
-            if ($price->is_base_price()) {
1742
-                $price_row++;
1743
-                continue;
1744
-            }
1745
-
1746
-            $show_trash  = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1747
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1748
-
1749
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1750
-                $ticket_row,
1751
-                $price_row,
1752
-                $price,
1753
-                $default,
1754
-                $ticket,
1755
-                $show_trash,
1756
-                $show_create
1757
-            );
1758
-            $price_row++;
1759
-        }
1760
-        // filter $template_args
1761
-        $template_args = apply_filters(
1762
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1763
-            $template_args,
1764
-            $ticket_row,
1765
-            $ticket,
1766
-            $ticket_datetimes,
1767
-            $all_datetimes,
1768
-            $default,
1769
-            $all_tickets,
1770
-            $this->_is_creating_event
1771
-        );
1772
-        return EEH_Template::display_template(
1773
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1774
-            $template_args,
1775
-            true
1776
-        );
1777
-    }
1778
-
1779
-
1780
-    /**
1781
-     * @param int|string     $ticket_row
1782
-     * @param EE_Ticket|null $ticket
1783
-     * @return string
1784
-     * @throws DomainException
1785
-     * @throws EE_Error
1786
-     * @throws ReflectionException
1787
-     */
1788
-    protected function _get_tax_rows($ticket_row, ?EE_Ticket $ticket): string
1789
-    {
1790
-        $tax_rows = '';
1791
-        /** @var EE_Price[] $taxes */
1792
-        $taxes = EE_Taxes::get_taxes_for_admin();
1793
-        foreach ($taxes as $tax) {
1794
-            $tax_added     = $this->_get_tax_added($tax, $ticket);
1795
-            $template_args = [
1796
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1797
-                    ? ''
1798
-                    : 'display:none;',
1799
-                'tax_id'            => $tax->ID(),
1800
-                'tkt_row'           => $ticket_row,
1801
-                'tax_label'         => $tax->get('PRC_name'),
1802
-                'tax_added'         => $tax_added,
1803
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1804
-                'tax_amount'        => $tax->get('PRC_amount'),
1805
-            ];
1806
-            $template_args = apply_filters(
1807
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1808
-                $template_args,
1809
-                $ticket_row,
1810
-                $ticket,
1811
-                $this->_is_creating_event
1812
-            );
1813
-            $tax_rows      .= EEH_Template::display_template(
1814
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1815
-                $template_args,
1816
-                true
1817
-            );
1818
-        }
1819
-        return $tax_rows;
1820
-    }
1821
-
1822
-
1823
-    /**
1824
-     * @param EE_Price       $tax
1825
-     * @param EE_Ticket|null $ticket
1826
-     * @return float|int
1827
-     * @throws EE_Error
1828
-     * @throws ReflectionException
1829
-     */
1830
-    protected function _get_tax_added(EE_Price $tax, ?EE_Ticket $ticket)
1831
-    {
1832
-        $subtotal = empty($ticket)
1833
-            ? 0
1834
-            : $ticket->get_ticket_subtotal();
1835
-        return $subtotal * $tax->get('PRC_amount') / 100;
1836
-    }
1837
-
1838
-
1839
-    /**
1840
-     * @param int|string     $ticket_row
1841
-     * @param int|string     $price_row
1842
-     * @param EE_Price|null  $price
1843
-     * @param bool           $default
1844
-     * @param EE_Ticket|null $ticket
1845
-     * @param bool           $show_trash
1846
-     * @param bool           $show_create
1847
-     * @return string
1848
-     * @throws InvalidArgumentException
1849
-     * @throws InvalidInterfaceException
1850
-     * @throws InvalidDataTypeException
1851
-     * @throws DomainException
1852
-     * @throws EE_Error
1853
-     * @throws ReflectionException
1854
-     */
1855
-    protected function _get_ticket_price_row(
1856
-        $ticket_row,
1857
-        $price_row,
1858
-        ?EE_Price $price,
1859
-        bool $default,
1860
-        ?EE_Ticket $ticket,
1861
-        bool $show_trash = true,
1862
-        bool $show_create = true
1863
-    ): string {
1864
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1865
-        $template_args = [
1866
-            'tkt_row'               => $default && empty($ticket)
1867
-                ? 'TICKETNUM'
1868
-                : $ticket_row,
1869
-            'PRC_order'             => $default && empty($price)
1870
-                ? 'PRICENUM'
1871
-                : $price_row,
1872
-            'edit_prices_name'      => $default && empty($price)
1873
-                ? 'PRICENAMEATTR'
1874
-                : 'edit_prices',
1875
-            'price_type_selector'   => $default && empty($price)
1876
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, true)
1877
-                : $this->_get_price_type_selector(
1878
-                    $ticket_row,
1879
-                    $price_row,
1880
-                    $price,
1881
-                    $default,
1882
-                    $send_disabled
1883
-                ),
1884
-            'PRC_ID'                => $default && empty($price)
1885
-                ? 0
1886
-                : $price->ID(),
1887
-            'PRC_is_default'        => $default && empty($price)
1888
-                ? 0
1889
-                : $price->get('PRC_is_default'),
1890
-            'PRC_name'              => $default && empty($price)
1891
-                ? ''
1892
-                : $price->get('PRC_name'),
1893
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1894
-            'show_plus_or_minus'    => $default && empty($price)
1895
-                ? ''
1896
-                : 'display:none;',
1897
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1898
-                ? 'display:none;'
1899
-                : '',
1900
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1901
-                ? 'display:none;'
1902
-                : '',
1903
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1904
-                ? 'display:none'
1905
-                : '',
1906
-            'PRC_amount'            => $default && empty($price)
1907
-                ? 0
1908
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1909
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1910
-                ? 'display:none;'
1911
-                : '',
1912
-            'show_trash_icon'       => $show_trash
1913
-                ? ''
1914
-                : ' style="display:none;"',
1915
-            'show_create_button'    => $show_create
1916
-                ? ''
1917
-                : ' style="display:none;"',
1918
-            'PRC_desc'              => $default && empty($price)
1919
-                ? ''
1920
-                : $price->get('PRC_desc'),
1921
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1922
-        ];
1923
-        $template_args = apply_filters(
1924
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1925
-            $template_args,
1926
-            $ticket_row,
1927
-            $price_row,
1928
-            $price,
1929
-            $default,
1930
-            $ticket,
1931
-            $show_trash,
1932
-            $show_create,
1933
-            $this->_is_creating_event
1934
-        );
1935
-        return EEH_Template::display_template(
1936
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1937
-            $template_args,
1938
-            true
1939
-        );
1940
-    }
1941
-
1942
-
1943
-    /**
1944
-     * @param int|string    $ticket_row
1945
-     * @param int|string    $price_row
1946
-     * @param EE_Price|null $price
1947
-     * @param bool          $default
1948
-     * @param bool          $disabled
1949
-     * @return string
1950
-     * @throws ReflectionException
1951
-     * @throws InvalidArgumentException
1952
-     * @throws InvalidInterfaceException
1953
-     * @throws InvalidDataTypeException
1954
-     * @throws DomainException
1955
-     * @throws EE_Error
1956
-     */
1957
-    protected function _get_price_type_selector(
1958
-        $ticket_row,
1959
-        $price_row,
1960
-        ?EE_Price $price,
1961
-        bool $default,
1962
-        bool $disabled = false
1963
-    ): string {
1964
-        if ($price->is_base_price()) {
1965
-            return $this->_get_base_price_template(
1966
-                $ticket_row,
1967
-                $price_row,
1968
-                $price,
1969
-                $default
1970
-            );
1971
-        }
1972
-        return $this->_get_price_modifier_template(
1973
-            $ticket_row,
1974
-            $price_row,
1975
-            $price,
1976
-            $default,
1977
-            $disabled
1978
-        );
1979
-    }
1980
-
1981
-
1982
-    /**
1983
-     * @param int|string    $ticket_row
1984
-     * @param int|string    $price_row
1985
-     * @param EE_Price|null $price
1986
-     * @param bool          $default
1987
-     * @return string
1988
-     * @throws DomainException
1989
-     * @throws EE_Error
1990
-     * @throws ReflectionException
1991
-     */
1992
-    protected function _get_base_price_template(
1993
-        $ticket_row,
1994
-        $price_row,
1995
-        ?EE_Price $price,
1996
-        bool $default
1997
-    ): string {
1998
-        $template_args = [
1999
-            'tkt_row'                   => $default
2000
-                ? 'TICKETNUM'
2001
-                : $ticket_row,
2002
-            'PRC_order'                 => $default && empty($price)
2003
-                ? 'PRICENUM'
2004
-                : $price_row,
2005
-            'PRT_ID'                    => $default && empty($price)
2006
-                ? 1
2007
-                : $price->get('PRT_ID'),
2008
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
2009
-            'price_selected_operator'   => '+',
2010
-            'price_selected_is_percent' => 0,
2011
-        ];
2012
-        $template_args = apply_filters(
2013
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
2014
-            $template_args,
2015
-            $ticket_row,
2016
-            $price_row,
2017
-            $price,
2018
-            $default,
2019
-            $this->_is_creating_event
2020
-        );
2021
-        return EEH_Template::display_template(
2022
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
2023
-            $template_args,
2024
-            true
2025
-        );
2026
-    }
2027
-
2028
-
2029
-    /**
2030
-     * @param int|string    $ticket_row
2031
-     * @param int|string    $price_row
2032
-     * @param EE_Price|null $price
2033
-     * @param bool          $default
2034
-     * @param bool          $disabled
2035
-     * @return string
2036
-     * @throws ReflectionException
2037
-     * @throws InvalidArgumentException
2038
-     * @throws InvalidInterfaceException
2039
-     * @throws InvalidDataTypeException
2040
-     * @throws DomainException
2041
-     * @throws EE_Error
2042
-     */
2043
-    protected function _get_price_modifier_template(
2044
-        $ticket_row,
2045
-        $price_row,
2046
-        ?EE_Price $price,
2047
-        bool $default,
2048
-        bool $disabled = false
2049
-    ): string {
2050
-        $select_name = $default && ! $price instanceof EE_Price
2051
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
2052
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
2053
-
2054
-        $price_type_model       = EEM_Price_Type::instance();
2055
-        $price_types            = $price_type_model->get_all(
2056
-            [
2057
-                [
2058
-                    'OR' => [
2059
-                        'PBT_ID'  => '2',
2060
-                        'PBT_ID*' => '3',
2061
-                    ],
2062
-                ],
2063
-            ]
2064
-        );
2065
-        $all_price_types        = $default && ! $price instanceof EE_Price
2066
-            ? [esc_html__('Select Modifier', 'event_espresso')]
2067
-            : [];
2068
-        $selected_price_type_id = $default && ! $price instanceof EE_Price
2069
-            ? 0
2070
-            : $price->type();
2071
-        $price_option_spans     = '';
2072
-        // setup price types for selector
2073
-        foreach ($price_types as $price_type) {
2074
-            if (! $price_type instanceof EE_Price_Type) {
2075
-                continue;
2076
-            }
2077
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
2078
-            // while we're in the loop let's setup the option spans used by js
2079
-            $span_args          = [
2080
-                'PRT_ID'         => $price_type->ID(),
2081
-                'PRT_operator'   => $price_type->is_discount()
2082
-                    ? '-'
2083
-                    : '+',
2084
-                'PRT_is_percent' => $price_type->get('PRT_is_percent')
2085
-                    ? 1
2086
-                    : 0,
2087
-            ];
2088
-            $price_option_spans .= EEH_Template::display_template(
2089
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
2090
-                $span_args,
2091
-                true
2092
-            );
2093
-        }
2094
-
2095
-        $select_name = $disabled
2096
-            ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
2097
-            : $select_name;
2098
-
2099
-        $select_input = new EE_Select_Input(
2100
-            $all_price_types,
2101
-            [
2102
-                'default'               => $selected_price_type_id,
2103
-                'html_name'             => $select_name,
2104
-                'html_class'            => 'edit-price-PRT_ID',
2105
-                'other_html_attributes' => $disabled
2106
-                    ? 'style="width:auto;" disabled'
2107
-                    : 'style="width:auto;"',
2108
-            ]
2109
-        );
2110
-
2111
-        $price_selected_operator   = $price instanceof EE_Price && $price->is_discount()
2112
-            ? '-'
2113
-            : '+';
2114
-        $price_selected_operator   = $default && ! $price instanceof EE_Price
2115
-            ? ''
2116
-            : $price_selected_operator;
2117
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent()
2118
-            ? 1
2119
-            : 0;
2120
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price
2121
-            ? ''
2122
-            : $price_selected_is_percent;
2123
-        $template_args             = [
2124
-            'tkt_row'                   => $default
2125
-                ? 'TICKETNUM'
2126
-                : $ticket_row,
2127
-            'PRC_order'                 => $default && ! $price instanceof EE_Price
2128
-                ? 'PRICENUM'
2129
-                : $price_row,
2130
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
2131
-            'main_name'                 => $select_name,
2132
-            'selected_price_type_id'    => $selected_price_type_id,
2133
-            'price_option_spans'        => $price_option_spans,
2134
-            'price_selected_operator'   => $price_selected_operator,
2135
-            'price_selected_is_percent' => $price_selected_is_percent,
2136
-            'disabled'                  => $disabled,
2137
-        ];
2138
-        $template_args             = apply_filters(
2139
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2140
-            $template_args,
2141
-            $ticket_row,
2142
-            $price_row,
2143
-            $price,
2144
-            $default,
2145
-            $disabled,
2146
-            $this->_is_creating_event
2147
-        );
2148
-        return EEH_Template::display_template(
2149
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2150
-            $template_args,
2151
-            true
2152
-        );
2153
-    }
2154
-
2155
-
2156
-    /**
2157
-     * @param int|string       $datetime_row
2158
-     * @param int|string       $ticket_row
2159
-     * @param EE_Datetime|null $datetime
2160
-     * @param EE_Ticket|null   $ticket
2161
-     * @param array            $ticket_datetimes
2162
-     * @param bool             $default
2163
-     * @return string
2164
-     * @throws DomainException
2165
-     * @throws EE_Error
2166
-     * @throws ReflectionException
2167
-     */
2168
-    protected function _get_ticket_datetime_list_item(
2169
-        $datetime_row,
2170
-        $ticket_row,
2171
-        ?EE_Datetime $datetime,
2172
-        ?EE_Ticket $ticket,
2173
-        array $ticket_datetimes = [],
2174
-        bool $default = false
2175
-    ): string {
2176
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2177
-            ? $ticket_datetimes[ $ticket->ID() ]
2178
-            : [];
2179
-        $template_args = [
2180
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2181
-                ? 'DTTNUM'
2182
-                : $datetime_row,
2183
-            'tkt_row'                  => $default
2184
-                ? 'TICKETNUM'
2185
-                : $ticket_row,
2186
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2187
-                ? ' ticket-selected'
2188
-                : '',
2189
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2190
-                ? ' checked'
2191
-                : '',
2192
-            'DTT_name'                 => $default && empty($datetime)
2193
-                ? 'DTTNAME'
2194
-                : $datetime->get_dtt_display_name(true),
2195
-            'tkt_status_class'         => '',
2196
-        ];
2197
-        $template_args = apply_filters(
2198
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2199
-            $template_args,
2200
-            $datetime_row,
2201
-            $ticket_row,
2202
-            $datetime,
2203
-            $ticket,
2204
-            $ticket_datetimes,
2205
-            $default,
2206
-            $this->_is_creating_event
2207
-        );
2208
-        return EEH_Template::display_template(
2209
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2210
-            $template_args,
2211
-            true
2212
-        );
2213
-    }
2214
-
2215
-
2216
-    /**
2217
-     * @param array $all_datetimes
2218
-     * @param array $all_tickets
2219
-     * @return string
2220
-     * @throws ReflectionException
2221
-     * @throws InvalidArgumentException
2222
-     * @throws InvalidInterfaceException
2223
-     * @throws InvalidDataTypeException
2224
-     * @throws DomainException
2225
-     * @throws EE_Error
2226
-     */
2227
-    protected function _get_ticket_js_structure(array $all_datetimes = [], array $all_tickets = []): string
2228
-    {
2229
-        $template_args = [
2230
-            'default_datetime_edit_row' => $this->_get_dtt_edit_row(
2231
-                'DTTNUM',
2232
-                null,
2233
-                true,
2234
-                $all_datetimes
2235
-            ),
2236
-            'default_ticket_row'        => $this->_get_ticket_row(
2237
-                'TICKETNUM',
2238
-                null,
2239
-                [],
2240
-                [],
2241
-                true
2242
-            ),
2243
-            'default_price_row'         => $this->_get_ticket_price_row(
2244
-                'TICKETNUM',
2245
-                'PRICENUM',
2246
-                null,
2247
-                true,
2248
-                null
2249
-            ),
2250
-
2251
-            'default_price_rows'                       => '',
2252
-            'default_base_price_amount'                => 0,
2253
-            'default_base_price_name'                  => '',
2254
-            'default_base_price_description'           => '',
2255
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2256
-                'TICKETNUM',
2257
-                'PRICENUM',
2258
-                null,
2259
-                true
2260
-            ),
2261
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2262
-                'DTTNUM',
2263
-                null,
2264
-                [],
2265
-                [],
2266
-                true
2267
-            ),
2268
-            'existing_available_datetime_tickets_list' => '',
2269
-            'existing_available_ticket_datetimes_list' => '',
2270
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2271
-                'DTTNUM',
2272
-                'TICKETNUM',
2273
-                null,
2274
-                null,
2275
-                [],
2276
-                true
2277
-            ),
2278
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2279
-                'DTTNUM',
2280
-                'TICKETNUM',
2281
-                null,
2282
-                null,
2283
-                [],
2284
-                true
2285
-            ),
2286
-        ];
2287
-        $ticket_row    = 1;
2288
-        foreach ($all_tickets as $ticket) {
2289
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2290
-                'DTTNUM',
2291
-                $ticket_row,
2292
-                null,
2293
-                $ticket,
2294
-                [],
2295
-                true
2296
-            );
2297
-            $ticket_row++;
2298
-        }
2299
-        $datetime_row = 1;
2300
-        foreach ($all_datetimes as $datetime) {
2301
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2302
-                $datetime_row,
2303
-                'TICKETNUM',
2304
-                $datetime,
2305
-                null,
2306
-                [],
2307
-                true
2308
-            );
2309
-            $datetime_row++;
2310
-        }
2311
-        $price_model    = EEM_Price::instance();
2312
-        $default_prices = $price_model->get_all_default_prices();
2313
-        $price_row      = 1;
2314
-        foreach ($default_prices as $price) {
2315
-            if (! $price instanceof EE_Price) {
2316
-                continue;
2317
-            }
2318
-            if ($price->is_base_price()) {
2319
-                $template_args['default_base_price_amount']      = $price->get_pretty(
2320
-                    'PRC_amount',
2321
-                    'localized_float'
2322
-                );
2323
-                $template_args['default_base_price_name']        = $price->get('PRC_name');
2324
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2325
-                $price_row++;
2326
-                continue;
2327
-            }
2328
-
2329
-            $show_trash  = ! ((count($default_prices) > 1 && $price_row === 1) || count($default_prices) === 1);
2330
-            $show_create = ! (count($default_prices) > 1 && count($default_prices) !== $price_row);
2331
-
2332
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2333
-                'TICKETNUM',
2334
-                $price_row,
2335
-                $price,
2336
-                true,
2337
-                null,
2338
-                $show_trash,
2339
-                $show_create
2340
-            );
2341
-            $price_row++;
2342
-        }
2343
-        $template_args = apply_filters(
2344
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2345
-            $template_args,
2346
-            $all_datetimes,
2347
-            $all_tickets,
2348
-            $this->_is_creating_event
2349
-        );
2350
-        return EEH_Template::display_template(
2351
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2352
-            $template_args,
2353
-            true
2354
-        );
2355
-    }
231
+					],
232
+					'DTT_OVERSELL_WARNING'  => [
233
+						'datetime_ticket' => esc_html__(
234
+							'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
235
+							'event_espresso'
236
+						),
237
+						'ticket_datetime' => esc_html__(
238
+							'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
239
+							'event_espresso'
240
+						),
241
+					],
242
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
243
+						$this->_date_format_strings['date'],
244
+						$this->_date_format_strings['time']
245
+					),
246
+					'DTT_START_OF_WEEK'     => ['dayValue' => (int) get_option('start_of_week')],
247
+				],
248
+			],
249
+		];
250
+	}
251
+
252
+
253
+	/**
254
+	 * @param array $update_callbacks
255
+	 * @return array
256
+	 */
257
+	public function caf_updates(array $update_callbacks): array
258
+	{
259
+		unset($update_callbacks['_default_tickets_update']);
260
+		$update_callbacks['datetime_and_tickets_caf_update'] = [$this, 'datetime_and_tickets_caf_update'];
261
+		return $update_callbacks;
262
+	}
263
+
264
+
265
+	/**
266
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
267
+	 *
268
+	 * @param EE_Event $event The Event object we're attaching data to
269
+	 * @param array    $data  The request data from the form
270
+	 * @throws ReflectionException
271
+	 * @throws Exception
272
+	 * @throws InvalidInterfaceException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws EE_Error
275
+	 * @throws InvalidArgumentException
276
+	 */
277
+	public function datetime_and_tickets_caf_update(EE_Event $event, array $data)
278
+	{
279
+		// first we need to start with datetimes cause they are the "root" items attached to events.
280
+		$saved_datetimes = $this->_update_datetimes($event, $data);
281
+		// next tackle the tickets (and prices?)
282
+		$this->_update_tickets($event, $saved_datetimes, $data);
283
+	}
284
+
285
+
286
+	/**
287
+	 * update event_datetimes
288
+	 *
289
+	 * @param EE_Event $event Event being updated
290
+	 * @param array    $data  the request data from the form
291
+	 * @return EE_Datetime[]
292
+	 * @throws Exception
293
+	 * @throws ReflectionException
294
+	 * @throws InvalidInterfaceException
295
+	 * @throws InvalidDataTypeException
296
+	 * @throws InvalidArgumentException
297
+	 * @throws EE_Error
298
+	 */
299
+	protected function _update_datetimes(EE_Event $event, array $data): array
300
+	{
301
+		$saved_datetime_ids  = [];
302
+		$saved_datetime_objs = [];
303
+		$timezone            = $data['timezone_string'] ?? null;
304
+		$datetime_model      = EEM_Datetime::instance($timezone);
305
+
306
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
307
+			throw new InvalidArgumentException(
308
+				esc_html__(
309
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
310
+					'event_espresso'
311
+				)
312
+			);
313
+		}
314
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
315
+			// trim all values to ensure any excess whitespace is removed.
316
+			$datetime_data = array_map(
317
+				function ($datetime_data) {
318
+					return is_array($datetime_data)
319
+						? $datetime_data
320
+						: trim($datetime_data);
321
+				},
322
+				$datetime_data
323
+			);
324
+
325
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
326
+											&& ! empty($datetime_data['DTT_EVT_end'])
327
+				? $datetime_data['DTT_EVT_end']
328
+				: $datetime_data['DTT_EVT_start'];
329
+			$datetime_values              = [
330
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
331
+					? $datetime_data['DTT_ID']
332
+					: null,
333
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
334
+					? $datetime_data['DTT_name']
335
+					: '',
336
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
337
+					? $datetime_data['DTT_description']
338
+					: '',
339
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
340
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
341
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
342
+					? EE_INF
343
+					: $datetime_data['DTT_reg_limit'],
344
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
345
+					? $row
346
+					: $datetime_data['DTT_order'],
347
+			];
348
+
349
+			// if we have an id then let's get existing object first and then set the new values.
350
+			// Otherwise we instantiate a new object for save.
351
+			if (! empty($datetime_data['DTT_ID'])) {
352
+				$datetime = EE_Registry::instance()
353
+									   ->load_model('Datetime', [$timezone])
354
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
355
+				// set date and time format according to what is set in this class.
356
+				$datetime->set_date_format($this->_date_format_strings['date']);
357
+				$datetime->set_time_format($this->_date_format_strings['time']);
358
+				foreach ($datetime_values as $field => $value) {
359
+					$datetime->set($field, $value);
360
+				}
361
+
362
+				// make sure the $datetime_id here is saved just in case
363
+				// after the add_relation_to() the autosave replaces it.
364
+				// We need to do this so we dont' TRASH the parent DTT.
365
+				// (save the ID for both key and value to avoid duplications)
366
+				$saved_datetime_ids[ $datetime->ID() ] = $datetime->ID();
367
+			} else {
368
+				$datetime = EE_Datetime::new_instance(
369
+					$datetime_values,
370
+					$timezone,
371
+					[$this->_date_format_strings['date'], $this->_date_format_strings['time']]
372
+				);
373
+				foreach ($datetime_values as $field => $value) {
374
+					$datetime->set($field, $value);
375
+				}
376
+			}
377
+			$datetime->save();
378
+			do_action(
379
+				'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
380
+				$datetime,
381
+				$row,
382
+				$datetime_data,
383
+				$data
384
+			);
385
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
386
+			// before going any further make sure our dates are setup correctly
387
+			// so that the end date is always equal or greater than the start date.
388
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
389
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
390
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
391
+				$datetime->save();
392
+			}
393
+			// now we have to make sure we add the new DTT_ID to the $saved_datetime_ids array
394
+			// because it is possible there was a new one created for the autosave.
395
+			// (save the ID for both key and value to avoid duplications)
396
+			$DTT_ID                        = $datetime->ID();
397
+			$saved_datetime_ids[ $DTT_ID ] = $DTT_ID;
398
+			$saved_datetime_objs[ $row ]   = $datetime;
399
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
400
+		}
401
+		$event->save();
402
+		// now we need to REMOVE any datetimes that got deleted.
403
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
404
+		// So its safe to permanently delete at this point.
405
+		$old_datetimes = explode(',', $data['datetime_IDs']);
406
+		$old_datetimes = $old_datetimes[0] === ''
407
+			? []
408
+			: $old_datetimes;
409
+		if (is_array($old_datetimes)) {
410
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_datetime_ids);
411
+			foreach ($datetimes_to_delete as $id) {
412
+				$id = absint($id);
413
+				if (empty($id)) {
414
+					continue;
415
+				}
416
+				$dtt_to_remove = $datetime_model->get_one_by_ID($id);
417
+				// remove tkt relationships.
418
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
419
+				foreach ($related_tickets as $ticket) {
420
+					$dtt_to_remove->_remove_relation_to($ticket, 'Ticket');
421
+				}
422
+				$event->_remove_relation_to($id, 'Datetime');
423
+				$dtt_to_remove->refresh_cache_of_related_objects();
424
+			}
425
+		}
426
+		return $saved_datetime_objs;
427
+	}
428
+
429
+
430
+	/**
431
+	 * update tickets
432
+	 *
433
+	 * @param EE_Event      $event           Event object being updated
434
+	 * @param EE_Datetime[] $saved_datetimes an array of datetime ids being updated
435
+	 * @param array         $data            incoming request data
436
+	 * @return EE_Ticket[]
437
+	 * @throws Exception
438
+	 * @throws ReflectionException
439
+	 * @throws InvalidInterfaceException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidArgumentException
442
+	 * @throws EE_Error
443
+	 */
444
+	protected function _update_tickets(EE_Event $event, array $saved_datetimes, array $data): array
445
+	{
446
+		$new_ticket = null;
447
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
448
+		$data         = stripslashes_deep($data);
449
+		$timezone     = $data['timezone_string'] ?? null;
450
+		$ticket_model = EEM_Ticket::instance($timezone);
451
+
452
+		$saved_tickets = [];
453
+		$old_tickets   = isset($data['ticket_IDs'])
454
+			? explode(',', $data['ticket_IDs'])
455
+			: [];
456
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
457
+			throw new InvalidArgumentException(
458
+				esc_html__(
459
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
460
+					'event_espresso'
461
+				)
462
+			);
463
+		}
464
+		foreach ($data['edit_tickets'] as $row => $ticket_data) {
465
+			$update_prices = $create_new_TKT = false;
466
+			// figure out what datetimes were added to the ticket
467
+			// and what datetimes were removed from the ticket in the session.
468
+			$starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
469
+			$ticket_datetime_rows          = explode(',', $data['ticket_datetime_rows'][ $row ]);
470
+			$datetimes_added               = array_diff($ticket_datetime_rows, $starting_ticket_datetime_rows);
471
+			$datetimes_removed             = array_diff($starting_ticket_datetime_rows, $ticket_datetime_rows);
472
+			// trim inputs to ensure any excess whitespace is removed.
473
+			$ticket_data = array_map(
474
+				function ($ticket_data) {
475
+					return is_array($ticket_data)
476
+						? $ticket_data
477
+						: trim($ticket_data);
478
+				},
479
+				$ticket_data
480
+			);
481
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
482
+			// because we're doing calculations prior to using the models.
483
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
484
+			$ticket_price = isset($ticket_data['TKT_price'])
485
+				? round((float) $ticket_data['TKT_price'], 3)
486
+				: 0;
487
+			// note incoming base price needs converted from localized value.
488
+			$base_price = isset($ticket_data['TKT_base_price'])
489
+				? EEH_Money::convert_to_float_from_localized_money($ticket_data['TKT_base_price'])
490
+				: 0;
491
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
492
+			$ticket_price  = $ticket_price === 0 && $base_price !== 0
493
+				? $base_price
494
+				: $ticket_price;
495
+			$base_price_id = $ticket_data['TKT_base_price_ID'] ?? 0;
496
+			$price_rows    = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
497
+				? $data['edit_prices'][ $row ]
498
+				: [];
499
+			$now           = null;
500
+			if (empty($ticket_data['TKT_start_date'])) {
501
+				// lets' use now in the set timezone.
502
+				$now                           = new DateTime('now', new DateTimeZone($event->get_timezone()));
503
+				$ticket_data['TKT_start_date'] = $now->format($this->_date_time_format);
504
+			}
505
+			if (empty($ticket_data['TKT_end_date'])) {
506
+				/**
507
+				 * set the TKT_end_date to the first datetime attached to the ticket.
508
+				 */
509
+				$first_datetime              = $saved_datetimes[ reset($ticket_datetime_rows) ];
510
+				$ticket_data['TKT_end_date'] = $first_datetime->start_date_and_time($this->_date_time_format);
511
+			}
512
+			$TKT_values = [
513
+				'TKT_ID'          => ! empty($ticket_data['TKT_ID'])
514
+					? $ticket_data['TKT_ID']
515
+					: null,
516
+				'TTM_ID'          => ! empty($ticket_data['TTM_ID'])
517
+					? $ticket_data['TTM_ID']
518
+					: 0,
519
+				'TKT_name'        => ! empty($ticket_data['TKT_name'])
520
+					? $ticket_data['TKT_name']
521
+					: '',
522
+				'TKT_description' => ! empty($ticket_data['TKT_description'])
523
+									 && $ticket_data['TKT_description'] !== esc_html__(
524
+					'You can modify this description',
525
+					'event_espresso'
526
+				)
527
+					? $ticket_data['TKT_description']
528
+					: '',
529
+				'TKT_start_date'  => $ticket_data['TKT_start_date'],
530
+				'TKT_end_date'    => $ticket_data['TKT_end_date'],
531
+				'TKT_qty'         => ! isset($ticket_data['TKT_qty']) || $ticket_data['TKT_qty'] === ''
532
+					? EE_INF
533
+					: $ticket_data['TKT_qty'],
534
+				'TKT_uses'        => ! isset($ticket_data['TKT_uses']) || $ticket_data['TKT_uses'] === ''
535
+					? EE_INF
536
+					: $ticket_data['TKT_uses'],
537
+				'TKT_min'         => empty($ticket_data['TKT_min'])
538
+					? 0
539
+					: $ticket_data['TKT_min'],
540
+				'TKT_max'         => empty($ticket_data['TKT_max'])
541
+					? EE_INF
542
+					: $ticket_data['TKT_max'],
543
+				'TKT_row'         => $row,
544
+				'TKT_order'       => $ticket_data['TKT_order'] ?? 0,
545
+				'TKT_taxable'     => ! empty($ticket_data['TKT_taxable'])
546
+					? 1
547
+					: 0,
548
+				'TKT_required'    => ! empty($ticket_data['TKT_required'])
549
+					? 1
550
+					: 0,
551
+				'TKT_price'       => $ticket_price,
552
+			];
553
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
554
+			// which means in turn that the prices will become new prices as well.
555
+			if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) {
556
+				$TKT_values['TKT_ID']         = 0;
557
+				$TKT_values['TKT_is_default'] = 0;
558
+				$update_prices                = true;
559
+			}
560
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
561
+			// we actually do our saves ahead of doing any add_relations to
562
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
563
+			// but DID have it's items modified.
564
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
565
+			// then we won't be updating the ticket but instead a new ticket will be created and the old one archived.
566
+			if (absint($TKT_values['TKT_ID'])) {
567
+				$ticket = EE_Registry::instance()
568
+									 ->load_model('Ticket', [$timezone])
569
+									 ->get_one_by_ID($TKT_values['TKT_ID']);
570
+				if ($ticket instanceof EE_Ticket) {
571
+					$ticket = $this->_update_ticket_datetimes(
572
+						$ticket,
573
+						$saved_datetimes,
574
+						$datetimes_added,
575
+						$datetimes_removed
576
+					);
577
+					// are there any registrations using this ticket ?
578
+					$tickets_sold = $ticket->count_related(
579
+						'Registration',
580
+						[
581
+							[
582
+								'STS_ID' => ['NOT IN', [EEM_Registration::status_id_incomplete]],
583
+							],
584
+						]
585
+					);
586
+					// set ticket formats
587
+					$ticket->set_date_format($this->_date_format_strings['date']);
588
+					$ticket->set_time_format($this->_date_format_strings['time']);
589
+					// let's just check the total price for the existing ticket
590
+					// and determine if it matches the new total price.
591
+					// if they are different then we create a new ticket (if tickets sold)
592
+					// if they aren't different then we go ahead and modify existing ticket.
593
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
594
+					// set new values
595
+					foreach ($TKT_values as $field => $value) {
596
+						if ($field === 'TKT_qty') {
597
+							$ticket->set_qty($value);
598
+						} else {
599
+							$ticket->set($field, $value);
600
+						}
601
+					}
602
+					// if $create_new_TKT is false then we can safely update the existing ticket.
603
+					// Otherwise we have to create a new ticket.
604
+					if ($create_new_TKT) {
605
+						$new_ticket = $this->_duplicate_ticket(
606
+							$ticket,
607
+							$price_rows,
608
+							$ticket_price,
609
+							$base_price,
610
+							$base_price_id
611
+						);
612
+					}
613
+				}
614
+			} else {
615
+				// no TKT_id so a new TKT
616
+				$ticket = EE_Ticket::new_instance(
617
+					$TKT_values,
618
+					$timezone,
619
+					[$this->_date_format_strings['date'], $this->_date_format_strings['time']]
620
+				);
621
+				if ($ticket instanceof EE_Ticket) {
622
+					// make sure ticket has an ID of setting relations won't work
623
+					$ticket->save();
624
+					$ticket        = $this->_update_ticket_datetimes(
625
+						$ticket,
626
+						$saved_datetimes,
627
+						$datetimes_added,
628
+						$datetimes_removed
629
+					);
630
+					$update_prices = true;
631
+				}
632
+			}
633
+			// make sure any current values have been saved.
634
+			// $ticket->save();
635
+			// before going any further make sure our dates are setup correctly
636
+			// so that the end date is always equal or greater than the start date.
637
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
638
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
639
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
640
+			}
641
+			// let's make sure the base price is handled
642
+			$ticket = ! $create_new_TKT
643
+				? $this->_add_prices_to_ticket(
644
+					[],
645
+					$ticket,
646
+					$update_prices,
647
+					$base_price,
648
+					$base_price_id
649
+				)
650
+				: $ticket;
651
+			// add/update price_modifiers
652
+			$ticket = ! $create_new_TKT
653
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
654
+				: $ticket;
655
+			// need to make sue that the TKT_price is accurate after saving the prices.
656
+			$ticket->ensure_TKT_Price_correct();
657
+			// handle CREATING a default ticket from the incoming ticket but ONLY if this isn't an autosave.
658
+			if (! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) {
659
+				$new_default = clone $ticket;
660
+				$new_default->set('TKT_ID', 0);
661
+				$new_default->set('TKT_is_default', 1);
662
+				$new_default->set('TKT_row', 1);
663
+				$new_default->set('TKT_price', $ticket_price);
664
+				// remove any datetime relations cause we DON'T want datetime relations attached
665
+				// (note this is just removing the cached relations in the object)
666
+				$new_default->_remove_relations('Datetime');
667
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
668
+				$new_default = $this->_add_prices_to_ticket(
669
+					$price_rows,
670
+					$new_default,
671
+					true
672
+				);
673
+				// don't forget the base price!
674
+				$new_default = $this->_add_prices_to_ticket(
675
+					[],
676
+					$new_default,
677
+					true,
678
+					$base_price,
679
+					$base_price_id
680
+				);
681
+				$new_default->save();
682
+				do_action(
683
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
684
+					$new_default,
685
+					$row,
686
+					$ticket,
687
+					$data
688
+				);
689
+			}
690
+			// DO ALL datetime relationships for both current tickets and any archived tickets
691
+			// for the given datetime that are related to the current ticket.
692
+			// TODO... not sure exactly how we're going to do this considering we don't know
693
+			// what current ticket the archived tickets are related to
694
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
695
+			// let's assign any tickets that have been setup to the saved_tickets tracker
696
+			// save existing TKT
697
+			$ticket->save();
698
+			if ($create_new_TKT && $new_ticket instanceof EE_Ticket) {
699
+				// save new TKT
700
+				$new_ticket->save();
701
+				// add new ticket to array
702
+				$saved_tickets[ $new_ticket->ID() ] = $new_ticket;
703
+				do_action(
704
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
705
+					$new_ticket,
706
+					$row,
707
+					$ticket_data,
708
+					$data
709
+				);
710
+			} else {
711
+				// add ticket to saved tickets
712
+				$saved_tickets[ $ticket->ID() ] = $ticket;
713
+				do_action(
714
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
715
+					$ticket,
716
+					$row,
717
+					$ticket_data,
718
+					$data
719
+				);
720
+			}
721
+		}
722
+		// now we need to handle tickets actually "deleted permanently".
723
+		// There are cases where we'd want this to happen
724
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
725
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
726
+		// No sense in keeping all the related data in the db!
727
+		$old_tickets     = isset($old_tickets[0]) && $old_tickets[0] === ''
728
+			? []
729
+			: $old_tickets;
730
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
731
+		foreach ($tickets_removed as $id) {
732
+			$id = absint($id);
733
+			// get the ticket for this id
734
+			$ticket_to_remove = $ticket_model->get_one_by_ID($id);
735
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
736
+			if ($ticket_to_remove->get('TKT_is_default')) {
737
+				continue;
738
+			}
739
+			// if this ticket has any registrations attached so then we just ARCHIVE
740
+			// because we don't actually permanently delete these tickets.
741
+			if ($ticket_to_remove->count_related('Registration') > 0) {
742
+				$ticket_to_remove->delete();
743
+				continue;
744
+			}
745
+			// need to get all the related datetimes on this ticket and remove from every single one of them
746
+			// (remember this process can ONLY kick off if there are NO tickets_sold)
747
+			$datetimes = $ticket_to_remove->get_many_related('Datetime');
748
+			foreach ($datetimes as $datetime) {
749
+				$ticket_to_remove->_remove_relation_to($datetime, 'Datetime');
750
+			}
751
+			// need to do the same for prices (except these prices can also be deleted because again,
752
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
753
+			$ticket_to_remove->delete_related('Price');
754
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $ticket_to_remove);
755
+			// finally let's delete this ticket
756
+			// (which should not be blocked at this point b/c we've removed all our relationships)
757
+			$ticket_to_remove->delete_or_restore();
758
+		}
759
+		return $saved_tickets;
760
+	}
761
+
762
+
763
+	/**
764
+	 * @access  protected
765
+	 * @param EE_Ticket     $ticket
766
+	 * @param EE_Datetime[] $saved_datetimes
767
+	 * @param int[]         $added_datetimes
768
+	 * @param int[]         $removed_datetimes
769
+	 * @return EE_Ticket
770
+	 * @throws EE_Error
771
+	 * @throws ReflectionException
772
+	 */
773
+	protected function _update_ticket_datetimes(
774
+		EE_Ticket $ticket,
775
+		array $saved_datetimes = [],
776
+		array $added_datetimes = [],
777
+		array $removed_datetimes = []
778
+	): EE_Ticket {
779
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
780
+		// and removing the ticket from datetimes it got removed from.
781
+		// first let's add datetimes
782
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
783
+			foreach ($added_datetimes as $row_id) {
784
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
785
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
786
+					// Is this an existing ticket (has an ID) and does it have any sold?
787
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
788
+					if ($ticket->ID() && $ticket->sold() > 0) {
789
+						$saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
790
+					}
791
+				}
792
+			}
793
+		}
794
+		// then remove datetimes
795
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
796
+			foreach ($removed_datetimes as $row_id) {
797
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
798
+				// So make sure we skip over this if the datetime isn't in the $saved_datetimes array)
799
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
800
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
801
+				}
802
+			}
803
+		}
804
+		// cap ticket qty by datetime reg limits
805
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
806
+		return $ticket;
807
+	}
808
+
809
+
810
+	/**
811
+	 * @access  protected
812
+	 * @param EE_Ticket $ticket
813
+	 * @param array     $price_rows
814
+	 * @param int|float $ticket_price
815
+	 * @param int|float $base_price
816
+	 * @param int       $base_price_id
817
+	 * @return EE_Ticket
818
+	 * @throws ReflectionException
819
+	 * @throws InvalidArgumentException
820
+	 * @throws InvalidInterfaceException
821
+	 * @throws InvalidDataTypeException
822
+	 * @throws EE_Error
823
+	 */
824
+	protected function _duplicate_ticket(
825
+		EE_Ticket $ticket,
826
+		array $price_rows = [],
827
+		$ticket_price = 0,
828
+		$base_price = 0,
829
+		int $base_price_id = 0
830
+	): EE_Ticket {
831
+		// create new ticket that's a copy of the existing
832
+		// except a new id of course (and not archived)
833
+		// AND has the new TKT_price associated with it.
834
+		$new_ticket = clone $ticket;
835
+		$new_ticket->set('TKT_ID', 0);
836
+		$new_ticket->set_deleted(0);
837
+		$new_ticket->set_price($ticket_price);
838
+		$new_ticket->set_sold(0);
839
+		// let's get a new ID for this ticket
840
+		$new_ticket->save();
841
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
842
+		$datetimes_on_existing = $ticket->datetimes();
843
+		$new_ticket            = $this->_update_ticket_datetimes(
844
+			$new_ticket,
845
+			$datetimes_on_existing,
846
+			array_keys($datetimes_on_existing)
847
+		);
848
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
849
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
850
+		// available.
851
+		if ($ticket->sold() > 0) {
852
+			$new_qty = $ticket->qty() - $ticket->sold();
853
+			$new_ticket->set_qty($new_qty);
854
+		}
855
+		// now we update the prices just for this ticket
856
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
857
+		// and we update the base price
858
+		return $this->_add_prices_to_ticket(
859
+			[],
860
+			$new_ticket,
861
+			true,
862
+			$base_price,
863
+			$base_price_id
864
+		);
865
+	}
866
+
867
+
868
+	/**
869
+	 * This attaches a list of given prices to a ticket.
870
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
871
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
872
+	 * price info and prices are automatically "archived" via the ticket.
873
+	 *
874
+	 * @access  private
875
+	 * @param array     $prices        Array of prices from the form.
876
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
877
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
878
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
879
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
880
+	 * @return EE_Ticket
881
+	 * @throws ReflectionException
882
+	 * @throws InvalidArgumentException
883
+	 * @throws InvalidInterfaceException
884
+	 * @throws InvalidDataTypeException
885
+	 * @throws EE_Error
886
+	 */
887
+	protected function _add_prices_to_ticket(
888
+		array $prices,
889
+		EE_Ticket $ticket,
890
+		bool $new_prices = false,
891
+		$base_price = false,
892
+		$base_price_id = false
893
+	): EE_Ticket {
894
+		$price_model = EEM_Price::instance();
895
+		// let's just get any current prices that may exist on the given ticket
896
+		// so we can remove any prices that got trashed in this session.
897
+		$current_prices_on_ticket = $base_price !== false
898
+			? $ticket->base_price(true)
899
+			: $ticket->price_modifiers();
900
+		$updated_prices           = [];
901
+		// if $base_price ! FALSE then updating a base price.
902
+		if ($base_price !== false) {
903
+			$prices[1] = [
904
+				'PRC_ID'     => $new_prices || $base_price_id === 1
905
+					? null
906
+					: $base_price_id,
907
+				'PRT_ID'     => 1,
908
+				'PRC_amount' => $base_price,
909
+				'PRC_name'   => $ticket->get('TKT_name'),
910
+				'PRC_desc'   => $ticket->get('TKT_description'),
911
+			];
912
+		}
913
+		// possibly need to save ticket
914
+		if (! $ticket->ID()) {
915
+			$ticket->save();
916
+		}
917
+		foreach ($prices as $row => $prc) {
918
+			$prt_id = ! empty($prc['PRT_ID'])
919
+				? $prc['PRT_ID']
920
+				: null;
921
+			if (empty($prt_id)) {
922
+				continue;
923
+			} //prices MUST have a price type id.
924
+			$PRC_values = [
925
+				'PRC_ID'         => ! empty($prc['PRC_ID'])
926
+					? $prc['PRC_ID']
927
+					: null,
928
+				'PRT_ID'         => $prt_id,
929
+				'PRC_amount'     => ! empty($prc['PRC_amount'])
930
+					? $prc['PRC_amount']
931
+					: 0,
932
+				'PRC_name'       => ! empty($prc['PRC_name'])
933
+					? $prc['PRC_name']
934
+					: '',
935
+				'PRC_desc'       => ! empty($prc['PRC_desc'])
936
+					? $prc['PRC_desc']
937
+					: '',
938
+				'PRC_is_default' => false,
939
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
940
+				'PRC_order'      => $row,
941
+			];
942
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
943
+				$PRC_values['PRC_ID'] = 0;
944
+				$price                = EE_Registry::instance()->load_class(
945
+					'Price',
946
+					[$PRC_values],
947
+					false,
948
+					false
949
+				);
950
+			} else {
951
+				$price = $price_model->get_one_by_ID($prc['PRC_ID']);
952
+				// update this price with new values
953
+				foreach ($PRC_values as $field => $value) {
954
+					$price->set($field, $value);
955
+				}
956
+			}
957
+			$price->save();
958
+			$updated_prices[ $price->ID() ] = $price;
959
+			$ticket->_add_relation_to($price, 'Price');
960
+		}
961
+		// now let's remove any prices that got removed from the ticket
962
+		if (! empty($current_prices_on_ticket)) {
963
+			$current          = array_keys($current_prices_on_ticket);
964
+			$updated          = array_keys($updated_prices);
965
+			$prices_to_remove = array_diff($current, $updated);
966
+			if (! empty($prices_to_remove)) {
967
+				foreach ($prices_to_remove as $prc_id) {
968
+					$p = $current_prices_on_ticket[ $prc_id ];
969
+					$ticket->_remove_relation_to($p, 'Price');
970
+					// delete permanently the price
971
+					$p->delete_or_restore();
972
+				}
973
+			}
974
+		}
975
+		return $ticket;
976
+	}
977
+
978
+
979
+	/**
980
+	 * @throws ReflectionException
981
+	 * @throws InvalidArgumentException
982
+	 * @throws InvalidInterfaceException
983
+	 * @throws InvalidDataTypeException
984
+	 * @throws DomainException
985
+	 * @throws EE_Error
986
+	 */
987
+	public function pricing_metabox()
988
+	{
989
+		$event          = $this->_adminpage_obj->get_cpt_model_obj();
990
+		$timezone       = $event instanceof EE_Event
991
+			? $event->timezone_string()
992
+			: null;
993
+		$price_model    = EEM_Price::instance($timezone);
994
+		$ticket_model   = EEM_Ticket::instance($timezone);
995
+		$datetime_model = EEM_Datetime::instance($timezone);
996
+		$all_tickets    = [];
997
+
998
+		// set is_creating_event property.
999
+		$EVT_ID                   = $event->ID();
1000
+		$this->_is_creating_event = empty($this->_req_data['post']);
1001
+		$existing_datetime_ids    = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = [];
1002
+
1003
+		// default main template args
1004
+		$main_template_args = [
1005
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1006
+				'event_editor_event_datetimes_help_tab',
1007
+				$this->_adminpage_obj->page_slug,
1008
+				$this->_adminpage_obj->get_req_action()
1009
+			),
1010
+
1011
+			// todo need to add a filter to the template for the help text
1012
+			// in the Events_Admin_Page core file so we can add further help
1013
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1014
+				'add_new_dtt_info',
1015
+				$this->_adminpage_obj->page_slug,
1016
+				$this->_adminpage_obj->get_req_action()
1017
+			),
1018
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1019
+			'datetime_rows'            => '',
1020
+			'show_tickets_container'   => '',
1021
+			'ticket_rows'              => '',
1022
+			'ee_collapsible_status'    => ' ee-collapsible-open',
1023
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1024
+		];
1025
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1026
+
1027
+		/**
1028
+		 * 1. Start with retrieving Datetimes
1029
+		 * 2. For each datetime get related tickets
1030
+		 * 3. For each ticket get related prices
1031
+		 */
1032
+		$datetimes                            = $datetime_model->get_all_event_dates($EVT_ID);
1033
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1034
+
1035
+		/**
1036
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1037
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1038
+		 */
1039
+		$datetime_row = 1;
1040
+		foreach ($datetimes as $datetime) {
1041
+			$DTT_ID = $datetime->get('DTT_ID');
1042
+			$datetime->set('DTT_order', $datetime_row);
1043
+			$existing_datetime_ids[] = $DTT_ID;
1044
+			// tickets attached
1045
+			$related_tickets = $datetime->ID() > 0
1046
+				? $datetime->get_many_related(
1047
+					'Ticket',
1048
+					[
1049
+						[
1050
+							'OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0],
1051
+						],
1052
+						'default_where_conditions' => 'none',
1053
+						'order_by'                 => ['TKT_order' => 'ASC'],
1054
+					]
1055
+				)
1056
+				: [];
1057
+			// if there are no related tickets this is likely a new event OR auto-draft
1058
+			// event so we need to generate the default tickets because datetimes
1059
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1060
+			// datetime on the event.
1061
+			if (empty($related_tickets) && count($datetimes) < 2) {
1062
+				$related_tickets = $ticket_model->get_all_default_tickets();
1063
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1064
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1065
+				$default_prices      = $price_model->get_all_default_prices();
1066
+				$main_default_ticket = reset($related_tickets);
1067
+				if ($main_default_ticket instanceof EE_Ticket) {
1068
+					foreach ($default_prices as $default_price) {
1069
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1070
+							continue;
1071
+						}
1072
+						$main_default_ticket->cache('Price', $default_price);
1073
+					}
1074
+				}
1075
+			}
1076
+			// we can't actually setup rows in this loop yet cause we don't know all
1077
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1078
+			// So we're going to temporarily cache some of that information.
1079
+			// loop through and setup the ticket rows and make sure the order is set.
1080
+			foreach ($related_tickets as $ticket) {
1081
+				$TKT_ID     = $ticket->get('TKT_ID');
1082
+				$ticket_row = $ticket->get('TKT_row');
1083
+				// we only want unique tickets in our final display!!
1084
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1085
+					$existing_ticket_ids[] = $TKT_ID;
1086
+					$all_tickets[]         = $ticket;
1087
+				}
1088
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1089
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1090
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1091
+				if (
1092
+					! isset($ticket_datetimes[ $TKT_ID ])
1093
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1094
+				) {
1095
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1096
+				}
1097
+			}
1098
+			$datetime_row++;
1099
+		}
1100
+		$main_template_args['total_ticket_rows']     = count($existing_ticket_ids);
1101
+		$main_template_args['existing_ticket_ids']   = implode(',', $existing_ticket_ids);
1102
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1103
+		// sort $all_tickets by order
1104
+		usort(
1105
+			$all_tickets,
1106
+			function (EE_Ticket $a, EE_Ticket $b) {
1107
+				$a_order = (int) $a->get('TKT_order');
1108
+				$b_order = (int) $b->get('TKT_order');
1109
+				if ($a_order === $b_order) {
1110
+					return 0;
1111
+				}
1112
+				return ($a_order < $b_order)
1113
+					? -1
1114
+					: 1;
1115
+			}
1116
+		);
1117
+		// k NOW we have all the data we need for setting up the datetime rows
1118
+		// and ticket rows so we start our datetime loop again.
1119
+		$datetime_row = 1;
1120
+		foreach ($datetimes as $datetime) {
1121
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1122
+				$datetime_row,
1123
+				$datetime,
1124
+				$datetime_tickets,
1125
+				$all_tickets,
1126
+				false,
1127
+				$datetimes
1128
+			);
1129
+			$datetime_row++;
1130
+		}
1131
+		// then loop through all tickets for the ticket rows.
1132
+		$ticket_row = 1;
1133
+		foreach ($all_tickets as $ticket) {
1134
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1135
+				$ticket_row,
1136
+				$ticket,
1137
+				$ticket_datetimes,
1138
+				$datetimes,
1139
+				false,
1140
+				$all_tickets
1141
+			);
1142
+			$ticket_row++;
1143
+		}
1144
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1145
+
1146
+		$status_change_notice = LoaderFactory::getLoader()->getShared(
1147
+			'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
1148
+		);
1149
+
1150
+		$main_template_args['status_change_notice'] = $status_change_notice->display(
1151
+			'__event-editor',
1152
+			'espresso-events'
1153
+		);
1154
+
1155
+		EEH_Template::display_template(
1156
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1157
+			$main_template_args
1158
+		);
1159
+	}
1160
+
1161
+
1162
+	/**
1163
+	 * @param int|string  $datetime_row
1164
+	 * @param EE_Datetime $datetime
1165
+	 * @param array       $datetime_tickets
1166
+	 * @param array       $all_tickets
1167
+	 * @param bool        $default
1168
+	 * @param array       $all_datetimes
1169
+	 * @return string
1170
+	 * @throws DomainException
1171
+	 * @throws EE_Error
1172
+	 * @throws ReflectionException
1173
+	 */
1174
+	protected function _get_datetime_row(
1175
+		$datetime_row,
1176
+		EE_Datetime $datetime,
1177
+		array $datetime_tickets = [],
1178
+		array $all_tickets = [],
1179
+		bool $default = false,
1180
+		array $all_datetimes = []
1181
+	): string {
1182
+		return EEH_Template::display_template(
1183
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1184
+			[
1185
+				'dtt_edit_row'             => $this->_get_dtt_edit_row(
1186
+					$datetime_row,
1187
+					$datetime,
1188
+					$default,
1189
+					$all_datetimes
1190
+				),
1191
+				'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1192
+					$datetime_row,
1193
+					$datetime,
1194
+					$datetime_tickets,
1195
+					$all_tickets,
1196
+					$default
1197
+				),
1198
+				'dtt_row'                  => $default
1199
+					? 'DTTNUM'
1200
+					: $datetime_row,
1201
+			],
1202
+			true
1203
+		);
1204
+	}
1205
+
1206
+
1207
+	/**
1208
+	 * This method is used to generate a datetime fields  edit row.
1209
+	 * The same row is used to generate a row with valid DTT objects
1210
+	 * and the default row that is used as the skeleton by the js.
1211
+	 *
1212
+	 * @param int|string       $datetime_row  The row number for the row being generated.
1213
+	 * @param EE_Datetime|null $datetime
1214
+	 * @param bool             $default       Whether a default row is being generated or not.
1215
+	 * @param EE_Datetime[]    $all_datetimes This is the array of all datetimes used in the editor.
1216
+	 * @return string
1217
+	 * @throws EE_Error
1218
+	 * @throws ReflectionException
1219
+	 */
1220
+	protected function _get_dtt_edit_row(
1221
+		$datetime_row,
1222
+		?EE_Datetime $datetime,
1223
+		bool $default,
1224
+		array $all_datetimes
1225
+	): string {
1226
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1227
+		$default                     = ! $datetime instanceof EE_Datetime
1228
+			? true
1229
+			: $default;
1230
+		$template_args               = [
1231
+			'dtt_row'              => $default
1232
+				? 'DTTNUM'
1233
+				: $datetime_row,
1234
+			'event_datetimes_name' => $default
1235
+				? 'DTTNAMEATTR'
1236
+				: 'edit_event_datetimes',
1237
+			'edit_dtt_expanded'    => '',
1238
+			'DTT_ID'               => $default
1239
+				? ''
1240
+				: $datetime->ID(),
1241
+			'DTT_name'             => $default
1242
+				? ''
1243
+				: $datetime->get_f('DTT_name'),
1244
+			'DTT_description'      => $default
1245
+				? ''
1246
+				: $datetime->get_raw('DTT_description'),
1247
+			'DTT_EVT_start'        => $default
1248
+				? ''
1249
+				: $datetime->start_date($this->_date_time_format),
1250
+			'DTT_EVT_end'          => $default
1251
+				? ''
1252
+				: $datetime->end_date($this->_date_time_format),
1253
+			'DTT_reg_limit'        => $default
1254
+				? ''
1255
+				: $datetime->get_pretty(
1256
+					'DTT_reg_limit',
1257
+					'input'
1258
+				),
1259
+			'DTT_order'            => $default
1260
+				? 'DTTNUM'
1261
+				: $datetime_row,
1262
+			'dtt_sold'             => $default
1263
+				? '0'
1264
+				: $datetime->get('DTT_sold'),
1265
+			'dtt_reserved'         => $default
1266
+				? '0'
1267
+				: $datetime->reserved(),
1268
+			'can_clone'            => $datetime instanceof EE_Datetime,
1269
+			'can_trash'            => count($all_datetimes) > 1
1270
+									  && $datetime instanceof EE_Datetime
1271
+									  && ! $datetime->get('DTT_sold'),
1272
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1273
+				? 'trash-entity dashicons dashicons-lock'
1274
+				: 'trash-entity dashicons dashicons-post-trash clickable',
1275
+			'reg_list_url'         => $default || ! $datetime->event() instanceof EE_Event
1276
+				? ''
1277
+				: EE_Admin_Page::add_query_args_and_nonce(
1278
+					[
1279
+						'event_id'    => $datetime->event()->ID(),
1280
+						'datetime_id' => $datetime->ID(),
1281
+						'use_filters' => true,
1282
+					],
1283
+					REG_ADMIN_URL
1284
+				),
1285
+		];
1286
+		$template_args['show_trash'] = count($all_datetimes) === 1
1287
+									   && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1288
+			? 'display:none'
1289
+			: '';
1290
+		// allow filtering of template args at this point.
1291
+		$template_args = apply_filters(
1292
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1293
+			$template_args,
1294
+			$datetime_row,
1295
+			$datetime,
1296
+			$default,
1297
+			$all_datetimes,
1298
+			$this->_is_creating_event
1299
+		);
1300
+		return EEH_Template::display_template(
1301
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1302
+			$template_args,
1303
+			true
1304
+		);
1305
+	}
1306
+
1307
+
1308
+	/**
1309
+	 * @param int|string       $datetime_row
1310
+	 * @param EE_Datetime|null $datetime
1311
+	 * @param array            $datetime_tickets
1312
+	 * @param array            $all_tickets
1313
+	 * @param bool             $default
1314
+	 * @return string
1315
+	 * @throws DomainException
1316
+	 * @throws EE_Error
1317
+	 * @throws ReflectionException
1318
+	 */
1319
+	protected function _get_dtt_attached_tickets_row(
1320
+		$datetime_row,
1321
+		?EE_Datetime $datetime,
1322
+		array $datetime_tickets = [],
1323
+		array $all_tickets = [],
1324
+		bool $default = false
1325
+	): string {
1326
+		$template_args = [
1327
+			'dtt_row'                           => $default
1328
+				? 'DTTNUM'
1329
+				: $datetime_row,
1330
+			'event_datetimes_name'              => $default
1331
+				? 'DTTNAMEATTR'
1332
+				: 'edit_event_datetimes',
1333
+			'DTT_description'                   => $default
1334
+				? ''
1335
+				: $datetime->get_raw('DTT_description'),
1336
+			'datetime_tickets_list'             => $default
1337
+				? '<li class="hidden"></li>'
1338
+				: '',
1339
+			'show_tickets_row'                  => 'display:none;',
1340
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1341
+				'add_new_ticket_via_datetime',
1342
+				$this->_adminpage_obj->page_slug,
1343
+				$this->_adminpage_obj->get_req_action()
1344
+			),
1345
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1346
+			'DTT_ID'                            => $default
1347
+				? ''
1348
+				: $datetime->ID(),
1349
+		];
1350
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1351
+		if (! $default) {
1352
+			$ticket_row = 1;
1353
+			foreach ($all_tickets as $ticket) {
1354
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1355
+					$datetime_row,
1356
+					$ticket_row,
1357
+					$datetime,
1358
+					$ticket,
1359
+					$datetime_tickets
1360
+				);
1361
+				$ticket_row++;
1362
+			}
1363
+		}
1364
+		// filter template args at this point
1365
+		$template_args = apply_filters(
1366
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1367
+			$template_args,
1368
+			$datetime_row,
1369
+			$datetime,
1370
+			$datetime_tickets,
1371
+			$all_tickets,
1372
+			$default,
1373
+			$this->_is_creating_event
1374
+		);
1375
+		return EEH_Template::display_template(
1376
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1377
+			$template_args,
1378
+			true
1379
+		);
1380
+	}
1381
+
1382
+
1383
+	/**
1384
+	 * @param int|string       $datetime_row
1385
+	 * @param int|string       $ticket_row
1386
+	 * @param EE_Datetime|null $datetime
1387
+	 * @param EE_Ticket|null   $ticket
1388
+	 * @param array            $datetime_tickets
1389
+	 * @param bool             $default
1390
+	 * @return string
1391
+	 * @throws EE_Error
1392
+	 * @throws ReflectionException
1393
+	 */
1394
+	protected function _get_datetime_tickets_list_item(
1395
+		$datetime_row,
1396
+		$ticket_row,
1397
+		?EE_Datetime $datetime,
1398
+		?EE_Ticket $ticket,
1399
+		array $datetime_tickets = [],
1400
+		bool $default = false
1401
+	): string {
1402
+		$datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1403
+			? $datetime_tickets[ $datetime->ID() ]
1404
+			: [];
1405
+		$display_row      = $ticket instanceof EE_Ticket
1406
+			? $ticket->get('TKT_row')
1407
+			: 0;
1408
+		$no_ticket        = $default && empty($ticket);
1409
+		$template_args    = [
1410
+			'dtt_row'                 => $default
1411
+				? 'DTTNUM'
1412
+				: $datetime_row,
1413
+			'tkt_row'                 => $no_ticket
1414
+				? 'TICKETNUM'
1415
+				: $ticket_row,
1416
+			'datetime_ticket_checked' => in_array($display_row, $datetime_tickets, true)
1417
+				? ' checked'
1418
+				: '',
1419
+			'ticket_selected'         => in_array($display_row, $datetime_tickets, true)
1420
+				? ' ticket-selected'
1421
+				: '',
1422
+			'TKT_name'                => $no_ticket
1423
+				? 'TKTNAME'
1424
+				: $ticket->get('TKT_name'),
1425
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1426
+				? ' tkt-status-' . EE_Ticket::onsale
1427
+				: ' tkt-status-' . $ticket->ticket_status(),
1428
+		];
1429
+		// filter template args
1430
+		$template_args = apply_filters(
1431
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1432
+			$template_args,
1433
+			$datetime_row,
1434
+			$ticket_row,
1435
+			$datetime,
1436
+			$ticket,
1437
+			$datetime_tickets,
1438
+			$default,
1439
+			$this->_is_creating_event
1440
+		);
1441
+		return EEH_Template::display_template(
1442
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1443
+			$template_args,
1444
+			true
1445
+		);
1446
+	}
1447
+
1448
+
1449
+	/**
1450
+	 * This generates the ticket row for tickets.
1451
+	 * This same method is used to generate both the actual rows and the js skeleton row
1452
+	 * (when default === true)
1453
+	 *
1454
+	 * @param int|string     $ticket_row       Represents the row number being generated.
1455
+	 * @param EE_Ticket|null $ticket
1456
+	 * @param EE_Datetime[]  $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1457
+	 *                                         or empty for default
1458
+	 * @param EE_Datetime[]  $all_datetimes    All Datetimes on the event or empty for default.
1459
+	 * @param bool           $default          Whether default row being generated or not.
1460
+	 * @param EE_Ticket[]    $all_tickets      This is an array of all tickets attached to the event
1461
+	 *                                         (or empty in the case of defaults)
1462
+	 * @return string
1463
+	 * @throws InvalidArgumentException
1464
+	 * @throws InvalidInterfaceException
1465
+	 * @throws InvalidDataTypeException
1466
+	 * @throws DomainException
1467
+	 * @throws EE_Error
1468
+	 * @throws ReflectionException
1469
+	 */
1470
+	protected function _get_ticket_row(
1471
+		$ticket_row,
1472
+		?EE_Ticket $ticket,
1473
+		array $ticket_datetimes,
1474
+		array $all_datetimes,
1475
+		bool $default = false,
1476
+		array $all_tickets = []
1477
+	): string {
1478
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1479
+		$default = ! $ticket instanceof EE_Ticket
1480
+			? true
1481
+			: $default;
1482
+		$prices  = ! empty($ticket) && ! $default
1483
+			? $ticket->get_many_related(
1484
+				'Price',
1485
+				['default_where_conditions' => 'none', 'order_by' => ['PRC_order' => 'ASC']]
1486
+			)
1487
+			: [];
1488
+		// if there is only one price (which would be the base price)
1489
+		// or NO prices and this ticket is a default ticket,
1490
+		// let's just make sure there are no cached default prices on the object.
1491
+		// This is done by not including any query_params.
1492
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1493
+			$prices = $ticket->prices();
1494
+		}
1495
+		// check if we're dealing with a default ticket in which case
1496
+		// we don't want any starting_ticket_datetime_row values set
1497
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1498
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1499
+		$default_datetime = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1500
+		$tkt_datetimes    = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1501
+			? $ticket_datetimes[ $ticket->ID() ]
1502
+			: [];
1503
+		$ticket_subtotal  = $default
1504
+			? 0
1505
+			: $ticket->get_ticket_subtotal();
1506
+		$base_price       = $default
1507
+			? null
1508
+			: $ticket->base_price();
1509
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1510
+		// breaking out complicated condition for ticket_status
1511
+		if ($default) {
1512
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1513
+		} else {
1514
+			$ticket_status_class = $ticket->is_default()
1515
+				? ' tkt-status-' . EE_Ticket::onsale
1516
+				: ' tkt-status-' . $ticket->ticket_status();
1517
+		}
1518
+		// breaking out complicated condition for TKT_taxable
1519
+		if ($default) {
1520
+			$TKT_taxable = '';
1521
+		} else {
1522
+			$TKT_taxable = $ticket->taxable()
1523
+				? 'checked'
1524
+				: '';
1525
+		}
1526
+		if ($default) {
1527
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1528
+		} elseif ($ticket->is_default()) {
1529
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1530
+		} else {
1531
+			$TKT_status = $ticket->ticket_status(true);
1532
+		}
1533
+		if ($default) {
1534
+			$TKT_min = '';
1535
+		} else {
1536
+			$TKT_min = $ticket->min();
1537
+			if ($TKT_min === -1 || $TKT_min === 0) {
1538
+				$TKT_min = '';
1539
+			}
1540
+		}
1541
+		$template_args                 = [
1542
+			'tkt_row'                       => $default
1543
+				? 'TICKETNUM'
1544
+				: $ticket_row,
1545
+			'TKT_order'                     => $default
1546
+				? 'TICKETNUM'
1547
+				: $ticket_row,
1548
+			// on initial page load this will always be the correct order.
1549
+			'tkt_status_class'              => $ticket_status_class,
1550
+			'display_edit_tkt_row'          => 'display:none;',
1551
+			'edit_tkt_expanded'             => '',
1552
+			'edit_tickets_name'             => $default
1553
+				? 'TICKETNAMEATTR'
1554
+				: 'edit_tickets',
1555
+			'TKT_name'                      => $default
1556
+				? ''
1557
+				: $ticket->get_f('TKT_name'),
1558
+			'TKT_start_date'                => $default
1559
+				? ''
1560
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1561
+			'TKT_end_date'                  => $default
1562
+				? ''
1563
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1564
+			'TKT_status'                    => $TKT_status,
1565
+			'TKT_price'                     => $default
1566
+				? ''
1567
+				: EEH_Template::format_currency(
1568
+					$ticket->get_ticket_total_with_taxes(),
1569
+					false,
1570
+					false
1571
+				),
1572
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1573
+			'TKT_price_amount'              => $default
1574
+				? 0
1575
+				: $ticket_subtotal,
1576
+			'TKT_qty'                       => $default
1577
+				? ''
1578
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1579
+			'TKT_qty_for_input'             => $default
1580
+				? ''
1581
+				: $ticket->get_pretty('TKT_qty', 'input'),
1582
+			'TKT_uses'                      => $default
1583
+				? ''
1584
+				: $ticket->get_pretty('TKT_uses', 'input'),
1585
+			'TKT_min'                       => $TKT_min,
1586
+			'TKT_max'                       => $default
1587
+				? ''
1588
+				: $ticket->get_pretty('TKT_max', 'input'),
1589
+			'TKT_sold'                      => $default
1590
+				? 0
1591
+				: $ticket->tickets_sold(),
1592
+			'TKT_reserved'                  => $default
1593
+				? 0
1594
+				: $ticket->reserved(),
1595
+			'TKT_registrations'             => $default
1596
+				? 0
1597
+				: $ticket->count_registrations(
1598
+					[
1599
+						[
1600
+							'STS_ID' => [
1601
+								'!=',
1602
+								EEM_Registration::status_id_incomplete,
1603
+							],
1604
+						],
1605
+					]
1606
+				),
1607
+			'TKT_ID'                        => $default
1608
+				? 0
1609
+				: $ticket->ID(),
1610
+			'TKT_description'               => $default
1611
+				? ''
1612
+				: $ticket->get_raw('TKT_description'),
1613
+			'TKT_is_default'                => $default
1614
+				? 0
1615
+				: $ticket->is_default(),
1616
+			'TKT_required'                  => $default
1617
+				? 0
1618
+				: $ticket->required(),
1619
+			'TKT_is_default_selector'       => '',
1620
+			'ticket_price_rows'             => '',
1621
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1622
+				? ''
1623
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1624
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price
1625
+				? 0
1626
+				: $base_price->ID(),
1627
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1628
+				? ''
1629
+				: 'display:none;',
1630
+			'show_price_mod_button'         => count($prices) > 1
1631
+											   || ($default && $count_price_mods > 0)
1632
+											   || (! $default && $ticket->deleted())
1633
+				? 'display:none;'
1634
+				: '',
1635
+			'total_price_rows'              => count($prices) > 1
1636
+				? count($prices)
1637
+				: 1,
1638
+			'ticket_datetimes_list'         => $default
1639
+				? '<li class="hidden"></li>'
1640
+				: '',
1641
+			'starting_ticket_datetime_rows' => $default || $default_datetime
1642
+				? ''
1643
+				: implode(',', $tkt_datetimes),
1644
+			'ticket_datetime_rows'          => $default
1645
+				? ''
1646
+				: implode(',', $tkt_datetimes),
1647
+			'existing_ticket_price_ids'     => $default
1648
+				? ''
1649
+				: implode(',', array_keys($prices)),
1650
+			'ticket_template_id'            => $default
1651
+				? 0
1652
+				: $ticket->get('TTM_ID'),
1653
+			'TKT_taxable'                   => $TKT_taxable,
1654
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1655
+				? ''
1656
+				: 'display:none;',
1657
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1658
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1659
+				$ticket_subtotal,
1660
+				false,
1661
+				false
1662
+			),
1663
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1664
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1665
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1666
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1667
+				? ' ticket-archived'
1668
+				: '',
1669
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1670
+											   && $ticket->deleted()
1671
+											   && ! $ticket->is_permanently_deleteable()
1672
+				? 'dashicons dashicons-lock '
1673
+				: 'trash-entity dashicons dashicons-post-trash clickable',
1674
+
1675
+			'can_clone' => $ticket instanceof EE_Ticket && ! $ticket->deleted(),
1676
+			'can_trash' => $ticket instanceof EE_Ticket
1677
+						   && (! $ticket->deleted() && $ticket->is_permanently_deleteable()),
1678
+		];
1679
+		$template_args['trash_hidden'] = count($all_tickets) === 1
1680
+										 && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1681
+			? 'display:none'
1682
+			: '';
1683
+		// handle rows that should NOT be empty
1684
+		if (empty($template_args['TKT_start_date'])) {
1685
+			// if empty then the start date will be now.
1686
+			$template_args['TKT_start_date']   = date(
1687
+				$this->_date_time_format,
1688
+				current_time('timestamp')
1689
+			);
1690
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1691
+		}
1692
+		if (empty($template_args['TKT_end_date'])) {
1693
+			// get the earliest datetime (if present);
1694
+			$earliest_datetime = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1695
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1696
+					'Datetime',
1697
+					['order_by' => ['DTT_EVT_start' => 'ASC']]
1698
+				)
1699
+				: null;
1700
+			if (! empty($earliest_datetime)) {
1701
+				$template_args['TKT_end_date'] = $earliest_datetime->get_datetime(
1702
+					'DTT_EVT_start',
1703
+					$this->_date_time_format
1704
+				);
1705
+			} else {
1706
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1707
+				$template_args['TKT_end_date'] = date(
1708
+					$this->_date_time_format,
1709
+					mktime(
1710
+						24,
1711
+						0,
1712
+						0,
1713
+						date('m'),
1714
+						date('d') + 29,
1715
+						date('Y')
1716
+					)
1717
+				);
1718
+			}
1719
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1720
+		}
1721
+		// generate ticket_datetime items
1722
+		if (! $default) {
1723
+			$datetime_row = 1;
1724
+			foreach ($all_datetimes as $datetime) {
1725
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1726
+					$datetime_row,
1727
+					$ticket_row,
1728
+					$datetime,
1729
+					$ticket,
1730
+					$ticket_datetimes,
1731
+					$default
1732
+				);
1733
+				$datetime_row++;
1734
+			}
1735
+		}
1736
+		$price_row = 1;
1737
+		foreach ($prices as $price) {
1738
+			if (! $price instanceof EE_Price) {
1739
+				continue;
1740
+			}
1741
+			if ($price->is_base_price()) {
1742
+				$price_row++;
1743
+				continue;
1744
+			}
1745
+
1746
+			$show_trash  = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1747
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1748
+
1749
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1750
+				$ticket_row,
1751
+				$price_row,
1752
+				$price,
1753
+				$default,
1754
+				$ticket,
1755
+				$show_trash,
1756
+				$show_create
1757
+			);
1758
+			$price_row++;
1759
+		}
1760
+		// filter $template_args
1761
+		$template_args = apply_filters(
1762
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1763
+			$template_args,
1764
+			$ticket_row,
1765
+			$ticket,
1766
+			$ticket_datetimes,
1767
+			$all_datetimes,
1768
+			$default,
1769
+			$all_tickets,
1770
+			$this->_is_creating_event
1771
+		);
1772
+		return EEH_Template::display_template(
1773
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1774
+			$template_args,
1775
+			true
1776
+		);
1777
+	}
1778
+
1779
+
1780
+	/**
1781
+	 * @param int|string     $ticket_row
1782
+	 * @param EE_Ticket|null $ticket
1783
+	 * @return string
1784
+	 * @throws DomainException
1785
+	 * @throws EE_Error
1786
+	 * @throws ReflectionException
1787
+	 */
1788
+	protected function _get_tax_rows($ticket_row, ?EE_Ticket $ticket): string
1789
+	{
1790
+		$tax_rows = '';
1791
+		/** @var EE_Price[] $taxes */
1792
+		$taxes = EE_Taxes::get_taxes_for_admin();
1793
+		foreach ($taxes as $tax) {
1794
+			$tax_added     = $this->_get_tax_added($tax, $ticket);
1795
+			$template_args = [
1796
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1797
+					? ''
1798
+					: 'display:none;',
1799
+				'tax_id'            => $tax->ID(),
1800
+				'tkt_row'           => $ticket_row,
1801
+				'tax_label'         => $tax->get('PRC_name'),
1802
+				'tax_added'         => $tax_added,
1803
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1804
+				'tax_amount'        => $tax->get('PRC_amount'),
1805
+			];
1806
+			$template_args = apply_filters(
1807
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1808
+				$template_args,
1809
+				$ticket_row,
1810
+				$ticket,
1811
+				$this->_is_creating_event
1812
+			);
1813
+			$tax_rows      .= EEH_Template::display_template(
1814
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1815
+				$template_args,
1816
+				true
1817
+			);
1818
+		}
1819
+		return $tax_rows;
1820
+	}
1821
+
1822
+
1823
+	/**
1824
+	 * @param EE_Price       $tax
1825
+	 * @param EE_Ticket|null $ticket
1826
+	 * @return float|int
1827
+	 * @throws EE_Error
1828
+	 * @throws ReflectionException
1829
+	 */
1830
+	protected function _get_tax_added(EE_Price $tax, ?EE_Ticket $ticket)
1831
+	{
1832
+		$subtotal = empty($ticket)
1833
+			? 0
1834
+			: $ticket->get_ticket_subtotal();
1835
+		return $subtotal * $tax->get('PRC_amount') / 100;
1836
+	}
1837
+
1838
+
1839
+	/**
1840
+	 * @param int|string     $ticket_row
1841
+	 * @param int|string     $price_row
1842
+	 * @param EE_Price|null  $price
1843
+	 * @param bool           $default
1844
+	 * @param EE_Ticket|null $ticket
1845
+	 * @param bool           $show_trash
1846
+	 * @param bool           $show_create
1847
+	 * @return string
1848
+	 * @throws InvalidArgumentException
1849
+	 * @throws InvalidInterfaceException
1850
+	 * @throws InvalidDataTypeException
1851
+	 * @throws DomainException
1852
+	 * @throws EE_Error
1853
+	 * @throws ReflectionException
1854
+	 */
1855
+	protected function _get_ticket_price_row(
1856
+		$ticket_row,
1857
+		$price_row,
1858
+		?EE_Price $price,
1859
+		bool $default,
1860
+		?EE_Ticket $ticket,
1861
+		bool $show_trash = true,
1862
+		bool $show_create = true
1863
+	): string {
1864
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1865
+		$template_args = [
1866
+			'tkt_row'               => $default && empty($ticket)
1867
+				? 'TICKETNUM'
1868
+				: $ticket_row,
1869
+			'PRC_order'             => $default && empty($price)
1870
+				? 'PRICENUM'
1871
+				: $price_row,
1872
+			'edit_prices_name'      => $default && empty($price)
1873
+				? 'PRICENAMEATTR'
1874
+				: 'edit_prices',
1875
+			'price_type_selector'   => $default && empty($price)
1876
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, true)
1877
+				: $this->_get_price_type_selector(
1878
+					$ticket_row,
1879
+					$price_row,
1880
+					$price,
1881
+					$default,
1882
+					$send_disabled
1883
+				),
1884
+			'PRC_ID'                => $default && empty($price)
1885
+				? 0
1886
+				: $price->ID(),
1887
+			'PRC_is_default'        => $default && empty($price)
1888
+				? 0
1889
+				: $price->get('PRC_is_default'),
1890
+			'PRC_name'              => $default && empty($price)
1891
+				? ''
1892
+				: $price->get('PRC_name'),
1893
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1894
+			'show_plus_or_minus'    => $default && empty($price)
1895
+				? ''
1896
+				: 'display:none;',
1897
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1898
+				? 'display:none;'
1899
+				: '',
1900
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1901
+				? 'display:none;'
1902
+				: '',
1903
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1904
+				? 'display:none'
1905
+				: '',
1906
+			'PRC_amount'            => $default && empty($price)
1907
+				? 0
1908
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1909
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1910
+				? 'display:none;'
1911
+				: '',
1912
+			'show_trash_icon'       => $show_trash
1913
+				? ''
1914
+				: ' style="display:none;"',
1915
+			'show_create_button'    => $show_create
1916
+				? ''
1917
+				: ' style="display:none;"',
1918
+			'PRC_desc'              => $default && empty($price)
1919
+				? ''
1920
+				: $price->get('PRC_desc'),
1921
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1922
+		];
1923
+		$template_args = apply_filters(
1924
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1925
+			$template_args,
1926
+			$ticket_row,
1927
+			$price_row,
1928
+			$price,
1929
+			$default,
1930
+			$ticket,
1931
+			$show_trash,
1932
+			$show_create,
1933
+			$this->_is_creating_event
1934
+		);
1935
+		return EEH_Template::display_template(
1936
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1937
+			$template_args,
1938
+			true
1939
+		);
1940
+	}
1941
+
1942
+
1943
+	/**
1944
+	 * @param int|string    $ticket_row
1945
+	 * @param int|string    $price_row
1946
+	 * @param EE_Price|null $price
1947
+	 * @param bool          $default
1948
+	 * @param bool          $disabled
1949
+	 * @return string
1950
+	 * @throws ReflectionException
1951
+	 * @throws InvalidArgumentException
1952
+	 * @throws InvalidInterfaceException
1953
+	 * @throws InvalidDataTypeException
1954
+	 * @throws DomainException
1955
+	 * @throws EE_Error
1956
+	 */
1957
+	protected function _get_price_type_selector(
1958
+		$ticket_row,
1959
+		$price_row,
1960
+		?EE_Price $price,
1961
+		bool $default,
1962
+		bool $disabled = false
1963
+	): string {
1964
+		if ($price->is_base_price()) {
1965
+			return $this->_get_base_price_template(
1966
+				$ticket_row,
1967
+				$price_row,
1968
+				$price,
1969
+				$default
1970
+			);
1971
+		}
1972
+		return $this->_get_price_modifier_template(
1973
+			$ticket_row,
1974
+			$price_row,
1975
+			$price,
1976
+			$default,
1977
+			$disabled
1978
+		);
1979
+	}
1980
+
1981
+
1982
+	/**
1983
+	 * @param int|string    $ticket_row
1984
+	 * @param int|string    $price_row
1985
+	 * @param EE_Price|null $price
1986
+	 * @param bool          $default
1987
+	 * @return string
1988
+	 * @throws DomainException
1989
+	 * @throws EE_Error
1990
+	 * @throws ReflectionException
1991
+	 */
1992
+	protected function _get_base_price_template(
1993
+		$ticket_row,
1994
+		$price_row,
1995
+		?EE_Price $price,
1996
+		bool $default
1997
+	): string {
1998
+		$template_args = [
1999
+			'tkt_row'                   => $default
2000
+				? 'TICKETNUM'
2001
+				: $ticket_row,
2002
+			'PRC_order'                 => $default && empty($price)
2003
+				? 'PRICENUM'
2004
+				: $price_row,
2005
+			'PRT_ID'                    => $default && empty($price)
2006
+				? 1
2007
+				: $price->get('PRT_ID'),
2008
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
2009
+			'price_selected_operator'   => '+',
2010
+			'price_selected_is_percent' => 0,
2011
+		];
2012
+		$template_args = apply_filters(
2013
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
2014
+			$template_args,
2015
+			$ticket_row,
2016
+			$price_row,
2017
+			$price,
2018
+			$default,
2019
+			$this->_is_creating_event
2020
+		);
2021
+		return EEH_Template::display_template(
2022
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
2023
+			$template_args,
2024
+			true
2025
+		);
2026
+	}
2027
+
2028
+
2029
+	/**
2030
+	 * @param int|string    $ticket_row
2031
+	 * @param int|string    $price_row
2032
+	 * @param EE_Price|null $price
2033
+	 * @param bool          $default
2034
+	 * @param bool          $disabled
2035
+	 * @return string
2036
+	 * @throws ReflectionException
2037
+	 * @throws InvalidArgumentException
2038
+	 * @throws InvalidInterfaceException
2039
+	 * @throws InvalidDataTypeException
2040
+	 * @throws DomainException
2041
+	 * @throws EE_Error
2042
+	 */
2043
+	protected function _get_price_modifier_template(
2044
+		$ticket_row,
2045
+		$price_row,
2046
+		?EE_Price $price,
2047
+		bool $default,
2048
+		bool $disabled = false
2049
+	): string {
2050
+		$select_name = $default && ! $price instanceof EE_Price
2051
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
2052
+			: 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
2053
+
2054
+		$price_type_model       = EEM_Price_Type::instance();
2055
+		$price_types            = $price_type_model->get_all(
2056
+			[
2057
+				[
2058
+					'OR' => [
2059
+						'PBT_ID'  => '2',
2060
+						'PBT_ID*' => '3',
2061
+					],
2062
+				],
2063
+			]
2064
+		);
2065
+		$all_price_types        = $default && ! $price instanceof EE_Price
2066
+			? [esc_html__('Select Modifier', 'event_espresso')]
2067
+			: [];
2068
+		$selected_price_type_id = $default && ! $price instanceof EE_Price
2069
+			? 0
2070
+			: $price->type();
2071
+		$price_option_spans     = '';
2072
+		// setup price types for selector
2073
+		foreach ($price_types as $price_type) {
2074
+			if (! $price_type instanceof EE_Price_Type) {
2075
+				continue;
2076
+			}
2077
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
2078
+			// while we're in the loop let's setup the option spans used by js
2079
+			$span_args          = [
2080
+				'PRT_ID'         => $price_type->ID(),
2081
+				'PRT_operator'   => $price_type->is_discount()
2082
+					? '-'
2083
+					: '+',
2084
+				'PRT_is_percent' => $price_type->get('PRT_is_percent')
2085
+					? 1
2086
+					: 0,
2087
+			];
2088
+			$price_option_spans .= EEH_Template::display_template(
2089
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
2090
+				$span_args,
2091
+				true
2092
+			);
2093
+		}
2094
+
2095
+		$select_name = $disabled
2096
+			? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
2097
+			: $select_name;
2098
+
2099
+		$select_input = new EE_Select_Input(
2100
+			$all_price_types,
2101
+			[
2102
+				'default'               => $selected_price_type_id,
2103
+				'html_name'             => $select_name,
2104
+				'html_class'            => 'edit-price-PRT_ID',
2105
+				'other_html_attributes' => $disabled
2106
+					? 'style="width:auto;" disabled'
2107
+					: 'style="width:auto;"',
2108
+			]
2109
+		);
2110
+
2111
+		$price_selected_operator   = $price instanceof EE_Price && $price->is_discount()
2112
+			? '-'
2113
+			: '+';
2114
+		$price_selected_operator   = $default && ! $price instanceof EE_Price
2115
+			? ''
2116
+			: $price_selected_operator;
2117
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent()
2118
+			? 1
2119
+			: 0;
2120
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price
2121
+			? ''
2122
+			: $price_selected_is_percent;
2123
+		$template_args             = [
2124
+			'tkt_row'                   => $default
2125
+				? 'TICKETNUM'
2126
+				: $ticket_row,
2127
+			'PRC_order'                 => $default && ! $price instanceof EE_Price
2128
+				? 'PRICENUM'
2129
+				: $price_row,
2130
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
2131
+			'main_name'                 => $select_name,
2132
+			'selected_price_type_id'    => $selected_price_type_id,
2133
+			'price_option_spans'        => $price_option_spans,
2134
+			'price_selected_operator'   => $price_selected_operator,
2135
+			'price_selected_is_percent' => $price_selected_is_percent,
2136
+			'disabled'                  => $disabled,
2137
+		];
2138
+		$template_args             = apply_filters(
2139
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2140
+			$template_args,
2141
+			$ticket_row,
2142
+			$price_row,
2143
+			$price,
2144
+			$default,
2145
+			$disabled,
2146
+			$this->_is_creating_event
2147
+		);
2148
+		return EEH_Template::display_template(
2149
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2150
+			$template_args,
2151
+			true
2152
+		);
2153
+	}
2154
+
2155
+
2156
+	/**
2157
+	 * @param int|string       $datetime_row
2158
+	 * @param int|string       $ticket_row
2159
+	 * @param EE_Datetime|null $datetime
2160
+	 * @param EE_Ticket|null   $ticket
2161
+	 * @param array            $ticket_datetimes
2162
+	 * @param bool             $default
2163
+	 * @return string
2164
+	 * @throws DomainException
2165
+	 * @throws EE_Error
2166
+	 * @throws ReflectionException
2167
+	 */
2168
+	protected function _get_ticket_datetime_list_item(
2169
+		$datetime_row,
2170
+		$ticket_row,
2171
+		?EE_Datetime $datetime,
2172
+		?EE_Ticket $ticket,
2173
+		array $ticket_datetimes = [],
2174
+		bool $default = false
2175
+	): string {
2176
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2177
+			? $ticket_datetimes[ $ticket->ID() ]
2178
+			: [];
2179
+		$template_args = [
2180
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2181
+				? 'DTTNUM'
2182
+				: $datetime_row,
2183
+			'tkt_row'                  => $default
2184
+				? 'TICKETNUM'
2185
+				: $ticket_row,
2186
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2187
+				? ' ticket-selected'
2188
+				: '',
2189
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2190
+				? ' checked'
2191
+				: '',
2192
+			'DTT_name'                 => $default && empty($datetime)
2193
+				? 'DTTNAME'
2194
+				: $datetime->get_dtt_display_name(true),
2195
+			'tkt_status_class'         => '',
2196
+		];
2197
+		$template_args = apply_filters(
2198
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2199
+			$template_args,
2200
+			$datetime_row,
2201
+			$ticket_row,
2202
+			$datetime,
2203
+			$ticket,
2204
+			$ticket_datetimes,
2205
+			$default,
2206
+			$this->_is_creating_event
2207
+		);
2208
+		return EEH_Template::display_template(
2209
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2210
+			$template_args,
2211
+			true
2212
+		);
2213
+	}
2214
+
2215
+
2216
+	/**
2217
+	 * @param array $all_datetimes
2218
+	 * @param array $all_tickets
2219
+	 * @return string
2220
+	 * @throws ReflectionException
2221
+	 * @throws InvalidArgumentException
2222
+	 * @throws InvalidInterfaceException
2223
+	 * @throws InvalidDataTypeException
2224
+	 * @throws DomainException
2225
+	 * @throws EE_Error
2226
+	 */
2227
+	protected function _get_ticket_js_structure(array $all_datetimes = [], array $all_tickets = []): string
2228
+	{
2229
+		$template_args = [
2230
+			'default_datetime_edit_row' => $this->_get_dtt_edit_row(
2231
+				'DTTNUM',
2232
+				null,
2233
+				true,
2234
+				$all_datetimes
2235
+			),
2236
+			'default_ticket_row'        => $this->_get_ticket_row(
2237
+				'TICKETNUM',
2238
+				null,
2239
+				[],
2240
+				[],
2241
+				true
2242
+			),
2243
+			'default_price_row'         => $this->_get_ticket_price_row(
2244
+				'TICKETNUM',
2245
+				'PRICENUM',
2246
+				null,
2247
+				true,
2248
+				null
2249
+			),
2250
+
2251
+			'default_price_rows'                       => '',
2252
+			'default_base_price_amount'                => 0,
2253
+			'default_base_price_name'                  => '',
2254
+			'default_base_price_description'           => '',
2255
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2256
+				'TICKETNUM',
2257
+				'PRICENUM',
2258
+				null,
2259
+				true
2260
+			),
2261
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2262
+				'DTTNUM',
2263
+				null,
2264
+				[],
2265
+				[],
2266
+				true
2267
+			),
2268
+			'existing_available_datetime_tickets_list' => '',
2269
+			'existing_available_ticket_datetimes_list' => '',
2270
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2271
+				'DTTNUM',
2272
+				'TICKETNUM',
2273
+				null,
2274
+				null,
2275
+				[],
2276
+				true
2277
+			),
2278
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2279
+				'DTTNUM',
2280
+				'TICKETNUM',
2281
+				null,
2282
+				null,
2283
+				[],
2284
+				true
2285
+			),
2286
+		];
2287
+		$ticket_row    = 1;
2288
+		foreach ($all_tickets as $ticket) {
2289
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2290
+				'DTTNUM',
2291
+				$ticket_row,
2292
+				null,
2293
+				$ticket,
2294
+				[],
2295
+				true
2296
+			);
2297
+			$ticket_row++;
2298
+		}
2299
+		$datetime_row = 1;
2300
+		foreach ($all_datetimes as $datetime) {
2301
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2302
+				$datetime_row,
2303
+				'TICKETNUM',
2304
+				$datetime,
2305
+				null,
2306
+				[],
2307
+				true
2308
+			);
2309
+			$datetime_row++;
2310
+		}
2311
+		$price_model    = EEM_Price::instance();
2312
+		$default_prices = $price_model->get_all_default_prices();
2313
+		$price_row      = 1;
2314
+		foreach ($default_prices as $price) {
2315
+			if (! $price instanceof EE_Price) {
2316
+				continue;
2317
+			}
2318
+			if ($price->is_base_price()) {
2319
+				$template_args['default_base_price_amount']      = $price->get_pretty(
2320
+					'PRC_amount',
2321
+					'localized_float'
2322
+				);
2323
+				$template_args['default_base_price_name']        = $price->get('PRC_name');
2324
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2325
+				$price_row++;
2326
+				continue;
2327
+			}
2328
+
2329
+			$show_trash  = ! ((count($default_prices) > 1 && $price_row === 1) || count($default_prices) === 1);
2330
+			$show_create = ! (count($default_prices) > 1 && count($default_prices) !== $price_row);
2331
+
2332
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2333
+				'TICKETNUM',
2334
+				$price_row,
2335
+				$price,
2336
+				true,
2337
+				null,
2338
+				$show_trash,
2339
+				$show_create
2340
+			);
2341
+			$price_row++;
2342
+		}
2343
+		$template_args = apply_filters(
2344
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2345
+			$template_args,
2346
+			$all_datetimes,
2347
+			$all_tickets,
2348
+			$this->_is_creating_event
2349
+		);
2350
+		return EEH_Template::display_template(
2351
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2352
+			$template_args,
2353
+			true
2354
+		);
2355
+	}
2356 2356
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     protected function _setup_metaboxes()
77 77
     {
78 78
         // if we were going to add our own metaboxes we'd use the below.
79
-        $this->_metaboxes        = [
79
+        $this->_metaboxes = [
80 80
             0 => [
81 81
                 'page_route' => ['edit', 'create_new'],
82 82
                 'func'       => [$this, 'pricing_metabox'],
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $this->_date_format_strings['date'] = $this->_date_format_strings['date'] ?? '';
120 120
         $this->_date_format_strings['time'] = $this->_date_format_strings['time'] ?? '';
121 121
 
122
-        $this->_date_time_format = $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'];
122
+        $this->_date_time_format = $this->_date_format_strings['date'].' '.$this->_date_format_strings['time'];
123 123
     }
124 124
 
125 125
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             );
144 144
             $msg .= '</p><ul>';
145 145
             foreach ($format_validation as $error) {
146
-                $msg .= '<li>' . $error . '</li>';
146
+                $msg .= '<li>'.$error.'</li>';
147 147
             }
148 148
             $msg .= '</ul><p>';
149 149
             $msg .= sprintf(
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
         $this->_scripts_styles = [
173 173
             'registers'   => [
174 174
                 'ee-tickets-datetimes-css' => [
175
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
175
+                    'url'  => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
176 176
                     'type' => 'css',
177 177
                 ],
178 178
                 'ee-dtt-ticket-metabox'    => [
179
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
179
+                    'url'     => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
180 180
                     'depends' => ['ee-datepicker', 'ee-dialog', 'underscore'],
181 181
                 ],
182 182
             ],
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
                         ),
202 202
                         'cancel_button'           => '
203 203
                             <button class="button--secondary ee-modal-cancel">
204
-                                ' . esc_html__('Cancel', 'event_espresso') . '
204
+                                ' . esc_html__('Cancel', 'event_espresso').'
205 205
                             </button>',
206 206
                         'close_button'            => '
207 207
                             <button class="button--secondary ee-modal-cancel">
208
-                                ' . esc_html__('Close', 'event_espresso') . '
208
+                                ' . esc_html__('Close', 'event_espresso').'
209 209
                             </button>',
210 210
                         'single_warning_from_tkt' => esc_html__(
211 211
                             'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                         ),
218 218
                         'dismiss_button'          => '
219 219
                             <button class="button--secondary ee-modal-cancel">
220
-                                ' . esc_html__('Dismiss', 'event_espresso') . '
220
+                                ' . esc_html__('Dismiss', 'event_espresso').'
221 221
                             </button>',
222 222
                     ],
223 223
                     'DTT_ERROR_MSG'         => [
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
                         'dismiss_button' => '
226 226
                             <div class="save-cancel-button-container">
227 227
                                 <button class="button--secondary ee-modal-cancel">
228
-                                    ' . esc_html__('Dismiss', 'event_espresso') . '
228
+                                    ' . esc_html__('Dismiss', 'event_espresso').'
229 229
                                 </button>
230 230
                             </div>',
231 231
                     ],
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
315 315
             // trim all values to ensure any excess whitespace is removed.
316 316
             $datetime_data = array_map(
317
-                function ($datetime_data) {
317
+                function($datetime_data) {
318 318
                     return is_array($datetime_data)
319 319
                         ? $datetime_data
320 320
                         : trim($datetime_data);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                                             && ! empty($datetime_data['DTT_EVT_end'])
327 327
                 ? $datetime_data['DTT_EVT_end']
328 328
                 : $datetime_data['DTT_EVT_start'];
329
-            $datetime_values              = [
329
+            $datetime_values = [
330 330
                 'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
331 331
                     ? $datetime_data['DTT_ID']
332 332
                     : null,
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
             // if we have an id then let's get existing object first and then set the new values.
350 350
             // Otherwise we instantiate a new object for save.
351
-            if (! empty($datetime_data['DTT_ID'])) {
351
+            if ( ! empty($datetime_data['DTT_ID'])) {
352 352
                 $datetime = EE_Registry::instance()
353 353
                                        ->load_model('Datetime', [$timezone])
354 354
                                        ->get_one_by_ID($datetime_data['DTT_ID']);
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                 // after the add_relation_to() the autosave replaces it.
364 364
                 // We need to do this so we dont' TRASH the parent DTT.
365 365
                 // (save the ID for both key and value to avoid duplications)
366
-                $saved_datetime_ids[ $datetime->ID() ] = $datetime->ID();
366
+                $saved_datetime_ids[$datetime->ID()] = $datetime->ID();
367 367
             } else {
368 368
                 $datetime = EE_Datetime::new_instance(
369 369
                     $datetime_values,
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
             // because it is possible there was a new one created for the autosave.
395 395
             // (save the ID for both key and value to avoid duplications)
396 396
             $DTT_ID                        = $datetime->ID();
397
-            $saved_datetime_ids[ $DTT_ID ] = $DTT_ID;
398
-            $saved_datetime_objs[ $row ]   = $datetime;
397
+            $saved_datetime_ids[$DTT_ID] = $DTT_ID;
398
+            $saved_datetime_objs[$row]   = $datetime;
399 399
             // @todo if ANY of these updates fail then we want the appropriate global error message.
400 400
         }
401 401
         $event->save();
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
             $update_prices = $create_new_TKT = false;
466 466
             // figure out what datetimes were added to the ticket
467 467
             // and what datetimes were removed from the ticket in the session.
468
-            $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
469
-            $ticket_datetime_rows          = explode(',', $data['ticket_datetime_rows'][ $row ]);
468
+            $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
469
+            $ticket_datetime_rows          = explode(',', $data['ticket_datetime_rows'][$row]);
470 470
             $datetimes_added               = array_diff($ticket_datetime_rows, $starting_ticket_datetime_rows);
471 471
             $datetimes_removed             = array_diff($starting_ticket_datetime_rows, $ticket_datetime_rows);
472 472
             // trim inputs to ensure any excess whitespace is removed.
473 473
             $ticket_data = array_map(
474
-                function ($ticket_data) {
474
+                function($ticket_data) {
475 475
                     return is_array($ticket_data)
476 476
                         ? $ticket_data
477 477
                         : trim($ticket_data);
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
                 ? $base_price
494 494
                 : $ticket_price;
495 495
             $base_price_id = $ticket_data['TKT_base_price_ID'] ?? 0;
496
-            $price_rows    = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
497
-                ? $data['edit_prices'][ $row ]
496
+            $price_rows    = is_array($data['edit_prices']) && isset($data['edit_prices'][$row])
497
+                ? $data['edit_prices'][$row]
498 498
                 : [];
499 499
             $now           = null;
500 500
             if (empty($ticket_data['TKT_start_date'])) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
                 /**
507 507
                  * set the TKT_end_date to the first datetime attached to the ticket.
508 508
                  */
509
-                $first_datetime              = $saved_datetimes[ reset($ticket_datetime_rows) ];
509
+                $first_datetime              = $saved_datetimes[reset($ticket_datetime_rows)];
510 510
                 $ticket_data['TKT_end_date'] = $first_datetime->start_date_and_time($this->_date_time_format);
511 511
             }
512 512
             $TKT_values = [
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
                 if ($ticket instanceof EE_Ticket) {
622 622
                     // make sure ticket has an ID of setting relations won't work
623 623
                     $ticket->save();
624
-                    $ticket        = $this->_update_ticket_datetimes(
624
+                    $ticket = $this->_update_ticket_datetimes(
625 625
                         $ticket,
626 626
                         $saved_datetimes,
627 627
                         $datetimes_added,
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
             // need to make sue that the TKT_price is accurate after saving the prices.
656 656
             $ticket->ensure_TKT_Price_correct();
657 657
             // handle CREATING a default ticket from the incoming ticket but ONLY if this isn't an autosave.
658
-            if (! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) {
658
+            if ( ! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) {
659 659
                 $new_default = clone $ticket;
660 660
                 $new_default->set('TKT_ID', 0);
661 661
                 $new_default->set('TKT_is_default', 1);
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
                 // save new TKT
700 700
                 $new_ticket->save();
701 701
                 // add new ticket to array
702
-                $saved_tickets[ $new_ticket->ID() ] = $new_ticket;
702
+                $saved_tickets[$new_ticket->ID()] = $new_ticket;
703 703
                 do_action(
704 704
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
705 705
                     $new_ticket,
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
                 );
710 710
             } else {
711 711
                 // add ticket to saved tickets
712
-                $saved_tickets[ $ticket->ID() ] = $ticket;
712
+                $saved_tickets[$ticket->ID()] = $ticket;
713 713
                 do_action(
714 714
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
715 715
                     $ticket,
@@ -779,25 +779,25 @@  discard block
 block discarded – undo
779 779
         // to start we have to add the ticket to all the datetimes its supposed to be with,
780 780
         // and removing the ticket from datetimes it got removed from.
781 781
         // first let's add datetimes
782
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
782
+        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
783 783
             foreach ($added_datetimes as $row_id) {
784
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
785
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
784
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
785
+                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
786 786
                     // Is this an existing ticket (has an ID) and does it have any sold?
787 787
                     // If so, then we need to add that to the DTT sold because this DTT is getting added.
788 788
                     if ($ticket->ID() && $ticket->sold() > 0) {
789
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
789
+                        $saved_datetimes[$row_id]->increaseSold($ticket->sold(), false);
790 790
                     }
791 791
                 }
792 792
             }
793 793
         }
794 794
         // then remove datetimes
795
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
795
+        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
796 796
             foreach ($removed_datetimes as $row_id) {
797 797
                 // its entirely possible that a datetime got deleted (instead of just removed from relationship.
798 798
                 // So make sure we skip over this if the datetime isn't in the $saved_datetimes array)
799
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
800
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
799
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
800
+                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
801 801
                 }
802 802
             }
803 803
         }
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
             ];
912 912
         }
913 913
         // possibly need to save ticket
914
-        if (! $ticket->ID()) {
914
+        if ( ! $ticket->ID()) {
915 915
             $ticket->save();
916 916
         }
917 917
         foreach ($prices as $row => $prc) {
@@ -955,17 +955,17 @@  discard block
 block discarded – undo
955 955
                 }
956 956
             }
957 957
             $price->save();
958
-            $updated_prices[ $price->ID() ] = $price;
958
+            $updated_prices[$price->ID()] = $price;
959 959
             $ticket->_add_relation_to($price, 'Price');
960 960
         }
961 961
         // now let's remove any prices that got removed from the ticket
962
-        if (! empty($current_prices_on_ticket)) {
962
+        if ( ! empty($current_prices_on_ticket)) {
963 963
             $current          = array_keys($current_prices_on_ticket);
964 964
             $updated          = array_keys($updated_prices);
965 965
             $prices_to_remove = array_diff($current, $updated);
966
-            if (! empty($prices_to_remove)) {
966
+            if ( ! empty($prices_to_remove)) {
967 967
                 foreach ($prices_to_remove as $prc_id) {
968
-                    $p = $current_prices_on_ticket[ $prc_id ];
968
+                    $p = $current_prices_on_ticket[$prc_id];
969 969
                     $ticket->_remove_relation_to($p, 'Price');
970 970
                     // delete permanently the price
971 971
                     $p->delete_or_restore();
@@ -1081,18 +1081,18 @@  discard block
 block discarded – undo
1081 1081
                 $TKT_ID     = $ticket->get('TKT_ID');
1082 1082
                 $ticket_row = $ticket->get('TKT_row');
1083 1083
                 // we only want unique tickets in our final display!!
1084
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1084
+                if ( ! in_array($TKT_ID, $existing_ticket_ids, true)) {
1085 1085
                     $existing_ticket_ids[] = $TKT_ID;
1086 1086
                     $all_tickets[]         = $ticket;
1087 1087
                 }
1088 1088
                 // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1089
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1089
+                $datetime_tickets[$DTT_ID][] = $ticket_row;
1090 1090
                 // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1091 1091
                 if (
1092
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1093
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1092
+                    ! isset($ticket_datetimes[$TKT_ID])
1093
+                    || ! in_array($datetime_row, $ticket_datetimes[$TKT_ID], true)
1094 1094
                 ) {
1095
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1095
+                    $ticket_datetimes[$TKT_ID][] = $datetime_row;
1096 1096
                 }
1097 1097
             }
1098 1098
             $datetime_row++;
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
         // sort $all_tickets by order
1104 1104
         usort(
1105 1105
             $all_tickets,
1106
-            function (EE_Ticket $a, EE_Ticket $b) {
1106
+            function(EE_Ticket $a, EE_Ticket $b) {
1107 1107
                 $a_order = (int) $a->get('TKT_order');
1108 1108
                 $b_order = (int) $b->get('TKT_order');
1109 1109
                 if ($a_order === $b_order) {
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
         );
1154 1154
 
1155 1155
         EEH_Template::display_template(
1156
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1156
+            PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php',
1157 1157
             $main_template_args
1158 1158
         );
1159 1159
     }
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
         array $all_datetimes = []
1181 1181
     ): string {
1182 1182
         return EEH_Template::display_template(
1183
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1183
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php',
1184 1184
             [
1185 1185
                 'dtt_edit_row'             => $this->_get_dtt_edit_row(
1186 1186
                     $datetime_row,
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
             $this->_is_creating_event
1299 1299
         );
1300 1300
         return EEH_Template::display_template(
1301
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1301
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php',
1302 1302
             $template_args,
1303 1303
             true
1304 1304
         );
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
                 : $datetime->ID(),
1349 1349
         ];
1350 1350
         // need to setup the list items (but only if this isn't a default skeleton setup)
1351
-        if (! $default) {
1351
+        if ( ! $default) {
1352 1352
             $ticket_row = 1;
1353 1353
             foreach ($all_tickets as $ticket) {
1354 1354
                 $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
             $this->_is_creating_event
1374 1374
         );
1375 1375
         return EEH_Template::display_template(
1376
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1376
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php',
1377 1377
             $template_args,
1378 1378
             true
1379 1379
         );
@@ -1399,8 +1399,8 @@  discard block
 block discarded – undo
1399 1399
         array $datetime_tickets = [],
1400 1400
         bool $default = false
1401 1401
     ): string {
1402
-        $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1403
-            ? $datetime_tickets[ $datetime->ID() ]
1402
+        $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[$datetime->ID()])
1403
+            ? $datetime_tickets[$datetime->ID()]
1404 1404
             : [];
1405 1405
         $display_row      = $ticket instanceof EE_Ticket
1406 1406
             ? $ticket->get('TKT_row')
@@ -1423,8 +1423,8 @@  discard block
 block discarded – undo
1423 1423
                 ? 'TKTNAME'
1424 1424
                 : $ticket->get('TKT_name'),
1425 1425
             'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1426
-                ? ' tkt-status-' . EE_Ticket::onsale
1427
-                : ' tkt-status-' . $ticket->ticket_status(),
1426
+                ? ' tkt-status-'.EE_Ticket::onsale
1427
+                : ' tkt-status-'.$ticket->ticket_status(),
1428 1428
         ];
1429 1429
         // filter template args
1430 1430
         $template_args = apply_filters(
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
             $this->_is_creating_event
1440 1440
         );
1441 1441
         return EEH_Template::display_template(
1442
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1442
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php',
1443 1443
             $template_args,
1444 1444
             true
1445 1445
         );
@@ -1497,8 +1497,8 @@  discard block
 block discarded – undo
1497 1497
         // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1498 1498
         // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1499 1499
         $default_datetime = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1500
-        $tkt_datetimes    = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1501
-            ? $ticket_datetimes[ $ticket->ID() ]
1500
+        $tkt_datetimes    = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
1501
+            ? $ticket_datetimes[$ticket->ID()]
1502 1502
             : [];
1503 1503
         $ticket_subtotal  = $default
1504 1504
             ? 0
@@ -1509,11 +1509,11 @@  discard block
 block discarded – undo
1509 1509
         $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1510 1510
         // breaking out complicated condition for ticket_status
1511 1511
         if ($default) {
1512
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1512
+            $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1513 1513
         } else {
1514 1514
             $ticket_status_class = $ticket->is_default()
1515
-                ? ' tkt-status-' . EE_Ticket::onsale
1516
-                : ' tkt-status-' . $ticket->ticket_status();
1515
+                ? ' tkt-status-'.EE_Ticket::onsale
1516
+                : ' tkt-status-'.$ticket->ticket_status();
1517 1517
         }
1518 1518
         // breaking out complicated condition for TKT_taxable
1519 1519
         if ($default) {
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
                 $TKT_min = '';
1539 1539
             }
1540 1540
         }
1541
-        $template_args                 = [
1541
+        $template_args = [
1542 1542
             'tkt_row'                       => $default
1543 1543
                 ? 'TICKETNUM'
1544 1544
                 : $ticket_row,
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
                 : 'display:none;',
1630 1630
             'show_price_mod_button'         => count($prices) > 1
1631 1631
                                                || ($default && $count_price_mods > 0)
1632
-                                               || (! $default && $ticket->deleted())
1632
+                                               || ( ! $default && $ticket->deleted())
1633 1633
                 ? 'display:none;'
1634 1634
                 : '',
1635 1635
             'total_price_rows'              => count($prices) > 1
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
 
1675 1675
             'can_clone' => $ticket instanceof EE_Ticket && ! $ticket->deleted(),
1676 1676
             'can_trash' => $ticket instanceof EE_Ticket
1677
-                           && (! $ticket->deleted() && $ticket->is_permanently_deleteable()),
1677
+                           && ( ! $ticket->deleted() && $ticket->is_permanently_deleteable()),
1678 1678
         ];
1679 1679
         $template_args['trash_hidden'] = count($all_tickets) === 1
1680 1680
                                          && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
@@ -1683,11 +1683,11 @@  discard block
 block discarded – undo
1683 1683
         // handle rows that should NOT be empty
1684 1684
         if (empty($template_args['TKT_start_date'])) {
1685 1685
             // if empty then the start date will be now.
1686
-            $template_args['TKT_start_date']   = date(
1686
+            $template_args['TKT_start_date'] = date(
1687 1687
                 $this->_date_time_format,
1688 1688
                 current_time('timestamp')
1689 1689
             );
1690
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1690
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1691 1691
         }
1692 1692
         if (empty($template_args['TKT_end_date'])) {
1693 1693
             // get the earliest datetime (if present);
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
                     ['order_by' => ['DTT_EVT_start' => 'ASC']]
1698 1698
                 )
1699 1699
                 : null;
1700
-            if (! empty($earliest_datetime)) {
1700
+            if ( ! empty($earliest_datetime)) {
1701 1701
                 $template_args['TKT_end_date'] = $earliest_datetime->get_datetime(
1702 1702
                     'DTT_EVT_start',
1703 1703
                     $this->_date_time_format
@@ -1716,10 +1716,10 @@  discard block
 block discarded – undo
1716 1716
                     )
1717 1717
                 );
1718 1718
             }
1719
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1719
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1720 1720
         }
1721 1721
         // generate ticket_datetime items
1722
-        if (! $default) {
1722
+        if ( ! $default) {
1723 1723
             $datetime_row = 1;
1724 1724
             foreach ($all_datetimes as $datetime) {
1725 1725
                 $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
         }
1736 1736
         $price_row = 1;
1737 1737
         foreach ($prices as $price) {
1738
-            if (! $price instanceof EE_Price) {
1738
+            if ( ! $price instanceof EE_Price) {
1739 1739
                 continue;
1740 1740
             }
1741 1741
             if ($price->is_base_price()) {
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
             $this->_is_creating_event
1771 1771
         );
1772 1772
         return EEH_Template::display_template(
1773
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1773
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php',
1774 1774
             $template_args,
1775 1775
             true
1776 1776
         );
@@ -1810,8 +1810,8 @@  discard block
 block discarded – undo
1810 1810
                 $ticket,
1811 1811
                 $this->_is_creating_event
1812 1812
             );
1813
-            $tax_rows      .= EEH_Template::display_template(
1814
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1813
+            $tax_rows .= EEH_Template::display_template(
1814
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php',
1815 1815
                 $template_args,
1816 1816
                 true
1817 1817
             );
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
             $this->_is_creating_event
1934 1934
         );
1935 1935
         return EEH_Template::display_template(
1936
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1936
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php',
1937 1937
             $template_args,
1938 1938
             true
1939 1939
         );
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
             $this->_is_creating_event
2020 2020
         );
2021 2021
         return EEH_Template::display_template(
2022
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
2022
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php',
2023 2023
             $template_args,
2024 2024
             true
2025 2025
         );
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
     ): string {
2050 2050
         $select_name = $default && ! $price instanceof EE_Price
2051 2051
             ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
2052
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
2052
+            : 'edit_prices['.esc_attr($ticket_row).']['.esc_attr($price_row).'][PRT_ID]';
2053 2053
 
2054 2054
         $price_type_model       = EEM_Price_Type::instance();
2055 2055
         $price_types            = $price_type_model->get_all(
@@ -2071,12 +2071,12 @@  discard block
 block discarded – undo
2071 2071
         $price_option_spans     = '';
2072 2072
         // setup price types for selector
2073 2073
         foreach ($price_types as $price_type) {
2074
-            if (! $price_type instanceof EE_Price_Type) {
2074
+            if ( ! $price_type instanceof EE_Price_Type) {
2075 2075
                 continue;
2076 2076
             }
2077
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
2077
+            $all_price_types[$price_type->ID()] = $price_type->get('PRT_name');
2078 2078
             // while we're in the loop let's setup the option spans used by js
2079
-            $span_args          = [
2079
+            $span_args = [
2080 2080
                 'PRT_ID'         => $price_type->ID(),
2081 2081
                 'PRT_operator'   => $price_type->is_discount()
2082 2082
                     ? '-'
@@ -2086,14 +2086,14 @@  discard block
 block discarded – undo
2086 2086
                     : 0,
2087 2087
             ];
2088 2088
             $price_option_spans .= EEH_Template::display_template(
2089
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
2089
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php',
2090 2090
                 $span_args,
2091 2091
                 true
2092 2092
             );
2093 2093
         }
2094 2094
 
2095 2095
         $select_name = $disabled
2096
-            ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
2096
+            ? 'archive_price['.$ticket_row.']['.$price_row.'][PRT_ID]'
2097 2097
             : $select_name;
2098 2098
 
2099 2099
         $select_input = new EE_Select_Input(
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
             'price_selected_is_percent' => $price_selected_is_percent,
2136 2136
             'disabled'                  => $disabled,
2137 2137
         ];
2138
-        $template_args             = apply_filters(
2138
+        $template_args = apply_filters(
2139 2139
             'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2140 2140
             $template_args,
2141 2141
             $ticket_row,
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
             $this->_is_creating_event
2147 2147
         );
2148 2148
         return EEH_Template::display_template(
2149
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2149
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php',
2150 2150
             $template_args,
2151 2151
             true
2152 2152
         );
@@ -2173,8 +2173,8 @@  discard block
 block discarded – undo
2173 2173
         array $ticket_datetimes = [],
2174 2174
         bool $default = false
2175 2175
     ): string {
2176
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2177
-            ? $ticket_datetimes[ $ticket->ID() ]
2176
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
2177
+            ? $ticket_datetimes[$ticket->ID()]
2178 2178
             : [];
2179 2179
         $template_args = [
2180 2180
             'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
             $this->_is_creating_event
2207 2207
         );
2208 2208
         return EEH_Template::display_template(
2209
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2209
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2210 2210
             $template_args,
2211 2211
             true
2212 2212
         );
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
                 true
2285 2285
             ),
2286 2286
         ];
2287
-        $ticket_row    = 1;
2287
+        $ticket_row = 1;
2288 2288
         foreach ($all_tickets as $ticket) {
2289 2289
             $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2290 2290
                 'DTTNUM',
@@ -2312,11 +2312,11 @@  discard block
 block discarded – undo
2312 2312
         $default_prices = $price_model->get_all_default_prices();
2313 2313
         $price_row      = 1;
2314 2314
         foreach ($default_prices as $price) {
2315
-            if (! $price instanceof EE_Price) {
2315
+            if ( ! $price instanceof EE_Price) {
2316 2316
                 continue;
2317 2317
             }
2318 2318
             if ($price->is_base_price()) {
2319
-                $template_args['default_base_price_amount']      = $price->get_pretty(
2319
+                $template_args['default_base_price_amount'] = $price->get_pretty(
2320 2320
                     'PRC_amount',
2321 2321
                     'localized_float'
2322 2322
                 );
@@ -2348,7 +2348,7 @@  discard block
 block discarded – undo
2348 2348
             $this->_is_creating_event
2349 2349
         );
2350 2350
         return EEH_Template::display_template(
2351
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2351
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php',
2352 2352
             $template_args,
2353 2353
             true
2354 2354
         );
Please login to merge, or discard this patch.
admin/extend/messages/espresso_events_Messages_Hooks_Extend.class.php 2 patches
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -16,282 +16,282 @@
 block discarded – undo
16 16
  */
17 17
 class espresso_events_Messages_Hooks_Extend extends espresso_events_Messages_Hooks
18 18
 {
19
-    /**
20
-     * espresso_events_Messages_Hooks_Extend constructor.
21
-     *
22
-     * @param EE_Admin_Page $admin_page
23
-     * @throws EE_Error
24
-     * @throws ReflectionException
25
-     */
26
-    public function __construct(EE_Admin_Page $admin_page)
27
-    {
28
-        /**
29
-         * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages
30
-         */
31
-        if (
32
-            ! EE_Registry::instance()->CAP->current_user_can(
33
-                'ee_edit_messages',
34
-                'messages_events_editor_metabox'
35
-            )
36
-        ) {
37
-            return;
38
-        }
39
-        add_filter(
40
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
41
-            [$this, 'caf_updates']
42
-        );
43
-        add_action(
44
-            'AHEE__Extend_Events_Admin_Page___duplicate_event__after',
45
-            [$this, 'duplicate_custom_message_settings'],
46
-            10,
47
-            2
48
-        );
49
-        parent::__construct($admin_page);
50
-    }
51
-
52
-
53
-    /**
54
-     * extending the properties set in espresso_events_Messages_Hooks
55
-     *
56
-     * @access protected
57
-     * @return void
58
-     */
59
-    protected function _extend_properties()
60
-    {
61
-        define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
62
-        $this->_ajax_func = ['ee_msgs_create_new_custom' => 'create_new_custom'];
63
-        $this->_metaboxes = [
64
-            0 => [
65
-                'page_route' => ['edit', 'create_new'],
66
-                'func'       => 'messages_metabox',
67
-                'label'      => esc_html__('Notifications', 'event_espresso'),
68
-                'priority'   => 'high',
69
-            ],
70
-        ];
71
-
72
-        // see explanation for layout in EE_Admin_Hooks
73
-        $this->_scripts_styles = [
74
-            'registers' => [
75
-                'events_msg_admin'     => [
76
-                    'url'     => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
77
-                    'depends' => ['ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'],
78
-                ],
79
-                'events_msg_admin_css' => [
80
-                    'url'  => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
81
-                    'type' => 'css',
82
-                ],
83
-            ],
84
-            'enqueues'  => [
85
-                'events_msg_admin'     => ['edit', 'create_new'],
86
-                'events_msg_admin_css' => ['edit', 'create_new'],
87
-            ],
88
-        ];
89
-    }
90
-
91
-
92
-    public function caf_updates($update_callbacks)
93
-    {
94
-        $update_callbacks[] = [$this, 'attach_evt_message_templates'];
95
-        return $update_callbacks;
96
-    }
97
-
98
-
99
-    /**
100
-     * Handles attaching Message Templates to the Event on save.
101
-     *
102
-     * @param EE_Event $event EE event object
103
-     * @param array    $data  The request data from the form
104
-     * @return bool success or fail
105
-     * @throws EE_Error
106
-     * @throws ReflectionException
107
-     */
108
-    public function attach_evt_message_templates(EE_Event $event, array $data): bool
109
-    {
110
-        $success = true;
111
-        if (isset($data['event_message_templates_relation'])) {
112
-            // first get all existing relations on the Event for message types.
113
-            $existing_templates = EEM_Event_Message_Template::instance()->messageTemplateGroupIDsForEvent($event);
114
-            $current_templates  = $data['event_message_templates_relation'];
115
-            // new templates are those in the $current_templates array that don't exist in $existing_templates
116
-            $templates_to_add = array_diff($current_templates, $existing_templates);
117
-            foreach ($templates_to_add as $template_to_add) {
118
-                $added_template = $event->_add_relation_to($template_to_add, 'Message_Template_Group');
119
-                // toggle success to false if we don't get back a template group object
120
-                $success = $added_template instanceof EE_Message_Template_Group ? $success : false;
121
-            }
122
-            // templates to remove are those in the $existing_templates array that don't exist in $current_templates
123
-            $templates_to_remove = array_diff($existing_templates, $current_templates);
124
-            foreach ($templates_to_remove as $template_to_remove) {
125
-                $removed_template = $event->_remove_relation_to($template_to_remove, 'Message_Template_Group');
126
-                // toggle success to false if we don't get back a template group object
127
-                $success = $removed_template instanceof EE_Message_Template_Group ? $success : false;
128
-            }
129
-        }
130
-        return $success;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param $event
136
-     * @param $callback_args
137
-     * @return string
138
-     * @throws EE_Error
139
-     * @throws ReflectionException
140
-     */
141
-    public function messages_metabox($event, $callback_args)
142
-    {
143
-        // convert 'evt_id' to 'EVT_ID'
144
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
145
-        $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int');
146
-        $EVT_ID = $this->request->getRequestParam('evt_id', $EVT_ID, 'int');
147
-        $this->request->setRequestParam('EVT_ID', $EVT_ID);
148
-
149
-        // get the active messengers (b/c messenger objects have the active message templates)
150
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
151
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
152
-        $active_messengers        = $message_resource_manager->active_messengers();
153
-        $tabs                     = [];
154
-
155
-        // empty messengers?
156
-        // Note message types will always have at least one available because every messenger has a default message type
157
-        // associated with it (payment) if no other message types are selected.
158
-        if (empty($active_messengers)) {
159
-            $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce(
160
-                ['action' => 'settings'],
161
-                EE_MSG_ADMIN_URL
162
-            );
163
-            $error_msg        = sprintf(
164
-                esc_html__(
165
-                    'There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.',
166
-                    'event_espresso'
167
-                ),
168
-                '<strong>',
169
-                '</strong>',
170
-                '<a href="' . esc_url_raw($msg_activate_url) . '">',
171
-                '</a>'
172
-            );
173
-            $error_content    = '<div class="error"><p>' . $error_msg . '</p></div>';
174
-            $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
175
-
176
-            echo wp_kses($error_content, AllowedTags::getAllowedTags());
177
-            echo wp_kses($internal_content, AllowedTags::getAllowedTags());
178
-            return '';
179
-        }
180
-
181
-        // get content for active messengers
182
-        foreach ($active_messengers as $name => $messenger) {
183
-            // first check if there are any active message types for this messenger.
184
-            $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name);
185
-            if (empty($active_mts)) {
186
-                continue;
187
-            }
188
-
189
-            $tab_content = $messenger->get_messenger_admin_page_content(
190
-                'events',
191
-                'edit',
192
-                ['event' => $EVT_ID]
193
-            );
194
-
195
-            if (! empty($tab_content)) {
196
-                $tabs[ $name ] = $tab_content;
197
-            }
198
-        }
199
-
200
-        // we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper.
201
-        $tabbed_content = EEH_Tabbed_Content::display($tabs);
202
-        if ($tabbed_content instanceof WP_Error) {
203
-            $tabbed_content = $tabbed_content->get_error_message();
204
-        }
205
-
206
-        $notices = '
19
+	/**
20
+	 * espresso_events_Messages_Hooks_Extend constructor.
21
+	 *
22
+	 * @param EE_Admin_Page $admin_page
23
+	 * @throws EE_Error
24
+	 * @throws ReflectionException
25
+	 */
26
+	public function __construct(EE_Admin_Page $admin_page)
27
+	{
28
+		/**
29
+		 * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages
30
+		 */
31
+		if (
32
+			! EE_Registry::instance()->CAP->current_user_can(
33
+				'ee_edit_messages',
34
+				'messages_events_editor_metabox'
35
+			)
36
+		) {
37
+			return;
38
+		}
39
+		add_filter(
40
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
41
+			[$this, 'caf_updates']
42
+		);
43
+		add_action(
44
+			'AHEE__Extend_Events_Admin_Page___duplicate_event__after',
45
+			[$this, 'duplicate_custom_message_settings'],
46
+			10,
47
+			2
48
+		);
49
+		parent::__construct($admin_page);
50
+	}
51
+
52
+
53
+	/**
54
+	 * extending the properties set in espresso_events_Messages_Hooks
55
+	 *
56
+	 * @access protected
57
+	 * @return void
58
+	 */
59
+	protected function _extend_properties()
60
+	{
61
+		define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
62
+		$this->_ajax_func = ['ee_msgs_create_new_custom' => 'create_new_custom'];
63
+		$this->_metaboxes = [
64
+			0 => [
65
+				'page_route' => ['edit', 'create_new'],
66
+				'func'       => 'messages_metabox',
67
+				'label'      => esc_html__('Notifications', 'event_espresso'),
68
+				'priority'   => 'high',
69
+			],
70
+		];
71
+
72
+		// see explanation for layout in EE_Admin_Hooks
73
+		$this->_scripts_styles = [
74
+			'registers' => [
75
+				'events_msg_admin'     => [
76
+					'url'     => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
77
+					'depends' => ['ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'],
78
+				],
79
+				'events_msg_admin_css' => [
80
+					'url'  => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
81
+					'type' => 'css',
82
+				],
83
+			],
84
+			'enqueues'  => [
85
+				'events_msg_admin'     => ['edit', 'create_new'],
86
+				'events_msg_admin_css' => ['edit', 'create_new'],
87
+			],
88
+		];
89
+	}
90
+
91
+
92
+	public function caf_updates($update_callbacks)
93
+	{
94
+		$update_callbacks[] = [$this, 'attach_evt_message_templates'];
95
+		return $update_callbacks;
96
+	}
97
+
98
+
99
+	/**
100
+	 * Handles attaching Message Templates to the Event on save.
101
+	 *
102
+	 * @param EE_Event $event EE event object
103
+	 * @param array    $data  The request data from the form
104
+	 * @return bool success or fail
105
+	 * @throws EE_Error
106
+	 * @throws ReflectionException
107
+	 */
108
+	public function attach_evt_message_templates(EE_Event $event, array $data): bool
109
+	{
110
+		$success = true;
111
+		if (isset($data['event_message_templates_relation'])) {
112
+			// first get all existing relations on the Event for message types.
113
+			$existing_templates = EEM_Event_Message_Template::instance()->messageTemplateGroupIDsForEvent($event);
114
+			$current_templates  = $data['event_message_templates_relation'];
115
+			// new templates are those in the $current_templates array that don't exist in $existing_templates
116
+			$templates_to_add = array_diff($current_templates, $existing_templates);
117
+			foreach ($templates_to_add as $template_to_add) {
118
+				$added_template = $event->_add_relation_to($template_to_add, 'Message_Template_Group');
119
+				// toggle success to false if we don't get back a template group object
120
+				$success = $added_template instanceof EE_Message_Template_Group ? $success : false;
121
+			}
122
+			// templates to remove are those in the $existing_templates array that don't exist in $current_templates
123
+			$templates_to_remove = array_diff($existing_templates, $current_templates);
124
+			foreach ($templates_to_remove as $template_to_remove) {
125
+				$removed_template = $event->_remove_relation_to($template_to_remove, 'Message_Template_Group');
126
+				// toggle success to false if we don't get back a template group object
127
+				$success = $removed_template instanceof EE_Message_Template_Group ? $success : false;
128
+			}
129
+		}
130
+		return $success;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param $event
136
+	 * @param $callback_args
137
+	 * @return string
138
+	 * @throws EE_Error
139
+	 * @throws ReflectionException
140
+	 */
141
+	public function messages_metabox($event, $callback_args)
142
+	{
143
+		// convert 'evt_id' to 'EVT_ID'
144
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
145
+		$EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int');
146
+		$EVT_ID = $this->request->getRequestParam('evt_id', $EVT_ID, 'int');
147
+		$this->request->setRequestParam('EVT_ID', $EVT_ID);
148
+
149
+		// get the active messengers (b/c messenger objects have the active message templates)
150
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
151
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
152
+		$active_messengers        = $message_resource_manager->active_messengers();
153
+		$tabs                     = [];
154
+
155
+		// empty messengers?
156
+		// Note message types will always have at least one available because every messenger has a default message type
157
+		// associated with it (payment) if no other message types are selected.
158
+		if (empty($active_messengers)) {
159
+			$msg_activate_url = EE_Admin_Page::add_query_args_and_nonce(
160
+				['action' => 'settings'],
161
+				EE_MSG_ADMIN_URL
162
+			);
163
+			$error_msg        = sprintf(
164
+				esc_html__(
165
+					'There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.',
166
+					'event_espresso'
167
+				),
168
+				'<strong>',
169
+				'</strong>',
170
+				'<a href="' . esc_url_raw($msg_activate_url) . '">',
171
+				'</a>'
172
+			);
173
+			$error_content    = '<div class="error"><p>' . $error_msg . '</p></div>';
174
+			$internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
175
+
176
+			echo wp_kses($error_content, AllowedTags::getAllowedTags());
177
+			echo wp_kses($internal_content, AllowedTags::getAllowedTags());
178
+			return '';
179
+		}
180
+
181
+		// get content for active messengers
182
+		foreach ($active_messengers as $name => $messenger) {
183
+			// first check if there are any active message types for this messenger.
184
+			$active_mts = $message_resource_manager->get_active_message_types_for_messenger($name);
185
+			if (empty($active_mts)) {
186
+				continue;
187
+			}
188
+
189
+			$tab_content = $messenger->get_messenger_admin_page_content(
190
+				'events',
191
+				'edit',
192
+				['event' => $EVT_ID]
193
+			);
194
+
195
+			if (! empty($tab_content)) {
196
+				$tabs[ $name ] = $tab_content;
197
+			}
198
+		}
199
+
200
+		// we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper.
201
+		$tabbed_content = EEH_Tabbed_Content::display($tabs);
202
+		if ($tabbed_content instanceof WP_Error) {
203
+			$tabbed_content = $tabbed_content->get_error_message();
204
+		}
205
+
206
+		$notices = '
207 207
         <div id="espresso-ajax-loading" class="ajax-loader-grey">
208 208
             <span class="ee-spinner ee-spin"></span>
209 209
             <span class="hidden">' . esc_html__('loading...', 'event_espresso') . '</span>
210 210
         </div>
211 211
         <div class="ee-notices"></div>';
212 212
 
213
-        if (defined('DOING_AJAX')) {
214
-            return $tabbed_content;
215
-        }
216
-
217
-        do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
218
-        echo wp_kses(
219
-            $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>',
220
-            AllowedTags::getWithFormTags()
221
-        );
222
-        do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
223
-        return '';
224
-    }
225
-
226
-
227
-    /**
228
-     * Ajax callback for ee_msgs_create_new_custom ajax request.
229
-     * Takes incoming GRP_ID and name and description values from ajax request
230
-     * to create a new custom template based off of the incoming GRP_ID.
231
-     *
232
-     * @access public
233
-     * @return void
234
-     * @throws EE_Error
235
-     * @throws ReflectionException
236
-     */
237
-    public function create_new_custom()
238
-    {
239
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
240
-            wp_die(esc_html__('You don\'t have privileges to do this action', 'event_espresso'));
241
-        }
242
-
243
-        /** @var RequestInterface $request */
244
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
245
-
246
-        // let's clean up the request data a bit for downstream usage of name and description.
247
-        $templateName = $this->request->getRequestParam('custom_template_args[MTP_name]', '');
248
-        $request->setRequestParam('templateName', $templateName);
249
-        $templateDescription = $this->request->getRequestParam('custom_template_args[MTP_description]', '');
250
-        $request->setRequestParam('templateDescription', $templateDescription);
251
-
252
-        /** @var MessageTemplateManager $message_template_manager */
253
-        $message_template_manager = LoaderFactory::getShared(MessageTemplateManager::class);
254
-        $message_template_manager->generateNewTemplates();
255
-    }
256
-
257
-
258
-    public function create_new_admin_footer()
259
-    {
260
-        $this->edit_admin_footer();
261
-    }
262
-
263
-
264
-    /**
265
-     * This is the dynamic method for this class
266
-     * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page.
267
-     *
268
-     * @return void
269
-     * @throws DomainException
270
-     */
271
-    public function edit_admin_footer()
272
-    {
273
-        EEH_Template::display_template(
274
-            EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
275
-        );
276
-    }
277
-
278
-
279
-    /**
280
-     * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate
281
-     * the assigned custom message templates.
282
-     *
283
-     * @param EE_Event $new_event
284
-     * @param EE_Event $original_event
285
-     * @throws EE_Error
286
-     * @throws ReflectionException
287
-     */
288
-    public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event)
289
-    {
290
-        $message_template_groups = $original_event->get_many_related('Message_Template_Group');
291
-        foreach ($message_template_groups as $message_template_group) {
292
-            $new_event->_add_relation_to($message_template_group, 'Message_Template_Group');
293
-        }
294
-        // save new event
295
-        $new_event->save();
296
-    }
213
+		if (defined('DOING_AJAX')) {
214
+			return $tabbed_content;
215
+		}
216
+
217
+		do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
218
+		echo wp_kses(
219
+			$notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>',
220
+			AllowedTags::getWithFormTags()
221
+		);
222
+		do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
223
+		return '';
224
+	}
225
+
226
+
227
+	/**
228
+	 * Ajax callback for ee_msgs_create_new_custom ajax request.
229
+	 * Takes incoming GRP_ID and name and description values from ajax request
230
+	 * to create a new custom template based off of the incoming GRP_ID.
231
+	 *
232
+	 * @access public
233
+	 * @return void
234
+	 * @throws EE_Error
235
+	 * @throws ReflectionException
236
+	 */
237
+	public function create_new_custom()
238
+	{
239
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
240
+			wp_die(esc_html__('You don\'t have privileges to do this action', 'event_espresso'));
241
+		}
242
+
243
+		/** @var RequestInterface $request */
244
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
245
+
246
+		// let's clean up the request data a bit for downstream usage of name and description.
247
+		$templateName = $this->request->getRequestParam('custom_template_args[MTP_name]', '');
248
+		$request->setRequestParam('templateName', $templateName);
249
+		$templateDescription = $this->request->getRequestParam('custom_template_args[MTP_description]', '');
250
+		$request->setRequestParam('templateDescription', $templateDescription);
251
+
252
+		/** @var MessageTemplateManager $message_template_manager */
253
+		$message_template_manager = LoaderFactory::getShared(MessageTemplateManager::class);
254
+		$message_template_manager->generateNewTemplates();
255
+	}
256
+
257
+
258
+	public function create_new_admin_footer()
259
+	{
260
+		$this->edit_admin_footer();
261
+	}
262
+
263
+
264
+	/**
265
+	 * This is the dynamic method for this class
266
+	 * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page.
267
+	 *
268
+	 * @return void
269
+	 * @throws DomainException
270
+	 */
271
+	public function edit_admin_footer()
272
+	{
273
+		EEH_Template::display_template(
274
+			EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
275
+		);
276
+	}
277
+
278
+
279
+	/**
280
+	 * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate
281
+	 * the assigned custom message templates.
282
+	 *
283
+	 * @param EE_Event $new_event
284
+	 * @param EE_Event $original_event
285
+	 * @throws EE_Error
286
+	 * @throws ReflectionException
287
+	 */
288
+	public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event)
289
+	{
290
+		$message_template_groups = $original_event->get_many_related('Message_Template_Group');
291
+		foreach ($message_template_groups as $message_template_group) {
292
+			$new_event->_add_relation_to($message_template_group, 'Message_Template_Group');
293
+		}
294
+		// save new event
295
+		$new_event->save();
296
+	}
297 297
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     protected function _extend_properties()
60 60
     {
61
-        define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
61
+        define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/');
62 62
         $this->_ajax_func = ['ee_msgs_create_new_custom' => 'create_new_custom'];
63 63
         $this->_metaboxes = [
64 64
             0 => [
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
         $this->_scripts_styles = [
74 74
             'registers' => [
75 75
                 'events_msg_admin'     => [
76
-                    'url'     => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
76
+                    'url'     => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js',
77 77
                     'depends' => ['ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'],
78 78
                 ],
79 79
                 'events_msg_admin_css' => [
80
-                    'url'  => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
80
+                    'url'  => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css',
81 81
                     'type' => 'css',
82 82
                 ],
83 83
             ],
@@ -160,18 +160,18 @@  discard block
 block discarded – undo
160 160
                 ['action' => 'settings'],
161 161
                 EE_MSG_ADMIN_URL
162 162
             );
163
-            $error_msg        = sprintf(
163
+            $error_msg = sprintf(
164 164
                 esc_html__(
165 165
                     'There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.',
166 166
                     'event_espresso'
167 167
                 ),
168 168
                 '<strong>',
169 169
                 '</strong>',
170
-                '<a href="' . esc_url_raw($msg_activate_url) . '">',
170
+                '<a href="'.esc_url_raw($msg_activate_url).'">',
171 171
                 '</a>'
172 172
             );
173
-            $error_content    = '<div class="error"><p>' . $error_msg . '</p></div>';
174
-            $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
173
+            $error_content    = '<div class="error"><p>'.$error_msg.'</p></div>';
174
+            $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>';
175 175
 
176 176
             echo wp_kses($error_content, AllowedTags::getAllowedTags());
177 177
             echo wp_kses($internal_content, AllowedTags::getAllowedTags());
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
                 ['event' => $EVT_ID]
193 193
             );
194 194
 
195
-            if (! empty($tab_content)) {
196
-                $tabs[ $name ] = $tab_content;
195
+            if ( ! empty($tab_content)) {
196
+                $tabs[$name] = $tab_content;
197 197
             }
198 198
         }
199 199
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $notices = '
207 207
         <div id="espresso-ajax-loading" class="ajax-loader-grey">
208 208
             <span class="ee-spinner ee-spin"></span>
209
-            <span class="hidden">' . esc_html__('loading...', 'event_espresso') . '</span>
209
+            <span class="hidden">' . esc_html__('loading...', 'event_espresso').'</span>
210 210
         </div>
211 211
         <div class="ee-notices"></div>';
212 212
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
         do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
218 218
         echo wp_kses(
219
-            $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>',
219
+            $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>',
220 220
             AllowedTags::getWithFormTags()
221 221
         );
222 222
         do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function create_new_custom()
238 238
     {
239
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
239
+        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
240 240
             wp_die(esc_html__('You don\'t have privileges to do this action', 'event_espresso'));
241 241
         }
242 242
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
     public function edit_admin_footer()
272 272
     {
273 273
         EEH_Template::display_template(
274
-            EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
274
+            EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php'
275 275
         );
276 276
     }
277 277
 
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +618 added lines, -618 removed lines patch added patch discarded remove patch
@@ -16,234 +16,234 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class EE_Event_Registrations_List_Table extends EE_Admin_List_Table
18 18
 {
19
-    protected RequestInterface $request;
20
-
21
-    /**
22
-     * @var Extend_Registrations_Admin_Page
23
-     */
24
-    protected $_admin_page;
25
-
26
-    /**
27
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
28
-     */
29
-    protected DatetimesForEventCheckIn  $datetimes_for_event;
30
-
31
-    protected ?DatetimesForEventCheckIn $datetimes_for_current_row = null;
32
-
33
-    /**
34
-     * The DTT_ID if the current view has a specified datetime.
35
-     */
36
-    protected int          $datetime_id = 0;
37
-
38
-    protected ?EE_Datetime $datetime    = null;
39
-
40
-    /**
41
-     * The event ID if one is specified in the request
42
-     */
43
-    protected int       $event_id      = 0;
44
-
45
-    protected ?EE_Event $event         = null;
46
-
47
-    protected bool      $hide_expired  = false;
48
-
49
-    protected bool      $hide_upcoming = false;
50
-
51
-    protected array     $_status       = [];
52
-
53
-
54
-    /**
55
-     * EE_Event_Registrations_List_Table constructor.
56
-     *
57
-     * @param Registrations_Admin_Page $admin_page
58
-     * @throws EE_Error
59
-     * @throws ReflectionException
60
-     */
61
-    public function __construct($admin_page)
62
-    {
63
-        $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
64
-        $this->resolveRequestVars();
65
-        parent::__construct($admin_page);
66
-    }
67
-
68
-
69
-    /**
70
-     * @throws EE_Error
71
-     * @throws ReflectionException
72
-     * @since 5.0.0.p
73
-     */
74
-    private function resolveRequestVars()
75
-    {
76
-        $this->event_id            = $this->request->getRequestParam('event_id', 0, 'int');
77
-        $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id);
78
-        // if we're filtering for a specific event and it only has one datetime, then grab its ID
79
-        $this->datetime    = $this->datetimes_for_event->getOneDatetimeForEvent();
80
-        $this->datetime_id = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0;
81
-        // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ)
82
-        $this->datetime_id = $this->request->getRequestParam(
83
-            'DTT_ID',
84
-            $this->datetime_id,
85
-            'int'
86
-        );
87
-    }
88
-
89
-
90
-    /**
91
-     * @throws EE_Error
92
-     * @throws ReflectionException
93
-     */
94
-    protected function _setup_data()
95
-    {
96
-        $this->_data = $this->_view !== 'trash'
97
-            ? $this->_admin_page->get_event_attendees($this->_per_page)
98
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
99
-
100
-        $this->_all_data_count = $this->_view !== 'trash'
101
-            ? $this->_admin_page->get_event_attendees($this->_per_page, true)
102
-            : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
103
-    }
104
-
105
-
106
-    /**
107
-     * @throws ReflectionException
108
-     * @throws EE_Error
109
-     */
110
-    protected function _set_properties()
111
-    {
112
-        $return_url = $this->getReturnUrl();
113
-
114
-        $this->_wp_list_args = [
115
-            'singular' => esc_html__('registrant', 'event_espresso'),
116
-            'plural'   => esc_html__('registrants', 'event_espresso'),
117
-            'ajax'     => true,
118
-            'screen'   => $this->_admin_page->get_current_screen()->id,
119
-        ];
120
-        $columns             = [];
121
-
122
-        $this->_columns = [
123
-            '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
124
-            'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
125
-            'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
126
-            'Event'               => esc_html__('Event', 'event_espresso'),
127
-            'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
128
-            '_REG_final_price'    => esc_html__('Price', 'event_espresso'),
129
-            'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
130
-            'TXN_total'           => esc_html__('Total', 'event_espresso'),
131
-        ];
132
-        // Add/remove columns when an event has been selected
133
-        if (! empty($this->event_id)) {
134
-            // Render a checkbox column
135
-            $columns['cb']              = '<input type="checkbox" />';
136
-            $this->_has_checkbox_column = true;
137
-            // Remove the 'Event' column
138
-            unset($this->_columns['Event']);
139
-            $this->setBottomButtons();
140
-        }
141
-        $this->_columns        = array_merge($columns, $this->_columns);
142
-        $this->_primary_column = '_REG_att_checked_in';
143
-
144
-        $csv_report = RegistrationsCsvReportParams::getRequestParams(
145
-            $return_url,
146
-            $this->_req_data,
147
-            $this->event_id,
148
-            $this->datetime_id
149
-        );
150
-        if (! empty($csv_report)) {
151
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
152
-        }
153
-
154
-        $this->_sortable_columns = [
155
-            /**
156
-             * Allows users to change the default sort if they wish.
157
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
158
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
159
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
160
-             * for a specific list table you can use the provided reference to this object instance.
161
-             */
162
-            'ATT_name' => [
163
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
164
-                true,
165
-                $this,
166
-            ]
167
-                ? ['ATT_lname' => true]
168
-                : ['ATT_fname' => true],
169
-            'Event'    => ['Event.EVT_name' => false],
170
-        ];
171
-        $this->_hidden_columns   = [];
172
-        $this->event             = EEM_Event::instance()->get_one_by_ID($this->event_id);
173
-        if ($this->event instanceof EE_Event) {
174
-            $this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event);
175
-        }
176
-    }
177
-
178
-
179
-    /**
180
-     * @param EE_Registration $item
181
-     * @return string
182
-     */
183
-    protected function _get_row_class($item): string
184
-    {
185
-        $class = parent::_get_row_class($item);
186
-        if ($this->_has_checkbox_column) {
187
-            $class .= ' has-checkbox-column';
188
-        }
189
-        return $class;
190
-    }
191
-
192
-
193
-    /**
194
-     * @return array
195
-     * @throws EE_Error
196
-     * @throws ReflectionException
197
-     */
198
-    protected function _get_table_filters()
199
-    {
200
-        $filters               = [];
201
-        $this->hide_expired    = $this->request->getRequestParam('hide_expired', false, 'bool');
202
-        $this->hide_upcoming   = $this->request->getRequestParam('hide_upcoming', false, 'bool');
203
-        $hide_expired_checked  = $this->hide_expired ? 'checked' : '';
204
-        $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
205
-        // get datetimes for ALL active events (note possible capability restrictions)
206
-        $events          = $this->datetimes_for_event->getAllEvents();
207
-        $event_options[] = [
208
-            'id'   => 0,
209
-            'text' => esc_html__(' - select an event - ', 'event_espresso'),
210
-        ];
211
-        foreach ($events as $event) {
212
-            // any registrations for this event?
213
-            if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
214
-                continue;
215
-            }
216
-            $expired_class  = $event->is_expired() ? 'ee-expired-event' : '';
217
-            $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : '';
218
-
219
-            $event_options[] = [
220
-                'id'    => $event->ID(),
221
-                'text'  => apply_filters(
222
-                    'FHEE__EE_Event_Registrations___get_table_filters__event_name',
223
-                    $event->name(),
224
-                    $event
225
-                ),
226
-                'class' => $expired_class . $upcoming_class,
227
-            ];
228
-            if ($event->ID() === $this->event_id) {
229
-                $this->hide_expired    = $expired_class === '' ? $this->hide_expired : false;
230
-                $hide_expired_checked  = $expired_class === '' ? $hide_expired_checked : '';
231
-                $this->hide_upcoming   = $upcoming_class === '' ? $this->hide_upcoming : false;
232
-                $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : '';
233
-            }
234
-        }
235
-
236
-        $select_class = $this->hide_expired ? 'ee-hide-expired-events' : '';
237
-        $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : '';
238
-        $select_input = EEH_Form_Fields::select_input(
239
-            'event_id',
240
-            $event_options,
241
-            $this->event_id,
242
-            '',
243
-            $select_class
244
-        );
245
-
246
-        $filters[] = '
19
+	protected RequestInterface $request;
20
+
21
+	/**
22
+	 * @var Extend_Registrations_Admin_Page
23
+	 */
24
+	protected $_admin_page;
25
+
26
+	/**
27
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
28
+	 */
29
+	protected DatetimesForEventCheckIn  $datetimes_for_event;
30
+
31
+	protected ?DatetimesForEventCheckIn $datetimes_for_current_row = null;
32
+
33
+	/**
34
+	 * The DTT_ID if the current view has a specified datetime.
35
+	 */
36
+	protected int          $datetime_id = 0;
37
+
38
+	protected ?EE_Datetime $datetime    = null;
39
+
40
+	/**
41
+	 * The event ID if one is specified in the request
42
+	 */
43
+	protected int       $event_id      = 0;
44
+
45
+	protected ?EE_Event $event         = null;
46
+
47
+	protected bool      $hide_expired  = false;
48
+
49
+	protected bool      $hide_upcoming = false;
50
+
51
+	protected array     $_status       = [];
52
+
53
+
54
+	/**
55
+	 * EE_Event_Registrations_List_Table constructor.
56
+	 *
57
+	 * @param Registrations_Admin_Page $admin_page
58
+	 * @throws EE_Error
59
+	 * @throws ReflectionException
60
+	 */
61
+	public function __construct($admin_page)
62
+	{
63
+		$this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
64
+		$this->resolveRequestVars();
65
+		parent::__construct($admin_page);
66
+	}
67
+
68
+
69
+	/**
70
+	 * @throws EE_Error
71
+	 * @throws ReflectionException
72
+	 * @since 5.0.0.p
73
+	 */
74
+	private function resolveRequestVars()
75
+	{
76
+		$this->event_id            = $this->request->getRequestParam('event_id', 0, 'int');
77
+		$this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id);
78
+		// if we're filtering for a specific event and it only has one datetime, then grab its ID
79
+		$this->datetime    = $this->datetimes_for_event->getOneDatetimeForEvent();
80
+		$this->datetime_id = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0;
81
+		// else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ)
82
+		$this->datetime_id = $this->request->getRequestParam(
83
+			'DTT_ID',
84
+			$this->datetime_id,
85
+			'int'
86
+		);
87
+	}
88
+
89
+
90
+	/**
91
+	 * @throws EE_Error
92
+	 * @throws ReflectionException
93
+	 */
94
+	protected function _setup_data()
95
+	{
96
+		$this->_data = $this->_view !== 'trash'
97
+			? $this->_admin_page->get_event_attendees($this->_per_page)
98
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
99
+
100
+		$this->_all_data_count = $this->_view !== 'trash'
101
+			? $this->_admin_page->get_event_attendees($this->_per_page, true)
102
+			: $this->_admin_page->get_event_attendees($this->_per_page, true, true);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @throws ReflectionException
108
+	 * @throws EE_Error
109
+	 */
110
+	protected function _set_properties()
111
+	{
112
+		$return_url = $this->getReturnUrl();
113
+
114
+		$this->_wp_list_args = [
115
+			'singular' => esc_html__('registrant', 'event_espresso'),
116
+			'plural'   => esc_html__('registrants', 'event_espresso'),
117
+			'ajax'     => true,
118
+			'screen'   => $this->_admin_page->get_current_screen()->id,
119
+		];
120
+		$columns             = [];
121
+
122
+		$this->_columns = [
123
+			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
124
+			'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
125
+			'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
126
+			'Event'               => esc_html__('Event', 'event_espresso'),
127
+			'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
128
+			'_REG_final_price'    => esc_html__('Price', 'event_espresso'),
129
+			'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
130
+			'TXN_total'           => esc_html__('Total', 'event_espresso'),
131
+		];
132
+		// Add/remove columns when an event has been selected
133
+		if (! empty($this->event_id)) {
134
+			// Render a checkbox column
135
+			$columns['cb']              = '<input type="checkbox" />';
136
+			$this->_has_checkbox_column = true;
137
+			// Remove the 'Event' column
138
+			unset($this->_columns['Event']);
139
+			$this->setBottomButtons();
140
+		}
141
+		$this->_columns        = array_merge($columns, $this->_columns);
142
+		$this->_primary_column = '_REG_att_checked_in';
143
+
144
+		$csv_report = RegistrationsCsvReportParams::getRequestParams(
145
+			$return_url,
146
+			$this->_req_data,
147
+			$this->event_id,
148
+			$this->datetime_id
149
+		);
150
+		if (! empty($csv_report)) {
151
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
152
+		}
153
+
154
+		$this->_sortable_columns = [
155
+			/**
156
+			 * Allows users to change the default sort if they wish.
157
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
158
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
159
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
160
+			 * for a specific list table you can use the provided reference to this object instance.
161
+			 */
162
+			'ATT_name' => [
163
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
164
+				true,
165
+				$this,
166
+			]
167
+				? ['ATT_lname' => true]
168
+				: ['ATT_fname' => true],
169
+			'Event'    => ['Event.EVT_name' => false],
170
+		];
171
+		$this->_hidden_columns   = [];
172
+		$this->event             = EEM_Event::instance()->get_one_by_ID($this->event_id);
173
+		if ($this->event instanceof EE_Event) {
174
+			$this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event);
175
+		}
176
+	}
177
+
178
+
179
+	/**
180
+	 * @param EE_Registration $item
181
+	 * @return string
182
+	 */
183
+	protected function _get_row_class($item): string
184
+	{
185
+		$class = parent::_get_row_class($item);
186
+		if ($this->_has_checkbox_column) {
187
+			$class .= ' has-checkbox-column';
188
+		}
189
+		return $class;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @return array
195
+	 * @throws EE_Error
196
+	 * @throws ReflectionException
197
+	 */
198
+	protected function _get_table_filters()
199
+	{
200
+		$filters               = [];
201
+		$this->hide_expired    = $this->request->getRequestParam('hide_expired', false, 'bool');
202
+		$this->hide_upcoming   = $this->request->getRequestParam('hide_upcoming', false, 'bool');
203
+		$hide_expired_checked  = $this->hide_expired ? 'checked' : '';
204
+		$hide_upcoming_checked = $this->hide_upcoming ? 'checked' : '';
205
+		// get datetimes for ALL active events (note possible capability restrictions)
206
+		$events          = $this->datetimes_for_event->getAllEvents();
207
+		$event_options[] = [
208
+			'id'   => 0,
209
+			'text' => esc_html__(' - select an event - ', 'event_espresso'),
210
+		];
211
+		foreach ($events as $event) {
212
+			// any registrations for this event?
213
+			if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
214
+				continue;
215
+			}
216
+			$expired_class  = $event->is_expired() ? 'ee-expired-event' : '';
217
+			$upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : '';
218
+
219
+			$event_options[] = [
220
+				'id'    => $event->ID(),
221
+				'text'  => apply_filters(
222
+					'FHEE__EE_Event_Registrations___get_table_filters__event_name',
223
+					$event->name(),
224
+					$event
225
+				),
226
+				'class' => $expired_class . $upcoming_class,
227
+			];
228
+			if ($event->ID() === $this->event_id) {
229
+				$this->hide_expired    = $expired_class === '' ? $this->hide_expired : false;
230
+				$hide_expired_checked  = $expired_class === '' ? $hide_expired_checked : '';
231
+				$this->hide_upcoming   = $upcoming_class === '' ? $this->hide_upcoming : false;
232
+				$hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : '';
233
+			}
234
+		}
235
+
236
+		$select_class = $this->hide_expired ? 'ee-hide-expired-events' : '';
237
+		$select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : '';
238
+		$select_input = EEH_Form_Fields::select_input(
239
+			'event_id',
240
+			$event_options,
241
+			$this->event_id,
242
+			'',
243
+			$select_class
244
+		);
245
+
246
+		$filters[] = '
247 247
         <div class="ee-event-filter__wrapper">
248 248
             <label class="ee-event-filter-main-label">
249 249
                 ' . esc_html__('Check-in Status for', 'event_espresso') . '
@@ -253,435 +253,435 @@  discard block
 block discarded – undo
253 253
                     <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label>
254 254
                     ' . $select_input . '
255 255
                 </span>';
256
-        // DTT datetimes filter
257
-        $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent(
258
-            $hide_upcoming_checked === 'checked'
259
-        );
260
-        if (count($datetimes_for_event) > 1) {
261
-            $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
262
-            foreach ($datetimes_for_event as $datetime) {
263
-                if ($datetime instanceof EE_Datetime) {
264
-                    $datetime_string = $datetime->name();
265
-                    $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : '';
266
-                    $datetime_string .= $datetime->date_and_time_range();
267
-                    $datetime_string .= $datetime->is_active() ? ' ∗' : '';
268
-                    $datetime_string .= $datetime->is_expired() ? ' «' : '';
269
-                    $datetime_string .= $datetime->is_upcoming() ? ' »' : '';
270
-                    // now put it all together
271
-                    $datetimes[ $datetime->ID() ] = $datetime_string;
272
-                }
273
-            }
274
-            $filters[] = '
256
+		// DTT datetimes filter
257
+		$datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent(
258
+			$hide_upcoming_checked === 'checked'
259
+		);
260
+		if (count($datetimes_for_event) > 1) {
261
+			$datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso');
262
+			foreach ($datetimes_for_event as $datetime) {
263
+				if ($datetime instanceof EE_Datetime) {
264
+					$datetime_string = $datetime->name();
265
+					$datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : '';
266
+					$datetime_string .= $datetime->date_and_time_range();
267
+					$datetime_string .= $datetime->is_active() ? ' ∗' : '';
268
+					$datetime_string .= $datetime->is_expired() ? ' «' : '';
269
+					$datetime_string .= $datetime->is_upcoming() ? ' »' : '';
270
+					// now put it all together
271
+					$datetimes[ $datetime->ID() ] = $datetime_string;
272
+				}
273
+			}
274
+			$filters[] = '
275 275
                 <span class="ee-datetime-selector">
276 276
                     <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label>
277 277
                     ' . EEH_Form_Fields::select_input(
278
-                        'DTT_ID',
279
-                        $datetimes,
280
-                        $this->datetime_id
281
-                    ) . '
278
+						'DTT_ID',
279
+						$datetimes,
280
+						$this->datetime_id
281
+					) . '
282 282
                 </span>';
283
-        }
284
-        $filters[] = '
283
+		}
284
+		$filters[] = '
285 285
                 <span class="ee-hide-upcoming-check">
286 286
                     <label for="js-ee-hide-upcoming-events">
287 287
                         <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" '
288
-                         . $hide_upcoming_checked
289
-                         . '>
288
+						 . $hide_upcoming_checked
289
+						 . '>
290 290
                             '
291
-                         . esc_html__('Hide Upcoming Events', 'event_espresso')
292
-                         . '
291
+						 . esc_html__('Hide Upcoming Events', 'event_espresso')
292
+						 . '
293 293
                     </label>
294 294
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" 
295 295
                           aria-label="'
296
-                         . esc_html__(
297
-                             'Will not display events with start dates in the future (ie: have not yet begun)',
298
-                             'event_espresso'
299
-                         ) . '"
296
+						 . esc_html__(
297
+							 'Will not display events with start dates in the future (ie: have not yet begun)',
298
+							 'event_espresso'
299
+						 ) . '"
300 300
                     ></span>
301 301
                 </span>
302 302
                 <span class="ee-hide-expired-check">
303 303
                     <label for="js-ee-hide-expired-events">
304 304
                         <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" '
305
-                         . $hide_expired_checked
306
-                         . '>
305
+						 . $hide_expired_checked
306
+						 . '>
307 307
                             ' . esc_html__('Hide Expired Events', 'event_espresso') . '
308 308
                     </label>
309 309
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" 
310 310
                           aria-label="'
311
-                         . esc_html__(
312
-                             'Will not display events with end dates in the past (ie: have already finished)',
313
-                             'event_espresso'
314
-                         )
315
-                         . '"
311
+						 . esc_html__(
312
+							 'Will not display events with end dates in the past (ie: have already finished)',
313
+							 'event_espresso'
314
+						 )
315
+						 . '"
316 316
                     ></span>
317 317
                 </span>
318 318
             </div>
319 319
         </div>';
320
-        return $filters;
321
-    }
322
-
323
-
324
-    /**
325
-     * @throws EE_Error
326
-     * @throws ReflectionException
327
-     */
328
-    protected function _add_view_counts()
329
-    {
330
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
331
-    }
332
-
333
-
334
-    /**
335
-     * @return int
336
-     * @throws EE_Error
337
-     * @throws ReflectionException
338
-     */
339
-    protected function _get_total_event_attendees(): int
340
-    {
341
-        $query_params = [];
342
-        if ($this->event_id) {
343
-            $query_params[0]['EVT_ID'] = $this->event_id;
344
-        }
345
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
346
-        if ($this->datetime_id) {
347
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
348
-        }
349
-        $status_ids_array          = apply_filters(
350
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
351
-            [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
352
-        );
353
-        $query_params[0]['STS_ID'] = ['IN', $status_ids_array];
354
-        return EEM_Registration::instance()->count($query_params);
355
-    }
356
-
357
-
358
-    /**
359
-     * @param EE_Registration $item
360
-     * @return string
361
-     * @throws EE_Error
362
-     * @throws ReflectionException
363
-     */
364
-    public function column_cb($item): string
365
-    {
366
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
367
-    }
368
-
369
-
370
-    /**
371
-     * column_REG_att_checked_in
372
-     *
373
-     * @param EE_Registration $registration
374
-     * @return string
375
-     * @throws EE_Error
376
-     * @throws InvalidArgumentException
377
-     * @throws InvalidDataTypeException
378
-     * @throws InvalidInterfaceException
379
-     * @throws ReflectionException
380
-     */
381
-    public function column__REG_att_checked_in(EE_Registration $registration): string
382
-    {
383
-        // we need a local variable for the datetime for each row
384
-        // (so that we don't pollute state for the entire table)
385
-        // so let's try to get it from the registration's event
386
-        $DTT_ID = $this->datetime_id;
387
-        if (! $DTT_ID) {
388
-            $reg_ticket_datetimes = $registration->ticket()->datetimes();
389
-            if (count($reg_ticket_datetimes) === 1) {
390
-                $reg_ticket_datetime = reset($reg_ticket_datetimes);
391
-                $DTT_ID              = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0;
392
-            }
393
-        }
394
-
395
-        if (! $DTT_ID) {
396
-            $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
397
-            $datetime                        = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID);
398
-            $DTT_ID                          = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
399
-        }
400
-
401
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
402
-            $registration,
403
-            $DTT_ID
404
-        );
405
-
406
-        $aria_label     = $checkin_status_dashicon->ariaLabel();
407
-        $dashicon_class = $checkin_status_dashicon->cssClasses();
408
-        $attributes     = ' onClick="return false"';
409
-        $button_class   = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box';
410
-
411
-        if (
412
-            $DTT_ID
413
-            && EE_Registry::instance()->CAP->current_user_can(
414
-                'ee_edit_checkin',
415
-                'espresso_registrations_toggle_checkin_status',
416
-                $registration->ID()
417
-            )
418
-        ) {
419
-            // overwrite the disabled attribute with data attributes for performing checkin
420
-            $attributes   = 'data-_regid="' . $registration->ID() . '"';
421
-            $attributes   .= ' data-dttid="' . $DTT_ID . '"';
422
-            $attributes   .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
423
-            $button_class .= ' clickable trigger-checkin';
424
-        }
425
-
426
-        $content = '
320
+		return $filters;
321
+	}
322
+
323
+
324
+	/**
325
+	 * @throws EE_Error
326
+	 * @throws ReflectionException
327
+	 */
328
+	protected function _add_view_counts()
329
+	{
330
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
331
+	}
332
+
333
+
334
+	/**
335
+	 * @return int
336
+	 * @throws EE_Error
337
+	 * @throws ReflectionException
338
+	 */
339
+	protected function _get_total_event_attendees(): int
340
+	{
341
+		$query_params = [];
342
+		if ($this->event_id) {
343
+			$query_params[0]['EVT_ID'] = $this->event_id;
344
+		}
345
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
346
+		if ($this->datetime_id) {
347
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
348
+		}
349
+		$status_ids_array          = apply_filters(
350
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
351
+			[EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
352
+		);
353
+		$query_params[0]['STS_ID'] = ['IN', $status_ids_array];
354
+		return EEM_Registration::instance()->count($query_params);
355
+	}
356
+
357
+
358
+	/**
359
+	 * @param EE_Registration $item
360
+	 * @return string
361
+	 * @throws EE_Error
362
+	 * @throws ReflectionException
363
+	 */
364
+	public function column_cb($item): string
365
+	{
366
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
367
+	}
368
+
369
+
370
+	/**
371
+	 * column_REG_att_checked_in
372
+	 *
373
+	 * @param EE_Registration $registration
374
+	 * @return string
375
+	 * @throws EE_Error
376
+	 * @throws InvalidArgumentException
377
+	 * @throws InvalidDataTypeException
378
+	 * @throws InvalidInterfaceException
379
+	 * @throws ReflectionException
380
+	 */
381
+	public function column__REG_att_checked_in(EE_Registration $registration): string
382
+	{
383
+		// we need a local variable for the datetime for each row
384
+		// (so that we don't pollute state for the entire table)
385
+		// so let's try to get it from the registration's event
386
+		$DTT_ID = $this->datetime_id;
387
+		if (! $DTT_ID) {
388
+			$reg_ticket_datetimes = $registration->ticket()->datetimes();
389
+			if (count($reg_ticket_datetimes) === 1) {
390
+				$reg_ticket_datetime = reset($reg_ticket_datetimes);
391
+				$DTT_ID              = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0;
392
+			}
393
+		}
394
+
395
+		if (! $DTT_ID) {
396
+			$this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
397
+			$datetime                        = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID);
398
+			$DTT_ID                          = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
399
+		}
400
+
401
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
402
+			$registration,
403
+			$DTT_ID
404
+		);
405
+
406
+		$aria_label     = $checkin_status_dashicon->ariaLabel();
407
+		$dashicon_class = $checkin_status_dashicon->cssClasses();
408
+		$attributes     = ' onClick="return false"';
409
+		$button_class   = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box';
410
+
411
+		if (
412
+			$DTT_ID
413
+			&& EE_Registry::instance()->CAP->current_user_can(
414
+				'ee_edit_checkin',
415
+				'espresso_registrations_toggle_checkin_status',
416
+				$registration->ID()
417
+			)
418
+		) {
419
+			// overwrite the disabled attribute with data attributes for performing checkin
420
+			$attributes   = 'data-_regid="' . $registration->ID() . '"';
421
+			$attributes   .= ' data-dttid="' . $DTT_ID . '"';
422
+			$attributes   .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
423
+			$button_class .= ' clickable trigger-checkin';
424
+		}
425
+
426
+		$content = '
427 427
         <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '>
428 428
             <span class="' . $dashicon_class . '" ></span>
429 429
         </button>
430 430
         <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>';
431
-        return $this->columnContent('_REG_att_checked_in', $content, 'center');
432
-    }
433
-
434
-
435
-    /**
436
-     * @param EE_Registration $registration
437
-     * @return string
438
-     * @throws EE_Error
439
-     * @throws ReflectionException
440
-     */
441
-    public function column_ATT_name(EE_Registration $registration): string
442
-    {
443
-        $attendee = $registration->attendee();
444
-        if (! $attendee instanceof EE_Attendee) {
445
-            return esc_html__('No contact record for this registration.', 'event_espresso');
446
-        }
447
-        // edit attendee link
448
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
449
-            ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
450
-            REG_ADMIN_URL
451
-        );
452
-        $name_link    = '
431
+		return $this->columnContent('_REG_att_checked_in', $content, 'center');
432
+	}
433
+
434
+
435
+	/**
436
+	 * @param EE_Registration $registration
437
+	 * @return string
438
+	 * @throws EE_Error
439
+	 * @throws ReflectionException
440
+	 */
441
+	public function column_ATT_name(EE_Registration $registration): string
442
+	{
443
+		$attendee = $registration->attendee();
444
+		if (! $attendee instanceof EE_Attendee) {
445
+			return esc_html__('No contact record for this registration.', 'event_espresso');
446
+		}
447
+		// edit attendee link
448
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
449
+			['action' => 'view_registration', '_REG_ID' => $registration->ID()],
450
+			REG_ADMIN_URL
451
+		);
452
+		$name_link    = '
453 453
             <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip"
454 454
             aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">
455 455
             </span>';
456
-        $name_link    .= EE_Registry::instance()->CAP->current_user_can(
457
-            'ee_edit_contacts',
458
-            'espresso_registrations_edit_attendee'
459
-        )
460
-            ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__(
461
-                'View Registration Details',
462
-                'event_espresso'
463
-            ) . '">'
464
-              . $registration->attendee()->full_name()
465
-              . '</a>'
466
-            : $registration->attendee()->full_name();
467
-        $name_link    .= $registration->count() === 1
468
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
469
-            : '';
470
-        // add group details
471
-        $name_link .= '&nbsp;' . sprintf(
472
-            esc_html__('(%s of %s)', 'event_espresso'),
473
-            $registration->count(),
474
-            $registration->group_size()
475
-        );
476
-        // add regcode
477
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
478
-            ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
479
-            REG_ADMIN_URL
480
-        );
481
-        $name_link .= '<br>';
482
-        $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
483
-            'ee_read_registration',
484
-            'view_registration',
485
-            $registration->ID()
486
-        )
487
-            ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
488
-                'View Registration Details',
489
-                'event_espresso'
490
-            ) . '">'
491
-              . $registration->reg_code()
492
-              . '</a>'
493
-            : $registration->reg_code();
494
-
495
-        $actions = [];
496
-        if (
497
-            $this->datetime_id
498
-            && EE_Registry::instance()->CAP->current_user_can(
499
-                'ee_read_checkins',
500
-                'espresso_registrations_registration_checkins'
501
-            )
502
-        ) {
503
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
504
-                ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id],
505
-                REG_ADMIN_URL
506
-            );
507
-            // get the timestamps for this registration's checkins, related to the selected datetime
508
-            /** @var EE_Checkin[] $checkins */
509
-            $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
510
-            if (! empty($checkins)) {
511
-                // get the last timestamp
512
-                $last_checkin = end($checkins);
513
-                // get timestamp string
514
-                $timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
515
-                $actions['checkin'] = '
456
+		$name_link    .= EE_Registry::instance()->CAP->current_user_can(
457
+			'ee_edit_contacts',
458
+			'espresso_registrations_edit_attendee'
459
+		)
460
+			? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__(
461
+				'View Registration Details',
462
+				'event_espresso'
463
+			) . '">'
464
+			  . $registration->attendee()->full_name()
465
+			  . '</a>'
466
+			: $registration->attendee()->full_name();
467
+		$name_link    .= $registration->count() === 1
468
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
469
+			: '';
470
+		// add group details
471
+		$name_link .= '&nbsp;' . sprintf(
472
+			esc_html__('(%s of %s)', 'event_espresso'),
473
+			$registration->count(),
474
+			$registration->group_size()
475
+		);
476
+		// add regcode
477
+		$link      = EE_Admin_Page::add_query_args_and_nonce(
478
+			['action' => 'view_registration', '_REG_ID' => $registration->ID()],
479
+			REG_ADMIN_URL
480
+		);
481
+		$name_link .= '<br>';
482
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
483
+			'ee_read_registration',
484
+			'view_registration',
485
+			$registration->ID()
486
+		)
487
+			? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
488
+				'View Registration Details',
489
+				'event_espresso'
490
+			) . '">'
491
+			  . $registration->reg_code()
492
+			  . '</a>'
493
+			: $registration->reg_code();
494
+
495
+		$actions = [];
496
+		if (
497
+			$this->datetime_id
498
+			&& EE_Registry::instance()->CAP->current_user_can(
499
+				'ee_read_checkins',
500
+				'espresso_registrations_registration_checkins'
501
+			)
502
+		) {
503
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
504
+				['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id],
505
+				REG_ADMIN_URL
506
+			);
507
+			// get the timestamps for this registration's checkins, related to the selected datetime
508
+			/** @var EE_Checkin[] $checkins */
509
+			$checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
510
+			if (! empty($checkins)) {
511
+				// get the last timestamp
512
+				$last_checkin = end($checkins);
513
+				// get timestamp string
514
+				$timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
515
+				$actions['checkin'] = '
516 516
                     <a  class="ee-aria-tooltip"
517 517
                         href="' . $checkin_list_url . '"
518 518
                         aria-label="' . esc_attr__(
519
-                            'View this registrant\'s check-ins/checkouts for the datetime',
520
-                            'event_espresso'
521
-                        ) . '"
519
+							'View this registrant\'s check-ins/checkouts for the datetime',
520
+							'event_espresso'
521
+						) . '"
522 522
                     >
523 523
                         ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . '
524 524
                     </a>';
525
-            }
526
-        }
527
-        $content = (! empty($this->datetime_id) && ! empty($checkins))
528
-            ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
529
-            : $name_link;
530
-        return $this->columnContent('ATT_name', $content);
531
-    }
532
-
533
-
534
-    /**
535
-     * @param EE_Registration $registration
536
-     * @return string
537
-     * @throws EE_Error
538
-     * @throws EE_Error
539
-     * @throws ReflectionException
540
-     */
541
-    public function column_ATT_email(EE_Registration $registration): string
542
-    {
543
-        $attendee = $registration->attendee();
544
-        $content  = $attendee instanceof EE_Attendee ? $attendee->email() : '';
545
-        return $this->columnContent('ATT_email', $content);
546
-    }
547
-
548
-
549
-    /**
550
-     * @param EE_Registration $registration
551
-     * @return string
552
-     * @throws EE_Error
553
-     * @throws ReflectionException
554
-     */
555
-    public function column_Event(EE_Registration $registration): string
556
-    {
557
-        try {
558
-            $event            = $this->event instanceof EE_Event ? $this->event : $registration->event();
559
-            $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce(
560
-                ['action' => 'event_registrations', 'event_id' => $event->ID()],
561
-                REG_ADMIN_URL
562
-            );
563
-            $content          = EE_Registry::instance()->CAP->current_user_can(
564
-                'ee_read_checkins',
565
-                'espresso_registrations_registration_checkins'
566
-            ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
567
-                . esc_attr__(
568
-                    'View Checkins for this Event',
569
-                    'event_espresso'
570
-                ) . '">' . $event->name() . '</a>' : $event->name();
571
-        } catch (EntityNotFoundException $e) {
572
-            $content = esc_html__('Unknown', 'event_espresso');
573
-        }
574
-        return $this->columnContent('Event', $content);
575
-    }
576
-
577
-
578
-    /**
579
-     * @param EE_Registration $registration
580
-     * @return string
581
-     * @throws EE_Error
582
-     * @throws ReflectionException
583
-     */
584
-    public function column_PRC_name(EE_Registration $registration): string
585
-    {
586
-        $content = $registration->ticket() instanceof EE_Ticket
587
-            ? $registration->ticket()->name()
588
-              . '<span class="ee-entity--id">(ID:' . $registration->ticket()->ID() . ')</span>'
589
-            : esc_html__(
590
-                "Unknown",
591
-                "event_espresso"
592
-            );
593
-        return $this->columnContent('PRC_name', $content);
594
-    }
595
-
596
-
597
-    /**
598
-     * column_REG_final_price
599
-     *
600
-     * @param EE_Registration $registration
601
-     * @return string
602
-     * @throws EE_Error
603
-     * @throws ReflectionException
604
-     */
605
-    public function column__REG_final_price(EE_Registration $registration): string
606
-    {
607
-        return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end');
608
-    }
609
-
610
-
611
-    /**
612
-     * column_TXN_paid
613
-     *
614
-     * @param EE_Registration $registration
615
-     * @return string
616
-     * @throws EE_Error
617
-     * @throws ReflectionException
618
-     */
619
-    public function column_TXN_paid(EE_Registration $registration): string
620
-    {
621
-        $content = '';
622
-        if ($registration->count() === 1) {
623
-            if ($registration->transaction()->paid() >= $registration->transaction()->total()) {
624
-                return '<div class="dashicons dashicons-yes green-icon"></div>';
625
-            } else {
626
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
627
-                    ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()],
628
-                    TXN_ADMIN_URL
629
-                );
630
-                $content          = EE_Registry::instance()->CAP->current_user_can(
631
-                    'ee_read_transaction',
632
-                    'espresso_transactions_view_transaction'
633
-                ) ? '
525
+			}
526
+		}
527
+		$content = (! empty($this->datetime_id) && ! empty($checkins))
528
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
529
+			: $name_link;
530
+		return $this->columnContent('ATT_name', $content);
531
+	}
532
+
533
+
534
+	/**
535
+	 * @param EE_Registration $registration
536
+	 * @return string
537
+	 * @throws EE_Error
538
+	 * @throws EE_Error
539
+	 * @throws ReflectionException
540
+	 */
541
+	public function column_ATT_email(EE_Registration $registration): string
542
+	{
543
+		$attendee = $registration->attendee();
544
+		$content  = $attendee instanceof EE_Attendee ? $attendee->email() : '';
545
+		return $this->columnContent('ATT_email', $content);
546
+	}
547
+
548
+
549
+	/**
550
+	 * @param EE_Registration $registration
551
+	 * @return string
552
+	 * @throws EE_Error
553
+	 * @throws ReflectionException
554
+	 */
555
+	public function column_Event(EE_Registration $registration): string
556
+	{
557
+		try {
558
+			$event            = $this->event instanceof EE_Event ? $this->event : $registration->event();
559
+			$checkin_link_url = EE_Admin_Page::add_query_args_and_nonce(
560
+				['action' => 'event_registrations', 'event_id' => $event->ID()],
561
+				REG_ADMIN_URL
562
+			);
563
+			$content          = EE_Registry::instance()->CAP->current_user_can(
564
+				'ee_read_checkins',
565
+				'espresso_registrations_registration_checkins'
566
+			) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
567
+				. esc_attr__(
568
+					'View Checkins for this Event',
569
+					'event_espresso'
570
+				) . '">' . $event->name() . '</a>' : $event->name();
571
+		} catch (EntityNotFoundException $e) {
572
+			$content = esc_html__('Unknown', 'event_espresso');
573
+		}
574
+		return $this->columnContent('Event', $content);
575
+	}
576
+
577
+
578
+	/**
579
+	 * @param EE_Registration $registration
580
+	 * @return string
581
+	 * @throws EE_Error
582
+	 * @throws ReflectionException
583
+	 */
584
+	public function column_PRC_name(EE_Registration $registration): string
585
+	{
586
+		$content = $registration->ticket() instanceof EE_Ticket
587
+			? $registration->ticket()->name()
588
+			  . '<span class="ee-entity--id">(ID:' . $registration->ticket()->ID() . ')</span>'
589
+			: esc_html__(
590
+				"Unknown",
591
+				"event_espresso"
592
+			);
593
+		return $this->columnContent('PRC_name', $content);
594
+	}
595
+
596
+
597
+	/**
598
+	 * column_REG_final_price
599
+	 *
600
+	 * @param EE_Registration $registration
601
+	 * @return string
602
+	 * @throws EE_Error
603
+	 * @throws ReflectionException
604
+	 */
605
+	public function column__REG_final_price(EE_Registration $registration): string
606
+	{
607
+		return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end');
608
+	}
609
+
610
+
611
+	/**
612
+	 * column_TXN_paid
613
+	 *
614
+	 * @param EE_Registration $registration
615
+	 * @return string
616
+	 * @throws EE_Error
617
+	 * @throws ReflectionException
618
+	 */
619
+	public function column_TXN_paid(EE_Registration $registration): string
620
+	{
621
+		$content = '';
622
+		if ($registration->count() === 1) {
623
+			if ($registration->transaction()->paid() >= $registration->transaction()->total()) {
624
+				return '<div class="dashicons dashicons-yes green-icon"></div>';
625
+			} else {
626
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
627
+					['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()],
628
+					TXN_ADMIN_URL
629
+				);
630
+				$content          = EE_Registry::instance()->CAP->current_user_can(
631
+					'ee_read_transaction',
632
+					'espresso_transactions_view_transaction'
633
+				) ? '
634 634
 				<a class="ee-aria-tooltip ee-status-color--'
635
-                    . $registration->transaction()->status_ID()
636
-                    . '" href="'
637
-                    . $view_txn_lnk_url
638
-                    . '"  aria-label="'
639
-                    . esc_attr__('View Transaction', 'event_espresso')
640
-                    . '">
635
+					. $registration->transaction()->status_ID()
636
+					. '" href="'
637
+					. $view_txn_lnk_url
638
+					. '"  aria-label="'
639
+					. esc_attr__('View Transaction', 'event_espresso')
640
+					. '">
641 641
 						'
642
-                    . $registration->transaction()->pretty_paid()
643
-                    . '
642
+					. $registration->transaction()->pretty_paid()
643
+					. '
644 644
 					</a>
645 645
 				' : $registration->transaction()->pretty_paid();
646
-            }
647
-        }
648
-        return $this->columnContent('TXN_paid', $content, 'end');
649
-    }
650
-
651
-
652
-    /**
653
-     *        column_TXN_total
654
-     *
655
-     * @param EE_Registration $registration
656
-     * @return string
657
-     * @throws EE_Error
658
-     * @throws ReflectionException
659
-     */
660
-    public function column_TXN_total(EE_Registration $registration): string
661
-    {
662
-        $content      = '';
663
-        $txn          = $registration->transaction();
664
-        $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL);
665
-        if ($registration->get('REG_count') === 1) {
666
-            $line_total_obj = $txn->total_line_item();
667
-            $txn_total      = $line_total_obj instanceof EE_Line_Item
668
-                ? $line_total_obj->get_pretty('LIN_total')
669
-                : esc_html__(
670
-                    'View Transaction',
671
-                    'event_espresso'
672
-                );
673
-            $content        = EE_Registry::instance()->CAP->current_user_can(
674
-                'ee_read_transaction',
675
-                'espresso_transactions_view_transaction'
676
-            ) ? '<a class="ee-aria-tooltip" href="'
677
-                . $view_txn_url
678
-                . '" aria-label="'
679
-                . esc_attr__('View Transaction', 'event_espresso')
680
-                . '">'
681
-                . $txn_total
682
-                . '</a>'
683
-                : $txn_total;
684
-        }
685
-        return $this->columnContent('TXN_total', $content, 'end');
686
-    }
646
+			}
647
+		}
648
+		return $this->columnContent('TXN_paid', $content, 'end');
649
+	}
650
+
651
+
652
+	/**
653
+	 *        column_TXN_total
654
+	 *
655
+	 * @param EE_Registration $registration
656
+	 * @return string
657
+	 * @throws EE_Error
658
+	 * @throws ReflectionException
659
+	 */
660
+	public function column_TXN_total(EE_Registration $registration): string
661
+	{
662
+		$content      = '';
663
+		$txn          = $registration->transaction();
664
+		$view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL);
665
+		if ($registration->get('REG_count') === 1) {
666
+			$line_total_obj = $txn->total_line_item();
667
+			$txn_total      = $line_total_obj instanceof EE_Line_Item
668
+				? $line_total_obj->get_pretty('LIN_total')
669
+				: esc_html__(
670
+					'View Transaction',
671
+					'event_espresso'
672
+				);
673
+			$content        = EE_Registry::instance()->CAP->current_user_can(
674
+				'ee_read_transaction',
675
+				'espresso_transactions_view_transaction'
676
+			) ? '<a class="ee-aria-tooltip" href="'
677
+				. $view_txn_url
678
+				. '" aria-label="'
679
+				. esc_attr__('View Transaction', 'event_espresso')
680
+				. '">'
681
+				. $txn_total
682
+				. '</a>'
683
+				: $txn_total;
684
+		}
685
+		return $this->columnContent('TXN_total', $content, 'end');
686
+	}
687 687
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             'ajax'     => true,
118 118
             'screen'   => $this->_admin_page->get_current_screen()->id,
119 119
         ];
120
-        $columns             = [];
120
+        $columns = [];
121 121
 
122 122
         $this->_columns = [
123 123
             '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             'TXN_total'           => esc_html__('Total', 'event_espresso'),
131 131
         ];
132 132
         // Add/remove columns when an event has been selected
133
-        if (! empty($this->event_id)) {
133
+        if ( ! empty($this->event_id)) {
134 134
             // Render a checkbox column
135 135
             $columns['cb']              = '<input type="checkbox" />';
136 136
             $this->_has_checkbox_column = true;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $this->event_id,
148 148
             $this->datetime_id
149 149
         );
150
-        if (! empty($csv_report)) {
150
+        if ( ! empty($csv_report)) {
151 151
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
152 152
         }
153 153
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         ];
211 211
         foreach ($events as $event) {
212 212
             // any registrations for this event?
213
-            if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
213
+            if ( ! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) {
214 214
                 continue;
215 215
             }
216 216
             $expired_class  = $event->is_expired() ? 'ee-expired-event' : '';
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                     $event->name(),
224 224
                     $event
225 225
                 ),
226
-                'class' => $expired_class . $upcoming_class,
226
+                'class' => $expired_class.$upcoming_class,
227 227
             ];
228 228
             if ($event->ID() === $this->event_id) {
229 229
                 $this->hide_expired    = $expired_class === '' ? $this->hide_expired : false;
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
         $filters[] = '
247 247
         <div class="ee-event-filter__wrapper">
248 248
             <label class="ee-event-filter-main-label">
249
-                ' . esc_html__('Check-in Status for', 'event_espresso') . '
249
+                ' . esc_html__('Check-in Status for', 'event_espresso').'
250 250
             </label>
251 251
             <div class="ee-event-filter ee-status-outline ee-status-bg--info">
252 252
                 <span class="ee-event-selector">
253
-                    <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label>
254
-                    ' . $select_input . '
253
+                    <label for="event_id">' . esc_html__('Event', 'event_espresso').'</label>
254
+                    ' . $select_input.'
255 255
                 </span>';
256 256
         // DTT datetimes filter
257 257
         $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent(
@@ -262,23 +262,23 @@  discard block
 block discarded – undo
262 262
             foreach ($datetimes_for_event as $datetime) {
263 263
                 if ($datetime instanceof EE_Datetime) {
264 264
                     $datetime_string = $datetime->name();
265
-                    $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : '';
265
+                    $datetime_string = ! empty($datetime_string) ? $datetime_string.': ' : '';
266 266
                     $datetime_string .= $datetime->date_and_time_range();
267 267
                     $datetime_string .= $datetime->is_active() ? ' ∗' : '';
268 268
                     $datetime_string .= $datetime->is_expired() ? ' «' : '';
269 269
                     $datetime_string .= $datetime->is_upcoming() ? ' »' : '';
270 270
                     // now put it all together
271
-                    $datetimes[ $datetime->ID() ] = $datetime_string;
271
+                    $datetimes[$datetime->ID()] = $datetime_string;
272 272
                 }
273 273
             }
274 274
             $filters[] = '
275 275
                 <span class="ee-datetime-selector">
276
-                    <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label>
276
+                    <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso').'</label>
277 277
                     ' . EEH_Form_Fields::select_input(
278 278
                         'DTT_ID',
279 279
                         $datetimes,
280 280
                         $this->datetime_id
281
-                    ) . '
281
+                    ).'
282 282
                 </span>';
283 283
         }
284 284
         $filters[] = '
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
                          . esc_html__(
297 297
                              'Will not display events with start dates in the future (ie: have not yet begun)',
298 298
                              'event_espresso'
299
-                         ) . '"
299
+                         ).'"
300 300
                     ></span>
301 301
                 </span>
302 302
                 <span class="ee-hide-expired-check">
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                         <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" '
305 305
                          . $hide_expired_checked
306 306
                          . '>
307
-                            ' . esc_html__('Hide Expired Events', 'event_espresso') . '
307
+                            ' . esc_html__('Hide Expired Events', 'event_espresso').'
308 308
                     </label>
309 309
                     <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" 
310 310
                           aria-label="'
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         if ($this->datetime_id) {
347 347
             $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id;
348 348
         }
349
-        $status_ids_array          = apply_filters(
349
+        $status_ids_array = apply_filters(
350 350
             'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
351 351
             [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
352 352
         );
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         // (so that we don't pollute state for the entire table)
385 385
         // so let's try to get it from the registration's event
386 386
         $DTT_ID = $this->datetime_id;
387
-        if (! $DTT_ID) {
387
+        if ( ! $DTT_ID) {
388 388
             $reg_ticket_datetimes = $registration->ticket()->datetimes();
389 389
             if (count($reg_ticket_datetimes) === 1) {
390 390
                 $reg_ticket_datetime = reset($reg_ticket_datetimes);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             }
393 393
         }
394 394
 
395
-        if (! $DTT_ID) {
395
+        if ( ! $DTT_ID) {
396 396
             $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration);
397 397
             $datetime                        = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID);
398 398
             $DTT_ID                          = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
@@ -417,17 +417,17 @@  discard block
 block discarded – undo
417 417
             )
418 418
         ) {
419 419
             // overwrite the disabled attribute with data attributes for performing checkin
420
-            $attributes   = 'data-_regid="' . $registration->ID() . '"';
421
-            $attributes   .= ' data-dttid="' . $DTT_ID . '"';
422
-            $attributes   .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"';
420
+            $attributes = 'data-_regid="'.$registration->ID().'"';
421
+            $attributes   .= ' data-dttid="'.$DTT_ID.'"';
422
+            $attributes   .= ' data-nonce="'.wp_create_nonce('checkin_nonce').'"';
423 423
             $button_class .= ' clickable trigger-checkin';
424 424
         }
425 425
 
426 426
         $content = '
427
-        <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '>
428
-            <span class="' . $dashicon_class . '" ></span>
427
+        <button aria-label="' . $aria_label.'" class="'.$button_class.'" '.$attributes.'>
428
+            <span class="' . $dashicon_class.'" ></span>
429 429
         </button>
430
-        <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>';
430
+        <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration).'</span>';
431 431
         return $this->columnContent('_REG_att_checked_in', $content, 'center');
432 432
     }
433 433
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
     public function column_ATT_name(EE_Registration $registration): string
442 442
     {
443 443
         $attendee = $registration->attendee();
444
-        if (! $attendee instanceof EE_Attendee) {
444
+        if ( ! $attendee instanceof EE_Attendee) {
445 445
             return esc_html__('No contact record for this registration.', 'event_espresso');
446 446
         }
447 447
         // edit attendee link
@@ -449,32 +449,32 @@  discard block
 block discarded – undo
449 449
             ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
450 450
             REG_ADMIN_URL
451 451
         );
452
-        $name_link    = '
453
-            <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip"
454
-            aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '">
452
+        $name_link = '
453
+            <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()).' ee-aria-tooltip"
454
+            aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'">
455 455
             </span>';
456
-        $name_link    .= EE_Registry::instance()->CAP->current_user_can(
456
+        $name_link .= EE_Registry::instance()->CAP->current_user_can(
457 457
             'ee_edit_contacts',
458 458
             'espresso_registrations_edit_attendee'
459 459
         )
460
-            ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__(
460
+            ? '<a class="ee-aria-tooltip" href="'.$edit_lnk_url.'" aria-label="'.esc_attr__(
461 461
                 'View Registration Details',
462 462
                 'event_espresso'
463
-            ) . '">'
463
+            ).'">'
464 464
               . $registration->attendee()->full_name()
465 465
               . '</a>'
466 466
             : $registration->attendee()->full_name();
467
-        $name_link    .= $registration->count() === 1
467
+        $name_link .= $registration->count() === 1
468 468
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
469 469
             : '';
470 470
         // add group details
471
-        $name_link .= '&nbsp;' . sprintf(
471
+        $name_link .= '&nbsp;'.sprintf(
472 472
             esc_html__('(%s of %s)', 'event_espresso'),
473 473
             $registration->count(),
474 474
             $registration->group_size()
475 475
         );
476 476
         // add regcode
477
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
477
+        $link = EE_Admin_Page::add_query_args_and_nonce(
478 478
             ['action' => 'view_registration', '_REG_ID' => $registration->ID()],
479 479
             REG_ADMIN_URL
480 480
         );
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
             'view_registration',
485 485
             $registration->ID()
486 486
         )
487
-            ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__(
487
+            ? '<a class="ee-aria-tooltip" href="'.$link.'" aria-label="'.esc_attr__(
488 488
                 'View Registration Details',
489 489
                 'event_espresso'
490
-            ) . '">'
490
+            ).'">'
491 491
               . $registration->reg_code()
492 492
               . '</a>'
493 493
             : $registration->reg_code();
@@ -507,24 +507,24 @@  discard block
 block discarded – undo
507 507
             // get the timestamps for this registration's checkins, related to the selected datetime
508 508
             /** @var EE_Checkin[] $checkins */
509 509
             $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]);
510
-            if (! empty($checkins)) {
510
+            if ( ! empty($checkins)) {
511 511
                 // get the last timestamp
512 512
                 $last_checkin = end($checkins);
513 513
                 // get timestamp string
514 514
                 $timestamp_string   = $last_checkin->get_datetime('CHK_timestamp');
515 515
                 $actions['checkin'] = '
516 516
                     <a  class="ee-aria-tooltip"
517
-                        href="' . $checkin_list_url . '"
517
+                        href="' . $checkin_list_url.'"
518 518
                         aria-label="' . esc_attr__(
519 519
                             'View this registrant\'s check-ins/checkouts for the datetime',
520 520
                             'event_espresso'
521
-                        ) . '"
521
+                        ).'"
522 522
                     >
523
-                        ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . '
523
+                        ' . $last_checkin->getCheckInText().': '.$timestamp_string.'
524 524
                     </a>';
525 525
             }
526 526
         }
527
-        $content = (! empty($this->datetime_id) && ! empty($checkins))
527
+        $content = ( ! empty($this->datetime_id) && ! empty($checkins))
528 528
             ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
529 529
             : $name_link;
530 530
         return $this->columnContent('ATT_name', $content);
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
                 ['action' => 'event_registrations', 'event_id' => $event->ID()],
561 561
                 REG_ADMIN_URL
562 562
             );
563
-            $content          = EE_Registry::instance()->CAP->current_user_can(
563
+            $content = EE_Registry::instance()->CAP->current_user_can(
564 564
                 'ee_read_checkins',
565 565
                 'espresso_registrations_registration_checkins'
566
-            ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="'
566
+            ) ? '<a class="ee-aria-tooltip" href="'.$checkin_link_url.'" aria-label="'
567 567
                 . esc_attr__(
568 568
                     'View Checkins for this Event',
569 569
                     'event_espresso'
570
-                ) . '">' . $event->name() . '</a>' : $event->name();
570
+                ).'">'.$event->name().'</a>' : $event->name();
571 571
         } catch (EntityNotFoundException $e) {
572 572
             $content = esc_html__('Unknown', 'event_espresso');
573 573
         }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
     {
586 586
         $content = $registration->ticket() instanceof EE_Ticket
587 587
             ? $registration->ticket()->name()
588
-              . '<span class="ee-entity--id">(ID:' . $registration->ticket()->ID() . ')</span>'
588
+              . '<span class="ee-entity--id">(ID:'.$registration->ticket()->ID().')</span>'
589 589
             : esc_html__(
590 590
                 "Unknown",
591 591
                 "event_espresso"
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
                     ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()],
628 628
                     TXN_ADMIN_URL
629 629
                 );
630
-                $content          = EE_Registry::instance()->CAP->current_user_can(
630
+                $content = EE_Registry::instance()->CAP->current_user_can(
631 631
                     'ee_read_transaction',
632 632
                     'espresso_transactions_view_transaction'
633 633
                 ) ? '
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                     'View Transaction',
671 671
                     'event_espresso'
672 672
                 );
673
-            $content        = EE_Registry::instance()->CAP->current_user_can(
673
+            $content = EE_Registry::instance()->CAP->current_user_can(
674 674
                 'ee_read_transaction',
675 675
                 'espresso_transactions_view_transaction'
676 676
             ) ? '<a class="ee-aria-tooltip" href="'
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 2 patches
Indentation   +1253 added lines, -1253 removed lines patch added patch discarded remove patch
@@ -15,1317 +15,1317 @@
 block discarded – undo
15 15
  */
16 16
 class Extend_Registrations_Admin_Page extends Registrations_Admin_Page
17 17
 {
18
-    /**
19
-     * This is used to hold the reports template data which is setup early in the request.
20
-     *
21
-     * @type array
22
-     */
23
-    protected $_reports_template_data = [];
18
+	/**
19
+	 * This is used to hold the reports template data which is setup early in the request.
20
+	 *
21
+	 * @type array
22
+	 */
23
+	protected $_reports_template_data = [];
24 24
 
25 25
 
26
-    /**
27
-     * Extend_Registrations_Admin_Page constructor.
28
-     *
29
-     * @param bool $routing
30
-     * @throws EE_Error
31
-     * @throws ReflectionException
32
-     */
33
-    public function __construct($routing = true)
34
-    {
35
-        parent::__construct($routing);
36
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
37
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
38
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
39
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
40
-        }
41
-    }
26
+	/**
27
+	 * Extend_Registrations_Admin_Page constructor.
28
+	 *
29
+	 * @param bool $routing
30
+	 * @throws EE_Error
31
+	 * @throws ReflectionException
32
+	 */
33
+	public function __construct($routing = true)
34
+	{
35
+		parent::__construct($routing);
36
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
37
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
38
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
39
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
40
+		}
41
+	}
42 42
 
43 43
 
44
-    protected function _set_page_config()
45
-    {
46
-        parent::_set_page_config();
44
+	protected function _set_page_config()
45
+	{
46
+		parent::_set_page_config();
47 47
 
48
-        $this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id                                           =
50
-            ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
51
-                ? $this->_req_data['_REG_ID']
52
-                : 0;
53
-        $new_page_routes                                  = [
54
-            'reports'                      => [
55
-                'func'       => '_registration_reports',
56
-                'capability' => 'ee_read_registrations',
57
-            ],
58
-            'registration_checkins'        => [
59
-                'func'       => '_registration_checkin_list_table',
60
-                'capability' => 'ee_read_checkins',
61
-            ],
62
-            'newsletter_selected_send'     => [
63
-                'func'       => '_newsletter_selected_send',
64
-                'noheader'   => true,
65
-                'capability' => 'ee_send_message',
66
-            ],
67
-            'delete_checkin_rows'          => [
68
-                'func'       => '_delete_checkin_rows',
69
-                'noheader'   => true,
70
-                'capability' => 'ee_delete_checkins',
71
-            ],
72
-            'delete_checkin_row'           => [
73
-                'func'       => '_delete_checkin_row',
74
-                'noheader'   => true,
75
-                'capability' => 'ee_delete_checkin',
76
-                'obj_id'     => $reg_id,
77
-            ],
78
-            'toggle_checkin_status'        => [
79
-                'func'       => '_toggle_checkin_status',
80
-                'noheader'   => true,
81
-                'capability' => 'ee_edit_checkin',
82
-                'obj_id'     => $reg_id,
83
-            ],
84
-            'toggle_checkin_status_bulk'   => [
85
-                'func'       => '_toggle_checkin_status',
86
-                'noheader'   => true,
87
-                'capability' => 'ee_edit_checkins',
88
-            ],
89
-            'event_registrations'          => [
90
-                'func'       => '_event_registrations_list_table',
91
-                'capability' => 'ee_read_checkins',
92
-            ],
93
-            'registrations_checkin_report' => [
94
-                'func'       => '_registrations_checkin_report',
95
-                'noheader'   => true,
96
-                'capability' => 'ee_read_registrations',
97
-            ],
98
-        ];
99
-        $this->_page_routes                               = array_merge($this->_page_routes, $new_page_routes);
100
-        $new_page_config                                  = [
101
-            'reports'               => [
102
-                'nav'           => [
103
-                    'label' => esc_html__('Reports', 'event_espresso'),
104
-                    'icon'  => 'dashicons-chart-bar',
105
-                    'order' => 30,
106
-                ],
107
-                'help_tabs'     => [
108
-                    'registrations_reports_help_tab' => [
109
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
110
-                        'filename' => 'registrations_reports',
111
-                    ],
112
-                ],
113
-                'require_nonce' => false,
114
-            ],
115
-            'event_registrations'   => [
116
-                'nav'           => [
117
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
118
-                    'icon'       => 'dashicons-yes-alt',
119
-                    'order'      => 10,
120
-                    'persistent' => true,
121
-                ],
122
-                'help_tabs'     => [
123
-                    'registrations_event_checkin_help_tab'                       => [
124
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
125
-                        'filename' => 'registrations_event_checkin',
126
-                    ],
127
-                    'registrations_event_checkin_table_column_headings_help_tab' => [
128
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
129
-                        'filename' => 'registrations_event_checkin_table_column_headings',
130
-                    ],
131
-                    'registrations_event_checkin_filters_help_tab'               => [
132
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
133
-                        'filename' => 'registrations_event_checkin_filters',
134
-                    ],
135
-                    'registrations_event_checkin_views_help_tab'                 => [
136
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
137
-                        'filename' => 'registrations_event_checkin_views',
138
-                    ],
139
-                    'registrations_event_checkin_other_help_tab'                 => [
140
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
141
-                        'filename' => 'registrations_event_checkin_other',
142
-                    ],
143
-                ],
144
-                'list_table'    => 'EE_Event_Registrations_List_Table',
145
-                'metaboxes'     => [],
146
-                'require_nonce' => false,
147
-            ],
148
-            'registration_checkins' => [
149
-                'nav'           => [
150
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
151
-                    'icon'       => 'dashicons-list-view',
152
-                    'order'      => 15,
153
-                    'persistent' => false,
154
-                    'url'        => '',
155
-                ],
156
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
157
-                'metaboxes'     => [],
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
-    }
48
+		$this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id                                           =
50
+			! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
51
+				? $this->_req_data['_REG_ID']
52
+				: 0;
53
+		$new_page_routes                                  = [
54
+			'reports'                      => [
55
+				'func'       => '_registration_reports',
56
+				'capability' => 'ee_read_registrations',
57
+			],
58
+			'registration_checkins'        => [
59
+				'func'       => '_registration_checkin_list_table',
60
+				'capability' => 'ee_read_checkins',
61
+			],
62
+			'newsletter_selected_send'     => [
63
+				'func'       => '_newsletter_selected_send',
64
+				'noheader'   => true,
65
+				'capability' => 'ee_send_message',
66
+			],
67
+			'delete_checkin_rows'          => [
68
+				'func'       => '_delete_checkin_rows',
69
+				'noheader'   => true,
70
+				'capability' => 'ee_delete_checkins',
71
+			],
72
+			'delete_checkin_row'           => [
73
+				'func'       => '_delete_checkin_row',
74
+				'noheader'   => true,
75
+				'capability' => 'ee_delete_checkin',
76
+				'obj_id'     => $reg_id,
77
+			],
78
+			'toggle_checkin_status'        => [
79
+				'func'       => '_toggle_checkin_status',
80
+				'noheader'   => true,
81
+				'capability' => 'ee_edit_checkin',
82
+				'obj_id'     => $reg_id,
83
+			],
84
+			'toggle_checkin_status_bulk'   => [
85
+				'func'       => '_toggle_checkin_status',
86
+				'noheader'   => true,
87
+				'capability' => 'ee_edit_checkins',
88
+			],
89
+			'event_registrations'          => [
90
+				'func'       => '_event_registrations_list_table',
91
+				'capability' => 'ee_read_checkins',
92
+			],
93
+			'registrations_checkin_report' => [
94
+				'func'       => '_registrations_checkin_report',
95
+				'noheader'   => true,
96
+				'capability' => 'ee_read_registrations',
97
+			],
98
+		];
99
+		$this->_page_routes                               = array_merge($this->_page_routes, $new_page_routes);
100
+		$new_page_config                                  = [
101
+			'reports'               => [
102
+				'nav'           => [
103
+					'label' => esc_html__('Reports', 'event_espresso'),
104
+					'icon'  => 'dashicons-chart-bar',
105
+					'order' => 30,
106
+				],
107
+				'help_tabs'     => [
108
+					'registrations_reports_help_tab' => [
109
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
110
+						'filename' => 'registrations_reports',
111
+					],
112
+				],
113
+				'require_nonce' => false,
114
+			],
115
+			'event_registrations'   => [
116
+				'nav'           => [
117
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
118
+					'icon'       => 'dashicons-yes-alt',
119
+					'order'      => 10,
120
+					'persistent' => true,
121
+				],
122
+				'help_tabs'     => [
123
+					'registrations_event_checkin_help_tab'                       => [
124
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
125
+						'filename' => 'registrations_event_checkin',
126
+					],
127
+					'registrations_event_checkin_table_column_headings_help_tab' => [
128
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
129
+						'filename' => 'registrations_event_checkin_table_column_headings',
130
+					],
131
+					'registrations_event_checkin_filters_help_tab'               => [
132
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
133
+						'filename' => 'registrations_event_checkin_filters',
134
+					],
135
+					'registrations_event_checkin_views_help_tab'                 => [
136
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
137
+						'filename' => 'registrations_event_checkin_views',
138
+					],
139
+					'registrations_event_checkin_other_help_tab'                 => [
140
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
141
+						'filename' => 'registrations_event_checkin_other',
142
+					],
143
+				],
144
+				'list_table'    => 'EE_Event_Registrations_List_Table',
145
+				'metaboxes'     => [],
146
+				'require_nonce' => false,
147
+			],
148
+			'registration_checkins' => [
149
+				'nav'           => [
150
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
151
+					'icon'       => 'dashicons-list-view',
152
+					'order'      => 15,
153
+					'persistent' => false,
154
+					'url'        => '',
155
+				],
156
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
157
+				'metaboxes'     => [],
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', [$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', [$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
-                ['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
-                [],
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
-                [$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
+				['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
+				[],
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
+				[$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
-            ['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
+			['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 = [
253
-            'all' => [
254
-                'slug'        => 'all',
255
-                'label'       => esc_html__('All', 'event_espresso'),
256
-                'count'       => 0,
257
-                'bulk_action' => ! isset($this->_req_data['event_id'])
258
-                    ? []
259
-                    : [
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 = [
253
+			'all' => [
254
+				'slug'        => 'all',
255
+				'label'       => esc_html__('All', 'event_espresso'),
256
+				'count'       => 0,
257
+				'bulk_action' => ! isset($this->_req_data['event_id'])
258
+					? []
259
+					: [
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 = [
273
-            'all' => [
274
-                'slug'        => 'all',
275
-                'label'       => esc_html__('All', 'event_espresso'),
276
-                'count'       => 0,
277
-                'bulk_action' => ['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 = [
273
+			'all' => [
274
+				'slug'        => 'all',
275
+				'label'       => esc_html__('All', 'event_espresso'),
276
+				'count'       => 0,
277
+				'bulk_action' => ['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
-     * @return void (JSON)
287
-     * @throws EE_Error
288
-     * @throws InvalidArgumentException
289
-     * @throws InvalidDataTypeException
290
-     * @throws InvalidInterfaceException
291
-     * @throws ReflectionException
292
-     * @since 4.3.0
293
-     */
294
-    public function get_newsletter_form_content()
295
-    {
296
-        // do a nonce check cause we're not coming in from an normal route here.
297
-        $nonce     = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
298
-            $this->_req_data['get_newsletter_form_content_nonce']
299
-        ) : '';
300
-        $nonce_ref = 'get_newsletter_form_content_nonce';
301
-        $this->_verify_nonce($nonce, $nonce_ref);
302
-        // let's get the mtp for the incoming MTP_ ID
303
-        if (! isset($this->_req_data['GRP_ID'])) {
304
-            EE_Error::add_error(
305
-                esc_html__(
306
-                    '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).',
307
-                    'event_espresso'
308
-                ),
309
-                __FILE__,
310
-                __FUNCTION__,
311
-                __LINE__
312
-            );
313
-            $this->_template_args['success'] = false;
314
-            $this->_template_args['error']   = true;
315
-            $this->_return_json();
316
-        }
317
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
-        if (! $MTPG instanceof EE_Message_Template_Group) {
319
-            EE_Error::add_error(
320
-                sprintf(
321
-                    esc_html__(
322
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
323
-                        'event_espresso'
324
-                    ),
325
-                    $this->_req_data['GRP_ID']
326
-                ),
327
-                __FILE__,
328
-                __FUNCTION__,
329
-                __LINE__
330
-            );
331
-            $this->_template_args['success'] = false;
332
-            $this->_template_args['error']   = true;
333
-            $this->_return_json();
334
-        }
335
-        $MTPs            = $MTPG->context_templates();
336
-        $MTPs            = $MTPs['attendee'];
337
-        $template_fields = [];
338
-        /** @var EE_Message_Template $MTP */
339
-        foreach ($MTPs as $MTP) {
340
-            $field = $MTP->get('MTP_template_field');
341
-            if ($field === 'content') {
342
-                $content = $MTP->get('MTP_content');
343
-                if (! empty($content['newsletter_content'])) {
344
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
345
-                }
346
-                continue;
347
-            }
348
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
-        }
350
-        $this->_template_args['success'] = true;
351
-        $this->_template_args['error']   = false;
352
-        $this->_template_args['data']    = [
353
-            'batch_message_from'    => isset($template_fields['from'])
354
-                ? $template_fields['from']
355
-                : '',
356
-            'batch_message_subject' => isset($template_fields['subject'])
357
-                ? $template_fields['subject']
358
-                : '',
359
-            'batch_message_content' => isset($template_fields['newsletter_content'])
360
-                ? $template_fields['newsletter_content']
361
-                : '',
362
-        ];
363
-        $this->_return_json();
364
-    }
283
+	/**
284
+	 * callback for ajax action.
285
+	 *
286
+	 * @return void (JSON)
287
+	 * @throws EE_Error
288
+	 * @throws InvalidArgumentException
289
+	 * @throws InvalidDataTypeException
290
+	 * @throws InvalidInterfaceException
291
+	 * @throws ReflectionException
292
+	 * @since 4.3.0
293
+	 */
294
+	public function get_newsletter_form_content()
295
+	{
296
+		// do a nonce check cause we're not coming in from an normal route here.
297
+		$nonce     = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
298
+			$this->_req_data['get_newsletter_form_content_nonce']
299
+		) : '';
300
+		$nonce_ref = 'get_newsletter_form_content_nonce';
301
+		$this->_verify_nonce($nonce, $nonce_ref);
302
+		// let's get the mtp for the incoming MTP_ ID
303
+		if (! isset($this->_req_data['GRP_ID'])) {
304
+			EE_Error::add_error(
305
+				esc_html__(
306
+					'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).',
307
+					'event_espresso'
308
+				),
309
+				__FILE__,
310
+				__FUNCTION__,
311
+				__LINE__
312
+			);
313
+			$this->_template_args['success'] = false;
314
+			$this->_template_args['error']   = true;
315
+			$this->_return_json();
316
+		}
317
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
+		if (! $MTPG instanceof EE_Message_Template_Group) {
319
+			EE_Error::add_error(
320
+				sprintf(
321
+					esc_html__(
322
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
323
+						'event_espresso'
324
+					),
325
+					$this->_req_data['GRP_ID']
326
+				),
327
+				__FILE__,
328
+				__FUNCTION__,
329
+				__LINE__
330
+			);
331
+			$this->_template_args['success'] = false;
332
+			$this->_template_args['error']   = true;
333
+			$this->_return_json();
334
+		}
335
+		$MTPs            = $MTPG->context_templates();
336
+		$MTPs            = $MTPs['attendee'];
337
+		$template_fields = [];
338
+		/** @var EE_Message_Template $MTP */
339
+		foreach ($MTPs as $MTP) {
340
+			$field = $MTP->get('MTP_template_field');
341
+			if ($field === 'content') {
342
+				$content = $MTP->get('MTP_content');
343
+				if (! empty($content['newsletter_content'])) {
344
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
345
+				}
346
+				continue;
347
+			}
348
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
+		}
350
+		$this->_template_args['success'] = true;
351
+		$this->_template_args['error']   = false;
352
+		$this->_template_args['data']    = [
353
+			'batch_message_from'    => isset($template_fields['from'])
354
+				? $template_fields['from']
355
+				: '',
356
+			'batch_message_subject' => isset($template_fields['subject'])
357
+				? $template_fields['subject']
358
+				: '',
359
+			'batch_message_content' => isset($template_fields['newsletter_content'])
360
+				? $template_fields['newsletter_content']
361
+				: '',
362
+		];
363
+		$this->_return_json();
364
+	}
365 365
 
366 366
 
367
-    /**
368
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
369
-     *
370
-     * @param EE_Admin_List_Table $list_table
371
-     * @return void
372
-     * @throws InvalidArgumentException
373
-     * @throws InvalidDataTypeException
374
-     * @throws InvalidInterfaceException
375
-     * @since 4.3.0
376
-     */
377
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
378
-    {
379
-        if (
380
-        ! EE_Registry::instance()->CAP->current_user_can(
381
-            'ee_send_message',
382
-            'espresso_registrations_newsletter_selected_send'
383
-        )
384
-        ) {
385
-            return;
386
-        }
387
-        $routes_to_add_to = [
388
-            'contact_list',
389
-            'event_registrations',
390
-            'default',
391
-        ];
392
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
-            if (
394
-                ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
395
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
396
-            ) {
397
-                echo '';
398
-            } else {
399
-                $button_text = sprintf(
400
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
401
-                    '<span class="send-selected-newsletter-count">0</span>'
402
-                );
403
-                echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
404
-                     . '<span class="dashicons dashicons-email "></span>'
405
-                     . $button_text
406
-                     . '</button>';
407
-                add_action('admin_footer', [$this, 'newsletter_send_form_skeleton']);
408
-            }
409
-        }
410
-    }
367
+	/**
368
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
369
+	 *
370
+	 * @param EE_Admin_List_Table $list_table
371
+	 * @return void
372
+	 * @throws InvalidArgumentException
373
+	 * @throws InvalidDataTypeException
374
+	 * @throws InvalidInterfaceException
375
+	 * @since 4.3.0
376
+	 */
377
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
378
+	{
379
+		if (
380
+		! EE_Registry::instance()->CAP->current_user_can(
381
+			'ee_send_message',
382
+			'espresso_registrations_newsletter_selected_send'
383
+		)
384
+		) {
385
+			return;
386
+		}
387
+		$routes_to_add_to = [
388
+			'contact_list',
389
+			'event_registrations',
390
+			'default',
391
+		];
392
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
+			if (
394
+				($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
395
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
396
+			) {
397
+				echo '';
398
+			} else {
399
+				$button_text = sprintf(
400
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
401
+					'<span class="send-selected-newsletter-count">0</span>'
402
+				);
403
+				echo '<button id="selected-batch-send-trigger" class="button button--secondary">'
404
+					 . '<span class="dashicons dashicons-email "></span>'
405
+					 . $button_text
406
+					 . '</button>';
407
+				add_action('admin_footer', [$this, 'newsletter_send_form_skeleton']);
408
+			}
409
+		}
410
+	}
411 411
 
412 412
 
413
-    /**
414
-     * @throws DomainException
415
-     * @throws EE_Error
416
-     * @throws InvalidArgumentException
417
-     * @throws InvalidDataTypeException
418
-     * @throws InvalidInterfaceException
419
-     * @throws ReflectionException
420
-     */
421
-    public function newsletter_send_form_skeleton()
422
-    {
423
-        $list_table = $this->_list_table_object;
424
-        $codes      = [];
425
-        // need to templates for the newsletter message type for the template selector.
426
-        $values[] = ['text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0];
427
-        $mtps     = EEM_Message_Template_Group::instance()->get_all(
428
-            [['MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email']]
429
-        );
430
-        foreach ($mtps as $mtp) {
431
-            $name     = $mtp->name();
432
-            $values[] = [
433
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
434
-                'id'   => $mtp->ID(),
435
-            ];
436
-        }
437
-        // need to get a list of shortcodes that are available for the newsletter message type.
438
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
439
-            'newsletter',
440
-            'email',
441
-            [],
442
-            'attendee',
443
-            false
444
-        );
445
-        foreach ($shortcodes as $field => $shortcode_array) {
446
-            $available_shortcodes = [];
447
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
448
-                $field_id               = $field === '[NEWSLETTER_CONTENT]'
449
-                    ? 'content'
450
-                    : $field;
451
-                $field_id               = 'batch-message-' . strtolower($field_id);
452
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
453
-                                          . $shortcode
454
-                                          . '" data-linked-input-id="' . $field_id . '">'
455
-                                          . $shortcode
456
-                                          . '</span>';
457
-            }
458
-            $codes[ $field ] = implode(', ', $available_shortcodes);
459
-        }
460
-        $shortcodes         = $codes;
461
-        $form_template      = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
462
-        $form_template_args = [
463
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
464
-            'form_route'        => 'newsletter_selected_send',
465
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
466
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
467
-            'redirect_back_to'  => $this->_req_action,
468
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
469
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
470
-            'shortcodes'        => $shortcodes,
471
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
472
-        ];
473
-        EEH_Template::display_template($form_template, $form_template_args);
474
-    }
413
+	/**
414
+	 * @throws DomainException
415
+	 * @throws EE_Error
416
+	 * @throws InvalidArgumentException
417
+	 * @throws InvalidDataTypeException
418
+	 * @throws InvalidInterfaceException
419
+	 * @throws ReflectionException
420
+	 */
421
+	public function newsletter_send_form_skeleton()
422
+	{
423
+		$list_table = $this->_list_table_object;
424
+		$codes      = [];
425
+		// need to templates for the newsletter message type for the template selector.
426
+		$values[] = ['text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0];
427
+		$mtps     = EEM_Message_Template_Group::instance()->get_all(
428
+			[['MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email']]
429
+		);
430
+		foreach ($mtps as $mtp) {
431
+			$name     = $mtp->name();
432
+			$values[] = [
433
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
434
+				'id'   => $mtp->ID(),
435
+			];
436
+		}
437
+		// need to get a list of shortcodes that are available for the newsletter message type.
438
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
439
+			'newsletter',
440
+			'email',
441
+			[],
442
+			'attendee',
443
+			false
444
+		);
445
+		foreach ($shortcodes as $field => $shortcode_array) {
446
+			$available_shortcodes = [];
447
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
448
+				$field_id               = $field === '[NEWSLETTER_CONTENT]'
449
+					? 'content'
450
+					: $field;
451
+				$field_id               = 'batch-message-' . strtolower($field_id);
452
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
453
+										  . $shortcode
454
+										  . '" data-linked-input-id="' . $field_id . '">'
455
+										  . $shortcode
456
+										  . '</span>';
457
+			}
458
+			$codes[ $field ] = implode(', ', $available_shortcodes);
459
+		}
460
+		$shortcodes         = $codes;
461
+		$form_template      = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
462
+		$form_template_args = [
463
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
464
+			'form_route'        => 'newsletter_selected_send',
465
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
466
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
467
+			'redirect_back_to'  => $this->_req_action,
468
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
469
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
470
+			'shortcodes'        => $shortcodes,
471
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
472
+		];
473
+		EEH_Template::display_template($form_template, $form_template_args);
474
+	}
475 475
 
476 476
 
477
-    /**
478
-     * Handles sending selected registrations/contacts a newsletter.
479
-     *
480
-     * @return void
481
-     * @throws EE_Error
482
-     * @throws InvalidArgumentException
483
-     * @throws InvalidDataTypeException
484
-     * @throws InvalidInterfaceException
485
-     * @throws ReflectionException
486
-     * @since  4.3.0
487
-     */
488
-    protected function _newsletter_selected_send()
489
-    {
490
-        $success = true;
491
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
492
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
493
-            EE_Error::add_error(
494
-                esc_html__(
495
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
496
-                    'event_espresso'
497
-                ),
498
-                __FILE__,
499
-                __FUNCTION__,
500
-                __LINE__
501
-            );
502
-            $success = false;
503
-        }
504
-        if ($success) {
505
-            // update Message template in case there are any changes
506
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
507
-                $this->_req_data['newsletter_mtp_selected']
508
-            );
509
-            $Message_Templates      = $Message_Template_Group instanceof EE_Message_Template_Group
510
-                ? $Message_Template_Group->context_templates()
511
-                : [];
512
-            if (empty($Message_Templates)) {
513
-                EE_Error::add_error(
514
-                    esc_html__(
515
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
516
-                        'event_espresso'
517
-                    ),
518
-                    __FILE__,
519
-                    __FUNCTION__,
520
-                    __LINE__
521
-                );
522
-            }
523
-            // let's just update the specific fields
524
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
525
-                if ($Message_Template instanceof EE_Message_Template) {
526
-                    $field       = $Message_Template->get('MTP_template_field');
527
-                    $content     = $Message_Template->get('MTP_content');
528
-                    $new_content = $content;
529
-                    switch ($field) {
530
-                        case 'from':
531
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
532
-                                ? $this->_req_data['batch_message']['from']
533
-                                : $content;
534
-                            break;
535
-                        case 'subject':
536
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
537
-                                ? $this->_req_data['batch_message']['subject']
538
-                                : $content;
539
-                            break;
540
-                        case 'content':
541
-                            $new_content                       = $content;
542
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
543
-                                ? $this->_req_data['batch_message']['content']
544
-                                : $content['newsletter_content'];
545
-                            break;
546
-                        default:
547
-                            // continue the foreach loop, we don't want to set $new_content nor save.
548
-                            continue 2;
549
-                    }
550
-                    $Message_Template->set('MTP_content', $new_content);
551
-                    $Message_Template->save();
552
-                }
553
-            }
554
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
555
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
556
-                ? $this->_req_data['batch_message']['id_type']
557
-                : 'registration';
558
-            // id_type will affect how we assemble the ids.
559
-            $ids                                 = ! empty($this->_req_data['batch_message']['ids'])
560
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
561
-                : [];
562
-            $registrations_used_for_contact_data = [];
563
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
564
-            switch ($id_type) {
565
-                case 'registration':
566
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
567
-                        [
568
-                            [
569
-                                'REG_ID' => ['IN', $ids],
570
-                            ],
571
-                        ]
572
-                    );
573
-                    break;
574
-                case 'contact':
575
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
576
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
577
-                                                                               $ids
578
-                                                                           );
579
-                    break;
580
-            }
581
-            do_action_ref_array(
582
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
583
-                [
584
-                    $registrations_used_for_contact_data,
585
-                    $Message_Template_Group->ID(),
586
-                ]
587
-            );
588
-            // kept for backward compat, internally we no longer use this action.
589
-            // @deprecated 4.8.36.rc.002
590
-            $contacts = $id_type === 'registration'
591
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
592
-                : EEM_Attendee::instance()->get_all([['ATT_ID' => ['in', $ids]]]);
593
-            do_action_ref_array(
594
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
595
-                [
596
-                    $contacts,
597
-                    $Message_Template_Group->ID(),
598
-                ]
599
-            );
600
-        }
601
-        $query_args = [
602
-            'action' => ! empty($this->_req_data['redirect_back_to'])
603
-                ? $this->_req_data['redirect_back_to']
604
-                : 'default',
605
-        ];
606
-        $this->_redirect_after_action(false, '', '', $query_args, true);
607
-    }
477
+	/**
478
+	 * Handles sending selected registrations/contacts a newsletter.
479
+	 *
480
+	 * @return void
481
+	 * @throws EE_Error
482
+	 * @throws InvalidArgumentException
483
+	 * @throws InvalidDataTypeException
484
+	 * @throws InvalidInterfaceException
485
+	 * @throws ReflectionException
486
+	 * @since  4.3.0
487
+	 */
488
+	protected function _newsletter_selected_send()
489
+	{
490
+		$success = true;
491
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
492
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
493
+			EE_Error::add_error(
494
+				esc_html__(
495
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
496
+					'event_espresso'
497
+				),
498
+				__FILE__,
499
+				__FUNCTION__,
500
+				__LINE__
501
+			);
502
+			$success = false;
503
+		}
504
+		if ($success) {
505
+			// update Message template in case there are any changes
506
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
507
+				$this->_req_data['newsletter_mtp_selected']
508
+			);
509
+			$Message_Templates      = $Message_Template_Group instanceof EE_Message_Template_Group
510
+				? $Message_Template_Group->context_templates()
511
+				: [];
512
+			if (empty($Message_Templates)) {
513
+				EE_Error::add_error(
514
+					esc_html__(
515
+						'Unable to retrieve message template fields from the db. Messages not sent.',
516
+						'event_espresso'
517
+					),
518
+					__FILE__,
519
+					__FUNCTION__,
520
+					__LINE__
521
+				);
522
+			}
523
+			// let's just update the specific fields
524
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
525
+				if ($Message_Template instanceof EE_Message_Template) {
526
+					$field       = $Message_Template->get('MTP_template_field');
527
+					$content     = $Message_Template->get('MTP_content');
528
+					$new_content = $content;
529
+					switch ($field) {
530
+						case 'from':
531
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
532
+								? $this->_req_data['batch_message']['from']
533
+								: $content;
534
+							break;
535
+						case 'subject':
536
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
537
+								? $this->_req_data['batch_message']['subject']
538
+								: $content;
539
+							break;
540
+						case 'content':
541
+							$new_content                       = $content;
542
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
543
+								? $this->_req_data['batch_message']['content']
544
+								: $content['newsletter_content'];
545
+							break;
546
+						default:
547
+							// continue the foreach loop, we don't want to set $new_content nor save.
548
+							continue 2;
549
+					}
550
+					$Message_Template->set('MTP_content', $new_content);
551
+					$Message_Template->save();
552
+				}
553
+			}
554
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
555
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
556
+				? $this->_req_data['batch_message']['id_type']
557
+				: 'registration';
558
+			// id_type will affect how we assemble the ids.
559
+			$ids                                 = ! empty($this->_req_data['batch_message']['ids'])
560
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
561
+				: [];
562
+			$registrations_used_for_contact_data = [];
563
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
564
+			switch ($id_type) {
565
+				case 'registration':
566
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
567
+						[
568
+							[
569
+								'REG_ID' => ['IN', $ids],
570
+							],
571
+						]
572
+					);
573
+					break;
574
+				case 'contact':
575
+					$registrations_used_for_contact_data = EEM_Registration::instance()
576
+																		   ->get_latest_registration_for_each_of_given_contacts(
577
+																			   $ids
578
+																		   );
579
+					break;
580
+			}
581
+			do_action_ref_array(
582
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
583
+				[
584
+					$registrations_used_for_contact_data,
585
+					$Message_Template_Group->ID(),
586
+				]
587
+			);
588
+			// kept for backward compat, internally we no longer use this action.
589
+			// @deprecated 4.8.36.rc.002
590
+			$contacts = $id_type === 'registration'
591
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
592
+				: EEM_Attendee::instance()->get_all([['ATT_ID' => ['in', $ids]]]);
593
+			do_action_ref_array(
594
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
595
+				[
596
+					$contacts,
597
+					$Message_Template_Group->ID(),
598
+				]
599
+			);
600
+		}
601
+		$query_args = [
602
+			'action' => ! empty($this->_req_data['redirect_back_to'])
603
+				? $this->_req_data['redirect_back_to']
604
+				: 'default',
605
+		];
606
+		$this->_redirect_after_action(false, '', '', $query_args, true);
607
+	}
608 608
 
609 609
 
610
-    /**
611
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
612
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
613
-     */
614
-    protected function _registration_reports_js_setup()
615
-    {
616
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
617
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
618
-    }
610
+	/**
611
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
612
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
613
+	 */
614
+	protected function _registration_reports_js_setup()
615
+	{
616
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
617
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
618
+	}
619 619
 
620 620
 
621
-    /**
622
-     *        generates Business Reports regarding Registrations
623
-     *
624
-     * @access protected
625
-     * @return void
626
-     * @throws DomainException
627
-     * @throws EE_Error
628
-     */
629
-    protected function _registration_reports()
630
-    {
631
-        $template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
632
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
633
-            $template_path,
634
-            $this->_reports_template_data,
635
-            true
636
-        );
637
-        // the final template wrapper
638
-        $this->display_admin_page_with_no_sidebar();
639
-    }
621
+	/**
622
+	 *        generates Business Reports regarding Registrations
623
+	 *
624
+	 * @access protected
625
+	 * @return void
626
+	 * @throws DomainException
627
+	 * @throws EE_Error
628
+	 */
629
+	protected function _registration_reports()
630
+	{
631
+		$template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
632
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
633
+			$template_path,
634
+			$this->_reports_template_data,
635
+			true
636
+		);
637
+		// the final template wrapper
638
+		$this->display_admin_page_with_no_sidebar();
639
+	}
640 640
 
641 641
 
642
-    /**
643
-     * Generates Business Report showing total registrations per day.
644
-     *
645
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
646
-     * @return string
647
-     * @throws EE_Error
648
-     * @throws InvalidArgumentException
649
-     * @throws InvalidDataTypeException
650
-     * @throws InvalidInterfaceException
651
-     * @throws ReflectionException
652
-     */
653
-    private function _registrations_per_day_report($period = '-1 month')
654
-    {
655
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
656
-        $results   = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
657
-        $results   = (array) $results;
658
-        $regs      = [];
659
-        $subtitle  = '';
660
-        if ($results) {
661
-            $column_titles = [];
662
-            $tracker       = 0;
663
-            foreach ($results as $result) {
664
-                $report_column_values = [];
665
-                foreach ($result as $property_name => $property_value) {
666
-                    $property_value         = $property_name === 'Registration_REG_date' ? $property_value
667
-                        : (int) $property_value;
668
-                    $report_column_values[] = $property_value;
669
-                    if ($tracker === 0) {
670
-                        if ($property_name === 'Registration_REG_date') {
671
-                            $column_titles[] = esc_html__(
672
-                                'Date (only days with registrations are shown)',
673
-                                'event_espresso'
674
-                            );
675
-                        } else {
676
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
677
-                        }
678
-                    }
679
-                }
680
-                $tracker++;
681
-                $regs[] = $report_column_values;
682
-            }
683
-            // make sure the column_titles is pushed to the beginning of the array
684
-            array_unshift($regs, $column_titles);
685
-            // setup the date range.
686
-            $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
687
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
688
-            $ending_date    = new DateTime("now", $DateTimeZone);
689
-            $subtitle       = sprintf(
690
-                wp_strip_all_tags(
691
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
692
-                ),
693
-                $beginning_date->format('Y-m-d'),
694
-                $ending_date->format('Y-m-d')
695
-            );
696
-        }
697
-        $report_title  = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
698
-        $report_params = [
699
-            'title'     => $report_title,
700
-            'subtitle'  => $subtitle,
701
-            'id'        => $report_ID,
702
-            'regs'      => $regs,
703
-            'noResults' => empty($regs),
704
-            'noRegsMsg' => sprintf(
705
-                wp_strip_all_tags(
706
-                    __(
707
-                        '%sThere are currently no registration records in the last month for this report.%s',
708
-                        'event_espresso'
709
-                    )
710
-                ),
711
-                '<h2>' . $report_title . '</h2><p>',
712
-                '</p>'
713
-            ),
714
-        ];
715
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
716
-        return $report_ID;
717
-    }
642
+	/**
643
+	 * Generates Business Report showing total registrations per day.
644
+	 *
645
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
646
+	 * @return string
647
+	 * @throws EE_Error
648
+	 * @throws InvalidArgumentException
649
+	 * @throws InvalidDataTypeException
650
+	 * @throws InvalidInterfaceException
651
+	 * @throws ReflectionException
652
+	 */
653
+	private function _registrations_per_day_report($period = '-1 month')
654
+	{
655
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
656
+		$results   = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
657
+		$results   = (array) $results;
658
+		$regs      = [];
659
+		$subtitle  = '';
660
+		if ($results) {
661
+			$column_titles = [];
662
+			$tracker       = 0;
663
+			foreach ($results as $result) {
664
+				$report_column_values = [];
665
+				foreach ($result as $property_name => $property_value) {
666
+					$property_value         = $property_name === 'Registration_REG_date' ? $property_value
667
+						: (int) $property_value;
668
+					$report_column_values[] = $property_value;
669
+					if ($tracker === 0) {
670
+						if ($property_name === 'Registration_REG_date') {
671
+							$column_titles[] = esc_html__(
672
+								'Date (only days with registrations are shown)',
673
+								'event_espresso'
674
+							);
675
+						} else {
676
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
677
+						}
678
+					}
679
+				}
680
+				$tracker++;
681
+				$regs[] = $report_column_values;
682
+			}
683
+			// make sure the column_titles is pushed to the beginning of the array
684
+			array_unshift($regs, $column_titles);
685
+			// setup the date range.
686
+			$DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
687
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
688
+			$ending_date    = new DateTime("now", $DateTimeZone);
689
+			$subtitle       = sprintf(
690
+				wp_strip_all_tags(
691
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
692
+				),
693
+				$beginning_date->format('Y-m-d'),
694
+				$ending_date->format('Y-m-d')
695
+			);
696
+		}
697
+		$report_title  = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
698
+		$report_params = [
699
+			'title'     => $report_title,
700
+			'subtitle'  => $subtitle,
701
+			'id'        => $report_ID,
702
+			'regs'      => $regs,
703
+			'noResults' => empty($regs),
704
+			'noRegsMsg' => sprintf(
705
+				wp_strip_all_tags(
706
+					__(
707
+						'%sThere are currently no registration records in the last month for this report.%s',
708
+						'event_espresso'
709
+					)
710
+				),
711
+				'<h2>' . $report_title . '</h2><p>',
712
+				'</p>'
713
+			),
714
+		];
715
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
716
+		return $report_ID;
717
+	}
718 718
 
719 719
 
720
-    /**
721
-     * Generates Business Report showing total registrations per event.
722
-     *
723
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
724
-     * @return string
725
-     * @throws EE_Error
726
-     * @throws InvalidArgumentException
727
-     * @throws InvalidDataTypeException
728
-     * @throws InvalidInterfaceException
729
-     * @throws ReflectionException
730
-     */
731
-    private function _registrations_per_event_report($period = '-1 month')
732
-    {
733
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
734
-        $results   = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
735
-        $results   = (array) $results;
736
-        $regs      = [];
737
-        $subtitle  = '';
738
-        if ($results) {
739
-            $column_titles = [];
740
-            $tracker       = 0;
741
-            foreach ($results as $result) {
742
-                $report_column_values = [];
743
-                foreach ($result as $property_name => $property_value) {
744
-                    $property_value         = $property_name === 'Registration_Event' ? wp_trim_words(
745
-                        $property_value,
746
-                        4,
747
-                        '...'
748
-                    ) : (int) $property_value;
749
-                    $report_column_values[] = $property_value;
750
-                    if ($tracker === 0) {
751
-                        if ($property_name === 'Registration_Event') {
752
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
753
-                        } else {
754
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
755
-                        }
756
-                    }
757
-                }
758
-                $tracker++;
759
-                $regs[] = $report_column_values;
760
-            }
761
-            // make sure the column_titles is pushed to the beginning of the array
762
-            array_unshift($regs, $column_titles);
763
-            // setup the date range.
764
-            $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
765
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
766
-            $ending_date    = new DateTime("now", $DateTimeZone);
767
-            $subtitle       = sprintf(
768
-                wp_strip_all_tags(
769
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
770
-                ),
771
-                $beginning_date->format('Y-m-d'),
772
-                $ending_date->format('Y-m-d')
773
-            );
774
-        }
775
-        $report_title  = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
776
-        $report_params = [
777
-            'title'     => $report_title,
778
-            'subtitle'  => $subtitle,
779
-            'id'        => $report_ID,
780
-            'regs'      => $regs,
781
-            'noResults' => empty($regs),
782
-            'noRegsMsg' => sprintf(
783
-                wp_strip_all_tags(
784
-                    __(
785
-                        '%sThere are currently no registration records in the last month for this report.%s',
786
-                        'event_espresso'
787
-                    )
788
-                ),
789
-                '<h2>' . $report_title . '</h2><p>',
790
-                '</p>'
791
-            ),
792
-        ];
793
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
794
-        return $report_ID;
795
-    }
720
+	/**
721
+	 * Generates Business Report showing total registrations per event.
722
+	 *
723
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
724
+	 * @return string
725
+	 * @throws EE_Error
726
+	 * @throws InvalidArgumentException
727
+	 * @throws InvalidDataTypeException
728
+	 * @throws InvalidInterfaceException
729
+	 * @throws ReflectionException
730
+	 */
731
+	private function _registrations_per_event_report($period = '-1 month')
732
+	{
733
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
734
+		$results   = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
735
+		$results   = (array) $results;
736
+		$regs      = [];
737
+		$subtitle  = '';
738
+		if ($results) {
739
+			$column_titles = [];
740
+			$tracker       = 0;
741
+			foreach ($results as $result) {
742
+				$report_column_values = [];
743
+				foreach ($result as $property_name => $property_value) {
744
+					$property_value         = $property_name === 'Registration_Event' ? wp_trim_words(
745
+						$property_value,
746
+						4,
747
+						'...'
748
+					) : (int) $property_value;
749
+					$report_column_values[] = $property_value;
750
+					if ($tracker === 0) {
751
+						if ($property_name === 'Registration_Event') {
752
+							$column_titles[] = esc_html__('Event', 'event_espresso');
753
+						} else {
754
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
755
+						}
756
+					}
757
+				}
758
+				$tracker++;
759
+				$regs[] = $report_column_values;
760
+			}
761
+			// make sure the column_titles is pushed to the beginning of the array
762
+			array_unshift($regs, $column_titles);
763
+			// setup the date range.
764
+			$DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
765
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
766
+			$ending_date    = new DateTime("now", $DateTimeZone);
767
+			$subtitle       = sprintf(
768
+				wp_strip_all_tags(
769
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
770
+				),
771
+				$beginning_date->format('Y-m-d'),
772
+				$ending_date->format('Y-m-d')
773
+			);
774
+		}
775
+		$report_title  = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
776
+		$report_params = [
777
+			'title'     => $report_title,
778
+			'subtitle'  => $subtitle,
779
+			'id'        => $report_ID,
780
+			'regs'      => $regs,
781
+			'noResults' => empty($regs),
782
+			'noRegsMsg' => sprintf(
783
+				wp_strip_all_tags(
784
+					__(
785
+						'%sThere are currently no registration records in the last month for this report.%s',
786
+						'event_espresso'
787
+					)
788
+				),
789
+				'<h2>' . $report_title . '</h2><p>',
790
+				'</p>'
791
+			),
792
+		];
793
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
794
+		return $report_ID;
795
+	}
796 796
 
797 797
 
798
-    /**
799
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
800
-     *
801
-     * @access protected
802
-     * @return void
803
-     * @throws EE_Error
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     * @throws EntityNotFoundException
808
-     * @throws ReflectionException
809
-     */
810
-    protected function _registration_checkin_list_table()
811
-    {
812
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
-        $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
814
-        /** @var EE_Registration $registration */
815
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
816
-        if (! $registration instanceof EE_Registration) {
817
-            throw new EE_Error(
818
-                sprintf(
819
-                    esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
820
-                    $reg_id
821
-                )
822
-            );
823
-        }
824
-        $attendee                                 = $registration->attendee();
825
-        $this->_admin_page_title                  .= $this->get_action_link_or_button(
826
-            'new_registration',
827
-            'add-registrant',
828
-            ['event_id' => $registration->event_ID()],
829
-            'add-new-h2'
830
-        );
831
-        $checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
832
-        $checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
833
-        $legend_items                             = [
834
-            'checkin'  => [
835
-                'class' => $checked_in->cssClasses(),
836
-                'desc'  => $checked_in->legendLabel(),
837
-            ],
838
-            'checkout' => [
839
-                'class' => $checked_out->cssClasses(),
840
-                'desc'  => $checked_out->legendLabel(),
841
-            ],
842
-        ];
843
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
844
-        $dtt_id                                   =
845
-            isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
846
-        /** @var EE_Datetime $datetime */
847
-        $datetime       = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
848
-        $datetime_label = '';
849
-        if ($datetime instanceof EE_Datetime) {
850
-            $datetime_label = $datetime->get_dtt_display_name(true);
851
-            $datetime_label .= ! empty($datetime_label)
852
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
853
-                : $datetime->get_dtt_display_name();
854
-        }
855
-        $datetime_link                                    = ! empty($dtt_id) && $registration instanceof EE_Registration
856
-            ? EE_Admin_Page::add_query_args_and_nonce(
857
-                [
858
-                    'action'   => 'event_registrations',
859
-                    'event_id' => $registration->event_ID(),
860
-                    'DTT_ID'   => $dtt_id,
861
-                ],
862
-                $this->_admin_base_url
863
-            )
864
-            : '';
865
-        $datetime_link                                    = ! empty($datetime_link)
866
-            ? '<a href="' . $datetime_link . '">'
867
-              . '<span id="checkin-dtt">'
868
-              . $datetime_label
869
-              . '</span></a>'
870
-            : $datetime_label;
871
-        $attendee_name                                    = $attendee instanceof EE_Attendee
872
-            ? $attendee->full_name()
873
-            : '';
874
-        $attendee_link                                    = $attendee instanceof EE_Attendee
875
-            ? $attendee->get_admin_details_link()
876
-            : '';
877
-        $attendee_link                                    = ! empty($attendee_link)
878
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
879
-              . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
880
-              . '<span id="checkin-attendee-name">'
881
-              . $attendee_name
882
-              . '</span></a>'
883
-            : '';
884
-        $event_link                                       = $registration->event() instanceof EE_Event
885
-            ? $registration->event()->get_admin_details_link()
886
-            : '';
887
-        $event_link                                       = ! empty($event_link)
888
-            ? '<a href="' . $event_link . '"'
889
-              . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
890
-              . '<span id="checkin-event-name">'
891
-              . $registration->event_name()
892
-              . '</span>'
893
-              . '</a>'
894
-            : '';
895
-        $this->_template_args['before_list_table']        = ! empty($reg_id) && ! empty($dtt_id)
896
-            ? '<h2>' . sprintf(
897
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
898
-                $attendee_link,
899
-                $datetime_link,
900
-                $event_link
901
-            ) . '</h2>'
902
-            : '';
903
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
904
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
905
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
906
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
907
-        $this->display_admin_list_table_page_with_no_sidebar();
908
-    }
798
+	/**
799
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
800
+	 *
801
+	 * @access protected
802
+	 * @return void
803
+	 * @throws EE_Error
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 * @throws EntityNotFoundException
808
+	 * @throws ReflectionException
809
+	 */
810
+	protected function _registration_checkin_list_table()
811
+	{
812
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
+		$reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
814
+		/** @var EE_Registration $registration */
815
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
816
+		if (! $registration instanceof EE_Registration) {
817
+			throw new EE_Error(
818
+				sprintf(
819
+					esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
820
+					$reg_id
821
+				)
822
+			);
823
+		}
824
+		$attendee                                 = $registration->attendee();
825
+		$this->_admin_page_title                  .= $this->get_action_link_or_button(
826
+			'new_registration',
827
+			'add-registrant',
828
+			['event_id' => $registration->event_ID()],
829
+			'add-new-h2'
830
+		);
831
+		$checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
832
+		$checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
833
+		$legend_items                             = [
834
+			'checkin'  => [
835
+				'class' => $checked_in->cssClasses(),
836
+				'desc'  => $checked_in->legendLabel(),
837
+			],
838
+			'checkout' => [
839
+				'class' => $checked_out->cssClasses(),
840
+				'desc'  => $checked_out->legendLabel(),
841
+			],
842
+		];
843
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
844
+		$dtt_id                                   =
845
+			isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
846
+		/** @var EE_Datetime $datetime */
847
+		$datetime       = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
848
+		$datetime_label = '';
849
+		if ($datetime instanceof EE_Datetime) {
850
+			$datetime_label = $datetime->get_dtt_display_name(true);
851
+			$datetime_label .= ! empty($datetime_label)
852
+				? ' (' . $datetime->get_dtt_display_name() . ')'
853
+				: $datetime->get_dtt_display_name();
854
+		}
855
+		$datetime_link                                    = ! empty($dtt_id) && $registration instanceof EE_Registration
856
+			? EE_Admin_Page::add_query_args_and_nonce(
857
+				[
858
+					'action'   => 'event_registrations',
859
+					'event_id' => $registration->event_ID(),
860
+					'DTT_ID'   => $dtt_id,
861
+				],
862
+				$this->_admin_base_url
863
+			)
864
+			: '';
865
+		$datetime_link                                    = ! empty($datetime_link)
866
+			? '<a href="' . $datetime_link . '">'
867
+			  . '<span id="checkin-dtt">'
868
+			  . $datetime_label
869
+			  . '</span></a>'
870
+			: $datetime_label;
871
+		$attendee_name                                    = $attendee instanceof EE_Attendee
872
+			? $attendee->full_name()
873
+			: '';
874
+		$attendee_link                                    = $attendee instanceof EE_Attendee
875
+			? $attendee->get_admin_details_link()
876
+			: '';
877
+		$attendee_link                                    = ! empty($attendee_link)
878
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
879
+			  . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
880
+			  . '<span id="checkin-attendee-name">'
881
+			  . $attendee_name
882
+			  . '</span></a>'
883
+			: '';
884
+		$event_link                                       = $registration->event() instanceof EE_Event
885
+			? $registration->event()->get_admin_details_link()
886
+			: '';
887
+		$event_link                                       = ! empty($event_link)
888
+			? '<a href="' . $event_link . '"'
889
+			  . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
890
+			  . '<span id="checkin-event-name">'
891
+			  . $registration->event_name()
892
+			  . '</span>'
893
+			  . '</a>'
894
+			: '';
895
+		$this->_template_args['before_list_table']        = ! empty($reg_id) && ! empty($dtt_id)
896
+			? '<h2>' . sprintf(
897
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
898
+				$attendee_link,
899
+				$datetime_link,
900
+				$event_link
901
+			) . '</h2>'
902
+			: '';
903
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
904
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
905
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
906
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
907
+		$this->display_admin_list_table_page_with_no_sidebar();
908
+	}
909 909
 
910 910
 
911
-    /**
912
-     * toggle the Check-in status for the given registration (coming from ajax)
913
-     *
914
-     * @return void (JSON)
915
-     * @throws EE_Error
916
-     * @throws InvalidArgumentException
917
-     * @throws InvalidDataTypeException
918
-     * @throws InvalidInterfaceException
919
-     * @throws ReflectionException
920
-     */
921
-    public function toggle_checkin_status()
922
-    {
923
-        // first make sure we have the necessary data
924
-        if (! isset($this->_req_data['_regid'])) {
925
-            EE_Error::add_error(
926
-                esc_html__(
927
-                    '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',
928
-                    'event_espresso'
929
-                ),
930
-                __FILE__,
931
-                __FUNCTION__,
932
-                __LINE__
933
-            );
934
-            $this->_template_args['success'] = false;
935
-            $this->_template_args['error']   = true;
936
-            $this->_return_json();
937
-        };
938
-        // do a nonce check cause we're not coming in from an normal route here.
939
-        $nonce     = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
940
-            : '';
941
-        $nonce_ref = 'checkin_nonce';
942
-        $this->_verify_nonce($nonce, $nonce_ref);
943
-        // beautiful! Made it this far so let's get the status.
944
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
945
-        // setup new class to return via ajax
946
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
947
-        $this->_template_args['success']            = true;
948
-        $this->_return_json();
949
-    }
911
+	/**
912
+	 * toggle the Check-in status for the given registration (coming from ajax)
913
+	 *
914
+	 * @return void (JSON)
915
+	 * @throws EE_Error
916
+	 * @throws InvalidArgumentException
917
+	 * @throws InvalidDataTypeException
918
+	 * @throws InvalidInterfaceException
919
+	 * @throws ReflectionException
920
+	 */
921
+	public function toggle_checkin_status()
922
+	{
923
+		// first make sure we have the necessary data
924
+		if (! isset($this->_req_data['_regid'])) {
925
+			EE_Error::add_error(
926
+				esc_html__(
927
+					'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',
928
+					'event_espresso'
929
+				),
930
+				__FILE__,
931
+				__FUNCTION__,
932
+				__LINE__
933
+			);
934
+			$this->_template_args['success'] = false;
935
+			$this->_template_args['error']   = true;
936
+			$this->_return_json();
937
+		};
938
+		// do a nonce check cause we're not coming in from an normal route here.
939
+		$nonce     = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
940
+			: '';
941
+		$nonce_ref = 'checkin_nonce';
942
+		$this->_verify_nonce($nonce, $nonce_ref);
943
+		// beautiful! Made it this far so let's get the status.
944
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
945
+		// setup new class to return via ajax
946
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
947
+		$this->_template_args['success']            = true;
948
+		$this->_return_json();
949
+	}
950 950
 
951 951
 
952
-    /**
953
-     * handles toggling the checkin status for the registration,
954
-     *
955
-     * @access protected
956
-     * @return int|void
957
-     * @throws EE_Error
958
-     * @throws InvalidArgumentException
959
-     * @throws InvalidDataTypeException
960
-     * @throws InvalidInterfaceException
961
-     * @throws ReflectionException
962
-     */
963
-    protected function _toggle_checkin_status()
964
-    {
965
-        // first let's get the query args out of the way for the redirect
966
-        $query_args = [
967
-            'action'   => 'event_registrations',
968
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
969
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
970
-        ];
971
-        $new_status = false;
972
-        // bulk action check in toggle
973
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
974
-            // cycle thru checkboxes
975
-            $checkboxes = $this->_req_data['checkbox'];
976
-            foreach (array_keys($checkboxes) as $REG_ID) {
977
-                $DTT_ID     = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
978
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
979
-            }
980
-        } elseif (isset($this->_req_data['_regid'])) {
981
-            // coming from ajax request
982
-            $DTT_ID               = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
983
-            $query_args['DTT_ID'] = $DTT_ID;
984
-            $new_status           = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
985
-        } else {
986
-            EE_Error::add_error(
987
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
988
-                __FILE__,
989
-                __FUNCTION__,
990
-                __LINE__
991
-            );
992
-        }
993
-        if (defined('DOING_AJAX')) {
994
-            return $new_status;
995
-        }
996
-        $this->_redirect_after_action(false, '', '', $query_args, true);
997
-    }
952
+	/**
953
+	 * handles toggling the checkin status for the registration,
954
+	 *
955
+	 * @access protected
956
+	 * @return int|void
957
+	 * @throws EE_Error
958
+	 * @throws InvalidArgumentException
959
+	 * @throws InvalidDataTypeException
960
+	 * @throws InvalidInterfaceException
961
+	 * @throws ReflectionException
962
+	 */
963
+	protected function _toggle_checkin_status()
964
+	{
965
+		// first let's get the query args out of the way for the redirect
966
+		$query_args = [
967
+			'action'   => 'event_registrations',
968
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
969
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
970
+		];
971
+		$new_status = false;
972
+		// bulk action check in toggle
973
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
974
+			// cycle thru checkboxes
975
+			$checkboxes = $this->_req_data['checkbox'];
976
+			foreach (array_keys($checkboxes) as $REG_ID) {
977
+				$DTT_ID     = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
978
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
979
+			}
980
+		} elseif (isset($this->_req_data['_regid'])) {
981
+			// coming from ajax request
982
+			$DTT_ID               = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
983
+			$query_args['DTT_ID'] = $DTT_ID;
984
+			$new_status           = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
985
+		} else {
986
+			EE_Error::add_error(
987
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
988
+				__FILE__,
989
+				__FUNCTION__,
990
+				__LINE__
991
+			);
992
+		}
993
+		if (defined('DOING_AJAX')) {
994
+			return $new_status;
995
+		}
996
+		$this->_redirect_after_action(false, '', '', $query_args, true);
997
+	}
998 998
 
999 999
 
1000
-    /**
1001
-     * This is toggles a single Check-in for the given registration and datetime.
1002
-     *
1003
-     * @param int $REG_ID The registration we're toggling
1004
-     * @param int $DTT_ID The datetime we're toggling
1005
-     * @return int The new status toggled to.
1006
-     * @throws EE_Error
1007
-     * @throws InvalidArgumentException
1008
-     * @throws InvalidDataTypeException
1009
-     * @throws InvalidInterfaceException
1010
-     * @throws ReflectionException
1011
-     */
1012
-    private function _toggle_checkin($REG_ID, $DTT_ID)
1013
-    {
1014
-        /** @var EE_Registration $REG */
1015
-        $REG        = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1016
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
1017
-        if ($new_status !== false) {
1018
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1019
-        } else {
1020
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1021
-            $new_status = false;
1022
-        }
1023
-        return $new_status;
1024
-    }
1000
+	/**
1001
+	 * This is toggles a single Check-in for the given registration and datetime.
1002
+	 *
1003
+	 * @param int $REG_ID The registration we're toggling
1004
+	 * @param int $DTT_ID The datetime we're toggling
1005
+	 * @return int The new status toggled to.
1006
+	 * @throws EE_Error
1007
+	 * @throws InvalidArgumentException
1008
+	 * @throws InvalidDataTypeException
1009
+	 * @throws InvalidInterfaceException
1010
+	 * @throws ReflectionException
1011
+	 */
1012
+	private function _toggle_checkin($REG_ID, $DTT_ID)
1013
+	{
1014
+		/** @var EE_Registration $REG */
1015
+		$REG        = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1016
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
1017
+		if ($new_status !== false) {
1018
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1019
+		} else {
1020
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1021
+			$new_status = false;
1022
+		}
1023
+		return $new_status;
1024
+	}
1025 1025
 
1026 1026
 
1027
-    /**
1028
-     * Takes care of deleting multiple EE_Checkin table rows
1029
-     *
1030
-     * @access protected
1031
-     * @return void
1032
-     * @throws EE_Error
1033
-     * @throws InvalidArgumentException
1034
-     * @throws InvalidDataTypeException
1035
-     * @throws InvalidInterfaceException
1036
-     * @throws ReflectionException
1037
-     */
1038
-    protected function _delete_checkin_rows()
1039
-    {
1040
-        $query_args = [
1041
-            'action'  => 'registration_checkins',
1042
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1043
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1044
-        ];
1045
-        $errors     = 0;
1046
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1047
-            $checkboxes = $this->_req_data['checkbox'];
1048
-            foreach (array_keys($checkboxes) as $CHK_ID) {
1049
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1050
-                    $errors++;
1051
-                }
1052
-            }
1053
-        } else {
1054
-            EE_Error::add_error(
1055
-                esc_html__(
1056
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1057
-                    'event_espresso'
1058
-                ),
1059
-                __FILE__,
1060
-                __FUNCTION__,
1061
-                __LINE__
1062
-            );
1063
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1064
-        }
1065
-        if ($errors > 0) {
1066
-            EE_Error::add_error(
1067
-                sprintf(
1068
-                    esc_html__('There were %d records that did not delete successfully', 'event_espresso'),
1069
-                    $errors
1070
-                ),
1071
-                __FILE__,
1072
-                __FUNCTION__,
1073
-                __LINE__
1074
-            );
1075
-        } else {
1076
-            EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1077
-        }
1078
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1079
-    }
1027
+	/**
1028
+	 * Takes care of deleting multiple EE_Checkin table rows
1029
+	 *
1030
+	 * @access protected
1031
+	 * @return void
1032
+	 * @throws EE_Error
1033
+	 * @throws InvalidArgumentException
1034
+	 * @throws InvalidDataTypeException
1035
+	 * @throws InvalidInterfaceException
1036
+	 * @throws ReflectionException
1037
+	 */
1038
+	protected function _delete_checkin_rows()
1039
+	{
1040
+		$query_args = [
1041
+			'action'  => 'registration_checkins',
1042
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1043
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1044
+		];
1045
+		$errors     = 0;
1046
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1047
+			$checkboxes = $this->_req_data['checkbox'];
1048
+			foreach (array_keys($checkboxes) as $CHK_ID) {
1049
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1050
+					$errors++;
1051
+				}
1052
+			}
1053
+		} else {
1054
+			EE_Error::add_error(
1055
+				esc_html__(
1056
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1057
+					'event_espresso'
1058
+				),
1059
+				__FILE__,
1060
+				__FUNCTION__,
1061
+				__LINE__
1062
+			);
1063
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1064
+		}
1065
+		if ($errors > 0) {
1066
+			EE_Error::add_error(
1067
+				sprintf(
1068
+					esc_html__('There were %d records that did not delete successfully', 'event_espresso'),
1069
+					$errors
1070
+				),
1071
+				__FILE__,
1072
+				__FUNCTION__,
1073
+				__LINE__
1074
+			);
1075
+		} else {
1076
+			EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1077
+		}
1078
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1079
+	}
1080 1080
 
1081 1081
 
1082
-    /**
1083
-     * Deletes a single EE_Checkin row
1084
-     *
1085
-     * @return void
1086
-     * @throws EE_Error
1087
-     * @throws InvalidArgumentException
1088
-     * @throws InvalidDataTypeException
1089
-     * @throws InvalidInterfaceException
1090
-     * @throws ReflectionException
1091
-     */
1092
-    protected function _delete_checkin_row()
1093
-    {
1094
-        $query_args = [
1095
-            'action'  => 'registration_checkins',
1096
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1097
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1098
-        ];
1099
-        if (! empty($this->_req_data['CHK_ID'])) {
1100
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1101
-                EE_Error::add_error(
1102
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1103
-                    __FILE__,
1104
-                    __FUNCTION__,
1105
-                    __LINE__
1106
-                );
1107
-            } else {
1108
-                EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1109
-            }
1110
-        } else {
1111
-            EE_Error::add_error(
1112
-                esc_html__(
1113
-                    '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',
1114
-                    'event_espresso'
1115
-                ),
1116
-                __FILE__,
1117
-                __FUNCTION__,
1118
-                __LINE__
1119
-            );
1120
-        }
1121
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1122
-    }
1082
+	/**
1083
+	 * Deletes a single EE_Checkin row
1084
+	 *
1085
+	 * @return void
1086
+	 * @throws EE_Error
1087
+	 * @throws InvalidArgumentException
1088
+	 * @throws InvalidDataTypeException
1089
+	 * @throws InvalidInterfaceException
1090
+	 * @throws ReflectionException
1091
+	 */
1092
+	protected function _delete_checkin_row()
1093
+	{
1094
+		$query_args = [
1095
+			'action'  => 'registration_checkins',
1096
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1097
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1098
+		];
1099
+		if (! empty($this->_req_data['CHK_ID'])) {
1100
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1101
+				EE_Error::add_error(
1102
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1103
+					__FILE__,
1104
+					__FUNCTION__,
1105
+					__LINE__
1106
+				);
1107
+			} else {
1108
+				EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1109
+			}
1110
+		} else {
1111
+			EE_Error::add_error(
1112
+				esc_html__(
1113
+					'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',
1114
+					'event_espresso'
1115
+				),
1116
+				__FILE__,
1117
+				__FUNCTION__,
1118
+				__LINE__
1119
+			);
1120
+		}
1121
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1122
+	}
1123 1123
 
1124 1124
 
1125
-    /**
1126
-     *        generates HTML for the Event Registrations List Table
1127
-     *
1128
-     * @access protected
1129
-     * @return void
1130
-     * @throws EE_Error
1131
-     * @throws InvalidArgumentException
1132
-     * @throws InvalidDataTypeException
1133
-     * @throws InvalidInterfaceException
1134
-     * @throws ReflectionException
1135
-     */
1136
-    protected function _event_registrations_list_table()
1137
-    {
1138
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1139
-        $this->_admin_page_title                  .= isset($this->_req_data['event_id'])
1140
-            ? $this->get_action_link_or_button(
1141
-                'new_registration',
1142
-                'add-registrant',
1143
-                ['event_id' => $this->_req_data['event_id']],
1144
-                'add-new-h2',
1145
-                '',
1146
-                false
1147
-            )
1148
-            : '';
1149
-        $checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1150
-        $checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1151
-        $checked_never                            = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1152
-        $checkin_invalid                          = new CheckinStatusDashicon(EE_Checkin::status_invalid);
1153
-        $legend_items                             = [
1154
-            'star-icon'        => [
1155
-                'class' => 'dashicons dashicons-star-filled gold-icon',
1156
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1157
-            ],
1158
-            'checkin'          => [
1159
-                'class' => $checked_in->cssClasses(),
1160
-                'desc'  => $checked_in->legendLabel(),
1161
-            ],
1162
-            'checkout'         => [
1163
-                'class' => $checked_out->cssClasses(),
1164
-                'desc'  => $checked_out->legendLabel(),
1165
-            ],
1166
-            'nocheckinrecord'  => [
1167
-                'class' => $checked_never->cssClasses(),
1168
-                'desc'  => $checked_never->legendLabel(),
1169
-            ],
1170
-            'canNotCheckin'    => [
1171
-                'class' => $checkin_invalid->cssClasses(),
1172
-                'desc'  => $checkin_invalid->legendLabel(),
1173
-            ],
1174
-            'approved_status'  => [
1175
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1176
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1177
-            ],
1178
-            'cancelled_status' => [
1179
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1180
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1181
-            ],
1182
-            'declined_status'  => [
1183
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1184
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1185
-            ],
1186
-            'not_approved'     => [
1187
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1188
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1189
-            ],
1190
-            'pending_status'   => [
1191
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1192
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1193
-            ],
1194
-            'wait_list'        => [
1195
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1196
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1197
-            ],
1198
-        ];
1199
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1200
-        $event_id                                 =
1201
-            isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
1202
-        /** @var EE_Event $event */
1203
-        $event                                     = EEM_Event::instance()->get_one_by_ID($event_id);
1204
-        $this->_template_args['before_list_table'] = $event instanceof EE_Event
1205
-            ? '<h2>
1125
+	/**
1126
+	 *        generates HTML for the Event Registrations List Table
1127
+	 *
1128
+	 * @access protected
1129
+	 * @return void
1130
+	 * @throws EE_Error
1131
+	 * @throws InvalidArgumentException
1132
+	 * @throws InvalidDataTypeException
1133
+	 * @throws InvalidInterfaceException
1134
+	 * @throws ReflectionException
1135
+	 */
1136
+	protected function _event_registrations_list_table()
1137
+	{
1138
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1139
+		$this->_admin_page_title                  .= isset($this->_req_data['event_id'])
1140
+			? $this->get_action_link_or_button(
1141
+				'new_registration',
1142
+				'add-registrant',
1143
+				['event_id' => $this->_req_data['event_id']],
1144
+				'add-new-h2',
1145
+				'',
1146
+				false
1147
+			)
1148
+			: '';
1149
+		$checked_in                               = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1150
+		$checked_out                              = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1151
+		$checked_never                            = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1152
+		$checkin_invalid                          = new CheckinStatusDashicon(EE_Checkin::status_invalid);
1153
+		$legend_items                             = [
1154
+			'star-icon'        => [
1155
+				'class' => 'dashicons dashicons-star-filled gold-icon',
1156
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1157
+			],
1158
+			'checkin'          => [
1159
+				'class' => $checked_in->cssClasses(),
1160
+				'desc'  => $checked_in->legendLabel(),
1161
+			],
1162
+			'checkout'         => [
1163
+				'class' => $checked_out->cssClasses(),
1164
+				'desc'  => $checked_out->legendLabel(),
1165
+			],
1166
+			'nocheckinrecord'  => [
1167
+				'class' => $checked_never->cssClasses(),
1168
+				'desc'  => $checked_never->legendLabel(),
1169
+			],
1170
+			'canNotCheckin'    => [
1171
+				'class' => $checkin_invalid->cssClasses(),
1172
+				'desc'  => $checkin_invalid->legendLabel(),
1173
+			],
1174
+			'approved_status'  => [
1175
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1176
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1177
+			],
1178
+			'cancelled_status' => [
1179
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1180
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1181
+			],
1182
+			'declined_status'  => [
1183
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1184
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1185
+			],
1186
+			'not_approved'     => [
1187
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1188
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1189
+			],
1190
+			'pending_status'   => [
1191
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1192
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1193
+			],
1194
+			'wait_list'        => [
1195
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1196
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1197
+			],
1198
+		];
1199
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1200
+		$event_id                                 =
1201
+			isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
1202
+		/** @var EE_Event $event */
1203
+		$event                                     = EEM_Event::instance()->get_one_by_ID($event_id);
1204
+		$this->_template_args['before_list_table'] = $event instanceof EE_Event
1205
+			? '<h2>
1206 1206
                 ' . sprintf(
1207
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1208
-                "<span class='ee-event-name'>{$event->name()}</span>"
1209
-            )
1210
-            : '';
1211
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1212
-        // the event.
1213
-        $DTT_ID   = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1214
-        $datetime = null;
1215
-        if ($event instanceof EE_Event) {
1216
-            $datetimes_on_event = $event->datetimes();
1217
-            if (count($datetimes_on_event) === 1) {
1218
-                $datetime = reset($datetimes_on_event);
1219
-            }
1220
-        }
1221
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1222
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1223
-            $active_status                             = $datetime->get_active_status();
1224
-            $datetime_status                           =
1225
-                '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1226
-                esc_attr($active_status) . '">'
1227
-                . EEH_Template::pretty_status($active_status, false, 'sentence')
1228
-                . '</span>';
1229
-            $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1230
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1231
-            $this->_template_args['before_list_table'] .= $datetime->name();
1232
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1233
-            $this->_template_args['before_list_table'] .= $datetime_status;
1234
-            $this->_template_args['before_list_table'] .= '</span>';
1235
-        }
1236
-        $this->_template_args['before_list_table'] .= '</h2>';
1237
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1238
-        // column represents
1239
-        if (! $datetime instanceof EE_Datetime) {
1240
-            $this->_template_args['before_list_table'] .= '
1207
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1208
+				"<span class='ee-event-name'>{$event->name()}</span>"
1209
+			)
1210
+			: '';
1211
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1212
+		// the event.
1213
+		$DTT_ID   = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1214
+		$datetime = null;
1215
+		if ($event instanceof EE_Event) {
1216
+			$datetimes_on_event = $event->datetimes();
1217
+			if (count($datetimes_on_event) === 1) {
1218
+				$datetime = reset($datetimes_on_event);
1219
+			}
1220
+		}
1221
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1222
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1223
+			$active_status                             = $datetime->get_active_status();
1224
+			$datetime_status                           =
1225
+				'<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1226
+				esc_attr($active_status) . '">'
1227
+				. EEH_Template::pretty_status($active_status, false, 'sentence')
1228
+				. '</span>';
1229
+			$this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1230
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1231
+			$this->_template_args['before_list_table'] .= $datetime->name();
1232
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1233
+			$this->_template_args['before_list_table'] .= $datetime_status;
1234
+			$this->_template_args['before_list_table'] .= '</span>';
1235
+		}
1236
+		$this->_template_args['before_list_table'] .= '</h2>';
1237
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1238
+		// column represents
1239
+		if (! $datetime instanceof EE_Datetime) {
1240
+			$this->_template_args['before_list_table'] .= '
1241 1241
                 <div class="description ee-status-outline ee-status-bg--info">'
1242
-                    . esc_html__(
1243
-                        'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1244
-                        'event_espresso'
1245
-                    ) . '
1242
+					. esc_html__(
1243
+						'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1244
+						'event_espresso'
1245
+					) . '
1246 1246
                 </div><br />';
1247
-        }
1248
-        $this->display_admin_list_table_page_with_no_sidebar();
1249
-    }
1247
+		}
1248
+		$this->display_admin_list_table_page_with_no_sidebar();
1249
+	}
1250 1250
 
1251 1251
 
1252
-    /**
1253
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1254
-     * conditions)
1255
-     *
1256
-     * @return void ends the request by a redirect or download
1257
-     */
1258
-    public function _registrations_checkin_report()
1259
-    {
1260
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1261
-    }
1252
+	/**
1253
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1254
+	 * conditions)
1255
+	 *
1256
+	 * @return void ends the request by a redirect or download
1257
+	 */
1258
+	public function _registrations_checkin_report()
1259
+	{
1260
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1261
+	}
1262 1262
 
1263 1263
 
1264
-    /**
1265
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1266
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1267
-     *
1268
-     * @param array $request
1269
-     * @param int   $per_page
1270
-     * @param bool  $count
1271
-     * @return array
1272
-     * @throws EE_Error
1273
-     */
1274
-    protected function _get_checkin_query_params_from_request(
1275
-        $request,
1276
-        $per_page = 10,
1277
-        $count = false
1278
-    ) {
1279
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1280
-        // unlike the regular registrations list table,
1281
-        $status_ids_array          = apply_filters(
1282
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1283
-            [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
1284
-        );
1285
-        $query_params[0]['STS_ID'] = ['IN', $status_ids_array];
1286
-        return $query_params;
1287
-    }
1264
+	/**
1265
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1266
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1267
+	 *
1268
+	 * @param array $request
1269
+	 * @param int   $per_page
1270
+	 * @param bool  $count
1271
+	 * @return array
1272
+	 * @throws EE_Error
1273
+	 */
1274
+	protected function _get_checkin_query_params_from_request(
1275
+		$request,
1276
+		$per_page = 10,
1277
+		$count = false
1278
+	) {
1279
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1280
+		// unlike the regular registrations list table,
1281
+		$status_ids_array          = apply_filters(
1282
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1283
+			[EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
1284
+		);
1285
+		$query_params[0]['STS_ID'] = ['IN', $status_ids_array];
1286
+		return $query_params;
1287
+	}
1288 1288
 
1289 1289
 
1290
-    /**
1291
-     * Gets registrations for an event
1292
-     *
1293
-     * @param int    $per_page
1294
-     * @param bool   $count whether to return count or data.
1295
-     * @param bool   $trash
1296
-     * @param string $orderby
1297
-     * @return EE_Registration[]|int
1298
-     * @throws EE_Error
1299
-     * @throws InvalidArgumentException
1300
-     * @throws InvalidDataTypeException
1301
-     * @throws InvalidInterfaceException
1302
-     * @throws ReflectionException
1303
-     */
1304
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1305
-    {
1306
-        // set some defaults, these will get overridden if included in the actual request parameters
1307
-        $defaults = [
1308
-            'orderby' => $orderby,
1309
-            'order'   => 'ASC',
1310
-        ];
1311
-        if ($trash) {
1312
-            $defaults['status'] = 'trash';
1313
-        }
1314
-        $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count);
1290
+	/**
1291
+	 * Gets registrations for an event
1292
+	 *
1293
+	 * @param int    $per_page
1294
+	 * @param bool   $count whether to return count or data.
1295
+	 * @param bool   $trash
1296
+	 * @param string $orderby
1297
+	 * @return EE_Registration[]|int
1298
+	 * @throws EE_Error
1299
+	 * @throws InvalidArgumentException
1300
+	 * @throws InvalidDataTypeException
1301
+	 * @throws InvalidInterfaceException
1302
+	 * @throws ReflectionException
1303
+	 */
1304
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1305
+	{
1306
+		// set some defaults, these will get overridden if included in the actual request parameters
1307
+		$defaults = [
1308
+			'orderby' => $orderby,
1309
+			'order'   => 'ASC',
1310
+		];
1311
+		if ($trash) {
1312
+			$defaults['status'] = 'trash';
1313
+		}
1314
+		$query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count);
1315 1315
 
1316
-        /**
1317
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1318
-         *
1319
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1320
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1321
-         *                             or if you have the development copy of EE you can view this at the path:
1322
-         *                             /docs/G--Model-System/model-query-params.md
1323
-         */
1324
-        $query_params['group_by'] = '';
1316
+		/**
1317
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1318
+		 *
1319
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1320
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1321
+		 *                             or if you have the development copy of EE you can view this at the path:
1322
+		 *                             /docs/G--Model-System/model-query-params.md
1323
+		 */
1324
+		$query_params['group_by'] = '';
1325 1325
 
1326
-        return $count
1327
-            ? EEM_Registration::instance()->count($query_params)
1328
-            /** @type EE_Registration[] */
1329
-            : EEM_Registration::instance()->get_all($query_params);
1330
-    }
1326
+		return $count
1327
+			? EEM_Registration::instance()->count($query_params)
1328
+			/** @type EE_Registration[] */
1329
+			: EEM_Registration::instance()->get_all($query_params);
1330
+	}
1331 1331
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
     public function __construct($routing = true)
34 34
     {
35 35
         parent::__construct($routing);
36
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
37
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
38
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
39
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
36
+        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
37
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
38
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
39
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
40 40
         }
41 41
     }
42 42
 
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
     {
46 46
         parent::_set_page_config();
47 47
 
48
-        $this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
48
+        $this->_admin_base_path                           = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
49 49
         $reg_id                                           =
50 50
             ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
51 51
                 ? $this->_req_data['_REG_ID']
52 52
                 : 0;
53
-        $new_page_routes                                  = [
53
+        $new_page_routes = [
54 54
             'reports'                      => [
55 55
                 'func'       => '_registration_reports',
56 56
                 'capability' => 'ee_read_registrations',
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
             // enqueue newsletter js
186 186
             wp_enqueue_script(
187 187
                 'ee-newsletter-trigger',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
188
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
189 189
                 ['ee-dialog'],
190 190
                 EVENT_ESPRESSO_VERSION,
191 191
                 true
192 192
             );
193 193
             wp_enqueue_style(
194 194
                 'ee-newsletter-trigger-css',
195
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
195
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
196 196
                 [],
197 197
                 EVENT_ESPRESSO_VERSION
198 198
             );
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     {
214 214
         wp_register_script(
215 215
             'ee-reg-reports-js',
216
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
216
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
217 217
             ['google-charts'],
218 218
             EVENT_ESPRESSO_VERSION,
219 219
             true
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         $nonce_ref = 'get_newsletter_form_content_nonce';
301 301
         $this->_verify_nonce($nonce, $nonce_ref);
302 302
         // let's get the mtp for the incoming MTP_ ID
303
-        if (! isset($this->_req_data['GRP_ID'])) {
303
+        if ( ! isset($this->_req_data['GRP_ID'])) {
304 304
             EE_Error::add_error(
305 305
                 esc_html__(
306 306
                     '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).',
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
             $this->_return_json();
316 316
         }
317 317
         $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
-        if (! $MTPG instanceof EE_Message_Template_Group) {
318
+        if ( ! $MTPG instanceof EE_Message_Template_Group) {
319 319
             EE_Error::add_error(
320 320
                 sprintf(
321 321
                     esc_html__(
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
             $field = $MTP->get('MTP_template_field');
341 341
             if ($field === 'content') {
342 342
                 $content = $MTP->get('MTP_content');
343
-                if (! empty($content['newsletter_content'])) {
343
+                if ( ! empty($content['newsletter_content'])) {
344 344
                     $template_fields['newsletter_content'] = $content['newsletter_content'];
345 345
                 }
346 346
                 continue;
347 347
             }
348
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
348
+            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
349 349
         }
350 350
         $this->_template_args['success'] = true;
351 351
         $this->_template_args['error']   = false;
@@ -448,17 +448,17 @@  discard block
 block discarded – undo
448 448
                 $field_id               = $field === '[NEWSLETTER_CONTENT]'
449 449
                     ? 'content'
450 450
                     : $field;
451
-                $field_id               = 'batch-message-' . strtolower($field_id);
451
+                $field_id               = 'batch-message-'.strtolower($field_id);
452 452
                 $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
453 453
                                           . $shortcode
454
-                                          . '" data-linked-input-id="' . $field_id . '">'
454
+                                          . '" data-linked-input-id="'.$field_id.'">'
455 455
                                           . $shortcode
456 456
                                           . '</span>';
457 457
             }
458
-            $codes[ $field ] = implode(', ', $available_shortcodes);
458
+            $codes[$field] = implode(', ', $available_shortcodes);
459 459
         }
460 460
         $shortcodes         = $codes;
461
-        $form_template      = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
461
+        $form_template      = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
462 462
         $form_template_args = [
463 463
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
464 464
             'form_route'        => 'newsletter_selected_send',
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
      */
629 629
     protected function _registration_reports()
630 630
     {
631
-        $template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
631
+        $template_path                              = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
632 632
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
633 633
             $template_path,
634 634
             $this->_reports_template_data,
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
             array_unshift($regs, $column_titles);
685 685
             // setup the date range.
686 686
             $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
687
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
687
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
688 688
             $ending_date    = new DateTime("now", $DateTimeZone);
689 689
             $subtitle       = sprintf(
690 690
                 wp_strip_all_tags(
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
                         'event_espresso'
709 709
                     )
710 710
                 ),
711
-                '<h2>' . $report_title . '</h2><p>',
711
+                '<h2>'.$report_title.'</h2><p>',
712 712
                 '</p>'
713 713
             ),
714 714
         ];
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
             foreach ($results as $result) {
742 742
                 $report_column_values = [];
743 743
                 foreach ($result as $property_name => $property_value) {
744
-                    $property_value         = $property_name === 'Registration_Event' ? wp_trim_words(
744
+                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
745 745
                         $property_value,
746 746
                         4,
747 747
                         '...'
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
             array_unshift($regs, $column_titles);
763 763
             // setup the date range.
764 764
             $DateTimeZone   = new DateTimeZone(EEH_DTT_Helper::get_timezone());
765
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
765
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
766 766
             $ending_date    = new DateTime("now", $DateTimeZone);
767 767
             $subtitle       = sprintf(
768 768
                 wp_strip_all_tags(
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
                         'event_espresso'
787 787
                     )
788 788
                 ),
789
-                '<h2>' . $report_title . '</h2><p>',
789
+                '<h2>'.$report_title.'</h2><p>',
790 790
                 '</p>'
791 791
             ),
792 792
         ];
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
         $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
814 814
         /** @var EE_Registration $registration */
815 815
         $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
816
-        if (! $registration instanceof EE_Registration) {
816
+        if ( ! $registration instanceof EE_Registration) {
817 817
             throw new EE_Error(
818 818
                 sprintf(
819 819
                     esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
                 )
822 822
             );
823 823
         }
824
-        $attendee                                 = $registration->attendee();
825
-        $this->_admin_page_title                  .= $this->get_action_link_or_button(
824
+        $attendee = $registration->attendee();
825
+        $this->_admin_page_title .= $this->get_action_link_or_button(
826 826
             'new_registration',
827 827
             'add-registrant',
828 828
             ['event_id' => $registration->event_ID()],
@@ -849,10 +849,10 @@  discard block
 block discarded – undo
849 849
         if ($datetime instanceof EE_Datetime) {
850 850
             $datetime_label = $datetime->get_dtt_display_name(true);
851 851
             $datetime_label .= ! empty($datetime_label)
852
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
852
+                ? ' ('.$datetime->get_dtt_display_name().')'
853 853
                 : $datetime->get_dtt_display_name();
854 854
         }
855
-        $datetime_link                                    = ! empty($dtt_id) && $registration instanceof EE_Registration
855
+        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
856 856
             ? EE_Admin_Page::add_query_args_and_nonce(
857 857
                 [
858 858
                     'action'   => 'event_registrations',
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
                 $this->_admin_base_url
863 863
             )
864 864
             : '';
865
-        $datetime_link                                    = ! empty($datetime_link)
866
-            ? '<a href="' . $datetime_link . '">'
865
+        $datetime_link = ! empty($datetime_link)
866
+            ? '<a href="'.$datetime_link.'">'
867 867
               . '<span id="checkin-dtt">'
868 868
               . $datetime_label
869 869
               . '</span></a>'
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
             ? $attendee->get_admin_details_link()
876 876
             : '';
877 877
         $attendee_link                                    = ! empty($attendee_link)
878
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
879
-              . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
878
+            ? '<a href="'.$attendee->get_admin_details_link().'"'
879
+              . ' aria-label="'.esc_html__('Click for attendee details', 'event_espresso').'">'
880 880
               . '<span id="checkin-attendee-name">'
881 881
               . $attendee_name
882 882
               . '</span></a>'
@@ -885,25 +885,25 @@  discard block
 block discarded – undo
885 885
             ? $registration->event()->get_admin_details_link()
886 886
             : '';
887 887
         $event_link                                       = ! empty($event_link)
888
-            ? '<a href="' . $event_link . '"'
889
-              . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
888
+            ? '<a href="'.$event_link.'"'
889
+              . ' aria-label="'.esc_html__('Click here to edit event.', 'event_espresso').'">'
890 890
               . '<span id="checkin-event-name">'
891 891
               . $registration->event_name()
892 892
               . '</span>'
893 893
               . '</a>'
894 894
             : '';
895
-        $this->_template_args['before_list_table']        = ! empty($reg_id) && ! empty($dtt_id)
896
-            ? '<h2>' . sprintf(
895
+        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
896
+            ? '<h2>'.sprintf(
897 897
                 esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
898 898
                 $attendee_link,
899 899
                 $datetime_link,
900 900
                 $event_link
901
-            ) . '</h2>'
901
+            ).'</h2>'
902 902
             : '';
903 903
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
904
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
904
+            ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : '';
905 905
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
906
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
906
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
907 907
         $this->display_admin_list_table_page_with_no_sidebar();
908 908
     }
909 909
 
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
     public function toggle_checkin_status()
922 922
     {
923 923
         // first make sure we have the necessary data
924
-        if (! isset($this->_req_data['_regid'])) {
924
+        if ( ! isset($this->_req_data['_regid'])) {
925 925
             EE_Error::add_error(
926 926
                 esc_html__(
927 927
                     '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',
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
         // beautiful! Made it this far so let's get the status.
944 944
         $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
945 945
         // setup new class to return via ajax
946
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
946
+        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses();
947 947
         $this->_template_args['success']            = true;
948 948
         $this->_return_json();
949 949
     }
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
         ];
971 971
         $new_status = false;
972 972
         // bulk action check in toggle
973
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
973
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
974 974
             // cycle thru checkboxes
975 975
             $checkboxes = $this->_req_data['checkbox'];
976 976
             foreach (array_keys($checkboxes) as $REG_ID) {
@@ -1042,11 +1042,11 @@  discard block
 block discarded – undo
1042 1042
             'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1043 1043
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1044 1044
         ];
1045
-        $errors     = 0;
1046
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1045
+        $errors = 0;
1046
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1047 1047
             $checkboxes = $this->_req_data['checkbox'];
1048 1048
             foreach (array_keys($checkboxes) as $CHK_ID) {
1049
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1049
+                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1050 1050
                     $errors++;
1051 1051
                 }
1052 1052
             }
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
             'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1097 1097
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1098 1098
         ];
1099
-        if (! empty($this->_req_data['CHK_ID'])) {
1100
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1099
+        if ( ! empty($this->_req_data['CHK_ID'])) {
1100
+            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1101 1101
                 EE_Error::add_error(
1102 1102
                     esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1103 1103
                     __FILE__,
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
     protected function _event_registrations_list_table()
1137 1137
     {
1138 1138
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1139
-        $this->_admin_page_title                  .= isset($this->_req_data['event_id'])
1139
+        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1140 1140
             ? $this->get_action_link_or_button(
1141 1141
                 'new_registration',
1142 1142
                 'add-registrant',
@@ -1172,27 +1172,27 @@  discard block
 block discarded – undo
1172 1172
                 'desc'  => $checkin_invalid->legendLabel(),
1173 1173
             ],
1174 1174
             'approved_status'  => [
1175
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1175
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_approved,
1176 1176
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1177 1177
             ],
1178 1178
             'cancelled_status' => [
1179
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1179
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_cancelled,
1180 1180
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1181 1181
             ],
1182 1182
             'declined_status'  => [
1183
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1183
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_declined,
1184 1184
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1185 1185
             ],
1186 1186
             'not_approved'     => [
1187
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1187
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_not_approved,
1188 1188
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1189 1189
             ],
1190 1190
             'pending_status'   => [
1191
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1191
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_pending_payment,
1192 1192
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1193 1193
             ],
1194 1194
             'wait_list'        => [
1195
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1195
+                'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_wait_list,
1196 1196
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1197 1197
             ],
1198 1198
         ];
@@ -1222,27 +1222,27 @@  discard block
 block discarded – undo
1222 1222
         if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1223 1223
             $active_status                             = $datetime->get_active_status();
1224 1224
             $datetime_status                           =
1225
-                '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
1226
-                esc_attr($active_status) . '">'
1225
+                '<span class="ee-status ee-status-bg--'.esc_attr($active_status).' event-active-status-'.
1226
+                esc_attr($active_status).'">'
1227 1227
                 . EEH_Template::pretty_status($active_status, false, 'sentence')
1228 1228
                 . '</span>';
1229 1229
             $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">';
1230 1230
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>';
1231 1231
             $this->_template_args['before_list_table'] .= $datetime->name();
1232
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1232
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1233 1233
             $this->_template_args['before_list_table'] .= $datetime_status;
1234 1234
             $this->_template_args['before_list_table'] .= '</span>';
1235 1235
         }
1236 1236
         $this->_template_args['before_list_table'] .= '</h2>';
1237 1237
         // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1238 1238
         // column represents
1239
-        if (! $datetime instanceof EE_Datetime) {
1239
+        if ( ! $datetime instanceof EE_Datetime) {
1240 1240
             $this->_template_args['before_list_table'] .= '
1241 1241
                 <div class="description ee-status-outline ee-status-bg--info">'
1242 1242
                     . esc_html__(
1243 1243
                         'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1244 1244
                         'event_espresso'
1245
-                    ) . '
1245
+                    ).'
1246 1246
                 </div><br />';
1247 1247
         }
1248 1248
         $this->display_admin_list_table_page_with_no_sidebar();
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
     ) {
1279 1279
         $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1280 1280
         // unlike the regular registrations list table,
1281
-        $status_ids_array          = apply_filters(
1281
+        $status_ids_array = apply_filters(
1282 1282
             'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1283 1283
             [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
1284 1284
         );
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
11 11
  */
12 12
 class espresso_events_Pricing_Hooks extends espresso_events_Events_Hooks_Extend
13 13
 {
14
-    protected function _set_hooks_properties()
15
-    {
16
-        $this->_name = 'events';
17
-    }
14
+	protected function _set_hooks_properties()
15
+	{
16
+		$this->_name = 'events';
17
+	}
18 18
 }
Please login to merge, or discard this patch.
pricing/templates/event_tickets_datetime_attached_tickets_row.template.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
                 <h3 class="ee-item-id">
25 25
                     <?php echo esc_html(
26 26
                         $DTT_ID
27
-                            ? sprintf( __('Datetime ID: %d', 'event_espresso'), $DTT_ID )
27
+                            ? sprintf(__('Datetime ID: %d', 'event_espresso'), $DTT_ID)
28 28
                             : ''
29 29
                     ); ?>
30 30
                 </h3>
31 31
             </div>
32 32
             <div class="datetime-description-container">
33
-                <label for="<?php echo esc_attr($event_datetimes_name . '-' . $dtt_row); ?>-DTT_description">
33
+                <label for="<?php echo esc_attr($event_datetimes_name.'-'.$dtt_row); ?>-DTT_description">
34 34
                     <?php esc_html_e('Datetime Description', 'event_espresso') ?>
35 35
                 </label>
36 36
                 <textarea name="<?php echo esc_attr($event_datetimes_name); ?>[<?php echo esc_attr($dtt_row); ?>][DTT_description]"
37
-                          id="<?php echo esc_attr($event_datetimes_name . '-' . $dtt_row); ?>-DTT_description"
37
+                          id="<?php echo esc_attr($event_datetimes_name.'-'.$dtt_row); ?>-DTT_description"
38 38
                           class="event-datetime-DTT_description ee-full-textarea-inp"
39 39
                 ><?php echo esc_textarea($DTT_description); ?></textarea>
40 40
             </div>
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             <div class="add-datetime-ticket-container">
54 54
                 <div class="ee-layout-row ee-layout-row--fixed">
55 55
                     <h4 class="datetime-tickets-heading">
56
-                        <?php esc_html_e( 'Add New Ticket', 'event_espresso' ); ?>
56
+                        <?php esc_html_e('Add New Ticket', 'event_espresso'); ?>
57 57
                     </h4>
58 58
                     <?php echo wp_kses($add_new_datetime_ticket_help_link, AllowedTags::getAllowedTags()); ?>
59 59
                 </div>
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
                         <tr valign="top">
64 64
                             <td>
65 65
                                 <span class="ANT_TKT_name_label">
66
-                                    <?php esc_html_e( 'Ticket Name', 'event_espresso' ); ?>
66
+                                    <?php esc_html_e('Ticket Name', 'event_espresso'); ?>
67 67
                                 </span>
68 68
                             </td>
69 69
                             <td>
70 70
                                 <span class="ANT_TKT_goes_on_sale_label">
71
-                                    <?php esc_html_e('Sale Starts', 'event_espresso' ); ?>
71
+                                    <?php esc_html_e('Sale Starts', 'event_espresso'); ?>
72 72
                                 </span>
73 73
                             </td>
74 74
                             <td>
75 75
                                 <span class="ANT_TKT_sell_until_label">
76
-                                    <?php esc_html_e( 'Sell Until',  'event_espresso' ); ?>
76
+                                    <?php esc_html_e('Sell Until', 'event_espresso'); ?>
77 77
                                 </span>
78 78
                             </td>
79 79
                             <td>
Please login to merge, or discard this patch.
caffeinated/core/services/licensing/LicenseService.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -15,86 +15,86 @@
 block discarded – undo
15 15
  */
16 16
 class LicenseService
17 17
 {
18
-    private Config $config;
18
+	private Config $config;
19 19
 
20
-    private Stats $stats_collection;
20
+	private Stats $stats_collection;
21 21
 
22
-    public function __construct(Stats $stats_collection, Config $config)
23
-    {
24
-        $this->config = $config;
25
-        $this->stats_collection = $stats_collection;
26
-    }
22
+	public function __construct(Stats $stats_collection, Config $config)
23
+	{
24
+		$this->config = $config;
25
+		$this->stats_collection = $stats_collection;
26
+	}
27 27
 
28
-    public function loadPueClient()
29
-    {
30
-        // PUE Auto Upgrades stuff
31
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
32
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
33
-            // $options needs to be an array with the included keys as listed.
34
-            $options = array(
35
-                // 'optionName' => '', //(optional) - used as the reference for saving update information in the
36
-                // clients options table.  Will be automatically set if left blank.
37
-                'apikey'                => $this->config->siteLicenseKey(),
38
-                // (required), you will need to obtain the apikey that the client gets from your site and
39
-                // then saves in their sites options table (see 'getting an api-key' below)
40
-                'lang_domain'           => $this->config->i18nDomain(),
41
-                // (optional) - put here whatever reference you are using for the localization of your plugin (if it's
42
-                // localized).  That way strings in this file will be included in the translation for your plugin.
43
-                'checkPeriod'           => $this->config->checkPeriod(),
44
-                // (optional) - use this parameter to indicate how often you want the client's install to ping your
45
-                // server for update checks.  The integer indicates hours.  If you don't include this parameter it will
46
-                // default to 12 hours.
47
-                'option_key'            => $this->config->optionKey(),
48
-                // this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
49
-                // updating your information message whenever this option_key is modified.
50
-                'options_page_slug'     => $this->config->optionsPageSlug(),
51
-                'plugin_basename'       => EE_PLUGIN_BASENAME,
52
-                'use_wp_update'         => true,
53
-                // if TRUE then you want FREE versions of the plugin to be updated from WP
54
-                'extra_stats'           => $this->stats_collection->statsCallback(),
55
-                'turn_on_notices_saved' => true,
56
-            );
57
-            // initiate the class and start the plugin update engine!
58
-            new PluginUpdateEngineChecker(
59
-                $this->config->hostServerUrl(),
60
-                $this->config->pluginSlug(),
61
-                $options
62
-            );
28
+	public function loadPueClient()
29
+	{
30
+		// PUE Auto Upgrades stuff
31
+		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
32
+			require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
33
+			// $options needs to be an array with the included keys as listed.
34
+			$options = array(
35
+				// 'optionName' => '', //(optional) - used as the reference for saving update information in the
36
+				// clients options table.  Will be automatically set if left blank.
37
+				'apikey'                => $this->config->siteLicenseKey(),
38
+				// (required), you will need to obtain the apikey that the client gets from your site and
39
+				// then saves in their sites options table (see 'getting an api-key' below)
40
+				'lang_domain'           => $this->config->i18nDomain(),
41
+				// (optional) - put here whatever reference you are using for the localization of your plugin (if it's
42
+				// localized).  That way strings in this file will be included in the translation for your plugin.
43
+				'checkPeriod'           => $this->config->checkPeriod(),
44
+				// (optional) - use this parameter to indicate how often you want the client's install to ping your
45
+				// server for update checks.  The integer indicates hours.  If you don't include this parameter it will
46
+				// default to 12 hours.
47
+				'option_key'            => $this->config->optionKey(),
48
+				// this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
49
+				// updating your information message whenever this option_key is modified.
50
+				'options_page_slug'     => $this->config->optionsPageSlug(),
51
+				'plugin_basename'       => EE_PLUGIN_BASENAME,
52
+				'use_wp_update'         => true,
53
+				// if TRUE then you want FREE versions of the plugin to be updated from WP
54
+				'extra_stats'           => $this->stats_collection->statsCallback(),
55
+				'turn_on_notices_saved' => true,
56
+			);
57
+			// initiate the class and start the plugin update engine!
58
+			new PluginUpdateEngineChecker(
59
+				$this->config->hostServerUrl(),
60
+				$this->config->pluginSlug(),
61
+				$options
62
+			);
63 63
 
64
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
65
-        }
66
-    }
64
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
65
+		}
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
71
-     *
72
-     * @param string $basename  Use the equivalent result from plugin_basename() for this param as WP uses that to
73
-     *                          identify plugins. Defaults to core update
74
-     * @return bool           True if update available, false if not.
75
-     */
76
-    public static function isUpdateAvailable(string $basename = ''): bool
77
-    {
78
-        $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
69
+	/**
70
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
71
+	 *
72
+	 * @param string $basename  Use the equivalent result from plugin_basename() for this param as WP uses that to
73
+	 *                          identify plugins. Defaults to core update
74
+	 * @return bool           True if update available, false if not.
75
+	 */
76
+	public static function isUpdateAvailable(string $basename = ''): bool
77
+	{
78
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
79 79
 
80
-        $update = false;
80
+		$update = false;
81 81
 
82
-        // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
83
-        $folder = '/' . dirname($basename);
82
+		// should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
83
+		$folder = '/' . dirname($basename);
84 84
 
85
-        $plugins = get_plugins($folder);
86
-        $current = get_site_transient('update_plugins');
87
-        foreach ($plugins as $plugin_file => $plugin_data) {
88
-            if (isset($current->response[ $plugin_file ])) {
89
-                $update = true;
90
-            }
91
-        }
85
+		$plugins = get_plugins($folder);
86
+		$current = get_site_transient('update_plugins');
87
+		foreach ($plugins as $plugin_file => $plugin_data) {
88
+			if (isset($current->response[ $plugin_file ])) {
89
+				$update = true;
90
+			}
91
+		}
92 92
 
93
-        // it's possible that there is an update but an invalid site-license-key is in use
94
-        if (get_site_option('pue_json_error_' . $basename)) {
95
-            $update = true;
96
-        }
93
+		// it's possible that there is an update but an invalid site-license-key is in use
94
+		if (get_site_option('pue_json_error_' . $basename)) {
95
+			$update = true;
96
+		}
97 97
 
98
-        return $update;
99
-    }
98
+		return $update;
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     public function loadPueClient()
29 29
     {
30 30
         // PUE Auto Upgrades stuff
31
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
32
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
31
+        if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { // include the file
32
+            require_once(EE_THIRD_PARTY.'pue/pue-client.php');
33 33
             // $options needs to be an array with the included keys as listed.
34 34
             $options = array(
35 35
                 // 'optionName' => '', //(optional) - used as the reference for saving update information in the
@@ -80,18 +80,18 @@  discard block
 block discarded – undo
80 80
         $update = false;
81 81
 
82 82
         // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
83
-        $folder = '/' . dirname($basename);
83
+        $folder = '/'.dirname($basename);
84 84
 
85 85
         $plugins = get_plugins($folder);
86 86
         $current = get_site_transient('update_plugins');
87 87
         foreach ($plugins as $plugin_file => $plugin_data) {
88
-            if (isset($current->response[ $plugin_file ])) {
88
+            if (isset($current->response[$plugin_file])) {
89 89
                 $update = true;
90 90
             }
91 91
         }
92 92
 
93 93
         // it's possible that there is an update but an invalid site-license-key is in use
94
-        if (get_site_option('pue_json_error_' . $basename)) {
94
+        if (get_site_option('pue_json_error_'.$basename)) {
95 95
             $update = true;
96 96
         }
97 97
 
Please login to merge, or discard this patch.
caffeinated/core/domain/services/pue/StatsGatherer.php 1 patch
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -15,288 +15,288 @@
 block discarded – undo
15 15
 
16 16
 class StatsGatherer
17 17
 {
18
-    public const COUNT_ALL_EVENTS                 = 'event';
18
+	public const COUNT_ALL_EVENTS                 = 'event';
19 19
 
20
-    public const COUNT_ACTIVE_EVENTS              = 'active_event';
20
+	public const COUNT_ACTIVE_EVENTS              = 'active_event';
21 21
 
22
-    public const COUNT_DATETIMES                  = 'datetime';
22
+	public const COUNT_DATETIMES                  = 'datetime';
23 23
 
24
-    public const COUNT_TICKETS                    = 'ticket';
24
+	public const COUNT_TICKETS                    = 'ticket';
25 25
 
26
-    public const COUNT_DATETIMES_SOLD             = 'datetime_sold';
26
+	public const COUNT_DATETIMES_SOLD             = 'datetime_sold';
27 27
 
28
-    public const COUNT_TICKETS_FREE               = 'free_ticket';
28
+	public const COUNT_TICKETS_FREE               = 'free_ticket';
29 29
 
30
-    public const COUNT_TICKETS_PAID               = 'paid_ticket';
30
+	public const COUNT_TICKETS_PAID               = 'paid_ticket';
31 31
 
32
-    public const COUNT_TICKETS_SOLD               = 'ticket_sold';
32
+	public const COUNT_TICKETS_SOLD               = 'ticket_sold';
33 33
 
34
-    public const COUNT_REGISTRATIONS_APPROVED     = 'registrations_approved';
34
+	public const COUNT_REGISTRATIONS_APPROVED     = 'registrations_approved';
35 35
 
36
-    public const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
36
+	public const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
37 37
 
38
-    public const COUNT_REGISTRATIONS_PENDING      = 'registrations_pending';
38
+	public const COUNT_REGISTRATIONS_PENDING      = 'registrations_pending';
39 39
 
40
-    public const COUNT_REGISTRATIONS_INCOMPLETE   = 'registrations_incomplete';
40
+	public const COUNT_REGISTRATIONS_INCOMPLETE   = 'registrations_incomplete';
41 41
 
42
-    public const COUNT_REGISTRATIONS_ALL          = 'registrations_all';
42
+	public const COUNT_REGISTRATIONS_ALL          = 'registrations_all';
43 43
 
44
-    public const COUNT_REGISTRATIONS_CANCELLED    = 'registrations_cancelled';
44
+	public const COUNT_REGISTRATIONS_CANCELLED    = 'registrations_cancelled';
45 45
 
46
-    public const COUNT_REGISTRATIONS_DECLINED     = 'registrations_declined';
46
+	public const COUNT_REGISTRATIONS_DECLINED     = 'registrations_declined';
47 47
 
48
-    public const SUM_TRANSACTIONS_COMPLETE_TOTAL  = 'transactions_complete_total_sum';
48
+	public const SUM_TRANSACTIONS_COMPLETE_TOTAL  = 'transactions_complete_total_sum';
49 49
 
50
-    public const SUM_TRANSACTIONS_ALL_PAID        = 'transactions_all_paid';
50
+	public const SUM_TRANSACTIONS_ALL_PAID        = 'transactions_all_paid';
51 51
 
52
-    public const INFO_SITE_CURRENCY               = 'site_currency';
52
+	public const INFO_SITE_CURRENCY               = 'site_currency';
53 53
 
54 54
 
55
-    /**
56
-     * @var EEM_Payment_Method
57
-     */
58
-    private $payment_method_model;
59
-
60
-
61
-    /**
62
-     * @var EEM_Event
63
-     */
64
-    private $event_model;
65
-
66
-    /**
67
-     * @var EEM_Datetime
68
-     */
69
-    private $datetime_model;
70
-
71
-
72
-    /**
73
-     * @var EEM_Ticket
74
-     */
75
-    private $ticket_model;
76
-
77
-
78
-    /**
79
-     * @var EEM_Registration
80
-     */
81
-    private $registration_model;
82
-
83
-
84
-    /**
85
-     * @var EEM_Transaction
86
-     */
87
-    private $transaction_model;
88
-
89
-
90
-    /**
91
-     * @var EE_Config
92
-     */
93
-    private $config;
94
-
95
-
96
-    /**
97
-     * StatsGatherer constructor.
98
-     *
99
-     * @param EEM_Payment_Method $payment_method_model
100
-     * @param EEM_Event          $event_model
101
-     * @param EEM_Datetime       $datetime_model
102
-     * @param EEM_Ticket         $ticket_model
103
-     * @param EEM_Registration   $registration_model
104
-     * @param EEM_Transaction    $transaction_model
105
-     * @param EE_Config          $config
106
-     */
107
-    public function __construct(
108
-        EEM_Payment_Method $payment_method_model,
109
-        EEM_Event $event_model,
110
-        EEM_Datetime $datetime_model,
111
-        EEM_Ticket $ticket_model,
112
-        EEM_Registration $registration_model,
113
-        EEM_Transaction $transaction_model,
114
-        EE_Config $config
115
-    ) {
116
-        $this->payment_method_model = $payment_method_model;
117
-        $this->event_model          = $event_model;
118
-        $this->datetime_model       = $datetime_model;
119
-        $this->ticket_model         = $ticket_model;
120
-        $this->registration_model   = $registration_model;
121
-        $this->transaction_model    = $transaction_model;
122
-        $this->config               = $config;
123
-    }
124
-
125
-
126
-    /**
127
-     * Return the stats array for PUE UXIP stats.
128
-     *
129
-     * @return array
130
-     */
131
-    public function stats(): array
132
-    {
133
-        global $wp_version;
134
-        $stats = $this->paymentMethodStats();
135
-        // a-ok so let's setup our stats.
136
-        $stats = array_merge(
137
-            $stats,
138
-            [
139
-                'is_multisite'                    => is_multisite() && is_main_site(),
140
-                'active_theme'                    => $this->getActiveThemeStat(),
141
-                'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
142
-                'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
143
-                'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
144
-                'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
145
-                'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
146
-                'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
147
-                'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
148
-                'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
149
-                'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
150
-                'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
151
-                'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
152
-                'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
153
-                'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
154
-                'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
155
-                'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
156
-                'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
157
-                'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
158
-                self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
159
-                    ? $this->config->currency->code
160
-                    : 'unknown',
161
-                'phpversion'                      => implode(
162
-                    '.',
163
-                    [PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION]
164
-                ),
165
-                'wpversion'                       => $wp_version,
166
-                'active_addons'                   => $this->getActiveAddons(),
167
-            ]
168
-        );
169
-        // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
170
-        return array_filter($stats, function ($value) {
171
-            return $value !== null;
172
-        });
173
-    }
174
-
175
-
176
-    /**
177
-     * @param string $which enum (@see constants prefixed with COUNT)
178
-     * @return int|float|null
179
-     */
180
-    private function getCountFor(string $which)
181
-    {
182
-        try {
183
-            switch ($which) {
184
-                case self::COUNT_ALL_EVENTS:
185
-                    $count = $this->event_model->count();
186
-                    break;
187
-                case self::COUNT_TICKETS:
188
-                    $count = $this->ticket_model->count();
189
-                    break;
190
-                case self::COUNT_DATETIMES:
191
-                    $count = $this->datetime_model->count();
192
-                    break;
193
-                case self::COUNT_ACTIVE_EVENTS:
194
-                    $count = $this->event_model->get_active_events([], true);
195
-                    break;
196
-                case self::COUNT_DATETIMES_SOLD:
197
-                    $count = $this->datetime_model->sum([], 'DTT_sold');
198
-                    break;
199
-                case self::COUNT_TICKETS_FREE:
200
-                    $count = $this->ticket_model->count([['TKT_price' => 0]]);
201
-                    break;
202
-                case self::COUNT_TICKETS_PAID:
203
-                    $count = $this->ticket_model->count([['TKT_price' => ['>', 0]]]);
204
-                    break;
205
-                case self::COUNT_TICKETS_SOLD:
206
-                    $count = $this->ticket_model->sum([], 'TKT_sold');
207
-                    break;
208
-                case self::COUNT_REGISTRATIONS_ALL:
209
-                    $count = $this->registration_model->count();
210
-                    break;
211
-                case self::COUNT_REGISTRATIONS_CANCELLED:
212
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_cancelled]]);
213
-                    break;
214
-                case self::COUNT_REGISTRATIONS_INCOMPLETE:
215
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_incomplete]]);
216
-                    break;
217
-                case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_not_approved]]);
219
-                    break;
220
-                case self::COUNT_REGISTRATIONS_DECLINED:
221
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_declined]]);
222
-                    break;
223
-                case self::COUNT_REGISTRATIONS_PENDING:
224
-                    $count = $this->registration_model->count(
225
-                        [['STS_ID' => EEM_Registration::status_id_pending_payment]]
226
-                    );
227
-                    break;
228
-                case self::COUNT_REGISTRATIONS_APPROVED:
229
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_approved]]);
230
-                    break;
231
-                case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
232
-                    $count = $this->transaction_model->sum(
233
-                        [['STS_ID' => EEM_Transaction::complete_status_code]],
234
-                        'TXN_total'
235
-                    );
236
-                    break;
237
-                case self::SUM_TRANSACTIONS_ALL_PAID:
238
-                    $count = $this->transaction_model->sum([], 'TXN_paid');
239
-                    break;
240
-                default:
241
-                    $count = null;
242
-                    break;
243
-            }
244
-        } catch (Exception $e) {
245
-            $count = null;
246
-        }
247
-        return $count;
248
-    }
249
-
250
-
251
-    /**
252
-     * Return the active theme.
253
-     *
254
-     * @return false|string
255
-     */
256
-    private function getActiveThemeStat()
257
-    {
258
-        $theme = wp_get_theme();
259
-        return $theme->get('Name');
260
-    }
261
-
262
-
263
-    /**
264
-     * @return array
265
-     */
266
-    private function paymentMethodStats(): array
267
-    {
268
-        $payment_method_stats = [];
269
-        try {
270
-            $active_payment_methods = $this->payment_method_model->get_all_active(
271
-                null,
272
-                ['group_by' => 'PMD_type']
273
-            );
274
-            if ($active_payment_methods) {
275
-                foreach ($active_payment_methods as $payment_method) {
276
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
277
-                }
278
-            }
279
-        } catch (Exception $e) {
280
-            // do nothing just prevents fatals.
281
-        }
282
-        return $payment_method_stats;
283
-    }
284
-
285
-
286
-    /**
287
-     * Return a list of active EE add-ons and their versions.
288
-     *
289
-     * @return string
290
-     */
291
-    private function getActiveAddons(): string
292
-    {
293
-        $activeAddons = [];
294
-        $addOns       = EE_Registry::instance()->addons;
295
-        if (! empty($addOns)) {
296
-            foreach ($addOns as $addon) {
297
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
298
-            }
299
-        }
300
-        return implode(',', $activeAddons);
301
-    }
55
+	/**
56
+	 * @var EEM_Payment_Method
57
+	 */
58
+	private $payment_method_model;
59
+
60
+
61
+	/**
62
+	 * @var EEM_Event
63
+	 */
64
+	private $event_model;
65
+
66
+	/**
67
+	 * @var EEM_Datetime
68
+	 */
69
+	private $datetime_model;
70
+
71
+
72
+	/**
73
+	 * @var EEM_Ticket
74
+	 */
75
+	private $ticket_model;
76
+
77
+
78
+	/**
79
+	 * @var EEM_Registration
80
+	 */
81
+	private $registration_model;
82
+
83
+
84
+	/**
85
+	 * @var EEM_Transaction
86
+	 */
87
+	private $transaction_model;
88
+
89
+
90
+	/**
91
+	 * @var EE_Config
92
+	 */
93
+	private $config;
94
+
95
+
96
+	/**
97
+	 * StatsGatherer constructor.
98
+	 *
99
+	 * @param EEM_Payment_Method $payment_method_model
100
+	 * @param EEM_Event          $event_model
101
+	 * @param EEM_Datetime       $datetime_model
102
+	 * @param EEM_Ticket         $ticket_model
103
+	 * @param EEM_Registration   $registration_model
104
+	 * @param EEM_Transaction    $transaction_model
105
+	 * @param EE_Config          $config
106
+	 */
107
+	public function __construct(
108
+		EEM_Payment_Method $payment_method_model,
109
+		EEM_Event $event_model,
110
+		EEM_Datetime $datetime_model,
111
+		EEM_Ticket $ticket_model,
112
+		EEM_Registration $registration_model,
113
+		EEM_Transaction $transaction_model,
114
+		EE_Config $config
115
+	) {
116
+		$this->payment_method_model = $payment_method_model;
117
+		$this->event_model          = $event_model;
118
+		$this->datetime_model       = $datetime_model;
119
+		$this->ticket_model         = $ticket_model;
120
+		$this->registration_model   = $registration_model;
121
+		$this->transaction_model    = $transaction_model;
122
+		$this->config               = $config;
123
+	}
124
+
125
+
126
+	/**
127
+	 * Return the stats array for PUE UXIP stats.
128
+	 *
129
+	 * @return array
130
+	 */
131
+	public function stats(): array
132
+	{
133
+		global $wp_version;
134
+		$stats = $this->paymentMethodStats();
135
+		// a-ok so let's setup our stats.
136
+		$stats = array_merge(
137
+			$stats,
138
+			[
139
+				'is_multisite'                    => is_multisite() && is_main_site(),
140
+				'active_theme'                    => $this->getActiveThemeStat(),
141
+				'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
142
+				'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
143
+				'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
144
+				'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
145
+				'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
146
+				'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
147
+				'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
148
+				'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
149
+				'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
150
+				'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
151
+				'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
152
+				'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
153
+				'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
154
+				'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
155
+				'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
156
+				'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
157
+				'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
158
+				self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
159
+					? $this->config->currency->code
160
+					: 'unknown',
161
+				'phpversion'                      => implode(
162
+					'.',
163
+					[PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION]
164
+				),
165
+				'wpversion'                       => $wp_version,
166
+				'active_addons'                   => $this->getActiveAddons(),
167
+			]
168
+		);
169
+		// remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
170
+		return array_filter($stats, function ($value) {
171
+			return $value !== null;
172
+		});
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param string $which enum (@see constants prefixed with COUNT)
178
+	 * @return int|float|null
179
+	 */
180
+	private function getCountFor(string $which)
181
+	{
182
+		try {
183
+			switch ($which) {
184
+				case self::COUNT_ALL_EVENTS:
185
+					$count = $this->event_model->count();
186
+					break;
187
+				case self::COUNT_TICKETS:
188
+					$count = $this->ticket_model->count();
189
+					break;
190
+				case self::COUNT_DATETIMES:
191
+					$count = $this->datetime_model->count();
192
+					break;
193
+				case self::COUNT_ACTIVE_EVENTS:
194
+					$count = $this->event_model->get_active_events([], true);
195
+					break;
196
+				case self::COUNT_DATETIMES_SOLD:
197
+					$count = $this->datetime_model->sum([], 'DTT_sold');
198
+					break;
199
+				case self::COUNT_TICKETS_FREE:
200
+					$count = $this->ticket_model->count([['TKT_price' => 0]]);
201
+					break;
202
+				case self::COUNT_TICKETS_PAID:
203
+					$count = $this->ticket_model->count([['TKT_price' => ['>', 0]]]);
204
+					break;
205
+				case self::COUNT_TICKETS_SOLD:
206
+					$count = $this->ticket_model->sum([], 'TKT_sold');
207
+					break;
208
+				case self::COUNT_REGISTRATIONS_ALL:
209
+					$count = $this->registration_model->count();
210
+					break;
211
+				case self::COUNT_REGISTRATIONS_CANCELLED:
212
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_cancelled]]);
213
+					break;
214
+				case self::COUNT_REGISTRATIONS_INCOMPLETE:
215
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_incomplete]]);
216
+					break;
217
+				case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_not_approved]]);
219
+					break;
220
+				case self::COUNT_REGISTRATIONS_DECLINED:
221
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_declined]]);
222
+					break;
223
+				case self::COUNT_REGISTRATIONS_PENDING:
224
+					$count = $this->registration_model->count(
225
+						[['STS_ID' => EEM_Registration::status_id_pending_payment]]
226
+					);
227
+					break;
228
+				case self::COUNT_REGISTRATIONS_APPROVED:
229
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_approved]]);
230
+					break;
231
+				case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
232
+					$count = $this->transaction_model->sum(
233
+						[['STS_ID' => EEM_Transaction::complete_status_code]],
234
+						'TXN_total'
235
+					);
236
+					break;
237
+				case self::SUM_TRANSACTIONS_ALL_PAID:
238
+					$count = $this->transaction_model->sum([], 'TXN_paid');
239
+					break;
240
+				default:
241
+					$count = null;
242
+					break;
243
+			}
244
+		} catch (Exception $e) {
245
+			$count = null;
246
+		}
247
+		return $count;
248
+	}
249
+
250
+
251
+	/**
252
+	 * Return the active theme.
253
+	 *
254
+	 * @return false|string
255
+	 */
256
+	private function getActiveThemeStat()
257
+	{
258
+		$theme = wp_get_theme();
259
+		return $theme->get('Name');
260
+	}
261
+
262
+
263
+	/**
264
+	 * @return array
265
+	 */
266
+	private function paymentMethodStats(): array
267
+	{
268
+		$payment_method_stats = [];
269
+		try {
270
+			$active_payment_methods = $this->payment_method_model->get_all_active(
271
+				null,
272
+				['group_by' => 'PMD_type']
273
+			);
274
+			if ($active_payment_methods) {
275
+				foreach ($active_payment_methods as $payment_method) {
276
+					$payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
277
+				}
278
+			}
279
+		} catch (Exception $e) {
280
+			// do nothing just prevents fatals.
281
+		}
282
+		return $payment_method_stats;
283
+	}
284
+
285
+
286
+	/**
287
+	 * Return a list of active EE add-ons and their versions.
288
+	 *
289
+	 * @return string
290
+	 */
291
+	private function getActiveAddons(): string
292
+	{
293
+		$activeAddons = [];
294
+		$addOns       = EE_Registry::instance()->addons;
295
+		if (! empty($addOns)) {
296
+			foreach ($addOns as $addon) {
297
+				$activeAddons[] = $addon->name() . '@' . $addon->version();
298
+			}
299
+		}
300
+		return implode(',', $activeAddons);
301
+	}
302 302
 }
Please login to merge, or discard this patch.
caffeinated/core/domain/entities/routing/handlers/admin/PueRequests.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -20,125 +20,125 @@
 block discarded – undo
20 20
  */
21 21
 class PueRequests extends Route
22 22
 {
23
-    /**
24
-     * @var   bool
25
-     * @since 5.0.0.p
26
-     */
27
-    private bool $load_pue = true;
23
+	/**
24
+	 * @var   bool
25
+	 * @since 5.0.0.p
26
+	 */
27
+	private bool $load_pue = true;
28 28
 
29 29
 
30
-    /**
31
-     * returns true if the current request matches this route
32
-     *
33
-     * @return bool
34
-     * @since   5.0.0.p
35
-     */
36
-    public function matchesCurrentRequest(): bool
37
-    {
38
-        // route may match, but PUE loading is still conditional based on this filter
39
-        $this->load_pue = (bool) apply_filters('FHEE__EE_System__brew_espresso__load_pue', true);
40
-        return $this->request->isAdmin() || $this->request->isAjax() || $this->request->isActivation();
41
-    }
30
+	/**
31
+	 * returns true if the current request matches this route
32
+	 *
33
+	 * @return bool
34
+	 * @since   5.0.0.p
35
+	 */
36
+	public function matchesCurrentRequest(): bool
37
+	{
38
+		// route may match, but PUE loading is still conditional based on this filter
39
+		$this->load_pue = (bool) apply_filters('FHEE__EE_System__brew_espresso__load_pue', true);
40
+		return $this->request->isAdmin() || $this->request->isAjax() || $this->request->isActivation();
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @since 5.0.0.p
46
-     */
47
-    protected function registerDependencies()
48
-    {
49
-        if ($this->load_pue) {
50
-            $this->dependency_map->registerDependencies(
51
-                'EventEspresso\caffeinated\core\services\licensing\LicenseService',
52
-                [
53
-                    'EventEspresso\caffeinated\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
54
-                    'EventEspresso\caffeinated\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
55
-                ]
56
-            );
57
-            $this->dependency_map->registerDependencies(
58
-                'EventEspresso\caffeinated\core\domain\services\pue\Stats',
59
-                [
60
-                    'EventEspresso\caffeinated\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
61
-                    'EE_Maintenance_Mode'                                              => EE_Dependency_Map::load_from_cache,
62
-                    'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
63
-                ]
64
-            );
65
-            $this->dependency_map->registerDependencies(
66
-                'EventEspresso\caffeinated\core\domain\services\pue\Config',
67
-                [
68
-                    'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
69
-                    'EE_Config'         => EE_Dependency_Map::load_from_cache,
70
-                ]
71
-            );
72
-            $this->dependency_map->registerDependencies(
73
-                'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer',
74
-                [
75
-                    'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
76
-                    'EEM_Event'          => EE_Dependency_Map::load_from_cache,
77
-                    'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
78
-                    'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
79
-                    'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
80
-                    'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
81
-                    'EE_Config'          => EE_Dependency_Map::load_from_cache,
82
-                ]
83
-            );
84
-            $this->dependency_map->registerDependencies(
85
-                'EventEspresso\caffeinated\core\services\licensing\UserExperienceForm',
86
-                [
87
-                    'EE_Core_Config'         => EE_Dependency_Map::load_from_cache,
88
-                    'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache,
89
-                ]
90
-            );
91
-        }
92
-    }
44
+	/**
45
+	 * @since 5.0.0.p
46
+	 */
47
+	protected function registerDependencies()
48
+	{
49
+		if ($this->load_pue) {
50
+			$this->dependency_map->registerDependencies(
51
+				'EventEspresso\caffeinated\core\services\licensing\LicenseService',
52
+				[
53
+					'EventEspresso\caffeinated\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
54
+					'EventEspresso\caffeinated\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
55
+				]
56
+			);
57
+			$this->dependency_map->registerDependencies(
58
+				'EventEspresso\caffeinated\core\domain\services\pue\Stats',
59
+				[
60
+					'EventEspresso\caffeinated\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
61
+					'EE_Maintenance_Mode'                                              => EE_Dependency_Map::load_from_cache,
62
+					'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
63
+				]
64
+			);
65
+			$this->dependency_map->registerDependencies(
66
+				'EventEspresso\caffeinated\core\domain\services\pue\Config',
67
+				[
68
+					'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
69
+					'EE_Config'         => EE_Dependency_Map::load_from_cache,
70
+				]
71
+			);
72
+			$this->dependency_map->registerDependencies(
73
+				'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer',
74
+				[
75
+					'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
76
+					'EEM_Event'          => EE_Dependency_Map::load_from_cache,
77
+					'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
78
+					'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
79
+					'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
80
+					'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
81
+					'EE_Config'          => EE_Dependency_Map::load_from_cache,
82
+				]
83
+			);
84
+			$this->dependency_map->registerDependencies(
85
+				'EventEspresso\caffeinated\core\services\licensing\UserExperienceForm',
86
+				[
87
+					'EE_Core_Config'         => EE_Dependency_Map::load_from_cache,
88
+					'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache,
89
+				]
90
+			);
91
+		}
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     * implements logic required to run during request
97
-     *
98
-     * @return bool
99
-     * @since   5.0.0.p
100
-     */
101
-    protected function requestHandler(): bool
102
-    {
103
-        add_filter(
104
-            'FHEE__EE_Register_Addon__register',
105
-            [RegisterAddonPUE::class, 'registerPUE'],
106
-            10,
107
-            4
108
-        );
109
-        add_action(
110
-            'AHEE__EE_Register_Addon___load_and_init_addon_class',
111
-            [RegisterAddonPUE::class, 'setAddonPueSlug'],
112
-            10,
113
-            2
114
-        );
115
-        if ($this->load_pue) {
116
-            add_action('AHEE__EE_System__brew_espresso__complete', [$this, 'loadLicenseService']);
117
-            add_filter(
118
-                'FHEE__EventEspresso_admin_pages_general_settings_OrganizationSettings__generate__form',
119
-                [$this, 'loadUserExperienceForm']
120
-            );
121
-        }
95
+	/**
96
+	 * implements logic required to run during request
97
+	 *
98
+	 * @return bool
99
+	 * @since   5.0.0.p
100
+	 */
101
+	protected function requestHandler(): bool
102
+	{
103
+		add_filter(
104
+			'FHEE__EE_Register_Addon__register',
105
+			[RegisterAddonPUE::class, 'registerPUE'],
106
+			10,
107
+			4
108
+		);
109
+		add_action(
110
+			'AHEE__EE_Register_Addon___load_and_init_addon_class',
111
+			[RegisterAddonPUE::class, 'setAddonPueSlug'],
112
+			10,
113
+			2
114
+		);
115
+		if ($this->load_pue) {
116
+			add_action('AHEE__EE_System__brew_espresso__complete', [$this, 'loadLicenseService']);
117
+			add_filter(
118
+				'FHEE__EventEspresso_admin_pages_general_settings_OrganizationSettings__generate__form',
119
+				[$this, 'loadUserExperienceForm']
120
+			);
121
+		}
122 122
 
123
-        return true;
124
-    }
123
+		return true;
124
+	}
125 125
 
126 126
 
127
-    public function loadLicenseService()
128
-    {
129
-        /** @var LicenseService $license_service */
130
-        $license_service = $this->loader->getShared(LicenseService::class);
131
-        $license_service->loadPueClient();
132
-    }
127
+	public function loadLicenseService()
128
+	{
129
+		/** @var LicenseService $license_service */
130
+		$license_service = $this->loader->getShared(LicenseService::class);
131
+		$license_service->loadPueClient();
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * @throws EE_Error
137
-     */
138
-    public function loadUserExperienceForm(EE_Form_Section_Proper $org_settings_form): EE_Form_Section_Proper
139
-    {
140
-        /** @var UserExperienceForm $uxip_form */
141
-        $uxip_form = $this->loader->getShared(UserExperienceForm::class);
142
-        return $uxip_form->uxipFormSections($org_settings_form);
143
-    }
135
+	/**
136
+	 * @throws EE_Error
137
+	 */
138
+	public function loadUserExperienceForm(EE_Form_Section_Proper $org_settings_form): EE_Form_Section_Proper
139
+	{
140
+		/** @var UserExperienceForm $uxip_form */
141
+		$uxip_form = $this->loader->getShared(UserExperienceForm::class);
142
+		return $uxip_form->uxipFormSections($org_settings_form);
143
+	}
144 144
 }
Please login to merge, or discard this patch.