Completed
Branch 973/fix-visible-recaptcha (0580c7)
by
unknown
03:03 queued 30s
created
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +926 added lines, -926 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
8 8
 
9 9
 if (! function_exists('espresso_get_template_part')) {
10
-    /**
11
-     * espresso_get_template_part
12
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
13
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
14
-     *
15
-     * @param string $slug The slug name for the generic template.
16
-     * @param string $name The name of the specialised template.
17
-     */
18
-    function espresso_get_template_part($slug = null, $name = null)
19
-    {
20
-        EEH_Template::get_template_part($slug, $name);
21
-    }
10
+	/**
11
+	 * espresso_get_template_part
12
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
13
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
14
+	 *
15
+	 * @param string $slug The slug name for the generic template.
16
+	 * @param string $name The name of the specialised template.
17
+	 */
18
+	function espresso_get_template_part($slug = null, $name = null)
19
+	{
20
+		EEH_Template::get_template_part($slug, $name);
21
+	}
22 22
 }
23 23
 
24 24
 
25 25
 if (! function_exists('espresso_get_object_css_class')) {
26
-    /**
27
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
-     *
29
-     * @param EE_Base_Class $object the EE object the css class is being generated for
30
-     * @param string        $prefix added to the beginning of the generated class
31
-     * @param string        $suffix added to the end of the generated class
32
-     * @return string
33
-     * @throws EE_Error
34
-     * @throws ReflectionException
35
-     */
36
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
37
-    {
38
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
39
-    }
26
+	/**
27
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
+	 *
29
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
30
+	 * @param string        $prefix added to the beginning of the generated class
31
+	 * @param string        $suffix added to the end of the generated class
32
+	 * @return string
33
+	 * @throws EE_Error
34
+	 * @throws ReflectionException
35
+	 */
36
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
37
+	{
38
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
39
+	}
40 40
 }
41 41
 
42 42
 
@@ -51,640 +51,640 @@  discard block
 block discarded – undo
51 51
 class EEH_Template
52 52
 {
53 53
 
54
-    private static $_espresso_themes = [];
55
-
56
-
57
-    /**
58
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
59
-     *
60
-     * @return boolean
61
-     */
62
-    public static function is_espresso_theme()
63
-    {
64
-        return wp_get_theme()->get('TextDomain') === 'event_espresso';
65
-    }
66
-
67
-
68
-    /**
69
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
70
-     *    load its functions.php file ( if not already loaded )
71
-     *
72
-     * @return void
73
-     */
74
-    public static function load_espresso_theme_functions()
75
-    {
76
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
78
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
79
-            }
80
-        }
81
-    }
82
-
83
-
84
-    /**
85
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
86
-     *
87
-     * @return array
88
-     */
89
-    public static function get_espresso_themes()
90
-    {
91
-        if (empty(EEH_Template::$_espresso_themes)) {
92
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
93
-            if (empty($espresso_themes)) {
94
-                return [];
95
-            }
96
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
97
-                unset($espresso_themes[ $key ]);
98
-            }
99
-            EEH_Template::$_espresso_themes = [];
100
-            foreach ($espresso_themes as $espresso_theme) {
101
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
102
-            }
103
-        }
104
-        return EEH_Template::$_espresso_themes;
105
-    }
106
-
107
-
108
-    /**
109
-     * EEH_Template::get_template_part
110
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
111
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
112
-     * filtering based off of the entire template part name
113
-     *
114
-     * @param string $slug The slug name for the generic template.
115
-     * @param string $name The name of the specialised template.
116
-     * @param array  $template_args
117
-     * @param bool   $return_string
118
-     * @return string        the html output for the formatted money value
119
-     */
120
-    public static function get_template_part(
121
-        $slug = null,
122
-        $name = null,
123
-        $template_args = [],
124
-        $return_string = false
125
-    ) {
126
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127
-        $templates = [];
128
-        $name      = (string) $name;
129
-        if ($name != '') {
130
-            $templates[] = "{$slug}-{$name}.php";
131
-        }
132
-        // allow template parts to be turned off via something like:
133
-        // add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
134
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
135
-            return EEH_Template::locate_template($templates, $template_args, true, $return_string);
136
-        }
137
-        return '';
138
-    }
139
-
140
-
141
-    /**
142
-     *    locate_template
143
-     *    locate a template file by looking in the following places, in the following order:
144
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
145
-     *        <assumed full absolute server path>
146
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
147
-     *        <server path up to>/wp-content/uploads/espresso/templates/
148
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
149
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
150
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
151
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
152
-     *        Example:
153
-     *          You are using the WordPress Twenty Sixteen theme,
154
-     *        and you want to customize the "some-event.template.php" template,
155
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
156
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
157
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
158
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
159
-     *        /relative/path/to/some-event.template.php
160
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
161
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
162
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
164
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
165
-     *          Had you passed an absolute path to your template that was in some other location,
166
-     *        ie: "/absolute/path/to/some-event.template.php"
167
-     *          then the search would have been :
168
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
169
-     *        /absolute/path/to/some-event.template.php
170
-     *          and stopped there upon finding it in the second location
171
-     *
172
-     * @param array|string $templates       array of template file names including extension (or just a single string)
173
-     * @param array        $template_args   an array of arguments to be extracted for use in the template
174
-     * @param boolean      $load            whether to pass the located template path on to the
175
-     *                                      EEH_Template::display_template() method or simply return it
176
-     * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
177
-     *                                      string
178
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
179
-     *                                      generate a custom template or not. Used in places where you don't actually
180
-     *                                      load the template, you just want to know if there's a custom version of it.
181
-     * @return mixed
182
-     * @throws DomainException
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidInterfaceException
186
-     */
187
-    public static function locate_template(
188
-        $templates = [],
189
-        $template_args = [],
190
-        $load = true,
191
-        $return_string = true,
192
-        $check_if_custom = false
193
-    ) {
194
-        // first use WP locate_template to check for template in the current theme folder
195
-        $template_path = locate_template($templates);
196
-
197
-        if ($check_if_custom && ! empty($template_path)) {
198
-            return true;
199
-        }
200
-
201
-        // not in the theme
202
-        if (empty($template_path)) {
203
-            // not even a template to look for ?
204
-            if (empty($templates)) {
205
-                $loader = LoaderFactory::getLoader();
206
-                /** @var RequestInterface $request */
207
-                $request = $loader->getShared(RequestInterface::class);
208
-                // get post_type
209
-                $post_type = $request->getRequestParam('post_type');
210
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
211
-                $custom_post_types = $loader->getShared(
212
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
213
-                );
214
-                // get array of EE Custom Post Types
215
-                $EE_CPTs = $custom_post_types->getDefinitions();
216
-                // build template name based on request
217
-                if (isset($EE_CPTs[ $post_type ])) {
218
-                    $archive_or_single = is_archive() ? 'archive' : '';
219
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
220
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
221
-                }
222
-            }
223
-            // currently active EE template theme
224
-            $current_theme = EE_Config::get_current_theme();
225
-
226
-            // array of paths to folders that may contain templates
227
-            $template_folder_paths = [
228
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
229
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
230
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
231
-                EVENT_ESPRESSO_TEMPLATE_DIR,
232
-            ];
233
-
234
-            // add core plugin folders for checking only if we're not $check_if_custom
235
-            if (! $check_if_custom) {
236
-                $core_paths            = [
237
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
238
-                    EE_PUBLIC . $current_theme,
239
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
240
-                    EE_TEMPLATES . $current_theme,
241
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
242
-                    EE_PLUGIN_DIR_PATH,
243
-                ];
244
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
245
-            }
246
-
247
-            // now filter that array
248
-            $template_folder_paths = apply_filters(
249
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
250
-                $template_folder_paths
251
-            );
252
-            $templates             = is_array($templates) ? $templates : [$templates];
253
-            $template_folder_paths =
254
-                is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
255
-            // array to hold all possible template paths
256
-            $full_template_paths = [];
257
-            $file_name           = '';
258
-
259
-            // loop through $templates
260
-            foreach ($templates as $template) {
261
-                // normalize directory separators
262
-                $template                      = EEH_File::standardise_directory_separators($template);
263
-                $file_name                     = basename($template);
264
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
265
-                // while looping through all template folder paths
266
-                foreach ($template_folder_paths as $template_folder_path) {
267
-                    // normalize directory separators
268
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
269
-                    // determine if any common base path exists between the two paths
270
-                    $common_base_path = EEH_Template::_find_common_base_path(
271
-                        [$template_folder_path, $template_path_minus_file_name]
272
-                    );
273
-                    if ($common_base_path !== '') {
274
-                        // both paths have a common base, so just tack the filename onto our search path
275
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
276
-                    } else {
277
-                        // no common base path, so let's just concatenate
278
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
279
-                    }
280
-                    // build up our template locations array by adding our resolved paths
281
-                    $full_template_paths[] = $resolved_path;
282
-                }
283
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
284
-                array_unshift($full_template_paths, $template);
285
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
286
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
287
-            }
288
-            // filter final array of full template paths
289
-            $full_template_paths = apply_filters(
290
-                'FHEE__EEH_Template__locate_template__full_template_paths',
291
-                $full_template_paths,
292
-                $file_name
293
-            );
294
-            // now loop through our final array of template location paths and check each location
295
-            foreach ((array) $full_template_paths as $full_template_path) {
296
-                if (is_readable($full_template_path)) {
297
-                    $template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
298
-                    break;
299
-                }
300
-            }
301
-        }
302
-
303
-        // hook that can be used to display the full template path that will be used
304
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
305
-
306
-        // if we got it and you want to see it...
307
-        if ($template_path && $load && ! $check_if_custom) {
308
-            if ($return_string) {
309
-                return EEH_Template::display_template($template_path, $template_args, true);
310
-            }
311
-            EEH_Template::display_template($template_path, $template_args);
312
-        }
313
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
314
-    }
315
-
316
-
317
-    /**
318
-     * _find_common_base_path
319
-     * given two paths, this determines if there is a common base path between the two
320
-     *
321
-     * @param array $paths
322
-     * @return string
323
-     */
324
-    protected static function _find_common_base_path($paths)
325
-    {
326
-        $last_offset      = 0;
327
-        $common_base_path = '';
328
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
329
-            $dir_length = $index - $last_offset + 1;
330
-            $directory  = substr($paths[0], $last_offset, $dir_length);
331
-            foreach ($paths as $path) {
332
-                if (substr($path, $last_offset, $dir_length) != $directory) {
333
-                    return $common_base_path;
334
-                }
335
-            }
336
-            $common_base_path .= $directory;
337
-            $last_offset      = $index + 1;
338
-        }
339
-        return substr($common_base_path, 0, -1);
340
-    }
341
-
342
-
343
-    /**
344
-     * load and display a template
345
-     *
346
-     * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
347
-     * @param array       $template_args    an array of arguments to be extracted for use in the template
348
-     * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
349
-     *                                      string
350
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
351
-     *                                      not found or is not readable
352
-     * @return string
353
-     * @throws DomainException
354
-     */
355
-    public static function display_template(
356
-        $template_path = false,
357
-        $template_args = [],
358
-        $return_string = false,
359
-        $throw_exceptions = false
360
-    ) {
361
-
362
-        /**
363
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
364
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
365
-         * the display_template method are templates we DON'T want modified (usually because of js
366
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
367
-         * using this.
368
-         *
369
-         * @since 4.6.0
370
-         */
371
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
372
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
373
-
374
-        // you gimme nuttin - YOU GET NUTTIN !!
375
-        if (! $template_path || ! is_readable($template_path)) {
376
-            // ignore whether template is accessible ?
377
-            if ($throw_exceptions) {
378
-                throw new DomainException(
379
-                    esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
380
-                );
381
-            }
382
-            return '';
383
-        }
384
-        // if $template_args are not in an array, then make it so
385
-        if (! is_array($template_args) && ! is_object($template_args)) {
386
-            $template_args = [$template_args];
387
-        }
388
-        extract($template_args, EXTR_SKIP);
389
-
390
-        if ($return_string) {
391
-            // because we want to return a string, we are going to capture the output
392
-            ob_start();
393
-            include($template_path);
394
-            return ob_get_clean();
395
-        }
396
-        include($template_path);
397
-        return '';
398
-    }
399
-
400
-
401
-    /**
402
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
403
-     *
404
-     * @param EE_Base_Class $object the EE object the css class is being generated for
405
-     * @param string        $prefix added to the beginning of the generated class
406
-     * @param string        $suffix added to the end of the generated class
407
-     * @return string
408
-     * @throws EE_Error
409
-     * @throws ReflectionException
410
-     */
411
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
412
-    {
413
-        // in the beginning...
414
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
415
-        // da muddle
416
-        $class = '';
417
-        // the end
418
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
419
-        // is the passed object an EE object ?
420
-        if ($object instanceof EE_Base_Class) {
421
-            // grab the exact type of object
422
-            $obj_class = get_class($object);
423
-            // depending on the type of object...
424
-            switch ($obj_class) {
425
-                // no specifics just yet...
426
-                default:
427
-                    $class = strtolower(str_replace('_', '-', $obj_class));
428
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
429
-            }
430
-        }
431
-        return $prefix . $class . $suffix;
432
-    }
433
-
434
-
435
-    /**
436
-     * EEH_Template::format_currency
437
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
438
-     * the country currency settings from the supplied country ISO code
439
-     *
440
-     * @param float   $amount       raw money value
441
-     * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
442
-     * @param boolean $display_code whether to display the country code (USD). Default = TRUE
443
-     * @param string  $CNT_ISO      2 letter ISO code for a country
444
-     * @param string  $cur_code_span_class
445
-     * @return string        the html output for the formatted money value
446
-     */
447
-    public static function format_currency(
448
-        $amount = null,
449
-        $return_raw = false,
450
-        $display_code = true,
451
-        $CNT_ISO = '',
452
-        $cur_code_span_class = 'currency-code'
453
-    ) {
454
-        // ensure amount was received
455
-        if ($amount === null) {
456
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
457
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
458
-            return '';
459
-        }
460
-        // ensure amount is float
461
-        $amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
462
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
463
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
464
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
465
-        // still a number, or was amount converted to a string like "free" ?
466
-        if (! is_float($amount_formatted)) {
467
-            return esc_html($amount_formatted);
468
-        }
469
-        try {
470
-            // was a country ISO code passed ? if so generate currency config object for that country
471
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
472
-        } catch (Exception $e) {
473
-            // eat exception
474
-            $mny = null;
475
-        }
476
-        // verify results
477
-        if (! $mny instanceof EE_Currency_Config) {
478
-            // set default config country currency settings
479
-            $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
480
-                ? EE_Registry::instance()->CFG->currency
481
-                : new EE_Currency_Config();
482
-        }
483
-        // format float
484
-        $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
485
-        // add formatting ?
486
-        if (! $return_raw) {
487
-            // add currency sign
488
-            if ($mny->sign_b4) {
489
-                if ($amount >= 0) {
490
-                    $amount_formatted = $mny->sign . $amount_formatted;
491
-                } else {
492
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
493
-                }
494
-            } else {
495
-                $amount_formatted = $amount_formatted . $mny->sign;
496
-            }
497
-
498
-            // filter to allow global setting of display_code
499
-            $display_code = (bool) apply_filters(
500
-                'FHEE__EEH_Template__format_currency__display_code',
501
-                $display_code
502
-            );
503
-
504
-            // add currency code ?
505
-            $amount_formatted = $display_code
506
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
507
-                : $amount_formatted;
508
-        }
509
-        // filter results
510
-        $amount_formatted = apply_filters(
511
-            'FHEE__EEH_Template__format_currency__amount_formatted',
512
-            $amount_formatted,
513
-            $mny,
514
-            $return_raw
515
-        );
516
-        // clean up vars
517
-        unset($mny);
518
-        // return formatted currency amount
519
-        return $amount_formatted;
520
-    }
521
-
522
-
523
-    /**
524
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
525
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
526
-     * related status model or model object (i.e. in documentation etc.)
527
-     *
528
-     * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
529
-     *                            match, then 'Unknown' will be returned.
530
-     * @param boolean $plural     Whether to return plural or not
531
-     * @param string  $schema     'UPPER', 'lower', or 'Sentence'
532
-     * @return string             The localized label for the status id.
533
-     * @throws EE_Error
534
-     */
535
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
536
-    {
537
-        $status = EEM_Status::instance()->localized_status(
538
-            [$status_id => esc_html__('unknown', 'event_espresso')],
539
-            $plural,
540
-            $schema
541
-        );
542
-        return $status[ $status_id ];
543
-    }
544
-
545
-
546
-    /**
547
-     * This helper just returns a button or link for the given parameters
548
-     *
549
-     * @param string $url   the url for the link, note that `esc_url` will be called on it
550
-     * @param string $label What is the label you want displayed for the button
551
-     * @param string $class what class is used for the button (defaults to 'button-primary')
552
-     * @param string $icon
553
-     * @param string $title
554
-     * @return string the html output for the button
555
-     */
556
-    public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
557
-    {
558
-        $icon_html = '';
559
-        if (! empty($icon)) {
560
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
561
-            $dashicons = array_filter($dashicons);
562
-            $count     = count($dashicons);
563
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
564
-            foreach ($dashicons as $dashicon) {
565
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
567
-            }
568
-            $icon_html .= $count > 1 ? '</span>' : '';
569
-        }
570
-        // sanitize & escape
571
-        $id    = sanitize_title_with_dashes($label);
572
-        $url   = esc_url_raw($url);
573
-        $class = esc_attr($class);
574
-        $title = esc_attr($title);
575
-        $label = esc_html($label);
576
-        return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
577
-    }
578
-
579
-
580
-    /**
581
-     * This returns a generated link that will load the related help tab on admin pages.
582
-     *
583
-     * @param string      $help_tab_id the id for the connected help tab
584
-     * @param bool|string $page        The page identifier for the page the help tab is on
585
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
586
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
587
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
588
-     * @return string              generated link
589
-     */
590
-    public static function get_help_tab_link(
591
-        $help_tab_id,
592
-        $page = false,
593
-        $action = false,
594
-        $icon_style = false,
595
-        $help_text = false
596
-    ) {
597
-        $allowedtags = AllowedTags::getAllowedTags();
598
-        /** @var RequestInterface $request */
599
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
600
-        $page    = $page ?: $request->getRequestParam('page', '', 'key');
601
-        $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
602
-
603
-
604
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
605
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
606
-        $help_text    = ! $help_text ? '' : $help_text;
607
-        return '<a id="'
608
-               . esc_attr($help_tab_lnk)
609
-               . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
610
-               . esc_attr($icon)
611
-               . '" title="'
612
-               . esc_attr__(
613
-                   'Click to open the \'Help\' tab for more information about this feature.',
614
-                   'event_espresso'
615
-               )
616
-               . '" > '
617
-               . wp_kses($help_text, $allowedtags)
618
-               . ' </a>';
619
-    }
620
-
621
-
622
-    /**
623
-     * This is a helper method to generate a status legend for a given status array.
624
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
625
-     * status_array.
626
-     *
627
-     * @param array  $status_array   array of statuses that will make up the legend. In format:
628
-     *                               array(
629
-     *                               'status_item' => 'status_name'
630
-     *                               )
631
-     * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
632
-     *                               the legend.
633
-     * @return string               html structure for status.
634
-     * @throws EE_Error
635
-     */
636
-    public static function status_legend($status_array, $active_status = '')
637
-    {
638
-        if (! is_array($status_array)) {
639
-            throw new EE_Error(
640
-                esc_html__(
641
-                    'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
642
-                    'event_espresso'
643
-                )
644
-            );
645
-        }
646
-
647
-        $content = '
54
+	private static $_espresso_themes = [];
55
+
56
+
57
+	/**
58
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
59
+	 *
60
+	 * @return boolean
61
+	 */
62
+	public static function is_espresso_theme()
63
+	{
64
+		return wp_get_theme()->get('TextDomain') === 'event_espresso';
65
+	}
66
+
67
+
68
+	/**
69
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
70
+	 *    load its functions.php file ( if not already loaded )
71
+	 *
72
+	 * @return void
73
+	 */
74
+	public static function load_espresso_theme_functions()
75
+	{
76
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
78
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
79
+			}
80
+		}
81
+	}
82
+
83
+
84
+	/**
85
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
86
+	 *
87
+	 * @return array
88
+	 */
89
+	public static function get_espresso_themes()
90
+	{
91
+		if (empty(EEH_Template::$_espresso_themes)) {
92
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
93
+			if (empty($espresso_themes)) {
94
+				return [];
95
+			}
96
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
97
+				unset($espresso_themes[ $key ]);
98
+			}
99
+			EEH_Template::$_espresso_themes = [];
100
+			foreach ($espresso_themes as $espresso_theme) {
101
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
102
+			}
103
+		}
104
+		return EEH_Template::$_espresso_themes;
105
+	}
106
+
107
+
108
+	/**
109
+	 * EEH_Template::get_template_part
110
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
111
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
112
+	 * filtering based off of the entire template part name
113
+	 *
114
+	 * @param string $slug The slug name for the generic template.
115
+	 * @param string $name The name of the specialised template.
116
+	 * @param array  $template_args
117
+	 * @param bool   $return_string
118
+	 * @return string        the html output for the formatted money value
119
+	 */
120
+	public static function get_template_part(
121
+		$slug = null,
122
+		$name = null,
123
+		$template_args = [],
124
+		$return_string = false
125
+	) {
126
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127
+		$templates = [];
128
+		$name      = (string) $name;
129
+		if ($name != '') {
130
+			$templates[] = "{$slug}-{$name}.php";
131
+		}
132
+		// allow template parts to be turned off via something like:
133
+		// add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
134
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
135
+			return EEH_Template::locate_template($templates, $template_args, true, $return_string);
136
+		}
137
+		return '';
138
+	}
139
+
140
+
141
+	/**
142
+	 *    locate_template
143
+	 *    locate a template file by looking in the following places, in the following order:
144
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
145
+	 *        <assumed full absolute server path>
146
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
147
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
148
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
149
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
150
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
151
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
152
+	 *        Example:
153
+	 *          You are using the WordPress Twenty Sixteen theme,
154
+	 *        and you want to customize the "some-event.template.php" template,
155
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
156
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
157
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
158
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
159
+	 *        /relative/path/to/some-event.template.php
160
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
161
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
162
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
164
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
165
+	 *          Had you passed an absolute path to your template that was in some other location,
166
+	 *        ie: "/absolute/path/to/some-event.template.php"
167
+	 *          then the search would have been :
168
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
169
+	 *        /absolute/path/to/some-event.template.php
170
+	 *          and stopped there upon finding it in the second location
171
+	 *
172
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
173
+	 * @param array        $template_args   an array of arguments to be extracted for use in the template
174
+	 * @param boolean      $load            whether to pass the located template path on to the
175
+	 *                                      EEH_Template::display_template() method or simply return it
176
+	 * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
177
+	 *                                      string
178
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
179
+	 *                                      generate a custom template or not. Used in places where you don't actually
180
+	 *                                      load the template, you just want to know if there's a custom version of it.
181
+	 * @return mixed
182
+	 * @throws DomainException
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidInterfaceException
186
+	 */
187
+	public static function locate_template(
188
+		$templates = [],
189
+		$template_args = [],
190
+		$load = true,
191
+		$return_string = true,
192
+		$check_if_custom = false
193
+	) {
194
+		// first use WP locate_template to check for template in the current theme folder
195
+		$template_path = locate_template($templates);
196
+
197
+		if ($check_if_custom && ! empty($template_path)) {
198
+			return true;
199
+		}
200
+
201
+		// not in the theme
202
+		if (empty($template_path)) {
203
+			// not even a template to look for ?
204
+			if (empty($templates)) {
205
+				$loader = LoaderFactory::getLoader();
206
+				/** @var RequestInterface $request */
207
+				$request = $loader->getShared(RequestInterface::class);
208
+				// get post_type
209
+				$post_type = $request->getRequestParam('post_type');
210
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
211
+				$custom_post_types = $loader->getShared(
212
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
213
+				);
214
+				// get array of EE Custom Post Types
215
+				$EE_CPTs = $custom_post_types->getDefinitions();
216
+				// build template name based on request
217
+				if (isset($EE_CPTs[ $post_type ])) {
218
+					$archive_or_single = is_archive() ? 'archive' : '';
219
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
220
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
221
+				}
222
+			}
223
+			// currently active EE template theme
224
+			$current_theme = EE_Config::get_current_theme();
225
+
226
+			// array of paths to folders that may contain templates
227
+			$template_folder_paths = [
228
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
229
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
230
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
231
+				EVENT_ESPRESSO_TEMPLATE_DIR,
232
+			];
233
+
234
+			// add core plugin folders for checking only if we're not $check_if_custom
235
+			if (! $check_if_custom) {
236
+				$core_paths            = [
237
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
238
+					EE_PUBLIC . $current_theme,
239
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
240
+					EE_TEMPLATES . $current_theme,
241
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
242
+					EE_PLUGIN_DIR_PATH,
243
+				];
244
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
245
+			}
246
+
247
+			// now filter that array
248
+			$template_folder_paths = apply_filters(
249
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
250
+				$template_folder_paths
251
+			);
252
+			$templates             = is_array($templates) ? $templates : [$templates];
253
+			$template_folder_paths =
254
+				is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
255
+			// array to hold all possible template paths
256
+			$full_template_paths = [];
257
+			$file_name           = '';
258
+
259
+			// loop through $templates
260
+			foreach ($templates as $template) {
261
+				// normalize directory separators
262
+				$template                      = EEH_File::standardise_directory_separators($template);
263
+				$file_name                     = basename($template);
264
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
265
+				// while looping through all template folder paths
266
+				foreach ($template_folder_paths as $template_folder_path) {
267
+					// normalize directory separators
268
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
269
+					// determine if any common base path exists between the two paths
270
+					$common_base_path = EEH_Template::_find_common_base_path(
271
+						[$template_folder_path, $template_path_minus_file_name]
272
+					);
273
+					if ($common_base_path !== '') {
274
+						// both paths have a common base, so just tack the filename onto our search path
275
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
276
+					} else {
277
+						// no common base path, so let's just concatenate
278
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
279
+					}
280
+					// build up our template locations array by adding our resolved paths
281
+					$full_template_paths[] = $resolved_path;
282
+				}
283
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
284
+				array_unshift($full_template_paths, $template);
285
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
286
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
287
+			}
288
+			// filter final array of full template paths
289
+			$full_template_paths = apply_filters(
290
+				'FHEE__EEH_Template__locate_template__full_template_paths',
291
+				$full_template_paths,
292
+				$file_name
293
+			);
294
+			// now loop through our final array of template location paths and check each location
295
+			foreach ((array) $full_template_paths as $full_template_path) {
296
+				if (is_readable($full_template_path)) {
297
+					$template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
298
+					break;
299
+				}
300
+			}
301
+		}
302
+
303
+		// hook that can be used to display the full template path that will be used
304
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
305
+
306
+		// if we got it and you want to see it...
307
+		if ($template_path && $load && ! $check_if_custom) {
308
+			if ($return_string) {
309
+				return EEH_Template::display_template($template_path, $template_args, true);
310
+			}
311
+			EEH_Template::display_template($template_path, $template_args);
312
+		}
313
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
314
+	}
315
+
316
+
317
+	/**
318
+	 * _find_common_base_path
319
+	 * given two paths, this determines if there is a common base path between the two
320
+	 *
321
+	 * @param array $paths
322
+	 * @return string
323
+	 */
324
+	protected static function _find_common_base_path($paths)
325
+	{
326
+		$last_offset      = 0;
327
+		$common_base_path = '';
328
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
329
+			$dir_length = $index - $last_offset + 1;
330
+			$directory  = substr($paths[0], $last_offset, $dir_length);
331
+			foreach ($paths as $path) {
332
+				if (substr($path, $last_offset, $dir_length) != $directory) {
333
+					return $common_base_path;
334
+				}
335
+			}
336
+			$common_base_path .= $directory;
337
+			$last_offset      = $index + 1;
338
+		}
339
+		return substr($common_base_path, 0, -1);
340
+	}
341
+
342
+
343
+	/**
344
+	 * load and display a template
345
+	 *
346
+	 * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
347
+	 * @param array       $template_args    an array of arguments to be extracted for use in the template
348
+	 * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
349
+	 *                                      string
350
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
351
+	 *                                      not found or is not readable
352
+	 * @return string
353
+	 * @throws DomainException
354
+	 */
355
+	public static function display_template(
356
+		$template_path = false,
357
+		$template_args = [],
358
+		$return_string = false,
359
+		$throw_exceptions = false
360
+	) {
361
+
362
+		/**
363
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
364
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
365
+		 * the display_template method are templates we DON'T want modified (usually because of js
366
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
367
+		 * using this.
368
+		 *
369
+		 * @since 4.6.0
370
+		 */
371
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
372
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
373
+
374
+		// you gimme nuttin - YOU GET NUTTIN !!
375
+		if (! $template_path || ! is_readable($template_path)) {
376
+			// ignore whether template is accessible ?
377
+			if ($throw_exceptions) {
378
+				throw new DomainException(
379
+					esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
380
+				);
381
+			}
382
+			return '';
383
+		}
384
+		// if $template_args are not in an array, then make it so
385
+		if (! is_array($template_args) && ! is_object($template_args)) {
386
+			$template_args = [$template_args];
387
+		}
388
+		extract($template_args, EXTR_SKIP);
389
+
390
+		if ($return_string) {
391
+			// because we want to return a string, we are going to capture the output
392
+			ob_start();
393
+			include($template_path);
394
+			return ob_get_clean();
395
+		}
396
+		include($template_path);
397
+		return '';
398
+	}
399
+
400
+
401
+	/**
402
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
403
+	 *
404
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
405
+	 * @param string        $prefix added to the beginning of the generated class
406
+	 * @param string        $suffix added to the end of the generated class
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 * @throws ReflectionException
410
+	 */
411
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
412
+	{
413
+		// in the beginning...
414
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
415
+		// da muddle
416
+		$class = '';
417
+		// the end
418
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
419
+		// is the passed object an EE object ?
420
+		if ($object instanceof EE_Base_Class) {
421
+			// grab the exact type of object
422
+			$obj_class = get_class($object);
423
+			// depending on the type of object...
424
+			switch ($obj_class) {
425
+				// no specifics just yet...
426
+				default:
427
+					$class = strtolower(str_replace('_', '-', $obj_class));
428
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
429
+			}
430
+		}
431
+		return $prefix . $class . $suffix;
432
+	}
433
+
434
+
435
+	/**
436
+	 * EEH_Template::format_currency
437
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
438
+	 * the country currency settings from the supplied country ISO code
439
+	 *
440
+	 * @param float   $amount       raw money value
441
+	 * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
442
+	 * @param boolean $display_code whether to display the country code (USD). Default = TRUE
443
+	 * @param string  $CNT_ISO      2 letter ISO code for a country
444
+	 * @param string  $cur_code_span_class
445
+	 * @return string        the html output for the formatted money value
446
+	 */
447
+	public static function format_currency(
448
+		$amount = null,
449
+		$return_raw = false,
450
+		$display_code = true,
451
+		$CNT_ISO = '',
452
+		$cur_code_span_class = 'currency-code'
453
+	) {
454
+		// ensure amount was received
455
+		if ($amount === null) {
456
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
457
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
458
+			return '';
459
+		}
460
+		// ensure amount is float
461
+		$amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
462
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
463
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
464
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
465
+		// still a number, or was amount converted to a string like "free" ?
466
+		if (! is_float($amount_formatted)) {
467
+			return esc_html($amount_formatted);
468
+		}
469
+		try {
470
+			// was a country ISO code passed ? if so generate currency config object for that country
471
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
472
+		} catch (Exception $e) {
473
+			// eat exception
474
+			$mny = null;
475
+		}
476
+		// verify results
477
+		if (! $mny instanceof EE_Currency_Config) {
478
+			// set default config country currency settings
479
+			$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
480
+				? EE_Registry::instance()->CFG->currency
481
+				: new EE_Currency_Config();
482
+		}
483
+		// format float
484
+		$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
485
+		// add formatting ?
486
+		if (! $return_raw) {
487
+			// add currency sign
488
+			if ($mny->sign_b4) {
489
+				if ($amount >= 0) {
490
+					$amount_formatted = $mny->sign . $amount_formatted;
491
+				} else {
492
+					$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
493
+				}
494
+			} else {
495
+				$amount_formatted = $amount_formatted . $mny->sign;
496
+			}
497
+
498
+			// filter to allow global setting of display_code
499
+			$display_code = (bool) apply_filters(
500
+				'FHEE__EEH_Template__format_currency__display_code',
501
+				$display_code
502
+			);
503
+
504
+			// add currency code ?
505
+			$amount_formatted = $display_code
506
+				? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
507
+				: $amount_formatted;
508
+		}
509
+		// filter results
510
+		$amount_formatted = apply_filters(
511
+			'FHEE__EEH_Template__format_currency__amount_formatted',
512
+			$amount_formatted,
513
+			$mny,
514
+			$return_raw
515
+		);
516
+		// clean up vars
517
+		unset($mny);
518
+		// return formatted currency amount
519
+		return $amount_formatted;
520
+	}
521
+
522
+
523
+	/**
524
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
525
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
526
+	 * related status model or model object (i.e. in documentation etc.)
527
+	 *
528
+	 * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
529
+	 *                            match, then 'Unknown' will be returned.
530
+	 * @param boolean $plural     Whether to return plural or not
531
+	 * @param string  $schema     'UPPER', 'lower', or 'Sentence'
532
+	 * @return string             The localized label for the status id.
533
+	 * @throws EE_Error
534
+	 */
535
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
536
+	{
537
+		$status = EEM_Status::instance()->localized_status(
538
+			[$status_id => esc_html__('unknown', 'event_espresso')],
539
+			$plural,
540
+			$schema
541
+		);
542
+		return $status[ $status_id ];
543
+	}
544
+
545
+
546
+	/**
547
+	 * This helper just returns a button or link for the given parameters
548
+	 *
549
+	 * @param string $url   the url for the link, note that `esc_url` will be called on it
550
+	 * @param string $label What is the label you want displayed for the button
551
+	 * @param string $class what class is used for the button (defaults to 'button-primary')
552
+	 * @param string $icon
553
+	 * @param string $title
554
+	 * @return string the html output for the button
555
+	 */
556
+	public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
557
+	{
558
+		$icon_html = '';
559
+		if (! empty($icon)) {
560
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
561
+			$dashicons = array_filter($dashicons);
562
+			$count     = count($dashicons);
563
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
564
+			foreach ($dashicons as $dashicon) {
565
+				$type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
567
+			}
568
+			$icon_html .= $count > 1 ? '</span>' : '';
569
+		}
570
+		// sanitize & escape
571
+		$id    = sanitize_title_with_dashes($label);
572
+		$url   = esc_url_raw($url);
573
+		$class = esc_attr($class);
574
+		$title = esc_attr($title);
575
+		$label = esc_html($label);
576
+		return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
577
+	}
578
+
579
+
580
+	/**
581
+	 * This returns a generated link that will load the related help tab on admin pages.
582
+	 *
583
+	 * @param string      $help_tab_id the id for the connected help tab
584
+	 * @param bool|string $page        The page identifier for the page the help tab is on
585
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
586
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
587
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
588
+	 * @return string              generated link
589
+	 */
590
+	public static function get_help_tab_link(
591
+		$help_tab_id,
592
+		$page = false,
593
+		$action = false,
594
+		$icon_style = false,
595
+		$help_text = false
596
+	) {
597
+		$allowedtags = AllowedTags::getAllowedTags();
598
+		/** @var RequestInterface $request */
599
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
600
+		$page    = $page ?: $request->getRequestParam('page', '', 'key');
601
+		$action  = $action ?: $request->getRequestParam('action', 'default', 'key');
602
+
603
+
604
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
605
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
606
+		$help_text    = ! $help_text ? '' : $help_text;
607
+		return '<a id="'
608
+			   . esc_attr($help_tab_lnk)
609
+			   . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
610
+			   . esc_attr($icon)
611
+			   . '" title="'
612
+			   . esc_attr__(
613
+				   'Click to open the \'Help\' tab for more information about this feature.',
614
+				   'event_espresso'
615
+			   )
616
+			   . '" > '
617
+			   . wp_kses($help_text, $allowedtags)
618
+			   . ' </a>';
619
+	}
620
+
621
+
622
+	/**
623
+	 * This is a helper method to generate a status legend for a given status array.
624
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
625
+	 * status_array.
626
+	 *
627
+	 * @param array  $status_array   array of statuses that will make up the legend. In format:
628
+	 *                               array(
629
+	 *                               'status_item' => 'status_name'
630
+	 *                               )
631
+	 * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
632
+	 *                               the legend.
633
+	 * @return string               html structure for status.
634
+	 * @throws EE_Error
635
+	 */
636
+	public static function status_legend($status_array, $active_status = '')
637
+	{
638
+		if (! is_array($status_array)) {
639
+			throw new EE_Error(
640
+				esc_html__(
641
+					'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
642
+					'event_espresso'
643
+				)
644
+			);
645
+		}
646
+
647
+		$content = '
648 648
             <div class="ee-list-table-legend-container">
649 649
                 <h4 class="status-legend-title">
650 650
                     ' . esc_html__('Status Legend', 'event_espresso') . '
651 651
                 </h4>
652 652
                 <dl class="ee-list-table-legend">';
653 653
 
654
-        foreach ($status_array as $item => $status) {
655
-            $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
656
-            $content      .= '
654
+		foreach ($status_array as $item => $status) {
655
+			$active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
656
+			$content      .= '
657 657
                     <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
658 658
                         <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
659 659
                         <span class="ee-legend-description">
660 660
                             ' . EEH_Template::pretty_status($status, false, 'sentence') . '
661 661
                         </span>
662 662
                     </dt>';
663
-        }
663
+		}
664 664
 
665
-        $content .= '
665
+		$content .= '
666 666
                 </dl>
667 667
             </div>
668 668
 ';
669
-        return $content;
670
-    }
671
-
672
-
673
-    /**
674
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
675
-     * that's nice for presenting in the wp admin
676
-     *
677
-     * @param mixed $data
678
-     * @return string
679
-     */
680
-    public static function layout_array_as_table($data)
681
-    {
682
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
683
-            $data = (array) $data;
684
-        }
685
-        ob_start();
686
-        if (is_array($data)) {
687
-            if (EEH_Array::is_associative_array($data)) { ?>
669
+		return $content;
670
+	}
671
+
672
+
673
+	/**
674
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
675
+	 * that's nice for presenting in the wp admin
676
+	 *
677
+	 * @param mixed $data
678
+	 * @return string
679
+	 */
680
+	public static function layout_array_as_table($data)
681
+	{
682
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
683
+			$data = (array) $data;
684
+		}
685
+		ob_start();
686
+		if (is_array($data)) {
687
+			if (EEH_Array::is_associative_array($data)) { ?>
688 688
                 <table class="widefat">
689 689
                     <tbody>
690 690
                     <?php foreach ($data as $data_key => $data_values) { ?>
@@ -702,292 +702,292 @@  discard block
 block discarded – undo
702 702
             <?php } else { ?>
703 703
                 <ul>
704 704
                     <?php
705
-                    foreach ($data as $datum) {
706
-                        echo "<li>";
707
-                        echo self::layout_array_as_table($datum);
708
-                        echo "</li>";
709
-                    } ?>
705
+					foreach ($data as $datum) {
706
+						echo "<li>";
707
+						echo self::layout_array_as_table($datum);
708
+						echo "</li>";
709
+					} ?>
710 710
                 </ul>
711 711
             <?php }
712
-        } else {
713
-            // simple value
714
-            echo esc_html($data);
715
-        }
716
-        return ob_get_clean();
717
-    }
718
-
719
-
720
-    /**
721
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
722
-     *
723
-     * @param        $total_items
724
-     * @param        $current
725
-     * @param        $per_page
726
-     * @param        $url
727
-     * @param bool   $show_num_field
728
-     * @param string $paged_arg_name
729
-     * @param array  $items_label
730
-     * @see   self:get_paging_html() for argument docs.
731
-     * @since 4.4.0
732
-     */
733
-    public static function paging_html(
734
-        $total_items,
735
-        $current,
736
-        $per_page,
737
-        $url,
738
-        $show_num_field = true,
739
-        $paged_arg_name = 'paged',
740
-        $items_label = []
741
-    ) {
742
-        echo self::get_paging_html(
743
-            $total_items,
744
-            $current,
745
-            $per_page,
746
-            $url,
747
-            $show_num_field,
748
-            $paged_arg_name,
749
-            $items_label
750
-        );
751
-    }
752
-
753
-
754
-    /**
755
-     * A method for generating paging similar to WP_List_Table
756
-     *
757
-     * @param integer $total_items      How many total items there are to page.
758
-     * @param integer $current          What the current page is.
759
-     * @param integer $per_page         How many items per page.
760
-     * @param string  $url              What the base url for page links is.
761
-     * @param boolean $show_num_field   Whether to show the input for changing page number.
762
-     * @param string  $paged_arg_name   The name of the key for the paged query argument.
763
-     * @param array   $items_label      An array of singular/plural values for the items label:
764
-     *                                  array(
765
-     *                                  'single' => 'item',
766
-     *                                  'plural' => 'items'
767
-     *                                  )
768
-     * @return  string
769
-     * @since    4.4.0
770
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
771
-     */
772
-    public static function get_paging_html(
773
-        $total_items,
774
-        $current,
775
-        $per_page,
776
-        $url,
777
-        $show_num_field = true,
778
-        $paged_arg_name = 'paged',
779
-        $items_label = []
780
-    ) {
781
-        $page_links     = [];
782
-        $disable_first  = $disable_last = '';
783
-        $total_items    = (int) $total_items;
784
-        $per_page       = (int) $per_page;
785
-        $current        = (int) $current;
786
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
787
-
788
-        // filter items_label
789
-        $items_label = apply_filters(
790
-            'FHEE__EEH_Template__get_paging_html__items_label',
791
-            $items_label
792
-        );
793
-
794
-        if (
795
-            empty($items_label)
796
-            || ! is_array($items_label)
797
-            || ! isset($items_label['single'])
798
-            || ! isset($items_label['plural'])
799
-        ) {
800
-            $items_label = [
801
-                'single' => esc_html__('1 item', 'event_espresso'),
802
-                'plural' => esc_html__('%s items', 'event_espresso'),
803
-            ];
804
-        } else {
805
-            $items_label = [
806
-                'single' => '1 ' . esc_html($items_label['single']),
807
-                'plural' => '%s ' . esc_html($items_label['plural']),
808
-            ];
809
-        }
810
-
811
-        $total_pages = ceil($total_items / $per_page);
812
-
813
-        if ($total_pages <= 1) {
814
-            return '';
815
-        }
816
-
817
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
818
-
819
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
820
-
821
-        if ($current === 1) {
822
-            $disable_first = ' disabled';
823
-        }
824
-        if ($current == $total_pages) {
825
-            $disable_last = ' disabled';
826
-        }
827
-
828
-        $page_links[] = sprintf(
829
-            "<a class='%s' title='%s' href='%s'>%s</a>",
830
-            'first-page' . $disable_first,
831
-            esc_attr__('Go to the first page', 'event_espresso'),
832
-            esc_url_raw(remove_query_arg($paged_arg_name, $url)),
833
-            '&laquo;'
834
-        );
835
-
836
-        $page_links[] = sprintf(
837
-            '<a class="%s" title="%s" href="%s">%s</a>',
838
-            'prev-page' . $disable_first,
839
-            esc_attr__('Go to the previous page', 'event_espresso'),
840
-            esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
841
-            '&lsaquo;'
842
-        );
843
-
844
-        if (! $show_num_field) {
845
-            $html_current_page = $current;
846
-        } else {
847
-            $html_current_page = sprintf(
848
-                "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
849
-                esc_attr__('Current page', 'event_espresso'),
850
-                esc_attr($current),
851
-                strlen($total_pages)
852
-            );
853
-        }
854
-
855
-        $html_total_pages = sprintf(
856
-            '<span class="total-pages">%s</span>',
857
-            number_format_i18n($total_pages)
858
-        );
859
-        $page_links[]     = sprintf(
860
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
861
-            $html_current_page,
862
-            $html_total_pages,
863
-            '<span class="paging-input">',
864
-            '</span>'
865
-        );
866
-
867
-        $page_links[] = sprintf(
868
-            '<a class="%s" title="%s" href="%s">%s</a>',
869
-            'next-page' . $disable_last,
870
-            esc_attr__('Go to the next page', 'event_espresso'),
871
-            esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
872
-            '&rsaquo;'
873
-        );
874
-
875
-        $page_links[] = sprintf(
876
-            '<a class="%s" title="%s" href="%s">%s</a>',
877
-            'last-page' . $disable_last,
878
-            esc_attr__('Go to the last page', 'event_espresso'),
879
-            esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
880
-            '&raquo;'
881
-        );
882
-
883
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
884
-        // set page class
885
-        if ($total_pages) {
886
-            $page_class = $total_pages < 2 ? ' one-page' : '';
887
-        } else {
888
-            $page_class = ' no-pages';
889
-        }
890
-
891
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
892
-    }
893
-
894
-
895
-    /**
896
-     * @param string $wrap_class
897
-     * @param string $wrap_id
898
-     * @return string
899
-     */
900
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
901
-    {
902
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
903
-        if (
904
-            ! $admin
905
-            && ! apply_filters(
906
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
907
-                EE_Registry::instance()->CFG->admin->show_reg_footer
908
-            )
909
-        ) {
910
-            return '';
911
-        }
912
-        $tag        = $admin ? 'span' : 'div';
913
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
914
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
915
-        $attributes .= ! empty($wrap_class)
916
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
917
-            : ' class="powered-by-event-espresso-credit"';
918
-        $query_args = array_merge(
919
-            [
920
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
921
-                'utm_source'   => 'powered_by_event_espresso',
922
-                'utm_medium'   => 'link',
923
-                'utm_campaign' => 'powered_by',
924
-            ],
925
-            $query_args
926
-        );
927
-        $powered_by = apply_filters(
928
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
929
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
930
-        );
931
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
932
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
933
-        return (string) apply_filters(
934
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
935
-            sprintf(
936
-                esc_html_x(
937
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
938
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
939
-                    'event_espresso'
940
-                ),
941
-                "<{$tag}{$attributes}>",
942
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
943
-                $admin ? '' : '<br />'
944
-            ),
945
-            $wrap_class,
946
-            $wrap_id
947
-        );
948
-    }
949
-
950
-
951
-    /**
952
-     * @param string $image_name
953
-     * @return string|null
954
-     * @since   4.10.14.p
955
-     */
956
-    public static function getScreenshotUrl($image_name)
957
-    {
958
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
959
-    }
712
+		} else {
713
+			// simple value
714
+			echo esc_html($data);
715
+		}
716
+		return ob_get_clean();
717
+	}
718
+
719
+
720
+	/**
721
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
722
+	 *
723
+	 * @param        $total_items
724
+	 * @param        $current
725
+	 * @param        $per_page
726
+	 * @param        $url
727
+	 * @param bool   $show_num_field
728
+	 * @param string $paged_arg_name
729
+	 * @param array  $items_label
730
+	 * @see   self:get_paging_html() for argument docs.
731
+	 * @since 4.4.0
732
+	 */
733
+	public static function paging_html(
734
+		$total_items,
735
+		$current,
736
+		$per_page,
737
+		$url,
738
+		$show_num_field = true,
739
+		$paged_arg_name = 'paged',
740
+		$items_label = []
741
+	) {
742
+		echo self::get_paging_html(
743
+			$total_items,
744
+			$current,
745
+			$per_page,
746
+			$url,
747
+			$show_num_field,
748
+			$paged_arg_name,
749
+			$items_label
750
+		);
751
+	}
752
+
753
+
754
+	/**
755
+	 * A method for generating paging similar to WP_List_Table
756
+	 *
757
+	 * @param integer $total_items      How many total items there are to page.
758
+	 * @param integer $current          What the current page is.
759
+	 * @param integer $per_page         How many items per page.
760
+	 * @param string  $url              What the base url for page links is.
761
+	 * @param boolean $show_num_field   Whether to show the input for changing page number.
762
+	 * @param string  $paged_arg_name   The name of the key for the paged query argument.
763
+	 * @param array   $items_label      An array of singular/plural values for the items label:
764
+	 *                                  array(
765
+	 *                                  'single' => 'item',
766
+	 *                                  'plural' => 'items'
767
+	 *                                  )
768
+	 * @return  string
769
+	 * @since    4.4.0
770
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
771
+	 */
772
+	public static function get_paging_html(
773
+		$total_items,
774
+		$current,
775
+		$per_page,
776
+		$url,
777
+		$show_num_field = true,
778
+		$paged_arg_name = 'paged',
779
+		$items_label = []
780
+	) {
781
+		$page_links     = [];
782
+		$disable_first  = $disable_last = '';
783
+		$total_items    = (int) $total_items;
784
+		$per_page       = (int) $per_page;
785
+		$current        = (int) $current;
786
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
787
+
788
+		// filter items_label
789
+		$items_label = apply_filters(
790
+			'FHEE__EEH_Template__get_paging_html__items_label',
791
+			$items_label
792
+		);
793
+
794
+		if (
795
+			empty($items_label)
796
+			|| ! is_array($items_label)
797
+			|| ! isset($items_label['single'])
798
+			|| ! isset($items_label['plural'])
799
+		) {
800
+			$items_label = [
801
+				'single' => esc_html__('1 item', 'event_espresso'),
802
+				'plural' => esc_html__('%s items', 'event_espresso'),
803
+			];
804
+		} else {
805
+			$items_label = [
806
+				'single' => '1 ' . esc_html($items_label['single']),
807
+				'plural' => '%s ' . esc_html($items_label['plural']),
808
+			];
809
+		}
810
+
811
+		$total_pages = ceil($total_items / $per_page);
812
+
813
+		if ($total_pages <= 1) {
814
+			return '';
815
+		}
816
+
817
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
818
+
819
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
820
+
821
+		if ($current === 1) {
822
+			$disable_first = ' disabled';
823
+		}
824
+		if ($current == $total_pages) {
825
+			$disable_last = ' disabled';
826
+		}
827
+
828
+		$page_links[] = sprintf(
829
+			"<a class='%s' title='%s' href='%s'>%s</a>",
830
+			'first-page' . $disable_first,
831
+			esc_attr__('Go to the first page', 'event_espresso'),
832
+			esc_url_raw(remove_query_arg($paged_arg_name, $url)),
833
+			'&laquo;'
834
+		);
835
+
836
+		$page_links[] = sprintf(
837
+			'<a class="%s" title="%s" href="%s">%s</a>',
838
+			'prev-page' . $disable_first,
839
+			esc_attr__('Go to the previous page', 'event_espresso'),
840
+			esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
841
+			'&lsaquo;'
842
+		);
843
+
844
+		if (! $show_num_field) {
845
+			$html_current_page = $current;
846
+		} else {
847
+			$html_current_page = sprintf(
848
+				"<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
849
+				esc_attr__('Current page', 'event_espresso'),
850
+				esc_attr($current),
851
+				strlen($total_pages)
852
+			);
853
+		}
854
+
855
+		$html_total_pages = sprintf(
856
+			'<span class="total-pages">%s</span>',
857
+			number_format_i18n($total_pages)
858
+		);
859
+		$page_links[]     = sprintf(
860
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
861
+			$html_current_page,
862
+			$html_total_pages,
863
+			'<span class="paging-input">',
864
+			'</span>'
865
+		);
866
+
867
+		$page_links[] = sprintf(
868
+			'<a class="%s" title="%s" href="%s">%s</a>',
869
+			'next-page' . $disable_last,
870
+			esc_attr__('Go to the next page', 'event_espresso'),
871
+			esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
872
+			'&rsaquo;'
873
+		);
874
+
875
+		$page_links[] = sprintf(
876
+			'<a class="%s" title="%s" href="%s">%s</a>',
877
+			'last-page' . $disable_last,
878
+			esc_attr__('Go to the last page', 'event_espresso'),
879
+			esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
880
+			'&raquo;'
881
+		);
882
+
883
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
884
+		// set page class
885
+		if ($total_pages) {
886
+			$page_class = $total_pages < 2 ? ' one-page' : '';
887
+		} else {
888
+			$page_class = ' no-pages';
889
+		}
890
+
891
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
892
+	}
893
+
894
+
895
+	/**
896
+	 * @param string $wrap_class
897
+	 * @param string $wrap_id
898
+	 * @return string
899
+	 */
900
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
901
+	{
902
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
903
+		if (
904
+			! $admin
905
+			&& ! apply_filters(
906
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
907
+				EE_Registry::instance()->CFG->admin->show_reg_footer
908
+			)
909
+		) {
910
+			return '';
911
+		}
912
+		$tag        = $admin ? 'span' : 'div';
913
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
914
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
915
+		$attributes .= ! empty($wrap_class)
916
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
917
+			: ' class="powered-by-event-espresso-credit"';
918
+		$query_args = array_merge(
919
+			[
920
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
921
+				'utm_source'   => 'powered_by_event_espresso',
922
+				'utm_medium'   => 'link',
923
+				'utm_campaign' => 'powered_by',
924
+			],
925
+			$query_args
926
+		);
927
+		$powered_by = apply_filters(
928
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
929
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
930
+		);
931
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
932
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
933
+		return (string) apply_filters(
934
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
935
+			sprintf(
936
+				esc_html_x(
937
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
938
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
939
+					'event_espresso'
940
+				),
941
+				"<{$tag}{$attributes}>",
942
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
943
+				$admin ? '' : '<br />'
944
+			),
945
+			$wrap_class,
946
+			$wrap_id
947
+		);
948
+	}
949
+
950
+
951
+	/**
952
+	 * @param string $image_name
953
+	 * @return string|null
954
+	 * @since   4.10.14.p
955
+	 */
956
+	public static function getScreenshotUrl($image_name)
957
+	{
958
+		return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
959
+	}
960 960
 }
961 961
 
962 962
 
963 963
 if (! function_exists('espresso_pagination')) {
964
-    /**
965
-     *    espresso_pagination
966
-     *
967
-     * @access    public
968
-     * @return    void
969
-     */
970
-    function espresso_pagination()
971
-    {
972
-        global $wp_query;
973
-        $big        = 999999999; // need an unlikely integer
974
-        $pagination = paginate_links(
975
-            [
976
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
977
-                'format'       => '?paged=%#%',
978
-                'current'      => max(1, get_query_var('paged')),
979
-                'total'        => $wp_query->max_num_pages,
980
-                'show_all'     => true,
981
-                'end_size'     => 10,
982
-                'mid_size'     => 6,
983
-                'prev_next'    => true,
984
-                'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
985
-                'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
986
-                'type'         => 'plain',
987
-                'add_args'     => false,
988
-                'add_fragment' => '',
989
-            ]
990
-        );
991
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
992
-    }
964
+	/**
965
+	 *    espresso_pagination
966
+	 *
967
+	 * @access    public
968
+	 * @return    void
969
+	 */
970
+	function espresso_pagination()
971
+	{
972
+		global $wp_query;
973
+		$big        = 999999999; // need an unlikely integer
974
+		$pagination = paginate_links(
975
+			[
976
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
977
+				'format'       => '?paged=%#%',
978
+				'current'      => max(1, get_query_var('paged')),
979
+				'total'        => $wp_query->max_num_pages,
980
+				'show_all'     => true,
981
+				'end_size'     => 10,
982
+				'mid_size'     => 6,
983
+				'prev_next'    => true,
984
+				'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
985
+				'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
986
+				'type'         => 'plain',
987
+				'add_args'     => false,
988
+				'add_fragment' => '',
989
+			]
990
+		);
991
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
992
+	}
993 993
 }
994 994
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
8 8
 
9
-if (! function_exists('espresso_get_template_part')) {
9
+if ( ! function_exists('espresso_get_template_part')) {
10 10
     /**
11 11
      * espresso_get_template_part
12 12
      * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 }
23 23
 
24 24
 
25
-if (! function_exists('espresso_get_object_css_class')) {
25
+if ( ! function_exists('espresso_get_object_css_class')) {
26 26
     /**
27 27
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28 28
      *
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function load_espresso_theme_functions()
75 75
     {
76
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
78
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
76
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
78
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
79 79
             }
80 80
         }
81 81
     }
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
     public static function get_espresso_themes()
90 90
     {
91 91
         if (empty(EEH_Template::$_espresso_themes)) {
92
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
93 93
             if (empty($espresso_themes)) {
94 94
                 return [];
95 95
             }
96 96
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
97
-                unset($espresso_themes[ $key ]);
97
+                unset($espresso_themes[$key]);
98 98
             }
99 99
             EEH_Template::$_espresso_themes = [];
100 100
             foreach ($espresso_themes as $espresso_theme) {
101
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
102 102
             }
103 103
         }
104 104
         return EEH_Template::$_espresso_themes;
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
                 // get array of EE Custom Post Types
215 215
                 $EE_CPTs = $custom_post_types->getDefinitions();
216 216
                 // build template name based on request
217
-                if (isset($EE_CPTs[ $post_type ])) {
217
+                if (isset($EE_CPTs[$post_type])) {
218 218
                     $archive_or_single = is_archive() ? 'archive' : '';
219 219
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
220
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
220
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
221 221
                 }
222 222
             }
223 223
             // currently active EE template theme
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
             // array of paths to folders that may contain templates
227 227
             $template_folder_paths = [
228 228
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
229
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
230 230
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
231 231
                 EVENT_ESPRESSO_TEMPLATE_DIR,
232 232
             ];
233 233
 
234 234
             // add core plugin folders for checking only if we're not $check_if_custom
235
-            if (! $check_if_custom) {
236
-                $core_paths            = [
235
+            if ( ! $check_if_custom) {
236
+                $core_paths = [
237 237
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
238
-                    EE_PUBLIC . $current_theme,
238
+                    EE_PUBLIC.$current_theme,
239 239
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
240
-                    EE_TEMPLATES . $current_theme,
240
+                    EE_TEMPLATES.$current_theme,
241 241
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
242 242
                     EE_PLUGIN_DIR_PATH,
243 243
                 ];
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
                     );
273 273
                     if ($common_base_path !== '') {
274 274
                         // both paths have a common base, so just tack the filename onto our search path
275
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
276 276
                     } else {
277 277
                         // no common base path, so let's just concatenate
278
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
279 279
                     }
280 280
                     // build up our template locations array by adding our resolved paths
281 281
                     $full_template_paths[] = $resolved_path;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
284 284
                 array_unshift($full_template_paths, $template);
285 285
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
286
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
287 287
             }
288 288
             // filter final array of full template paths
289 289
             $full_template_paths = apply_filters(
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
                 }
335 335
             }
336 336
             $common_base_path .= $directory;
337
-            $last_offset      = $index + 1;
337
+            $last_offset = $index + 1;
338 338
         }
339 339
         return substr($common_base_path, 0, -1);
340 340
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
373 373
 
374 374
         // you gimme nuttin - YOU GET NUTTIN !!
375
-        if (! $template_path || ! is_readable($template_path)) {
375
+        if ( ! $template_path || ! is_readable($template_path)) {
376 376
             // ignore whether template is accessible ?
377 377
             if ($throw_exceptions) {
378 378
                 throw new DomainException(
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             return '';
383 383
         }
384 384
         // if $template_args are not in an array, then make it so
385
-        if (! is_array($template_args) && ! is_object($template_args)) {
385
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
386 386
             $template_args = [$template_args];
387 387
         }
388 388
         extract($template_args, EXTR_SKIP);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
412 412
     {
413 413
         // in the beginning...
414
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
415 415
         // da muddle
416 416
         $class = '';
417 417
         // the end
418
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
419 419
         // is the passed object an EE object ?
420 420
         if ($object instanceof EE_Base_Class) {
421 421
             // grab the exact type of object
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
                 // no specifics just yet...
426 426
                 default:
427 427
                     $class = strtolower(str_replace('_', '-', $obj_class));
428
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
429 429
             }
430 430
         }
431
-        return $prefix . $class . $suffix;
431
+        return $prefix.$class.$suffix;
432 432
     }
433 433
 
434 434
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         // filter raw amount (allows 0.00 to be changed to "free" for example)
464 464
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
465 465
         // still a number, or was amount converted to a string like "free" ?
466
-        if (! is_float($amount_formatted)) {
466
+        if ( ! is_float($amount_formatted)) {
467 467
             return esc_html($amount_formatted);
468 468
         }
469 469
         try {
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             $mny = null;
475 475
         }
476 476
         // verify results
477
-        if (! $mny instanceof EE_Currency_Config) {
477
+        if ( ! $mny instanceof EE_Currency_Config) {
478 478
             // set default config country currency settings
479 479
             $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
480 480
                 ? EE_Registry::instance()->CFG->currency
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
         // format float
484 484
         $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
485 485
         // add formatting ?
486
-        if (! $return_raw) {
486
+        if ( ! $return_raw) {
487 487
             // add currency sign
488 488
             if ($mny->sign_b4) {
489 489
                 if ($amount >= 0) {
490
-                    $amount_formatted = $mny->sign . $amount_formatted;
490
+                    $amount_formatted = $mny->sign.$amount_formatted;
491 491
                 } else {
492
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
+                    $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
493 493
                 }
494 494
             } else {
495
-                $amount_formatted = $amount_formatted . $mny->sign;
495
+                $amount_formatted = $amount_formatted.$mny->sign;
496 496
             }
497 497
 
498 498
             // filter to allow global setting of display_code
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
             // add currency code ?
505 505
             $amount_formatted = $display_code
506
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
+                ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
507 507
                 : $amount_formatted;
508 508
         }
509 509
         // filter results
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
             $plural,
540 540
             $schema
541 541
         );
542
-        return $status[ $status_id ];
542
+        return $status[$status_id];
543 543
     }
544 544
 
545 545
 
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
     public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
557 557
     {
558 558
         $icon_html = '';
559
-        if (! empty($icon)) {
559
+        if ( ! empty($icon)) {
560 560
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
561 561
             $dashicons = array_filter($dashicons);
562 562
             $count     = count($dashicons);
563 563
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
564 564
             foreach ($dashicons as $dashicon) {
565
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
565
+                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
567 567
             }
568 568
             $icon_html .= $count > 1 ? '</span>' : '';
569 569
         }
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
602 602
 
603 603
 
604
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
605 605
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
606 606
         $help_text    = ! $help_text ? '' : $help_text;
607 607
         return '<a id="'
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
      */
636 636
     public static function status_legend($status_array, $active_status = '')
637 637
     {
638
-        if (! is_array($status_array)) {
638
+        if ( ! is_array($status_array)) {
639 639
             throw new EE_Error(
640 640
                 esc_html__(
641 641
                     'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
@@ -647,17 +647,17 @@  discard block
 block discarded – undo
647 647
         $content = '
648 648
             <div class="ee-list-table-legend-container">
649 649
                 <h4 class="status-legend-title">
650
-                    ' . esc_html__('Status Legend', 'event_espresso') . '
650
+                    ' . esc_html__('Status Legend', 'event_espresso').'
651 651
                 </h4>
652 652
                 <dl class="ee-list-table-legend">';
653 653
 
654 654
         foreach ($status_array as $item => $status) {
655 655
             $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
656
-            $content      .= '
657
-                    <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
658
-                        <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
656
+            $content .= '
657
+                    <dt id="' . esc_attr('ee-legend-item-tooltip-'.$item).'" '.$active_class.'>
658
+                        <span class="' . esc_attr('ee-status-legend ee-status-legend-'.$status).'"></span>
659 659
                         <span class="ee-legend-description">
660
-                            ' . EEH_Template::pretty_status($status, false, 'sentence') . '
660
+                            ' . EEH_Template::pretty_status($status, false, 'sentence').'
661 661
                         </span>
662 662
                     </dt>';
663 663
         }
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
             ];
804 804
         } else {
805 805
             $items_label = [
806
-                'single' => '1 ' . esc_html($items_label['single']),
807
-                'plural' => '%s ' . esc_html($items_label['plural']),
806
+                'single' => '1 '.esc_html($items_label['single']),
807
+                'plural' => '%s '.esc_html($items_label['plural']),
808 808
             ];
809 809
         }
810 810
 
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 
817 817
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
818 818
 
819
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
819
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
820 820
 
821 821
         if ($current === 1) {
822 822
             $disable_first = ' disabled';
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
         $page_links[] = sprintf(
829 829
             "<a class='%s' title='%s' href='%s'>%s</a>",
830
-            'first-page' . $disable_first,
830
+            'first-page'.$disable_first,
831 831
             esc_attr__('Go to the first page', 'event_espresso'),
832 832
             esc_url_raw(remove_query_arg($paged_arg_name, $url)),
833 833
             '&laquo;'
@@ -835,13 +835,13 @@  discard block
 block discarded – undo
835 835
 
836 836
         $page_links[] = sprintf(
837 837
             '<a class="%s" title="%s" href="%s">%s</a>',
838
-            'prev-page' . $disable_first,
838
+            'prev-page'.$disable_first,
839 839
             esc_attr__('Go to the previous page', 'event_espresso'),
840 840
             esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
841 841
             '&lsaquo;'
842 842
         );
843 843
 
844
-        if (! $show_num_field) {
844
+        if ( ! $show_num_field) {
845 845
             $html_current_page = $current;
846 846
         } else {
847 847
             $html_current_page = sprintf(
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             '<span class="total-pages">%s</span>',
857 857
             number_format_i18n($total_pages)
858 858
         );
859
-        $page_links[]     = sprintf(
859
+        $page_links[] = sprintf(
860 860
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
861 861
             $html_current_page,
862 862
             $html_total_pages,
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
         $page_links[] = sprintf(
868 868
             '<a class="%s" title="%s" href="%s">%s</a>',
869
-            'next-page' . $disable_last,
869
+            'next-page'.$disable_last,
870 870
             esc_attr__('Go to the next page', 'event_espresso'),
871 871
             esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
872 872
             '&rsaquo;'
@@ -874,13 +874,13 @@  discard block
 block discarded – undo
874 874
 
875 875
         $page_links[] = sprintf(
876 876
             '<a class="%s" title="%s" href="%s">%s</a>',
877
-            'last-page' . $disable_last,
877
+            'last-page'.$disable_last,
878 878
             esc_attr__('Go to the last page', 'event_espresso'),
879 879
             esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
880 880
             '&raquo;'
881 881
         );
882 882
 
883
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
883
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
884 884
         // set page class
885 885
         if ($total_pages) {
886 886
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
             $page_class = ' no-pages';
889 889
         }
890 890
 
891
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
891
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
892 892
     }
893 893
 
894 894
 
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         );
927 927
         $powered_by = apply_filters(
928 928
             'FHEE__EEH_Template__powered_by_event_espresso_text',
929
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
929
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
930 930
         );
931 931
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
932 932
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
      */
956 956
     public static function getScreenshotUrl($image_name)
957 957
     {
958
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
958
+        return esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/screenshots/'.$image_name.'.jpg');
959 959
     }
960 960
 }
961 961
 
962 962
 
963
-if (! function_exists('espresso_pagination')) {
963
+if ( ! function_exists('espresso_pagination')) {
964 964
     /**
965 965
      *    espresso_pagination
966 966
      *
@@ -988,6 +988,6 @@  discard block
 block discarded – undo
988 988
                 'add_fragment' => '',
989 989
             ]
990 990
         );
991
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
991
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
992 992
     }
993 993
 }
994 994
\ No newline at end of file
Please login to merge, or discard this patch.
admin/registrations/list_table/csv_reports/RegistrationsCsvReportParams.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 
44 44
         $route_details = [
45 45
             'route'         => 'registrations_report',
46
-            'extra_request' => [ 'return_url' => $return_url ],
46
+            'extra_request' => ['return_url' => $return_url],
47 47
         ];
48
-        if (! empty($EVT_ID)) {
48
+        if ( ! empty($EVT_ID)) {
49 49
             $route_details['extra_request']['EVT_ID'] = $EVT_ID;
50 50
         }
51 51
         if ($DTT_ID) {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     <span class="csv-report-notice__wrapper">
76 76
         <span class="dashicons dashicons-info"></span>
77 77
         <span class="csv-report-notice__text">
78
-        ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button') . '
78
+        ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button').'
79 79
         </span>
80 80
     </span>';
81 81
     }
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,69 +14,69 @@
 block discarded – undo
14 14
  */
15 15
 class RegistrationsCsvReportParams
16 16
 {
17
-    /**
18
-     * @param string $return_url
19
-     * @param array  $request_params
20
-     * @param int    $EVT_ID
21
-     * @param int    $DTT_ID
22
-     * @return array
23
-     */
24
-    public static function getRequestParams(
25
-        $return_url,
26
-        $request_params = [],
27
-        $EVT_ID = 0,
28
-        $DTT_ID = 0
29
-    ) {
30
-        if (
31
-            ! EE_Capabilities::instance()->current_user_can(
32
-                'ee_read_registrations',
33
-                'espresso_registrations_registrations_reports',
34
-                $EVT_ID
35
-            )
36
-        ) {
37
-            return [];
38
-        }
39
-        unset($request_params['_wp_http_referer']);
40
-        add_action(
41
-            'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
-            [RegistrationsCsvReportParams::class, 'csvReportNotice']
43
-        );
17
+	/**
18
+	 * @param string $return_url
19
+	 * @param array  $request_params
20
+	 * @param int    $EVT_ID
21
+	 * @param int    $DTT_ID
22
+	 * @return array
23
+	 */
24
+	public static function getRequestParams(
25
+		$return_url,
26
+		$request_params = [],
27
+		$EVT_ID = 0,
28
+		$DTT_ID = 0
29
+	) {
30
+		if (
31
+			! EE_Capabilities::instance()->current_user_can(
32
+				'ee_read_registrations',
33
+				'espresso_registrations_registrations_reports',
34
+				$EVT_ID
35
+			)
36
+		) {
37
+			return [];
38
+		}
39
+		unset($request_params['_wp_http_referer']);
40
+		add_action(
41
+			'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
+			[RegistrationsCsvReportParams::class, 'csvReportNotice']
43
+		);
44 44
 
45
-        $route_details = [
46
-            'route'         => 'registrations_report',
47
-            'extra_request' => [ 'return_url' => $return_url ],
48
-        ];
49
-        if (! empty($EVT_ID)) {
50
-            $route_details['extra_request']['EVT_ID'] = $EVT_ID;
51
-        }
52
-        if ($DTT_ID) {
53
-            $route_details['extra_request']['DTT_ID'] = $DTT_ID;
54
-        }
55
-        if (
56
-            isset($request_params['use_filters'])
57
-            && filter_var($request_params['use_filters'], FILTER_VALIDATE_BOOLEAN)
58
-        ) {
59
-            $route_details['extra_request']['filters'] = array_diff_key(
60
-                $request_params,
61
-                [
62
-                    'page'          => '',
63
-                    'action'        => '',
64
-                    'default_nonce' => '',
65
-                ]
66
-            );
67
-        }
68
-        return $route_details;
69
-    }
45
+		$route_details = [
46
+			'route'         => 'registrations_report',
47
+			'extra_request' => [ 'return_url' => $return_url ],
48
+		];
49
+		if (! empty($EVT_ID)) {
50
+			$route_details['extra_request']['EVT_ID'] = $EVT_ID;
51
+		}
52
+		if ($DTT_ID) {
53
+			$route_details['extra_request']['DTT_ID'] = $DTT_ID;
54
+		}
55
+		if (
56
+			isset($request_params['use_filters'])
57
+			&& filter_var($request_params['use_filters'], FILTER_VALIDATE_BOOLEAN)
58
+		) {
59
+			$route_details['extra_request']['filters'] = array_diff_key(
60
+				$request_params,
61
+				[
62
+					'page'          => '',
63
+					'action'        => '',
64
+					'default_nonce' => '',
65
+				]
66
+			);
67
+		}
68
+		return $route_details;
69
+	}
70 70
 
71 71
 
72
-    public static function csvReportNotice()
73
-    {
74
-        echo '
72
+	public static function csvReportNotice()
73
+	{
74
+		echo '
75 75
     <span class="csv-report-notice__wrapper">
76 76
         <span class="dashicons dashicons-info"></span>
77 77
         <span class="csv-report-notice__text">
78 78
         ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button') . '
79 79
         </span>
80 80
     </span>';
81
-    }
81
+	}
82 82
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1414 added lines, -1414 removed lines patch added patch discarded remove patch
@@ -20,1429 +20,1429 @@
 block discarded – undo
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Core_Config
25
-     */
26
-    public $core_config;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
-    }
61
-
62
-
63
-    /**
64
-     * Set page routes property.
65
-     */
66
-    protected function _set_page_routes()
67
-    {
68
-        $this->_page_routes = [
69
-            'critical_pages'                => [
70
-                'func'       => '_espresso_page_settings',
71
-                'capability' => 'manage_options',
72
-            ],
73
-            'update_espresso_page_settings' => [
74
-                'func'       => '_update_espresso_page_settings',
75
-                'capability' => 'manage_options',
76
-                'noheader'   => true,
77
-            ],
78
-            'default'                       => [
79
-                'func'       => '_your_organization_settings',
80
-                'capability' => 'manage_options',
81
-            ],
82
-
83
-            'update_your_organization_settings' => [
84
-                'func'       => '_update_your_organization_settings',
85
-                'capability' => 'manage_options',
86
-                'noheader'   => true,
87
-            ],
88
-
89
-            'admin_option_settings' => [
90
-                'func'       => '_admin_option_settings',
91
-                'capability' => 'manage_options',
92
-            ],
93
-
94
-            'update_admin_option_settings' => [
95
-                'func'       => '_update_admin_option_settings',
96
-                'capability' => 'manage_options',
97
-                'noheader'   => true,
98
-            ],
99
-
100
-            'country_settings' => [
101
-                'func'       => '_country_settings',
102
-                'capability' => 'manage_options',
103
-            ],
104
-
105
-            'update_country_settings' => [
106
-                'func'       => '_update_country_settings',
107
-                'capability' => 'manage_options',
108
-                'noheader'   => true,
109
-            ],
110
-
111
-            'display_country_settings' => [
112
-                'func'       => 'display_country_settings',
113
-                'capability' => 'manage_options',
114
-                'noheader'   => true,
115
-            ],
116
-
117
-            'add_new_state' => [
118
-                'func'       => 'add_new_state',
119
-                'capability' => 'manage_options',
120
-                'noheader'   => true,
121
-            ],
122
-
123
-            'delete_state'            => [
124
-                'func'       => 'delete_state',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ],
128
-            'privacy_settings'        => [
129
-                'func'       => 'privacySettings',
130
-                'capability' => 'manage_options',
131
-            ],
132
-            'update_privacy_settings' => [
133
-                'func'               => 'updatePrivacySettings',
134
-                'capability'         => 'manage_options',
135
-                'noheader'           => true,
136
-                'headers_sent_route' => 'privacy_settings',
137
-            ],
138
-        ];
139
-    }
140
-
141
-
142
-    /**
143
-     * Set page configuration property
144
-     */
145
-    protected function _set_page_config()
146
-    {
147
-        $this->_page_config = [
148
-            'critical_pages'        => [
149
-                'nav'           => [
150
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'order' => 20,
166
-                ],
167
-                'help_tabs'     => [
168
-                    'general_settings_your_organization_help_tab' => [
169
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
170
-                        'filename' => 'general_settings_your_organization',
171
-                    ],
172
-                ],
173
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
-                'require_nonce' => false,
175
-            ],
176
-            'admin_option_settings' => [
177
-                'nav'           => [
178
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
179
-                    'order' => 60,
180
-                ],
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
-                'help_tabs'     => [
183
-                    'general_settings_admin_options_help_tab' => [
184
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
185
-                        'filename' => 'general_settings_admin_options',
186
-                    ],
187
-                ],
188
-                'require_nonce' => false,
189
-            ],
190
-            'country_settings'      => [
191
-                'nav'           => [
192
-                    'label' => esc_html__('Countries', 'event_espresso'),
193
-                    'order' => 70,
194
-                ],
195
-                'help_tabs'     => [
196
-                    'general_settings_countries_help_tab' => [
197
-                        'title'    => esc_html__('Countries', 'event_espresso'),
198
-                        'filename' => 'general_settings_countries',
199
-                    ],
200
-                ],
201
-                'require_nonce' => false,
202
-            ],
203
-            'privacy_settings'      => [
204
-                'nav'           => [
205
-                    'label' => esc_html__('Privacy', 'event_espresso'),
206
-                    'order' => 80,
207
-                ],
208
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
-                'require_nonce' => false,
210
-            ],
211
-        ];
212
-    }
213
-
214
-
215
-    protected function _add_screen_options()
216
-    {
217
-    }
218
-
219
-
220
-    protected function _add_feature_pointers()
221
-    {
222
-    }
223
-
224
-
225
-    /**
226
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
-     */
228
-    public function load_scripts_styles()
229
-    {
230
-        // styles
231
-        wp_enqueue_style('espresso-ui-theme');
232
-        // scripts
233
-        wp_enqueue_script('ee_admin_js');
234
-    }
235
-
236
-
237
-    /**
238
-     * Execute logic running on `admin_init`
239
-     */
240
-    public function admin_init()
241
-    {
242
-        $this->core_config = EE_Registry::instance()->CFG->core;
243
-
244
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
-            esc_html__(
246
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
-                'event_espresso'
248
-            )
249
-        );
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
-            esc_html__(
252
-                'An error occurred! Please refresh the page and try again.',
253
-                'event_espresso'
254
-            )
255
-        );
256
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
-            esc_html__(
258
-                'Are you sure you want to delete this State / Province?',
259
-                'event_espresso'
260
-            )
261
-        );
262
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
-            'admin-ajax.php?page=espresso_general_settings',
264
-            is_ssl() ? 'https://' : 'http://'
265
-        );
266
-    }
267
-
268
-
269
-    public function admin_notices()
270
-    {
271
-    }
272
-
273
-
274
-    public function admin_footer_scripts()
275
-    {
276
-    }
277
-
278
-
279
-    /**
280
-     * Enqueue scripts and styles for the default route.
281
-     */
282
-    public function load_scripts_styles_default()
283
-    {
284
-        // styles
285
-        wp_enqueue_style('thickbox');
286
-        // scripts
287
-        wp_enqueue_script('media-upload');
288
-        wp_enqueue_script('thickbox');
289
-        wp_register_script(
290
-            'organization_settings',
291
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
-            ['jquery', 'media-upload', 'thickbox'],
293
-            EVENT_ESPRESSO_VERSION,
294
-            true
295
-        );
296
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
-        wp_enqueue_script('organization_settings');
298
-        wp_enqueue_style('organization-css');
299
-        $confirm_image_delete = [
300
-            'text' => wp_strip_all_tags(
301
-                esc_html__(
302
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                    'event_espresso'
304
-                )
305
-            ),
306
-        ];
307
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
-    }
309
-
310
-
311
-    /**
312
-     * Enqueue scripts and styles for the country settings route.
313
-     */
314
-    public function load_scripts_styles_country_settings()
315
-    {
316
-        // scripts
317
-        wp_register_script(
318
-            'gen_settings_countries',
319
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
-            ['ee_admin_js'],
321
-            EVENT_ESPRESSO_VERSION,
322
-            true
323
-        );
324
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
-        wp_enqueue_script('gen_settings_countries');
326
-        wp_enqueue_style('organization-css');
327
-    }
328
-
329
-
330
-    /*************        Espresso Pages        *************/
331
-    /**
332
-     * _espresso_page_settings
333
-     *
334
-     * @throws EE_Error
335
-     * @throws DomainException
336
-     * @throws DomainException
337
-     * @throws InvalidDataTypeException
338
-     * @throws InvalidArgumentException
339
-     */
340
-    protected function _espresso_page_settings()
341
-    {
342
-        // Check to make sure all of the main pages are set up properly,
343
-        // if not create the default pages and display an admin notice
344
-        EEH_Activation::verify_default_pages_exist();
345
-        $this->_transient_garbage_collection();
346
-
347
-        $this->_template_args['values'] = $this->_yes_no_values;
348
-
349
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
350
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
351
-            ? get_post($this->core_config->reg_page_id)
352
-            : false;
353
-
354
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
355
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
356
-            ? get_post($this->core_config->txn_page_id)
357
-            : false;
358
-
359
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
-            ? get_post($this->core_config->thank_you_page_id)
362
-            : false;
363
-
364
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
365
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
366
-            ? get_post($this->core_config->cancel_page_id)
367
-            : false;
368
-
369
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
370
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
371
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
-            $this->_template_args,
374
-            true
375
-        );
376
-        $this->display_admin_page_with_sidebar();
377
-    }
378
-
379
-
380
-    /**
381
-     * Handler for updating espresso page settings.
382
-     *
383
-     * @throws EE_Error
384
-     */
385
-    protected function _update_espresso_page_settings()
386
-    {
387
-        // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
389
-            'reg_page_id',
390
-            $this->core_config->reg_page_id,
391
-            DataType::INT
392
-        );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
394
-            'txn_page_id',
395
-            $this->core_config->txn_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
-            'thank_you_page_id',
400
-            $this->core_config->thank_you_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
-            'cancel_page_id',
405
-            $this->core_config->cancel_page_id,
406
-            DataType::INT
407
-        );
408
-
409
-        $this->core_config = apply_filters(
410
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
-            $this->core_config,
412
-            $this->request->requestParams()
413
-        );
414
-
415
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
-        $this->_redirect_after_action(
417
-            $this->_update_espresso_configuration(
418
-                $what,
419
-                $this->core_config,
420
-                __FILE__,
421
-                __FUNCTION__,
422
-                __LINE__
423
-            ),
424
-            $what,
425
-            '',
426
-            [
427
-                'action' => 'critical_pages',
428
-            ],
429
-            true
430
-        );
431
-    }
432
-
433
-
434
-    /*************        Your Organization        *************/
435
-
436
-
437
-    /**
438
-     * @throws DomainException
439
-     * @throws EE_Error
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     */
444
-    protected function _your_organization_settings()
445
-    {
446
-        $this->_template_args['admin_page_content'] = '';
447
-        try {
448
-            /** @var OrganizationSettings $organization_settings_form */
449
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
-
451
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
452
-                $organization_settings_form->display(),
453
-                '',
454
-                'padding'
455
-            );
456
-        } catch (Exception $e) {
457
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
-        }
459
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
460
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
461
-        $this->display_admin_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * Handler for updating organization settings.
467
-     *
468
-     * @throws EE_Error
469
-     */
470
-    protected function _update_your_organization_settings()
471
-    {
472
-        try {
473
-            /** @var OrganizationSettings $organization_settings_form */
474
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
-
476
-            $success = $organization_settings_form->process($this->request->requestParams());
477
-
478
-            EE_Registry::instance()->CFG = apply_filters(
479
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
-                EE_Registry::instance()->CFG
481
-            );
482
-        } catch (Exception $e) {
483
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
-            $success = false;
485
-        }
486
-
487
-        if ($success) {
488
-            $success = $this->_update_espresso_configuration(
489
-                esc_html__('Your Organization Settings', 'event_espresso'),
490
-                EE_Registry::instance()->CFG,
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-
497
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
-    }
499
-
500
-
501
-
502
-    /*************        Admin Options        *************/
503
-
504
-
505
-    /**
506
-     * _admin_option_settings
507
-     *
508
-     * @throws EE_Error
509
-     * @throws LogicException
510
-     */
511
-    protected function _admin_option_settings()
512
-    {
513
-        $this->_template_args['admin_page_content'] = '';
514
-        try {
515
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
517
-            $this->_template_args['values'] = $this->_yes_no_values;
518
-            // also need to account for the do_action that was in the old template
519
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
520
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
521
-        } catch (Exception $e) {
522
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
523
-        }
524
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
525
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
526
-        $this->display_admin_page_with_sidebar();
527
-    }
528
-
529
-
530
-    /**
531
-     * _update_admin_option_settings
532
-     *
533
-     * @throws EE_Error
534
-     * @throws InvalidDataTypeException
535
-     * @throws InvalidFormSubmissionException
536
-     * @throws InvalidArgumentException
537
-     * @throws LogicException
538
-     */
539
-    protected function _update_admin_option_settings()
540
-    {
541
-        try {
542
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
543
-            $admin_options_settings_form->process(
544
-                $this->request->getRequestParam(
545
-                    $admin_options_settings_form->slug(),
546
-                    [],
547
-                    DataType::OBJECT // need to change this to ARRAY after min PHP version gets bumped to 7+
548
-                )
549
-            );
550
-            EE_Registry::instance()->CFG->admin = apply_filters(
551
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
-                EE_Registry::instance()->CFG->admin
553
-            );
554
-        } catch (Exception $e) {
555
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
-        }
557
-        $this->_redirect_after_action(
558
-            apply_filters(
559
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
-                $this->_update_espresso_configuration(
561
-                    esc_html__('Admin Options', 'event_espresso'),
562
-                    EE_Registry::instance()->CFG->admin,
563
-                    __FILE__,
564
-                    __FUNCTION__,
565
-                    __LINE__
566
-                )
567
-            ),
568
-            esc_html__('Admin Options', 'event_espresso'),
569
-            'updated',
570
-            ['action' => 'admin_option_settings']
571
-        );
572
-    }
573
-
574
-
575
-    /*************        Countries        *************/
576
-
577
-
578
-    /**
579
-     * @param string|null $default
580
-     * @return string
581
-     */
582
-    protected function getCountryISO(?string $default = null): string
583
-    {
584
-        $default = $default ?? $this->getCountryIsoForSite();
585
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
586
-        $CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
587
-        return strtoupper($CNT_ISO);
588
-    }
589
-
590
-
591
-    /**
592
-     * @return string
593
-     */
594
-    protected function getCountryIsoForSite(): string
595
-    {
596
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
597
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
598
-            : 'US';
599
-    }
600
-
601
-
602
-    /**
603
-     * @param string          $CNT_ISO
604
-     * @param EE_Country|null $country
605
-     * @return EE_Base_Class|EE_Country
606
-     * @throws EE_Error
607
-     * @throws InvalidArgumentException
608
-     * @throws InvalidDataTypeException
609
-     * @throws InvalidInterfaceException
610
-     * @throws ReflectionException
611
-     */
612
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
613
-    {
614
-        /** @var EE_Country $country */
615
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
616
-            ? $country
617
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
618
-    }
619
-
620
-
621
-    /**
622
-     * Output Country Settings view.
623
-     *
624
-     * @throws DomainException
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     * @throws ReflectionException
630
-     */
631
-    protected function _country_settings()
632
-    {
633
-        $CNT_ISO = $this->getCountryISO();
634
-
635
-        $this->_template_args['values']    = $this->_yes_no_values;
636
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
637
-            EE_Question::new_instance(
638
-                [
639
-                    'QST_ID'           => 0,
640
-                    'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
641
-                    'QST_system'       => 'admin-country',
642
-                ]
643
-            ),
644
-            EE_Answer::new_instance(
645
-                [
646
-                    'ANS_ID'    => 0,
647
-                    'ANS_value' => $CNT_ISO,
648
-                ]
649
-            ),
650
-            [
651
-                'input_id'       => 'country',
652
-                'input_name'     => 'country',
653
-                'input_prefix'   => '',
654
-                'append_qstn_id' => false,
655
-            ]
656
-        );
657
-
658
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
659
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
660
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
661
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
662
-            $country->ID(),
663
-            $country
664
-        );
665
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
666
-            $country->ID(),
667
-            $country
668
-        );
669
-        $this->_template_args['CNT_name_for_site']        = $country->name();
670
-
671
-        $this->_set_add_edit_form_tags('update_country_settings');
672
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
673
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
675
-            $this->_template_args,
676
-            true
677
-        );
678
-        $this->display_admin_page_with_no_sidebar();
679
-    }
680
-
681
-
682
-    /**
683
-     * @param string          $CNT_ISO
684
-     * @param EE_Country|null $country
685
-     * @return string
686
-     * @throws DomainException
687
-     * @throws EE_Error
688
-     * @throws InvalidArgumentException
689
-     * @throws InvalidDataTypeException
690
-     * @throws InvalidInterfaceException
691
-     * @throws ReflectionException
692
-     */
693
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
694
-    {
695
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
696
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
697
-
698
-        if (! $CNT_ISO) {
699
-            return '';
700
-        }
701
-
702
-        // for ajax
703
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
704
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
705
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
706
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
707
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
708
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710
-
711
-        $country_input_types            = [
712
-            'CNT_active'      => [
713
-                'type'             => 'RADIO_BTN',
714
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
715
-                'class'            => '',
716
-                'options'          => $this->_yes_no_values,
717
-                'use_desc_4_label' => true,
718
-            ],
719
-            'CNT_ISO'         => [
720
-                'type'       => 'TEXT',
721
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
722
-                'class'      => 'small-text',
723
-            ],
724
-            'CNT_ISO3'        => [
725
-                'type'       => 'TEXT',
726
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
727
-                'class'      => 'small-text',
728
-            ],
729
-            // 'RGN_ID'          => [
730
-            //     'type'       => 'TEXT',
731
-            //     'input_name' => 'cntry[' . $CNT_ISO . ']',
732
-            //     'class'      => 'ee-input-size--small',
733
-            // ],
734
-            'CNT_name'        => [
735
-                'type'       => 'TEXT',
736
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
737
-                'class'      => 'regular-text',
738
-            ],
739
-            'CNT_cur_code'    => [
740
-                'type'       => 'TEXT',
741
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
742
-                'class'      => 'small-text',
743
-                'disabled'   => $CNT_cur_disabled,
744
-            ],
745
-            'CNT_cur_single'  => [
746
-                'type'       => 'TEXT',
747
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
748
-                'class'      => 'medium-text',
749
-                'disabled'   => $CNT_cur_disabled,
750
-            ],
751
-            'CNT_cur_plural'  => [
752
-                'type'       => 'TEXT',
753
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
754
-                'class'      => 'medium-text',
755
-                'disabled'   => $CNT_cur_disabled,
756
-            ],
757
-            'CNT_cur_sign'    => [
758
-                'type'         => 'TEXT',
759
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
760
-                'class'        => 'small-text',
761
-                'htmlentities' => false,
762
-                'disabled'     => $CNT_cur_disabled,
763
-            ],
764
-            'CNT_cur_sign_b4' => [
765
-                'type'             => 'RADIO_BTN',
766
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
-                'class'            => '',
768
-                'options'          => $this->_yes_no_values,
769
-                'use_desc_4_label' => true,
770
-                'disabled'         => $CNT_cur_disabled,
771
-            ],
772
-            'CNT_cur_dec_plc' => [
773
-                'type'       => 'RADIO_BTN',
774
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
775
-                'class'      => '',
776
-                'options'    => [
777
-                    ['id' => 0, 'text' => ''],
778
-                    ['id' => 1, 'text' => ''],
779
-                    ['id' => 2, 'text' => ''],
780
-                    ['id' => 3, 'text' => ''],
781
-                ],
782
-                'disabled'   => $CNT_cur_disabled,
783
-            ],
784
-            'CNT_cur_dec_mrk' => [
785
-                'type'             => 'RADIO_BTN',
786
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
-                'class'            => '',
788
-                'options'          => [
789
-                    [
790
-                        'id'   => ',',
791
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
792
-                    ],
793
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
794
-                ],
795
-                'use_desc_4_label' => true,
796
-                'disabled'         => $CNT_cur_disabled,
797
-            ],
798
-            'CNT_cur_thsnds'  => [
799
-                'type'             => 'RADIO_BTN',
800
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
-                'class'            => '',
802
-                'options'          => [
803
-                    [
804
-                        'id'   => ',',
805
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
806
-                    ],
807
-                    [
808
-                        'id'   => '.',
809
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
810
-                    ],
811
-                    [
812
-                        'id'   => '&nbsp;',
813
-                        'text' => esc_html__('(space)', 'event_espresso'),
814
-                    ],
815
-                ],
816
-                'use_desc_4_label' => true,
817
-                'disabled'         => $CNT_cur_disabled,
818
-            ],
819
-            'CNT_tel_code'    => [
820
-                'type'       => 'TEXT',
821
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
822
-                'class'      => 'small-text',
823
-            ],
824
-            'CNT_is_EU'       => [
825
-                'type'             => 'RADIO_BTN',
826
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
827
-                'class'            => '',
828
-                'options'          => $this->_yes_no_values,
829
-                'use_desc_4_label' => true,
830
-            ],
831
-        ];
832
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
833
-            $country,
834
-            $country_input_types
835
-        );
836
-        $country_details_settings       = EEH_Template::display_template(
837
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
838
-            $this->_template_args,
839
-            true
840
-        );
841
-
842
-        if (defined('DOING_AJAX')) {
843
-            $notices = EE_Error::get_notices(false, false, false);
844
-            echo wp_json_encode(
845
-                [
846
-                    'return_data' => $country_details_settings,
847
-                    'success'     => $notices['success'],
848
-                    'errors'      => $notices['errors'],
849
-                ]
850
-            );
851
-            die();
852
-        }
853
-        return $country_details_settings;
854
-    }
855
-
856
-
857
-    /**
858
-     * @param string          $CNT_ISO
859
-     * @param EE_Country|null $country
860
-     * @return string
861
-     * @throws DomainException
862
-     * @throws EE_Error
863
-     * @throws InvalidArgumentException
864
-     * @throws InvalidDataTypeException
865
-     * @throws InvalidInterfaceException
866
-     * @throws ReflectionException
867
-     */
868
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
869
-    {
870
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
871
-        if (! $CNT_ISO) {
872
-            return '';
873
-        }
874
-        // for ajax
875
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
876
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
877
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
878
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
879
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
880
-        if (empty($states)) {
881
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
882
-            $countrySubRegionDao = $this->loader->getShared(
883
-                'EventEspresso\core\services\address\CountrySubRegionDao'
884
-            );
885
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
886
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
887
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
888
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
889
-                }
890
-            }
891
-        }
892
-        if (is_array($states)) {
893
-            foreach ($states as $STA_ID => $state) {
894
-                if ($state instanceof EE_State) {
895
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
896
-                        $state,
897
-                        [
898
-                            'STA_abbrev' => [
899
-                                'type'             => 'TEXT',
900
-                                'label'            => esc_html__('Code', 'event_espresso'),
901
-                                'input_name'       => 'states[' . $STA_ID . ']',
902
-                                'class'            => 'small-text',
903
-                                'add_mobile_label' => true,
904
-                            ],
905
-                            'STA_name'   => [
906
-                                'type'             => 'TEXT',
907
-                                'label'            => esc_html__('Name', 'event_espresso'),
908
-                                'input_name'       => 'states[' . $STA_ID . ']',
909
-                                'class'            => 'regular-text',
910
-                                'add_mobile_label' => true,
911
-                            ],
912
-                            'STA_active' => [
913
-                                'type'             => 'RADIO_BTN',
914
-                                'label'            => esc_html__(
915
-                                    'State Appears in Dropdown Select Lists',
916
-                                    'event_espresso'
917
-                                ),
918
-                                'input_name'       => 'states[' . $STA_ID . ']',
919
-                                'options'          => $this->_yes_no_values,
920
-                                'use_desc_4_label' => true,
921
-                                'add_mobile_label' => true,
922
-                            ],
923
-                        ]
924
-                    );
925
-
926
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
927
-                        [
928
-                            'action'     => 'delete_state',
929
-                            'STA_ID'     => $STA_ID,
930
-                            'CNT_ISO'    => $CNT_ISO,
931
-                            'STA_abbrev' => $state->abbrev(),
932
-                        ],
933
-                        GEN_SET_ADMIN_URL
934
-                    );
935
-
936
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
938
-                }
939
-            }
940
-        } else {
941
-            $this->_template_args['states'] = false;
942
-        }
943
-
944
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
945
-            ['action' => 'add_new_state'],
946
-            GEN_SET_ADMIN_URL
947
-        );
948
-
949
-        $state_details_settings = EEH_Template::display_template(
950
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
951
-            $this->_template_args,
952
-            true
953
-        );
954
-
955
-        if (defined('DOING_AJAX')) {
956
-            $notices = EE_Error::get_notices(false, false, false);
957
-            echo wp_json_encode(
958
-                [
959
-                    'return_data' => $state_details_settings,
960
-                    'success'     => $notices['success'],
961
-                    'errors'      => $notices['errors'],
962
-                ]
963
-            );
964
-            die();
965
-        }
966
-        return $state_details_settings;
967
-    }
968
-
969
-
970
-    /**
971
-     * @return void
972
-     * @throws EE_Error
973
-     * @throws InvalidArgumentException
974
-     * @throws InvalidDataTypeException
975
-     * @throws InvalidInterfaceException
976
-     * @throws ReflectionException
977
-     */
978
-    public function add_new_state()
979
-    {
980
-        $success = true;
981
-        $CNT_ISO = $this->getCountryISO('');
982
-        if (! $CNT_ISO) {
983
-            EE_Error::add_error(
984
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985
-                __FILE__,
986
-                __FUNCTION__,
987
-                __LINE__
988
-            );
989
-            $success = false;
990
-        }
991
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
-        if (! $STA_abbrev) {
993
-            EE_Error::add_error(
994
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995
-                __FILE__,
996
-                __FUNCTION__,
997
-                __LINE__
998
-            );
999
-            $success = false;
1000
-        }
1001
-        $STA_name = $this->request->getRequestParam('STA_name');
1002
-        if (! $STA_name) {
1003
-            EE_Error::add_error(
1004
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005
-                __FILE__,
1006
-                __FUNCTION__,
1007
-                __LINE__
1008
-            );
1009
-            $success = false;
1010
-        }
1011
-
1012
-        if ($success) {
1013
-            $cols_n_values = [
1014
-                'CNT_ISO'    => $CNT_ISO,
1015
-                'STA_abbrev' => $STA_abbrev,
1016
-                'STA_name'   => $STA_name,
1017
-                'STA_active' => true,
1018
-            ];
1019
-            $success       = EEM_State::instance()->insert($cols_n_values);
1020
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021
-        }
1022
-
1023
-        if (defined('DOING_AJAX')) {
1024
-            $notices = EE_Error::get_notices(false, false, false);
1025
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1026
-            die();
1027
-        } else {
1028
-            $this->_redirect_after_action(
1029
-                $success,
1030
-                esc_html__('State', 'event_espresso'),
1031
-                'added',
1032
-                ['action' => 'country_settings']
1033
-            );
1034
-        }
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @return void
1040
-     * @throws EE_Error
1041
-     * @throws InvalidArgumentException
1042
-     * @throws InvalidDataTypeException
1043
-     * @throws InvalidInterfaceException
1044
-     * @throws ReflectionException
1045
-     */
1046
-    public function delete_state()
1047
-    {
1048
-        $CNT_ISO    = $this->getCountryISO();
1049
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1050
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
-
1052
-        if (! $STA_ID) {
1053
-            EE_Error::add_error(
1054
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
-                __FILE__,
1056
-                __FUNCTION__,
1057
-                __LINE__
1058
-            );
1059
-            return;
1060
-        }
1061
-
1062
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
-        if ($success !== false) {
1064
-            do_action(
1065
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1066
-                $CNT_ISO,
1067
-                $STA_ID,
1068
-                ['STA_abbrev' => $STA_abbrev]
1069
-            );
1070
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1071
-        }
1072
-        if (defined('DOING_AJAX')) {
1073
-            $notices                = EE_Error::get_notices(false);
1074
-            $notices['return_data'] = true;
1075
-            echo wp_json_encode($notices);
1076
-            die();
1077
-        } else {
1078
-            $this->_redirect_after_action(
1079
-                $success,
1080
-                esc_html__('State', 'event_espresso'),
1081
-                'deleted',
1082
-                ['action' => 'country_settings']
1083
-            );
1084
-        }
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     *        _update_country_settings
1090
-     *
1091
-     * @return void
1092
-     * @throws EE_Error
1093
-     * @throws InvalidArgumentException
1094
-     * @throws InvalidDataTypeException
1095
-     * @throws InvalidInterfaceException
1096
-     * @throws ReflectionException
1097
-     */
1098
-    protected function _update_country_settings()
1099
-    {
1100
-        $CNT_ISO = $this->getCountryISO();
1101
-        if (! $CNT_ISO) {
1102
-            EE_Error::add_error(
1103
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1104
-                __FILE__,
1105
-                __FUNCTION__,
1106
-                __LINE__
1107
-            );
1108
-            return;
1109
-        }
1110
-
1111
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1112
-
1113
-        $cols_n_values                    = [];
1114
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1115
-            $this->request->getRequestParam('cntry', $country->ISO3())
1116
-        );
1117
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1118
-            "cntry[$CNT_ISO][CNT_name]",
1119
-            $country->name()
1120
-        );
1121
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1122
-            $this->request->getRequestParam(
1123
-                "cntry[$CNT_ISO][CNT_cur_code]",
1124
-                $country->currency_code()
1125
-            )
1126
-        );
1127
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1128
-            "cntry[$CNT_ISO][CNT_cur_single]",
1129
-            $country->currency_name_single()
1130
-        );
1131
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1132
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1133
-            $country->currency_name_plural()
1134
-        );
1135
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1136
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1137
-            $country->currency_sign()
1138
-        );
1139
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1140
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1141
-            $country->currency_sign_before(),
1142
-            DataType::BOOL
1143
-        );
1144
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1145
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1146
-            $country->currency_decimal_places()
1147
-        );
1148
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1149
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1150
-            $country->currency_decimal_mark()
1151
-        );
1152
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1153
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1154
-            $country->currency_thousands_separator()
1155
-        );
1156
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1157
-            "cntry[$CNT_ISO][CNT_tel_code]",
1158
-            $country->telephoneCode()
1159
-        );
1160
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1161
-            "cntry[$CNT_ISO][CNT_active]",
1162
-            $country->isActive(),
1163
-            DataType::BOOL
1164
-        );
1165
-
1166
-        // allow filtering of country data
1167
-        $cols_n_values = apply_filters(
1168
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1169
-            $cols_n_values
1170
-        );
1171
-
1172
-        // where values
1173
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1174
-        // run the update
1175
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1176
-
1177
-        // allow filtering of states data
1178
-        $states = apply_filters(
1179
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1180
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1181
-        );
1182
-
1183
-        if (! empty($states) && $success !== false) {
1184
-            // loop thru state data ( looks like : states[75][STA_name] )
1185
-            foreach ($states as $STA_ID => $state) {
1186
-                $cols_n_values = [
1187
-                    'CNT_ISO'    => $CNT_ISO,
1188
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1189
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1190
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1191
-                ];
1192
-                // where values
1193
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1194
-                // run the update
1195
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1196
-                if ($success !== false) {
1197
-                    do_action(
1198
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1199
-                        $CNT_ISO,
1200
-                        $STA_ID,
1201
-                        $cols_n_values
1202
-                    );
1203
-                }
1204
-            }
1205
-        }
1206
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1207
-        if (
1208
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1209
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1210
-        ) {
1211
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1212
-            EE_Registry::instance()->CFG->update_espresso_config();
1213
-        }
1214
-
1215
-        if ($success !== false) {
1216
-            EE_Error::add_success(
1217
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1218
-            );
1219
-        }
1220
-        $this->_redirect_after_action(
1221
-            $success,
1222
-            '',
1223
-            '',
1224
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1225
-            true
1226
-        );
1227
-    }
1228
-
1229
-
1230
-    /**
1231
-     * form_form_field_label_wrap
1232
-     *
1233
-     * @param string $label
1234
-     * @return string
1235
-     */
1236
-    public function country_form_field_label_wrap(string $label): string
1237
-    {
1238
-        return '
23
+	/**
24
+	 * @var EE_Core_Config
25
+	 */
26
+	public $core_config;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
+	}
61
+
62
+
63
+	/**
64
+	 * Set page routes property.
65
+	 */
66
+	protected function _set_page_routes()
67
+	{
68
+		$this->_page_routes = [
69
+			'critical_pages'                => [
70
+				'func'       => '_espresso_page_settings',
71
+				'capability' => 'manage_options',
72
+			],
73
+			'update_espresso_page_settings' => [
74
+				'func'       => '_update_espresso_page_settings',
75
+				'capability' => 'manage_options',
76
+				'noheader'   => true,
77
+			],
78
+			'default'                       => [
79
+				'func'       => '_your_organization_settings',
80
+				'capability' => 'manage_options',
81
+			],
82
+
83
+			'update_your_organization_settings' => [
84
+				'func'       => '_update_your_organization_settings',
85
+				'capability' => 'manage_options',
86
+				'noheader'   => true,
87
+			],
88
+
89
+			'admin_option_settings' => [
90
+				'func'       => '_admin_option_settings',
91
+				'capability' => 'manage_options',
92
+			],
93
+
94
+			'update_admin_option_settings' => [
95
+				'func'       => '_update_admin_option_settings',
96
+				'capability' => 'manage_options',
97
+				'noheader'   => true,
98
+			],
99
+
100
+			'country_settings' => [
101
+				'func'       => '_country_settings',
102
+				'capability' => 'manage_options',
103
+			],
104
+
105
+			'update_country_settings' => [
106
+				'func'       => '_update_country_settings',
107
+				'capability' => 'manage_options',
108
+				'noheader'   => true,
109
+			],
110
+
111
+			'display_country_settings' => [
112
+				'func'       => 'display_country_settings',
113
+				'capability' => 'manage_options',
114
+				'noheader'   => true,
115
+			],
116
+
117
+			'add_new_state' => [
118
+				'func'       => 'add_new_state',
119
+				'capability' => 'manage_options',
120
+				'noheader'   => true,
121
+			],
122
+
123
+			'delete_state'            => [
124
+				'func'       => 'delete_state',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			],
128
+			'privacy_settings'        => [
129
+				'func'       => 'privacySettings',
130
+				'capability' => 'manage_options',
131
+			],
132
+			'update_privacy_settings' => [
133
+				'func'               => 'updatePrivacySettings',
134
+				'capability'         => 'manage_options',
135
+				'noheader'           => true,
136
+				'headers_sent_route' => 'privacy_settings',
137
+			],
138
+		];
139
+	}
140
+
141
+
142
+	/**
143
+	 * Set page configuration property
144
+	 */
145
+	protected function _set_page_config()
146
+	{
147
+		$this->_page_config = [
148
+			'critical_pages'        => [
149
+				'nav'           => [
150
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'order' => 20,
166
+				],
167
+				'help_tabs'     => [
168
+					'general_settings_your_organization_help_tab' => [
169
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
170
+						'filename' => 'general_settings_your_organization',
171
+					],
172
+				],
173
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
+				'require_nonce' => false,
175
+			],
176
+			'admin_option_settings' => [
177
+				'nav'           => [
178
+					'label' => esc_html__('Admin Options', 'event_espresso'),
179
+					'order' => 60,
180
+				],
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
+				'help_tabs'     => [
183
+					'general_settings_admin_options_help_tab' => [
184
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
185
+						'filename' => 'general_settings_admin_options',
186
+					],
187
+				],
188
+				'require_nonce' => false,
189
+			],
190
+			'country_settings'      => [
191
+				'nav'           => [
192
+					'label' => esc_html__('Countries', 'event_espresso'),
193
+					'order' => 70,
194
+				],
195
+				'help_tabs'     => [
196
+					'general_settings_countries_help_tab' => [
197
+						'title'    => esc_html__('Countries', 'event_espresso'),
198
+						'filename' => 'general_settings_countries',
199
+					],
200
+				],
201
+				'require_nonce' => false,
202
+			],
203
+			'privacy_settings'      => [
204
+				'nav'           => [
205
+					'label' => esc_html__('Privacy', 'event_espresso'),
206
+					'order' => 80,
207
+				],
208
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
+				'require_nonce' => false,
210
+			],
211
+		];
212
+	}
213
+
214
+
215
+	protected function _add_screen_options()
216
+	{
217
+	}
218
+
219
+
220
+	protected function _add_feature_pointers()
221
+	{
222
+	}
223
+
224
+
225
+	/**
226
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
+	 */
228
+	public function load_scripts_styles()
229
+	{
230
+		// styles
231
+		wp_enqueue_style('espresso-ui-theme');
232
+		// scripts
233
+		wp_enqueue_script('ee_admin_js');
234
+	}
235
+
236
+
237
+	/**
238
+	 * Execute logic running on `admin_init`
239
+	 */
240
+	public function admin_init()
241
+	{
242
+		$this->core_config = EE_Registry::instance()->CFG->core;
243
+
244
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
+			esc_html__(
246
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
+				'event_espresso'
248
+			)
249
+		);
250
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
+			esc_html__(
252
+				'An error occurred! Please refresh the page and try again.',
253
+				'event_espresso'
254
+			)
255
+		);
256
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
+			esc_html__(
258
+				'Are you sure you want to delete this State / Province?',
259
+				'event_espresso'
260
+			)
261
+		);
262
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
+			'admin-ajax.php?page=espresso_general_settings',
264
+			is_ssl() ? 'https://' : 'http://'
265
+		);
266
+	}
267
+
268
+
269
+	public function admin_notices()
270
+	{
271
+	}
272
+
273
+
274
+	public function admin_footer_scripts()
275
+	{
276
+	}
277
+
278
+
279
+	/**
280
+	 * Enqueue scripts and styles for the default route.
281
+	 */
282
+	public function load_scripts_styles_default()
283
+	{
284
+		// styles
285
+		wp_enqueue_style('thickbox');
286
+		// scripts
287
+		wp_enqueue_script('media-upload');
288
+		wp_enqueue_script('thickbox');
289
+		wp_register_script(
290
+			'organization_settings',
291
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+			['jquery', 'media-upload', 'thickbox'],
293
+			EVENT_ESPRESSO_VERSION,
294
+			true
295
+		);
296
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
+		wp_enqueue_script('organization_settings');
298
+		wp_enqueue_style('organization-css');
299
+		$confirm_image_delete = [
300
+			'text' => wp_strip_all_tags(
301
+				esc_html__(
302
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+					'event_espresso'
304
+				)
305
+			),
306
+		];
307
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
+	}
309
+
310
+
311
+	/**
312
+	 * Enqueue scripts and styles for the country settings route.
313
+	 */
314
+	public function load_scripts_styles_country_settings()
315
+	{
316
+		// scripts
317
+		wp_register_script(
318
+			'gen_settings_countries',
319
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
+			['ee_admin_js'],
321
+			EVENT_ESPRESSO_VERSION,
322
+			true
323
+		);
324
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
+		wp_enqueue_script('gen_settings_countries');
326
+		wp_enqueue_style('organization-css');
327
+	}
328
+
329
+
330
+	/*************        Espresso Pages        *************/
331
+	/**
332
+	 * _espresso_page_settings
333
+	 *
334
+	 * @throws EE_Error
335
+	 * @throws DomainException
336
+	 * @throws DomainException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws InvalidArgumentException
339
+	 */
340
+	protected function _espresso_page_settings()
341
+	{
342
+		// Check to make sure all of the main pages are set up properly,
343
+		// if not create the default pages and display an admin notice
344
+		EEH_Activation::verify_default_pages_exist();
345
+		$this->_transient_garbage_collection();
346
+
347
+		$this->_template_args['values'] = $this->_yes_no_values;
348
+
349
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
350
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
351
+			? get_post($this->core_config->reg_page_id)
352
+			: false;
353
+
354
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
355
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
356
+			? get_post($this->core_config->txn_page_id)
357
+			: false;
358
+
359
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
+			? get_post($this->core_config->thank_you_page_id)
362
+			: false;
363
+
364
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
365
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
366
+			? get_post($this->core_config->cancel_page_id)
367
+			: false;
368
+
369
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
370
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
371
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+			$this->_template_args,
374
+			true
375
+		);
376
+		$this->display_admin_page_with_sidebar();
377
+	}
378
+
379
+
380
+	/**
381
+	 * Handler for updating espresso page settings.
382
+	 *
383
+	 * @throws EE_Error
384
+	 */
385
+	protected function _update_espresso_page_settings()
386
+	{
387
+		// capture incoming request data && set page IDs
388
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
389
+			'reg_page_id',
390
+			$this->core_config->reg_page_id,
391
+			DataType::INT
392
+		);
393
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
394
+			'txn_page_id',
395
+			$this->core_config->txn_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
+			'thank_you_page_id',
400
+			$this->core_config->thank_you_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
+			'cancel_page_id',
405
+			$this->core_config->cancel_page_id,
406
+			DataType::INT
407
+		);
408
+
409
+		$this->core_config = apply_filters(
410
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
+			$this->core_config,
412
+			$this->request->requestParams()
413
+		);
414
+
415
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
+		$this->_redirect_after_action(
417
+			$this->_update_espresso_configuration(
418
+				$what,
419
+				$this->core_config,
420
+				__FILE__,
421
+				__FUNCTION__,
422
+				__LINE__
423
+			),
424
+			$what,
425
+			'',
426
+			[
427
+				'action' => 'critical_pages',
428
+			],
429
+			true
430
+		);
431
+	}
432
+
433
+
434
+	/*************        Your Organization        *************/
435
+
436
+
437
+	/**
438
+	 * @throws DomainException
439
+	 * @throws EE_Error
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 */
444
+	protected function _your_organization_settings()
445
+	{
446
+		$this->_template_args['admin_page_content'] = '';
447
+		try {
448
+			/** @var OrganizationSettings $organization_settings_form */
449
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
+
451
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
452
+				$organization_settings_form->display(),
453
+				'',
454
+				'padding'
455
+			);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
+		}
459
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
460
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
461
+		$this->display_admin_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handler for updating organization settings.
467
+	 *
468
+	 * @throws EE_Error
469
+	 */
470
+	protected function _update_your_organization_settings()
471
+	{
472
+		try {
473
+			/** @var OrganizationSettings $organization_settings_form */
474
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
+
476
+			$success = $organization_settings_form->process($this->request->requestParams());
477
+
478
+			EE_Registry::instance()->CFG = apply_filters(
479
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
+				EE_Registry::instance()->CFG
481
+			);
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
+			$success = false;
485
+		}
486
+
487
+		if ($success) {
488
+			$success = $this->_update_espresso_configuration(
489
+				esc_html__('Your Organization Settings', 'event_espresso'),
490
+				EE_Registry::instance()->CFG,
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+
497
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
+	}
499
+
500
+
501
+
502
+	/*************        Admin Options        *************/
503
+
504
+
505
+	/**
506
+	 * _admin_option_settings
507
+	 *
508
+	 * @throws EE_Error
509
+	 * @throws LogicException
510
+	 */
511
+	protected function _admin_option_settings()
512
+	{
513
+		$this->_template_args['admin_page_content'] = '';
514
+		try {
515
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
517
+			$this->_template_args['values'] = $this->_yes_no_values;
518
+			// also need to account for the do_action that was in the old template
519
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
520
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
521
+		} catch (Exception $e) {
522
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
523
+		}
524
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
525
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
526
+		$this->display_admin_page_with_sidebar();
527
+	}
528
+
529
+
530
+	/**
531
+	 * _update_admin_option_settings
532
+	 *
533
+	 * @throws EE_Error
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws InvalidFormSubmissionException
536
+	 * @throws InvalidArgumentException
537
+	 * @throws LogicException
538
+	 */
539
+	protected function _update_admin_option_settings()
540
+	{
541
+		try {
542
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
543
+			$admin_options_settings_form->process(
544
+				$this->request->getRequestParam(
545
+					$admin_options_settings_form->slug(),
546
+					[],
547
+					DataType::OBJECT // need to change this to ARRAY after min PHP version gets bumped to 7+
548
+				)
549
+			);
550
+			EE_Registry::instance()->CFG->admin = apply_filters(
551
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
+				EE_Registry::instance()->CFG->admin
553
+			);
554
+		} catch (Exception $e) {
555
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
+		}
557
+		$this->_redirect_after_action(
558
+			apply_filters(
559
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
+				$this->_update_espresso_configuration(
561
+					esc_html__('Admin Options', 'event_espresso'),
562
+					EE_Registry::instance()->CFG->admin,
563
+					__FILE__,
564
+					__FUNCTION__,
565
+					__LINE__
566
+				)
567
+			),
568
+			esc_html__('Admin Options', 'event_espresso'),
569
+			'updated',
570
+			['action' => 'admin_option_settings']
571
+		);
572
+	}
573
+
574
+
575
+	/*************        Countries        *************/
576
+
577
+
578
+	/**
579
+	 * @param string|null $default
580
+	 * @return string
581
+	 */
582
+	protected function getCountryISO(?string $default = null): string
583
+	{
584
+		$default = $default ?? $this->getCountryIsoForSite();
585
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
586
+		$CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
587
+		return strtoupper($CNT_ISO);
588
+	}
589
+
590
+
591
+	/**
592
+	 * @return string
593
+	 */
594
+	protected function getCountryIsoForSite(): string
595
+	{
596
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
597
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
598
+			: 'US';
599
+	}
600
+
601
+
602
+	/**
603
+	 * @param string          $CNT_ISO
604
+	 * @param EE_Country|null $country
605
+	 * @return EE_Base_Class|EE_Country
606
+	 * @throws EE_Error
607
+	 * @throws InvalidArgumentException
608
+	 * @throws InvalidDataTypeException
609
+	 * @throws InvalidInterfaceException
610
+	 * @throws ReflectionException
611
+	 */
612
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
613
+	{
614
+		/** @var EE_Country $country */
615
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
616
+			? $country
617
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
618
+	}
619
+
620
+
621
+	/**
622
+	 * Output Country Settings view.
623
+	 *
624
+	 * @throws DomainException
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 * @throws ReflectionException
630
+	 */
631
+	protected function _country_settings()
632
+	{
633
+		$CNT_ISO = $this->getCountryISO();
634
+
635
+		$this->_template_args['values']    = $this->_yes_no_values;
636
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
637
+			EE_Question::new_instance(
638
+				[
639
+					'QST_ID'           => 0,
640
+					'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
641
+					'QST_system'       => 'admin-country',
642
+				]
643
+			),
644
+			EE_Answer::new_instance(
645
+				[
646
+					'ANS_ID'    => 0,
647
+					'ANS_value' => $CNT_ISO,
648
+				]
649
+			),
650
+			[
651
+				'input_id'       => 'country',
652
+				'input_name'     => 'country',
653
+				'input_prefix'   => '',
654
+				'append_qstn_id' => false,
655
+			]
656
+		);
657
+
658
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
659
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
660
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
661
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
662
+			$country->ID(),
663
+			$country
664
+		);
665
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
666
+			$country->ID(),
667
+			$country
668
+		);
669
+		$this->_template_args['CNT_name_for_site']        = $country->name();
670
+
671
+		$this->_set_add_edit_form_tags('update_country_settings');
672
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
673
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
675
+			$this->_template_args,
676
+			true
677
+		);
678
+		$this->display_admin_page_with_no_sidebar();
679
+	}
680
+
681
+
682
+	/**
683
+	 * @param string          $CNT_ISO
684
+	 * @param EE_Country|null $country
685
+	 * @return string
686
+	 * @throws DomainException
687
+	 * @throws EE_Error
688
+	 * @throws InvalidArgumentException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws InvalidInterfaceException
691
+	 * @throws ReflectionException
692
+	 */
693
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
694
+	{
695
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
696
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
697
+
698
+		if (! $CNT_ISO) {
699
+			return '';
700
+		}
701
+
702
+		// for ajax
703
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
704
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
705
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
706
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
707
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
708
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710
+
711
+		$country_input_types            = [
712
+			'CNT_active'      => [
713
+				'type'             => 'RADIO_BTN',
714
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
715
+				'class'            => '',
716
+				'options'          => $this->_yes_no_values,
717
+				'use_desc_4_label' => true,
718
+			],
719
+			'CNT_ISO'         => [
720
+				'type'       => 'TEXT',
721
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
722
+				'class'      => 'small-text',
723
+			],
724
+			'CNT_ISO3'        => [
725
+				'type'       => 'TEXT',
726
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
727
+				'class'      => 'small-text',
728
+			],
729
+			// 'RGN_ID'          => [
730
+			//     'type'       => 'TEXT',
731
+			//     'input_name' => 'cntry[' . $CNT_ISO . ']',
732
+			//     'class'      => 'ee-input-size--small',
733
+			// ],
734
+			'CNT_name'        => [
735
+				'type'       => 'TEXT',
736
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
737
+				'class'      => 'regular-text',
738
+			],
739
+			'CNT_cur_code'    => [
740
+				'type'       => 'TEXT',
741
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
742
+				'class'      => 'small-text',
743
+				'disabled'   => $CNT_cur_disabled,
744
+			],
745
+			'CNT_cur_single'  => [
746
+				'type'       => 'TEXT',
747
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
748
+				'class'      => 'medium-text',
749
+				'disabled'   => $CNT_cur_disabled,
750
+			],
751
+			'CNT_cur_plural'  => [
752
+				'type'       => 'TEXT',
753
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
754
+				'class'      => 'medium-text',
755
+				'disabled'   => $CNT_cur_disabled,
756
+			],
757
+			'CNT_cur_sign'    => [
758
+				'type'         => 'TEXT',
759
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
760
+				'class'        => 'small-text',
761
+				'htmlentities' => false,
762
+				'disabled'     => $CNT_cur_disabled,
763
+			],
764
+			'CNT_cur_sign_b4' => [
765
+				'type'             => 'RADIO_BTN',
766
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
+				'class'            => '',
768
+				'options'          => $this->_yes_no_values,
769
+				'use_desc_4_label' => true,
770
+				'disabled'         => $CNT_cur_disabled,
771
+			],
772
+			'CNT_cur_dec_plc' => [
773
+				'type'       => 'RADIO_BTN',
774
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
775
+				'class'      => '',
776
+				'options'    => [
777
+					['id' => 0, 'text' => ''],
778
+					['id' => 1, 'text' => ''],
779
+					['id' => 2, 'text' => ''],
780
+					['id' => 3, 'text' => ''],
781
+				],
782
+				'disabled'   => $CNT_cur_disabled,
783
+			],
784
+			'CNT_cur_dec_mrk' => [
785
+				'type'             => 'RADIO_BTN',
786
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
+				'class'            => '',
788
+				'options'          => [
789
+					[
790
+						'id'   => ',',
791
+						'text' => esc_html__(', (comma)', 'event_espresso'),
792
+					],
793
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
794
+				],
795
+				'use_desc_4_label' => true,
796
+				'disabled'         => $CNT_cur_disabled,
797
+			],
798
+			'CNT_cur_thsnds'  => [
799
+				'type'             => 'RADIO_BTN',
800
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
+				'class'            => '',
802
+				'options'          => [
803
+					[
804
+						'id'   => ',',
805
+						'text' => esc_html__(', (comma)', 'event_espresso'),
806
+					],
807
+					[
808
+						'id'   => '.',
809
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
810
+					],
811
+					[
812
+						'id'   => '&nbsp;',
813
+						'text' => esc_html__('(space)', 'event_espresso'),
814
+					],
815
+				],
816
+				'use_desc_4_label' => true,
817
+				'disabled'         => $CNT_cur_disabled,
818
+			],
819
+			'CNT_tel_code'    => [
820
+				'type'       => 'TEXT',
821
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
822
+				'class'      => 'small-text',
823
+			],
824
+			'CNT_is_EU'       => [
825
+				'type'             => 'RADIO_BTN',
826
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
827
+				'class'            => '',
828
+				'options'          => $this->_yes_no_values,
829
+				'use_desc_4_label' => true,
830
+			],
831
+		];
832
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
833
+			$country,
834
+			$country_input_types
835
+		);
836
+		$country_details_settings       = EEH_Template::display_template(
837
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
838
+			$this->_template_args,
839
+			true
840
+		);
841
+
842
+		if (defined('DOING_AJAX')) {
843
+			$notices = EE_Error::get_notices(false, false, false);
844
+			echo wp_json_encode(
845
+				[
846
+					'return_data' => $country_details_settings,
847
+					'success'     => $notices['success'],
848
+					'errors'      => $notices['errors'],
849
+				]
850
+			);
851
+			die();
852
+		}
853
+		return $country_details_settings;
854
+	}
855
+
856
+
857
+	/**
858
+	 * @param string          $CNT_ISO
859
+	 * @param EE_Country|null $country
860
+	 * @return string
861
+	 * @throws DomainException
862
+	 * @throws EE_Error
863
+	 * @throws InvalidArgumentException
864
+	 * @throws InvalidDataTypeException
865
+	 * @throws InvalidInterfaceException
866
+	 * @throws ReflectionException
867
+	 */
868
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
869
+	{
870
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
871
+		if (! $CNT_ISO) {
872
+			return '';
873
+		}
874
+		// for ajax
875
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
876
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
877
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
878
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
879
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
880
+		if (empty($states)) {
881
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
882
+			$countrySubRegionDao = $this->loader->getShared(
883
+				'EventEspresso\core\services\address\CountrySubRegionDao'
884
+			);
885
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
886
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
887
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
888
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
889
+				}
890
+			}
891
+		}
892
+		if (is_array($states)) {
893
+			foreach ($states as $STA_ID => $state) {
894
+				if ($state instanceof EE_State) {
895
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
896
+						$state,
897
+						[
898
+							'STA_abbrev' => [
899
+								'type'             => 'TEXT',
900
+								'label'            => esc_html__('Code', 'event_espresso'),
901
+								'input_name'       => 'states[' . $STA_ID . ']',
902
+								'class'            => 'small-text',
903
+								'add_mobile_label' => true,
904
+							],
905
+							'STA_name'   => [
906
+								'type'             => 'TEXT',
907
+								'label'            => esc_html__('Name', 'event_espresso'),
908
+								'input_name'       => 'states[' . $STA_ID . ']',
909
+								'class'            => 'regular-text',
910
+								'add_mobile_label' => true,
911
+							],
912
+							'STA_active' => [
913
+								'type'             => 'RADIO_BTN',
914
+								'label'            => esc_html__(
915
+									'State Appears in Dropdown Select Lists',
916
+									'event_espresso'
917
+								),
918
+								'input_name'       => 'states[' . $STA_ID . ']',
919
+								'options'          => $this->_yes_no_values,
920
+								'use_desc_4_label' => true,
921
+								'add_mobile_label' => true,
922
+							],
923
+						]
924
+					);
925
+
926
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
927
+						[
928
+							'action'     => 'delete_state',
929
+							'STA_ID'     => $STA_ID,
930
+							'CNT_ISO'    => $CNT_ISO,
931
+							'STA_abbrev' => $state->abbrev(),
932
+						],
933
+						GEN_SET_ADMIN_URL
934
+					);
935
+
936
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
938
+				}
939
+			}
940
+		} else {
941
+			$this->_template_args['states'] = false;
942
+		}
943
+
944
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
945
+			['action' => 'add_new_state'],
946
+			GEN_SET_ADMIN_URL
947
+		);
948
+
949
+		$state_details_settings = EEH_Template::display_template(
950
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
951
+			$this->_template_args,
952
+			true
953
+		);
954
+
955
+		if (defined('DOING_AJAX')) {
956
+			$notices = EE_Error::get_notices(false, false, false);
957
+			echo wp_json_encode(
958
+				[
959
+					'return_data' => $state_details_settings,
960
+					'success'     => $notices['success'],
961
+					'errors'      => $notices['errors'],
962
+				]
963
+			);
964
+			die();
965
+		}
966
+		return $state_details_settings;
967
+	}
968
+
969
+
970
+	/**
971
+	 * @return void
972
+	 * @throws EE_Error
973
+	 * @throws InvalidArgumentException
974
+	 * @throws InvalidDataTypeException
975
+	 * @throws InvalidInterfaceException
976
+	 * @throws ReflectionException
977
+	 */
978
+	public function add_new_state()
979
+	{
980
+		$success = true;
981
+		$CNT_ISO = $this->getCountryISO('');
982
+		if (! $CNT_ISO) {
983
+			EE_Error::add_error(
984
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985
+				__FILE__,
986
+				__FUNCTION__,
987
+				__LINE__
988
+			);
989
+			$success = false;
990
+		}
991
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
+		if (! $STA_abbrev) {
993
+			EE_Error::add_error(
994
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995
+				__FILE__,
996
+				__FUNCTION__,
997
+				__LINE__
998
+			);
999
+			$success = false;
1000
+		}
1001
+		$STA_name = $this->request->getRequestParam('STA_name');
1002
+		if (! $STA_name) {
1003
+			EE_Error::add_error(
1004
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005
+				__FILE__,
1006
+				__FUNCTION__,
1007
+				__LINE__
1008
+			);
1009
+			$success = false;
1010
+		}
1011
+
1012
+		if ($success) {
1013
+			$cols_n_values = [
1014
+				'CNT_ISO'    => $CNT_ISO,
1015
+				'STA_abbrev' => $STA_abbrev,
1016
+				'STA_name'   => $STA_name,
1017
+				'STA_active' => true,
1018
+			];
1019
+			$success       = EEM_State::instance()->insert($cols_n_values);
1020
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021
+		}
1022
+
1023
+		if (defined('DOING_AJAX')) {
1024
+			$notices = EE_Error::get_notices(false, false, false);
1025
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1026
+			die();
1027
+		} else {
1028
+			$this->_redirect_after_action(
1029
+				$success,
1030
+				esc_html__('State', 'event_espresso'),
1031
+				'added',
1032
+				['action' => 'country_settings']
1033
+			);
1034
+		}
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @return void
1040
+	 * @throws EE_Error
1041
+	 * @throws InvalidArgumentException
1042
+	 * @throws InvalidDataTypeException
1043
+	 * @throws InvalidInterfaceException
1044
+	 * @throws ReflectionException
1045
+	 */
1046
+	public function delete_state()
1047
+	{
1048
+		$CNT_ISO    = $this->getCountryISO();
1049
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1050
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
+
1052
+		if (! $STA_ID) {
1053
+			EE_Error::add_error(
1054
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
+				__FILE__,
1056
+				__FUNCTION__,
1057
+				__LINE__
1058
+			);
1059
+			return;
1060
+		}
1061
+
1062
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
+		if ($success !== false) {
1064
+			do_action(
1065
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1066
+				$CNT_ISO,
1067
+				$STA_ID,
1068
+				['STA_abbrev' => $STA_abbrev]
1069
+			);
1070
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1071
+		}
1072
+		if (defined('DOING_AJAX')) {
1073
+			$notices                = EE_Error::get_notices(false);
1074
+			$notices['return_data'] = true;
1075
+			echo wp_json_encode($notices);
1076
+			die();
1077
+		} else {
1078
+			$this->_redirect_after_action(
1079
+				$success,
1080
+				esc_html__('State', 'event_espresso'),
1081
+				'deleted',
1082
+				['action' => 'country_settings']
1083
+			);
1084
+		}
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 *        _update_country_settings
1090
+	 *
1091
+	 * @return void
1092
+	 * @throws EE_Error
1093
+	 * @throws InvalidArgumentException
1094
+	 * @throws InvalidDataTypeException
1095
+	 * @throws InvalidInterfaceException
1096
+	 * @throws ReflectionException
1097
+	 */
1098
+	protected function _update_country_settings()
1099
+	{
1100
+		$CNT_ISO = $this->getCountryISO();
1101
+		if (! $CNT_ISO) {
1102
+			EE_Error::add_error(
1103
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1104
+				__FILE__,
1105
+				__FUNCTION__,
1106
+				__LINE__
1107
+			);
1108
+			return;
1109
+		}
1110
+
1111
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1112
+
1113
+		$cols_n_values                    = [];
1114
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1115
+			$this->request->getRequestParam('cntry', $country->ISO3())
1116
+		);
1117
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1118
+			"cntry[$CNT_ISO][CNT_name]",
1119
+			$country->name()
1120
+		);
1121
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1122
+			$this->request->getRequestParam(
1123
+				"cntry[$CNT_ISO][CNT_cur_code]",
1124
+				$country->currency_code()
1125
+			)
1126
+		);
1127
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1128
+			"cntry[$CNT_ISO][CNT_cur_single]",
1129
+			$country->currency_name_single()
1130
+		);
1131
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1132
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1133
+			$country->currency_name_plural()
1134
+		);
1135
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1136
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1137
+			$country->currency_sign()
1138
+		);
1139
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1140
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1141
+			$country->currency_sign_before(),
1142
+			DataType::BOOL
1143
+		);
1144
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1145
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1146
+			$country->currency_decimal_places()
1147
+		);
1148
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1149
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1150
+			$country->currency_decimal_mark()
1151
+		);
1152
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1153
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1154
+			$country->currency_thousands_separator()
1155
+		);
1156
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1157
+			"cntry[$CNT_ISO][CNT_tel_code]",
1158
+			$country->telephoneCode()
1159
+		);
1160
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1161
+			"cntry[$CNT_ISO][CNT_active]",
1162
+			$country->isActive(),
1163
+			DataType::BOOL
1164
+		);
1165
+
1166
+		// allow filtering of country data
1167
+		$cols_n_values = apply_filters(
1168
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1169
+			$cols_n_values
1170
+		);
1171
+
1172
+		// where values
1173
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1174
+		// run the update
1175
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1176
+
1177
+		// allow filtering of states data
1178
+		$states = apply_filters(
1179
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1180
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1181
+		);
1182
+
1183
+		if (! empty($states) && $success !== false) {
1184
+			// loop thru state data ( looks like : states[75][STA_name] )
1185
+			foreach ($states as $STA_ID => $state) {
1186
+				$cols_n_values = [
1187
+					'CNT_ISO'    => $CNT_ISO,
1188
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1189
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1190
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1191
+				];
1192
+				// where values
1193
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1194
+				// run the update
1195
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1196
+				if ($success !== false) {
1197
+					do_action(
1198
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1199
+						$CNT_ISO,
1200
+						$STA_ID,
1201
+						$cols_n_values
1202
+					);
1203
+				}
1204
+			}
1205
+		}
1206
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1207
+		if (
1208
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1209
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1210
+		) {
1211
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1212
+			EE_Registry::instance()->CFG->update_espresso_config();
1213
+		}
1214
+
1215
+		if ($success !== false) {
1216
+			EE_Error::add_success(
1217
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1218
+			);
1219
+		}
1220
+		$this->_redirect_after_action(
1221
+			$success,
1222
+			'',
1223
+			'',
1224
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1225
+			true
1226
+		);
1227
+	}
1228
+
1229
+
1230
+	/**
1231
+	 * form_form_field_label_wrap
1232
+	 *
1233
+	 * @param string $label
1234
+	 * @return string
1235
+	 */
1236
+	public function country_form_field_label_wrap(string $label): string
1237
+	{
1238
+		return '
1239 1239
 			<tr>
1240 1240
 				<th>
1241 1241
 					' . $label . '
1242 1242
 				</th>';
1243
-    }
1244
-
1245
-
1246
-    /**
1247
-     * form_form_field_input__wrap
1248
-     *
1249
-     * @param string $input
1250
-     * @return string
1251
-     */
1252
-    public function country_form_field_input__wrap(string $input): string
1253
-    {
1254
-        return '
1243
+	}
1244
+
1245
+
1246
+	/**
1247
+	 * form_form_field_input__wrap
1248
+	 *
1249
+	 * @param string $input
1250
+	 * @return string
1251
+	 */
1252
+	public function country_form_field_input__wrap(string $input): string
1253
+	{
1254
+		return '
1255 1255
 				<td class="general-settings-country-input-td">
1256 1256
 					' . $input . '
1257 1257
 				</td>
1258 1258
 			</tr>';
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     * form_form_field_label_wrap
1264
-     *
1265
-     * @param string $label
1266
-     * @param string $required_text
1267
-     * @return string
1268
-     */
1269
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1270
-    {
1271
-        return $required_text;
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     * form_form_field_input__wrap
1277
-     *
1278
-     * @param string $input
1279
-     * @return string
1280
-     */
1281
-    public function state_form_field_input__wrap(string $input): string
1282
-    {
1283
-        return '
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 * form_form_field_label_wrap
1264
+	 *
1265
+	 * @param string $label
1266
+	 * @param string $required_text
1267
+	 * @return string
1268
+	 */
1269
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1270
+	{
1271
+		return $required_text;
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 * form_form_field_input__wrap
1277
+	 *
1278
+	 * @param string $input
1279
+	 * @return string
1280
+	 */
1281
+	public function state_form_field_input__wrap(string $input): string
1282
+	{
1283
+		return '
1284 1284
 				<td class="general-settings-country-state-input-td">
1285 1285
 					' . $input . '
1286 1286
 				</td>';
1287
-    }
1288
-
1289
-
1290
-    /***********/
1291
-
1292
-
1293
-    /**
1294
-     * displays edit and view links for critical EE pages
1295
-     *
1296
-     * @param int $ee_page_id
1297
-     * @return string
1298
-     */
1299
-    public static function edit_view_links(int $ee_page_id): string
1300
-    {
1301
-        $edit_url = add_query_arg(
1302
-            ['post' => $ee_page_id, 'action' => 'edit'],
1303
-            admin_url('post.php')
1304
-        );
1305
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1306
-        $links    .= ' &nbsp;|&nbsp; ';
1307
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1308
-
1309
-        return $links;
1310
-    }
1311
-
1312
-
1313
-    /**
1314
-     * displays page and shortcode status for critical EE pages
1315
-     *
1316
-     * @param WP_Post $ee_page
1317
-     * @param string  $shortcode
1318
-     * @return string
1319
-     */
1320
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1321
-    {
1322
-        // page status
1323
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1324
-            $pg_colour = 'green';
1325
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1326
-        } else {
1327
-            $pg_colour = 'red';
1328
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1329
-        }
1330
-
1331
-        // shortcode status
1332
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1333
-            $sc_colour = 'green';
1334
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1335
-        } else {
1336
-            $sc_colour = 'red';
1337
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1338
-        }
1339
-
1340
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1341
-               . $pg_status
1342
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1343
-    }
1344
-
1345
-
1346
-    /**
1347
-     * generates a dropdown of all parent pages - copied from WP core
1348
-     *
1349
-     * @param int  $default
1350
-     * @param int  $parent
1351
-     * @param int  $level
1352
-     * @param bool $echo
1353
-     * @return string;
1354
-     */
1355
-    public static function page_settings_dropdown(
1356
-        int $default = 0,
1357
-        int $parent = 0,
1358
-        int $level = 0,
1359
-        bool $echo = true
1360
-    ): string {
1361
-        global $wpdb;
1362
-        $items  = $wpdb->get_results(
1363
-            $wpdb->prepare(
1364
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1365
-                $parent
1366
-            )
1367
-        );
1368
-        $output = '';
1369
-
1370
-        if ($items) {
1371
-            $level = absint($level);
1372
-            foreach ($items as $item) {
1373
-                $ID         = absint($item->ID);
1374
-                $post_title = wp_strip_all_tags($item->post_title);
1375
-                $pad        = str_repeat('&nbsp;', $level * 3);
1376
-                $option     = "\n\t";
1377
-                $option     .= '<option class="level-' . $level . '" ';
1378
-                $option     .= 'value="' . $ID . '" ';
1379
-                $option     .= $ID === absint($default) ? ' selected' : '';
1380
-                $option     .= '>';
1381
-                $option     .= "$pad {$post_title}";
1382
-                $option     .= '</option>';
1383
-                $output     .= $option;
1384
-                ob_start();
1385
-                parent_dropdown($default, $item->ID, $level + 1);
1386
-                $output .= ob_get_clean();
1387
-            }
1388
-        }
1389
-        if ($echo) {
1390
-            echo wp_kses($output, AllowedTags::getAllowedTags());
1391
-            return '';
1392
-        }
1393
-        return $output;
1394
-    }
1395
-
1396
-
1397
-    /**
1398
-     * Loads the scripts for the privacy settings form
1399
-     */
1400
-    public function load_scripts_styles_privacy_settings()
1401
-    {
1402
-        $form_handler = $this->loader->getShared(
1403
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1404
-        );
1405
-        $form_handler->enqueueStylesAndScripts();
1406
-    }
1407
-
1408
-
1409
-    /**
1410
-     * display the privacy settings form
1411
-     *
1412
-     * @throws EE_Error
1413
-     */
1414
-    public function privacySettings()
1415
-    {
1416
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1417
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1418
-        $form_handler                               = $this->loader->getShared(
1419
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1420
-        );
1421
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1422
-            $form_handler->display(),
1423
-            '',
1424
-            'padding'
1425
-        );
1426
-        $this->display_admin_page_with_sidebar();
1427
-    }
1428
-
1429
-
1430
-    /**
1431
-     * Update the privacy settings from form data
1432
-     *
1433
-     * @throws EE_Error
1434
-     */
1435
-    public function updatePrivacySettings()
1436
-    {
1437
-        $form_handler = $this->loader->getShared(
1438
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1439
-        );
1440
-        $success      = $form_handler->process($this->get_request_data());
1441
-        $this->_redirect_after_action(
1442
-            $success,
1443
-            esc_html__('Registration Form Options', 'event_espresso'),
1444
-            'updated',
1445
-            ['action' => 'privacy_settings']
1446
-        );
1447
-    }
1287
+	}
1288
+
1289
+
1290
+	/***********/
1291
+
1292
+
1293
+	/**
1294
+	 * displays edit and view links for critical EE pages
1295
+	 *
1296
+	 * @param int $ee_page_id
1297
+	 * @return string
1298
+	 */
1299
+	public static function edit_view_links(int $ee_page_id): string
1300
+	{
1301
+		$edit_url = add_query_arg(
1302
+			['post' => $ee_page_id, 'action' => 'edit'],
1303
+			admin_url('post.php')
1304
+		);
1305
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1306
+		$links    .= ' &nbsp;|&nbsp; ';
1307
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1308
+
1309
+		return $links;
1310
+	}
1311
+
1312
+
1313
+	/**
1314
+	 * displays page and shortcode status for critical EE pages
1315
+	 *
1316
+	 * @param WP_Post $ee_page
1317
+	 * @param string  $shortcode
1318
+	 * @return string
1319
+	 */
1320
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1321
+	{
1322
+		// page status
1323
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1324
+			$pg_colour = 'green';
1325
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1326
+		} else {
1327
+			$pg_colour = 'red';
1328
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1329
+		}
1330
+
1331
+		// shortcode status
1332
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1333
+			$sc_colour = 'green';
1334
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1335
+		} else {
1336
+			$sc_colour = 'red';
1337
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1338
+		}
1339
+
1340
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1341
+			   . $pg_status
1342
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1343
+	}
1344
+
1345
+
1346
+	/**
1347
+	 * generates a dropdown of all parent pages - copied from WP core
1348
+	 *
1349
+	 * @param int  $default
1350
+	 * @param int  $parent
1351
+	 * @param int  $level
1352
+	 * @param bool $echo
1353
+	 * @return string;
1354
+	 */
1355
+	public static function page_settings_dropdown(
1356
+		int $default = 0,
1357
+		int $parent = 0,
1358
+		int $level = 0,
1359
+		bool $echo = true
1360
+	): string {
1361
+		global $wpdb;
1362
+		$items  = $wpdb->get_results(
1363
+			$wpdb->prepare(
1364
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1365
+				$parent
1366
+			)
1367
+		);
1368
+		$output = '';
1369
+
1370
+		if ($items) {
1371
+			$level = absint($level);
1372
+			foreach ($items as $item) {
1373
+				$ID         = absint($item->ID);
1374
+				$post_title = wp_strip_all_tags($item->post_title);
1375
+				$pad        = str_repeat('&nbsp;', $level * 3);
1376
+				$option     = "\n\t";
1377
+				$option     .= '<option class="level-' . $level . '" ';
1378
+				$option     .= 'value="' . $ID . '" ';
1379
+				$option     .= $ID === absint($default) ? ' selected' : '';
1380
+				$option     .= '>';
1381
+				$option     .= "$pad {$post_title}";
1382
+				$option     .= '</option>';
1383
+				$output     .= $option;
1384
+				ob_start();
1385
+				parent_dropdown($default, $item->ID, $level + 1);
1386
+				$output .= ob_get_clean();
1387
+			}
1388
+		}
1389
+		if ($echo) {
1390
+			echo wp_kses($output, AllowedTags::getAllowedTags());
1391
+			return '';
1392
+		}
1393
+		return $output;
1394
+	}
1395
+
1396
+
1397
+	/**
1398
+	 * Loads the scripts for the privacy settings form
1399
+	 */
1400
+	public function load_scripts_styles_privacy_settings()
1401
+	{
1402
+		$form_handler = $this->loader->getShared(
1403
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1404
+		);
1405
+		$form_handler->enqueueStylesAndScripts();
1406
+	}
1407
+
1408
+
1409
+	/**
1410
+	 * display the privacy settings form
1411
+	 *
1412
+	 * @throws EE_Error
1413
+	 */
1414
+	public function privacySettings()
1415
+	{
1416
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1417
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1418
+		$form_handler                               = $this->loader->getShared(
1419
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1420
+		);
1421
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1422
+			$form_handler->display(),
1423
+			'',
1424
+			'padding'
1425
+		);
1426
+		$this->display_admin_page_with_sidebar();
1427
+	}
1428
+
1429
+
1430
+	/**
1431
+	 * Update the privacy settings from form data
1432
+	 *
1433
+	 * @throws EE_Error
1434
+	 */
1435
+	public function updatePrivacySettings()
1436
+	{
1437
+		$form_handler = $this->loader->getShared(
1438
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1439
+		);
1440
+		$success      = $form_handler->process($this->get_request_data());
1441
+		$this->_redirect_after_action(
1442
+			$success,
1443
+			esc_html__('Registration Form Options', 'event_espresso'),
1444
+			'updated',
1445
+			['action' => 'privacy_settings']
1446
+		);
1447
+	}
1448 1448
 }
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 2 patches
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -41,501 +41,501 @@
 block discarded – undo
41 41
  */
42 42
 class RegistrationsReport extends JobHandlerFile
43 43
 {
44
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
46
-    /**
47
-     * Performs any necessary setup for starting the job. This is also a good
48
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
49
-     * when continue_job will be called
50
-     *
51
-     * @param JobParameters $job_parameters
52
-     * @return JobStepResponse
53
-     * @throws BatchRequestException
54
-     * @throws EE_Error
55
-     * @throws ReflectionException
56
-     */
57
-    public function create_job(JobParameters $job_parameters)
58
-    {
59
-        $event_id = (int) $job_parameters->request_datum('EVT_ID', '0');
60
-        $DTT_ID   = (int) $job_parameters->request_datum('DTT_ID', '0');
61
-        if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
62
-            throw new BatchRequestException(
63
-                esc_html__('You do not have permission to view registrations', 'event_espresso')
64
-            );
65
-        }
66
-        $filepath = $this->create_file_from_job_with_name(
67
-            $job_parameters->job_id(),
68
-            $this->get_filename()
69
-        );
70
-        $job_parameters->add_extra_data('filepath', $filepath);
44
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
46
+	/**
47
+	 * Performs any necessary setup for starting the job. This is also a good
48
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
49
+	 * when continue_job will be called
50
+	 *
51
+	 * @param JobParameters $job_parameters
52
+	 * @return JobStepResponse
53
+	 * @throws BatchRequestException
54
+	 * @throws EE_Error
55
+	 * @throws ReflectionException
56
+	 */
57
+	public function create_job(JobParameters $job_parameters)
58
+	{
59
+		$event_id = (int) $job_parameters->request_datum('EVT_ID', '0');
60
+		$DTT_ID   = (int) $job_parameters->request_datum('DTT_ID', '0');
61
+		if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
62
+			throw new BatchRequestException(
63
+				esc_html__('You do not have permission to view registrations', 'event_espresso')
64
+			);
65
+		}
66
+		$filepath = $this->create_file_from_job_with_name(
67
+			$job_parameters->job_id(),
68
+			$this->get_filename()
69
+		);
70
+		$job_parameters->add_extra_data('filepath', $filepath);
71 71
 
72
-        if ($job_parameters->request_datum('use_filters', false)) {
73
-            $query_params = maybe_unserialize($job_parameters->request_datum('filters', []));
74
-        } else {
75
-            $query_params = [
76
-                [
77
-                    'OR'                 => [
78
-                        // don't include registrations from failed or abandoned transactions...
79
-                        'Transaction.STS_ID' => [
80
-                            'NOT IN',
81
-                            [
82
-                                EEM_Transaction::failed_status_code,
83
-                                EEM_Transaction::abandoned_status_code,
84
-                            ],
85
-                        ],
86
-                        // unless the registration is approved, in which case include it regardless of transaction status
87
-                        'STS_ID'             => EEM_Registration::status_id_approved,
88
-                    ],
89
-                    'Ticket.TKT_deleted' => ['IN', [true, false]],
90
-                ],
91
-                'order_by'   => ['Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'],
92
-                'force_join' => ['Transaction', 'Ticket', 'Attendee'],
93
-                'caps'       => EEM_Base::caps_read_admin,
94
-            ];
95
-            if ($event_id) {
96
-                $query_params[0]['EVT_ID'] = $event_id;
97
-            } else {
98
-                $query_params['force_join'][] = 'Event';
99
-            }
100
-        }
72
+		if ($job_parameters->request_datum('use_filters', false)) {
73
+			$query_params = maybe_unserialize($job_parameters->request_datum('filters', []));
74
+		} else {
75
+			$query_params = [
76
+				[
77
+					'OR'                 => [
78
+						// don't include registrations from failed or abandoned transactions...
79
+						'Transaction.STS_ID' => [
80
+							'NOT IN',
81
+							[
82
+								EEM_Transaction::failed_status_code,
83
+								EEM_Transaction::abandoned_status_code,
84
+							],
85
+						],
86
+						// unless the registration is approved, in which case include it regardless of transaction status
87
+						'STS_ID'             => EEM_Registration::status_id_approved,
88
+					],
89
+					'Ticket.TKT_deleted' => ['IN', [true, false]],
90
+				],
91
+				'order_by'   => ['Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'],
92
+				'force_join' => ['Transaction', 'Ticket', 'Attendee'],
93
+				'caps'       => EEM_Base::caps_read_admin,
94
+			];
95
+			if ($event_id) {
96
+				$query_params[0]['EVT_ID'] = $event_id;
97
+			} else {
98
+				$query_params['force_join'][] = 'Event';
99
+			}
100
+		}
101 101
 
102
-        if (! isset($query_params['force_join'])) {
103
-            $query_params['force_join'] = ['Event', 'Transaction', 'Ticket', 'Attendee'];
104
-        }
102
+		if (! isset($query_params['force_join'])) {
103
+			$query_params['force_join'] = ['Event', 'Transaction', 'Ticket', 'Attendee'];
104
+		}
105 105
 
106
-        $query_params = apply_filters(
107
-            'FHEE__EE_Export__report_registration_for_event',
108
-            $query_params,
109
-            $event_id
110
-        );
106
+		$query_params = apply_filters(
107
+			'FHEE__EE_Export__report_registration_for_event',
108
+			$query_params,
109
+			$event_id
110
+		);
111 111
 
112
-        $job_parameters->add_extra_data('query_params', $query_params);
113
-        $question_labels = $this->_get_question_labels($query_params);
114
-        $job_parameters->add_extra_data('question_labels', $question_labels);
115
-        $job_parameters->set_job_size($this->count_units_to_process($query_params));
116
-        // we should also set the header columns
117
-        $csv_data_for_row = $this->get_csv_data_for(
118
-            $event_id,
119
-            0,
120
-            1,
121
-            $job_parameters->extra_datum('question_labels'),
122
-            $job_parameters->extra_datum('query_params'),
123
-            $DTT_ID
124
-        );
125
-        EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
126
-        // if we actually processed a row there, record it
127
-        if ($job_parameters->job_size()) {
128
-            $job_parameters->mark_processed(1);
129
-        }
130
-        return new JobStepResponse(
131
-            $job_parameters,
132
-            esc_html__('Registrations report started successfully...', 'event_espresso')
133
-        );
134
-    }
112
+		$job_parameters->add_extra_data('query_params', $query_params);
113
+		$question_labels = $this->_get_question_labels($query_params);
114
+		$job_parameters->add_extra_data('question_labels', $question_labels);
115
+		$job_parameters->set_job_size($this->count_units_to_process($query_params));
116
+		// we should also set the header columns
117
+		$csv_data_for_row = $this->get_csv_data_for(
118
+			$event_id,
119
+			0,
120
+			1,
121
+			$job_parameters->extra_datum('question_labels'),
122
+			$job_parameters->extra_datum('query_params'),
123
+			$DTT_ID
124
+		);
125
+		EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
126
+		// if we actually processed a row there, record it
127
+		if ($job_parameters->job_size()) {
128
+			$job_parameters->mark_processed(1);
129
+		}
130
+		return new JobStepResponse(
131
+			$job_parameters,
132
+			esc_html__('Registrations report started successfully...', 'event_espresso')
133
+		);
134
+	}
135 135
 
136 136
 
137
-    /**
138
-     * Gets the filename
139
-     *
140
-     * @return string
141
-     */
142
-    protected function get_filename()
143
-    {
144
-        return apply_filters(
145
-            'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename',
146
-            sprintf(
147
-                "event-espresso-registrations-%s.csv",
148
-                str_replace(array(':', ' '), '-', current_time('mysql'))
149
-            )
150
-        );
151
-    }
137
+	/**
138
+	 * Gets the filename
139
+	 *
140
+	 * @return string
141
+	 */
142
+	protected function get_filename()
143
+	{
144
+		return apply_filters(
145
+			'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename',
146
+			sprintf(
147
+				"event-espresso-registrations-%s.csv",
148
+				str_replace(array(':', ' '), '-', current_time('mysql'))
149
+			)
150
+		);
151
+	}
152 152
 
153 153
 
154
-    /**
155
-     * Gets the questions which are to be used for this report, so they
156
-     * can be remembered for later
157
-     *
158
-     * @param array $registration_query_params
159
-     * @return array question admin labels to be used for this report
160
-     * @throws EE_Error
161
-     */
162
-    protected function _get_question_labels($registration_query_params)
163
-    {
164
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
165
-        $question_query_params = array();
166
-        if ($where !== null) {
167
-            $question_query_params = array(
168
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
169
-            );
170
-        }
171
-        // Make sure it's not a system question
172
-        $question_query_params[0]['OR*not-system-questions'] = [
173
-            'QST_system' => '',
174
-            'QST_system*null' => ['IS_NULL']
175
-        ];
176
-        if (
177
-            apply_filters(
178
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
179
-                false,
180
-                $registration_query_params
181
-            )
182
-        ) {
183
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
184
-        }
185
-        $question_query_params['group_by'] = array('QST_ID');
186
-        return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
187
-    }
154
+	/**
155
+	 * Gets the questions which are to be used for this report, so they
156
+	 * can be remembered for later
157
+	 *
158
+	 * @param array $registration_query_params
159
+	 * @return array question admin labels to be used for this report
160
+	 * @throws EE_Error
161
+	 */
162
+	protected function _get_question_labels($registration_query_params)
163
+	{
164
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
165
+		$question_query_params = array();
166
+		if ($where !== null) {
167
+			$question_query_params = array(
168
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
169
+			);
170
+		}
171
+		// Make sure it's not a system question
172
+		$question_query_params[0]['OR*not-system-questions'] = [
173
+			'QST_system' => '',
174
+			'QST_system*null' => ['IS_NULL']
175
+		];
176
+		if (
177
+			apply_filters(
178
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
179
+				false,
180
+				$registration_query_params
181
+			)
182
+		) {
183
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
184
+		}
185
+		$question_query_params['group_by'] = array('QST_ID');
186
+		return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * Takes where params meant for registrations and changes them to work for questions
192
-     *
193
-     * @param array $reg_where_params
194
-     * @return array
195
-     * @throws EE_Error
196
-     */
197
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
198
-    {
199
-        $question_where_params = array();
200
-        foreach ($reg_where_params as $key => $val) {
201
-            if (EEM_Registration::instance()->is_logic_query_param_key($key)) {
202
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
203
-            } else {
204
-                // it's a normal where condition
205
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
206
-            }
207
-        }
208
-        return $question_where_params;
209
-    }
190
+	/**
191
+	 * Takes where params meant for registrations and changes them to work for questions
192
+	 *
193
+	 * @param array $reg_where_params
194
+	 * @return array
195
+	 * @throws EE_Error
196
+	 */
197
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
198
+	{
199
+		$question_where_params = array();
200
+		foreach ($reg_where_params as $key => $val) {
201
+			if (EEM_Registration::instance()->is_logic_query_param_key($key)) {
202
+				$question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
203
+			} else {
204
+				// it's a normal where condition
205
+				$question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
206
+			}
207
+		}
208
+		return $question_where_params;
209
+	}
210 210
 
211 211
 
212
-    /**
213
-     * Performs another step of the job
214
-     *
215
-     * @param JobParameters $job_parameters
216
-     * @param int $batch_size
217
-     * @return JobStepResponse
218
-     * @throws EE_Error
219
-     * @throws ReflectionException
220
-     */
221
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
222
-    {
223
-        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
224
-            $csv_data = $this->get_csv_data_for(
225
-                (int) $job_parameters->request_datum('EVT_ID', '0'),
226
-                $job_parameters->units_processed(),
227
-                $batch_size,
228
-                $job_parameters->extra_datum('question_labels'),
229
-                $job_parameters->extra_datum('query_params'),
230
-                (int) $job_parameters->request_datum('DTT_ID', '0')
231
-            );
232
-            EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
233
-            $units_processed = count($csv_data);
234
-        } else {
235
-            $csv_data = array();
236
-            $units_processed = 0;
237
-        }
238
-        $job_parameters->mark_processed($units_processed);
239
-        $extra_response_data = array(
240
-            'file_url' => '',
241
-        );
242
-        if ($units_processed < $batch_size) {
243
-            $job_parameters->set_status(JobParameters::status_complete);
244
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
245
-        }
212
+	/**
213
+	 * Performs another step of the job
214
+	 *
215
+	 * @param JobParameters $job_parameters
216
+	 * @param int $batch_size
217
+	 * @return JobStepResponse
218
+	 * @throws EE_Error
219
+	 * @throws ReflectionException
220
+	 */
221
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
222
+	{
223
+		if ($job_parameters->units_processed() < $job_parameters->job_size()) {
224
+			$csv_data = $this->get_csv_data_for(
225
+				(int) $job_parameters->request_datum('EVT_ID', '0'),
226
+				$job_parameters->units_processed(),
227
+				$batch_size,
228
+				$job_parameters->extra_datum('question_labels'),
229
+				$job_parameters->extra_datum('query_params'),
230
+				(int) $job_parameters->request_datum('DTT_ID', '0')
231
+			);
232
+			EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
233
+			$units_processed = count($csv_data);
234
+		} else {
235
+			$csv_data = array();
236
+			$units_processed = 0;
237
+		}
238
+		$job_parameters->mark_processed($units_processed);
239
+		$extra_response_data = array(
240
+			'file_url' => '',
241
+		);
242
+		if ($units_processed < $batch_size) {
243
+			$job_parameters->set_status(JobParameters::status_complete);
244
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
245
+		}
246 246
 
247
-        return new JobStepResponse(
248
-            $job_parameters,
249
-            sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
250
-            $extra_response_data
251
-        );
252
-    }
247
+		return new JobStepResponse(
248
+			$job_parameters,
249
+			sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
250
+			$extra_response_data
251
+		);
252
+	}
253 253
 
254 254
 
255
-    /**
256
-     * Gets the csv data for a batch of registrations
257
-     *
258
-     * @param int|null $event_id
259
-     * @param int $offset
260
-     * @param int $limit
261
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
262
-     * @param array $query_params for using where querying the model
263
-     * @param int $DTT_ID
264
-     * @return array top-level keys are numeric, next-level keys are column headers
265
-     * @throws EE_Error
266
-     * @throws ReflectionException
267
-     */
268
-    public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $DTT_ID = 0)
269
-    {
270
-        $reg_fields_to_include = [
271
-            'TXN_ID',
272
-            'ATT_ID',
273
-            'REG_date',
274
-            'REG_code',
275
-            'REG_count',
276
-            'REG_final_price',
277
-        ];
278
-        $att_fields_to_include = [
279
-            'ATT_fname',
280
-            'ATT_lname',
281
-            'ATT_email',
282
-            'ATT_address',
283
-            'ATT_address2',
284
-            'ATT_city',
285
-            'STA_ID',
286
-            'CNT_ISO',
287
-            'ATT_zip',
288
-            'ATT_phone',
289
-        ];
290
-        $registrations_csv_ready_array = [];
291
-        $reg_model = EE_Registry::instance()->load_model('Registration');
292
-        $query_params['limit'] = [$offset, $limit];
293
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
294
-        foreach ($registration_rows as $reg_row) {
295
-            if (!is_array($reg_row)) {
296
-                continue;
297
-            }
298
-            $reg_csv_array = [];
299
-            // registration Id
300
-            $reg_id_field = $reg_model->field_settings_for('REG_ID');
301
-            $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display(
302
-                $reg_model,
303
-                'REG_ID',
304
-                $reg_row[ $reg_id_field->get_qualified_column() ]
305
-            );
306
-            if (! $event_id) {
307
-                // get the event's name and Id
308
-                $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf(
309
-                    /* translators: 1: event name, 2: event ID */
310
-                    esc_html__('%1$s (%2$s)', 'event_espresso'),
311
-                    EEH_Export::prepare_value_from_db_for_display(
312
-                        EEM_Event::instance(),
313
-                        'EVT_name',
314
-                        $reg_row['Event_CPT.post_title']
315
-                    ),
316
-                    $reg_row['Event_CPT.ID']
317
-                );
318
-            }
319
-            // add attendee columns
320
-            $reg_csv_array = AttendeeCSV::addAttendeeColumns($att_fields_to_include, $reg_row, $reg_csv_array);
321
-            // add registration columns
322
-            $reg_csv_array = RegistrationCSV::addRegistrationColumns($reg_fields_to_include, $reg_row, $reg_model, $reg_csv_array);
323
-            // get pretty status
324
-            $stati = EEM_Status::instance()->localized_status(
325
-                [
326
-                    $reg_row['Registration.STS_ID']     => esc_html__('unknown', 'event_espresso'),
327
-                    $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'),
328
-                ],
329
-                false,
330
-                'sentence'
331
-            );
332
-            $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
333
-            $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
334
-            // get pretty transaction status
335
-            $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
336
-            $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
337
-                ? EEH_Export::prepare_value_from_db_for_display(
338
-                    EEM_Transaction::instance(),
339
-                    'TXN_total',
340
-                    $reg_row['TransactionTable.TXN_total'],
341
-                    'localized_float'
342
-                ) : '0.00';
343
-            $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg
344
-                ? EEH_Export::prepare_value_from_db_for_display(
345
-                    EEM_Transaction::instance(),
346
-                    'TXN_paid',
347
-                    $reg_row['TransactionTable.TXN_paid'],
348
-                    'localized_float'
349
-                ) : '0.00';
350
-            $payment_methods = [];
351
-            $gateway_txn_ids_etc = [];
352
-            $payment_times = [];
353
-            if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
354
-                $payments_info = EEM_Payment::instance()->get_all_wpdb_results(
355
-                    [
356
-                        [
357
-                            'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
358
-                            'STS_ID' => EEM_Payment::status_id_approved,
359
-                        ],
360
-                        'force_join' => ['Payment_Method'],
361
-                    ],
362
-                    ARRAY_A,
363
-                    'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
364
-                );
365
-                [$payment_methods, $gateway_txn_ids_etc, $payment_times] = PaymentsInfoCSV::extractPaymentInfo($payments_info);
366
-            }
367
-            $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
368
-            $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
369
-            $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
370
-                ',',
371
-                $gateway_txn_ids_etc
372
-            );
373
-            // get ticket of registration and its price
374
-            $ticket_model = EE_Registry::instance()->load_model('Ticket');
375
-            if ($reg_row['Ticket.TKT_ID']) {
376
-                $ticket_name = EEH_Export::prepare_value_from_db_for_display(
377
-                    $ticket_model,
378
-                    'TKT_name',
379
-                    $reg_row['Ticket.TKT_name']
380
-                );
381
-                $datetimes_strings = [];
382
-                foreach (
383
-                    EEM_Datetime::instance()->get_all_wpdb_results(
384
-                        [
385
-                            ['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']],
386
-                            'order_by' => ['DTT_EVT_start' => 'ASC'],
387
-                            'default_where_conditions' => 'none',
388
-                        ]
389
-                    ) as $datetime
390
-                ) {
391
-                    $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
392
-                        EEM_Datetime::instance(),
393
-                        'DTT_EVT_start',
394
-                        $datetime['Datetime.DTT_EVT_start']
395
-                    );
396
-                }
397
-            } else {
398
-                $ticket_name = esc_html__('Unknown', 'event_espresso');
399
-                $datetimes_strings = [esc_html__('Unknown', 'event_espresso')];
400
-            }
401
-            $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
402
-            $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
403
-            // add answer columns
404
-            $reg_csv_array = AnswersCSV::addAnswerColumns($reg_row, $reg_csv_array, $question_labels);
405
-            // Include check-in data
406
-            if ($event_id && $DTT_ID) {
407
-                // get whether or not the user has checked in
408
-                $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related(
409
-                    $reg_row['Registration.REG_ID'],
410
-                    'Checkin',
411
-                    [
412
-                        [
413
-                            'DTT_ID' => $DTT_ID
414
-                        ]
415
-                    ]
416
-                );
417
-                /** @var EE_Datetime $datetime */
418
-                $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
419
-                $checkin_rows = EEM_Checkin::instance()->get_all(
420
-                    [
421
-                        [
422
-                            'REG_ID' => $reg_row['Registration.REG_ID'],
423
-                            'DTT_ID' => $datetime->get('DTT_ID'),
424
-                        ],
425
-                    ]
426
-                );
427
-                $checkins = [];
428
-                foreach ($checkin_rows as $checkin_row) {
429
-                    /** @var EE_Checkin $checkin_row */
430
-                    $checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
431
-                    if ($checkin_value) {
432
-                        $checkins[] = $checkin_value;
433
-                    }
434
-                }
435
-                $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
436
-                $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins);
437
-            } elseif ($event_id) {
438
-                // get whether or not the user has checked in
439
-                $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related(
440
-                    $reg_row['Registration.REG_ID'],
441
-                    'Checkin'
442
-                );
443
-                $datetimes = EEM_Datetime::instance()->get_all(
444
-                    [
445
-                        [
446
-                            'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'],
447
-                        ],
448
-                        'order_by' => ['DTT_EVT_start' => 'ASC'],
449
-                        'default_where_conditions' => 'none',
450
-                    ]
451
-                );
452
-                foreach ($datetimes as $datetime) {
453
-                    /** @var EE_Checkin $checkin_row */
454
-                    $checkin_row = EEM_Checkin::instance()->get_one(
455
-                        [
456
-                            [
457
-                                'REG_ID' => $reg_row['Registration.REG_ID'],
458
-                                'DTT_ID' => $datetime->get('DTT_ID'),
459
-                            ],
460
-                            'limit' => 1,
461
-                            'order_by' => [
462
-                                'CHK_ID' => 'DESC'
463
-                            ]
464
-                        ]
465
-                    );
466
-                    $checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
467
-                    $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
468
-                    $reg_csv_array[ (string) $datetime_name ] = $checkin_value;
469
-                }
470
-            }
471
-            /**
472
-             * Filter to change the contents of each row of the registrations report CSV file.
473
-             * This can be used to add or remote columns from the CSV file, or change their values.
474
-             * Note when using: all rows in the CSV should have the same columns.
475
-             * @param array $reg_csv_array keys are the column names, values are their cell values
476
-             * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
477
-             */
478
-            $registrations_csv_ready_array[] = apply_filters(
479
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
480
-                $reg_csv_array,
481
-                $reg_row
482
-            );
483
-        }
484
-        // if we couldn't export anything, we want to at least show the column headers
485
-        if (empty($registrations_csv_ready_array)) {
486
-            $reg_csv_array = [];
487
-            $model_and_fields_to_include = [
488
-                'Registration' => $reg_fields_to_include,
489
-                'Attendee'     => $att_fields_to_include,
490
-            ];
491
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
492
-                $model = EE_Registry::instance()->load_model($model_name);
493
-                foreach ($field_list as $field_name) {
494
-                    $field = $model->field_settings_for($field_name);
495
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
496
-                }
497
-            }
498
-            $registrations_csv_ready_array[] = $reg_csv_array;
499
-        }
500
-        return $registrations_csv_ready_array;
501
-    }
255
+	/**
256
+	 * Gets the csv data for a batch of registrations
257
+	 *
258
+	 * @param int|null $event_id
259
+	 * @param int $offset
260
+	 * @param int $limit
261
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
262
+	 * @param array $query_params for using where querying the model
263
+	 * @param int $DTT_ID
264
+	 * @return array top-level keys are numeric, next-level keys are column headers
265
+	 * @throws EE_Error
266
+	 * @throws ReflectionException
267
+	 */
268
+	public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $DTT_ID = 0)
269
+	{
270
+		$reg_fields_to_include = [
271
+			'TXN_ID',
272
+			'ATT_ID',
273
+			'REG_date',
274
+			'REG_code',
275
+			'REG_count',
276
+			'REG_final_price',
277
+		];
278
+		$att_fields_to_include = [
279
+			'ATT_fname',
280
+			'ATT_lname',
281
+			'ATT_email',
282
+			'ATT_address',
283
+			'ATT_address2',
284
+			'ATT_city',
285
+			'STA_ID',
286
+			'CNT_ISO',
287
+			'ATT_zip',
288
+			'ATT_phone',
289
+		];
290
+		$registrations_csv_ready_array = [];
291
+		$reg_model = EE_Registry::instance()->load_model('Registration');
292
+		$query_params['limit'] = [$offset, $limit];
293
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
294
+		foreach ($registration_rows as $reg_row) {
295
+			if (!is_array($reg_row)) {
296
+				continue;
297
+			}
298
+			$reg_csv_array = [];
299
+			// registration Id
300
+			$reg_id_field = $reg_model->field_settings_for('REG_ID');
301
+			$reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display(
302
+				$reg_model,
303
+				'REG_ID',
304
+				$reg_row[ $reg_id_field->get_qualified_column() ]
305
+			);
306
+			if (! $event_id) {
307
+				// get the event's name and Id
308
+				$reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf(
309
+					/* translators: 1: event name, 2: event ID */
310
+					esc_html__('%1$s (%2$s)', 'event_espresso'),
311
+					EEH_Export::prepare_value_from_db_for_display(
312
+						EEM_Event::instance(),
313
+						'EVT_name',
314
+						$reg_row['Event_CPT.post_title']
315
+					),
316
+					$reg_row['Event_CPT.ID']
317
+				);
318
+			}
319
+			// add attendee columns
320
+			$reg_csv_array = AttendeeCSV::addAttendeeColumns($att_fields_to_include, $reg_row, $reg_csv_array);
321
+			// add registration columns
322
+			$reg_csv_array = RegistrationCSV::addRegistrationColumns($reg_fields_to_include, $reg_row, $reg_model, $reg_csv_array);
323
+			// get pretty status
324
+			$stati = EEM_Status::instance()->localized_status(
325
+				[
326
+					$reg_row['Registration.STS_ID']     => esc_html__('unknown', 'event_espresso'),
327
+					$reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'),
328
+				],
329
+				false,
330
+				'sentence'
331
+			);
332
+			$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
333
+			$reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
334
+			// get pretty transaction status
335
+			$reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
336
+			$reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
337
+				? EEH_Export::prepare_value_from_db_for_display(
338
+					EEM_Transaction::instance(),
339
+					'TXN_total',
340
+					$reg_row['TransactionTable.TXN_total'],
341
+					'localized_float'
342
+				) : '0.00';
343
+			$reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg
344
+				? EEH_Export::prepare_value_from_db_for_display(
345
+					EEM_Transaction::instance(),
346
+					'TXN_paid',
347
+					$reg_row['TransactionTable.TXN_paid'],
348
+					'localized_float'
349
+				) : '0.00';
350
+			$payment_methods = [];
351
+			$gateway_txn_ids_etc = [];
352
+			$payment_times = [];
353
+			if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
354
+				$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
355
+					[
356
+						[
357
+							'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
358
+							'STS_ID' => EEM_Payment::status_id_approved,
359
+						],
360
+						'force_join' => ['Payment_Method'],
361
+					],
362
+					ARRAY_A,
363
+					'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
364
+				);
365
+				[$payment_methods, $gateway_txn_ids_etc, $payment_times] = PaymentsInfoCSV::extractPaymentInfo($payments_info);
366
+			}
367
+			$reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
368
+			$reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
369
+			$reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
370
+				',',
371
+				$gateway_txn_ids_etc
372
+			);
373
+			// get ticket of registration and its price
374
+			$ticket_model = EE_Registry::instance()->load_model('Ticket');
375
+			if ($reg_row['Ticket.TKT_ID']) {
376
+				$ticket_name = EEH_Export::prepare_value_from_db_for_display(
377
+					$ticket_model,
378
+					'TKT_name',
379
+					$reg_row['Ticket.TKT_name']
380
+				);
381
+				$datetimes_strings = [];
382
+				foreach (
383
+					EEM_Datetime::instance()->get_all_wpdb_results(
384
+						[
385
+							['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']],
386
+							'order_by' => ['DTT_EVT_start' => 'ASC'],
387
+							'default_where_conditions' => 'none',
388
+						]
389
+					) as $datetime
390
+				) {
391
+					$datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
392
+						EEM_Datetime::instance(),
393
+						'DTT_EVT_start',
394
+						$datetime['Datetime.DTT_EVT_start']
395
+					);
396
+				}
397
+			} else {
398
+				$ticket_name = esc_html__('Unknown', 'event_espresso');
399
+				$datetimes_strings = [esc_html__('Unknown', 'event_espresso')];
400
+			}
401
+			$reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
402
+			$reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
403
+			// add answer columns
404
+			$reg_csv_array = AnswersCSV::addAnswerColumns($reg_row, $reg_csv_array, $question_labels);
405
+			// Include check-in data
406
+			if ($event_id && $DTT_ID) {
407
+				// get whether or not the user has checked in
408
+				$reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related(
409
+					$reg_row['Registration.REG_ID'],
410
+					'Checkin',
411
+					[
412
+						[
413
+							'DTT_ID' => $DTT_ID
414
+						]
415
+					]
416
+				);
417
+				/** @var EE_Datetime $datetime */
418
+				$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
419
+				$checkin_rows = EEM_Checkin::instance()->get_all(
420
+					[
421
+						[
422
+							'REG_ID' => $reg_row['Registration.REG_ID'],
423
+							'DTT_ID' => $datetime->get('DTT_ID'),
424
+						],
425
+					]
426
+				);
427
+				$checkins = [];
428
+				foreach ($checkin_rows as $checkin_row) {
429
+					/** @var EE_Checkin $checkin_row */
430
+					$checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
431
+					if ($checkin_value) {
432
+						$checkins[] = $checkin_value;
433
+					}
434
+				}
435
+				$datetime_name = CheckinsCSV::getDatetineLabel($datetime);
436
+				$reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins);
437
+			} elseif ($event_id) {
438
+				// get whether or not the user has checked in
439
+				$reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related(
440
+					$reg_row['Registration.REG_ID'],
441
+					'Checkin'
442
+				);
443
+				$datetimes = EEM_Datetime::instance()->get_all(
444
+					[
445
+						[
446
+							'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'],
447
+						],
448
+						'order_by' => ['DTT_EVT_start' => 'ASC'],
449
+						'default_where_conditions' => 'none',
450
+					]
451
+				);
452
+				foreach ($datetimes as $datetime) {
453
+					/** @var EE_Checkin $checkin_row */
454
+					$checkin_row = EEM_Checkin::instance()->get_one(
455
+						[
456
+							[
457
+								'REG_ID' => $reg_row['Registration.REG_ID'],
458
+								'DTT_ID' => $datetime->get('DTT_ID'),
459
+							],
460
+							'limit' => 1,
461
+							'order_by' => [
462
+								'CHK_ID' => 'DESC'
463
+							]
464
+						]
465
+					);
466
+					$checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
467
+					$datetime_name = CheckinsCSV::getDatetineLabel($datetime);
468
+					$reg_csv_array[ (string) $datetime_name ] = $checkin_value;
469
+				}
470
+			}
471
+			/**
472
+			 * Filter to change the contents of each row of the registrations report CSV file.
473
+			 * This can be used to add or remote columns from the CSV file, or change their values.
474
+			 * Note when using: all rows in the CSV should have the same columns.
475
+			 * @param array $reg_csv_array keys are the column names, values are their cell values
476
+			 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
477
+			 */
478
+			$registrations_csv_ready_array[] = apply_filters(
479
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
480
+				$reg_csv_array,
481
+				$reg_row
482
+			);
483
+		}
484
+		// if we couldn't export anything, we want to at least show the column headers
485
+		if (empty($registrations_csv_ready_array)) {
486
+			$reg_csv_array = [];
487
+			$model_and_fields_to_include = [
488
+				'Registration' => $reg_fields_to_include,
489
+				'Attendee'     => $att_fields_to_include,
490
+			];
491
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
492
+				$model = EE_Registry::instance()->load_model($model_name);
493
+				foreach ($field_list as $field_name) {
494
+					$field = $model->field_settings_for($field_name);
495
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
496
+				}
497
+			}
498
+			$registrations_csv_ready_array[] = $reg_csv_array;
499
+		}
500
+		return $registrations_csv_ready_array;
501
+	}
502 502
 
503 503
 
504
-    /**
505
-     * Counts total unit to process
506
-     *
507
-     * @param array $query_params
508
-     * @return int
509
-     * @throws EE_Error
510
-     */
511
-    public function count_units_to_process($query_params)
512
-    {
513
-        return EEM_Registration::instance()->count(
514
-            array_diff_key(
515
-                $query_params,
516
-                array_flip(
517
-                    ['limit']
518
-                )
519
-            )
520
-        );
521
-    }
504
+	/**
505
+	 * Counts total unit to process
506
+	 *
507
+	 * @param array $query_params
508
+	 * @return int
509
+	 * @throws EE_Error
510
+	 */
511
+	public function count_units_to_process($query_params)
512
+	{
513
+		return EEM_Registration::instance()->count(
514
+			array_diff_key(
515
+				$query_params,
516
+				array_flip(
517
+					['limit']
518
+				)
519
+			)
520
+		);
521
+	}
522 522
 
523 523
 
524
-    /**
525
-     * Performs any clean-up logic when we know the job is completed.
526
-     * In this case, we delete the temporary file
527
-     *
528
-     * @param JobParameters $job_parameters
529
-     * @return JobStepResponse
530
-     * @throws EE_Error
531
-     */
532
-    public function cleanup_job(JobParameters $job_parameters)
533
-    {
534
-        $this->_file_helper->delete(
535
-            EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
536
-            true,
537
-            'd'
538
-        );
539
-        return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso'));
540
-    }
524
+	/**
525
+	 * Performs any clean-up logic when we know the job is completed.
526
+	 * In this case, we delete the temporary file
527
+	 *
528
+	 * @param JobParameters $job_parameters
529
+	 * @return JobStepResponse
530
+	 * @throws EE_Error
531
+	 */
532
+	public function cleanup_job(JobParameters $job_parameters)
533
+	{
534
+		$this->_file_helper->delete(
535
+			EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
536
+			true,
537
+			'd'
538
+		);
539
+		return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso'));
540
+	}
541 541
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $event_id = (int) $job_parameters->request_datum('EVT_ID', '0');
60 60
         $DTT_ID   = (int) $job_parameters->request_datum('DTT_ID', '0');
61
-        if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
61
+        if ( ! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
62 62
             throw new BatchRequestException(
63 63
                 esc_html__('You do not have permission to view registrations', 'event_espresso')
64 64
             );
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             }
100 100
         }
101 101
 
102
-        if (! isset($query_params['force_join'])) {
102
+        if ( ! isset($query_params['force_join'])) {
103 103
             $query_params['force_join'] = ['Event', 'Transaction', 'Ticket', 'Attendee'];
104 104
         }
105 105
 
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
         $question_where_params = array();
200 200
         foreach ($reg_where_params as $key => $val) {
201 201
             if (EEM_Registration::instance()->is_logic_query_param_key($key)) {
202
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
202
+                $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
203 203
             } else {
204 204
                 // it's a normal where condition
205
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
205
+                $question_where_params['Question_Group.Event.Registration.'.$key] = $val;
206 206
             }
207 207
         }
208 208
         return $question_where_params;
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
         $query_params['limit'] = [$offset, $limit];
293 293
         $registration_rows = $reg_model->get_all_wpdb_results($query_params);
294 294
         foreach ($registration_rows as $reg_row) {
295
-            if (!is_array($reg_row)) {
295
+            if ( ! is_array($reg_row)) {
296 296
                 continue;
297 297
             }
298 298
             $reg_csv_array = [];
299 299
             // registration Id
300 300
             $reg_id_field = $reg_model->field_settings_for('REG_ID');
301
-            $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display(
301
+            $reg_csv_array[EEH_Export::get_column_name_for_field($reg_id_field)] = EEH_Export::prepare_value_from_db_for_display(
302 302
                 $reg_model,
303 303
                 'REG_ID',
304
-                $reg_row[ $reg_id_field->get_qualified_column() ]
304
+                $reg_row[$reg_id_field->get_qualified_column()]
305 305
             );
306
-            if (! $event_id) {
306
+            if ( ! $event_id) {
307 307
                 // get the event's name and Id
308
-                $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf(
308
+                $reg_csv_array[(string) esc_html__('Event', 'event_espresso')] = sprintf(
309 309
                     /* translators: 1: event name, 2: event ID */
310 310
                     esc_html__('%1$s (%2$s)', 'event_espresso'),
311 311
                     EEH_Export::prepare_value_from_db_for_display(
@@ -330,17 +330,17 @@  discard block
 block discarded – undo
330 330
                 'sentence'
331 331
             );
332 332
             $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
333
-            $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
333
+            $reg_csv_array[(string) esc_html__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
334 334
             // get pretty transaction status
335
-            $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
336
-            $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
335
+            $reg_csv_array[(string) esc_html__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
336
+            $reg_csv_array[(string) esc_html__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
337 337
                 ? EEH_Export::prepare_value_from_db_for_display(
338 338
                     EEM_Transaction::instance(),
339 339
                     'TXN_total',
340 340
                     $reg_row['TransactionTable.TXN_total'],
341 341
                     'localized_float'
342 342
                 ) : '0.00';
343
-            $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg
343
+            $reg_csv_array[(string) esc_html__('Amount Paid', 'event_espresso')] = $is_primary_reg
344 344
                 ? EEH_Export::prepare_value_from_db_for_display(
345 345
                     EEM_Transaction::instance(),
346 346
                     'TXN_paid',
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
                 );
365 365
                 [$payment_methods, $gateway_txn_ids_etc, $payment_times] = PaymentsInfoCSV::extractPaymentInfo($payments_info);
366 366
             }
367
-            $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
368
-            $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
369
-            $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
367
+            $reg_csv_array[(string) esc_html__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
368
+            $reg_csv_array[(string) esc_html__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
369
+            $reg_csv_array[(string) esc_html__('Gateway Transaction ID(s)', 'event_espresso')] = implode(
370 370
                 ',',
371 371
                 $gateway_txn_ids_etc
372 372
             );
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
                 $ticket_name = esc_html__('Unknown', 'event_espresso');
399 399
                 $datetimes_strings = [esc_html__('Unknown', 'event_espresso')];
400 400
             }
401
-            $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
402
-            $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
401
+            $reg_csv_array[(string) $ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
402
+            $reg_csv_array[(string) esc_html__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
403 403
             // add answer columns
404 404
             $reg_csv_array = AnswersCSV::addAnswerColumns($reg_row, $reg_csv_array, $question_labels);
405 405
             // Include check-in data
406 406
             if ($event_id && $DTT_ID) {
407 407
                 // get whether or not the user has checked in
408
-                $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related(
408
+                $reg_csv_array[(string) esc_html__('Datetime Check-ins #', 'event_espresso')] = $reg_model->count_related(
409 409
                     $reg_row['Registration.REG_ID'],
410 410
                     'Checkin',
411 411
                     [
@@ -433,10 +433,10 @@  discard block
 block discarded – undo
433 433
                     }
434 434
                 }
435 435
                 $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
436
-                $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins);
436
+                $reg_csv_array[(string) $datetime_name] = implode(' --- ', $checkins);
437 437
             } elseif ($event_id) {
438 438
                 // get whether or not the user has checked in
439
-                $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related(
439
+                $reg_csv_array[(string) esc_html__('Event Check-ins #', 'event_espresso')] = $reg_model->count_related(
440 440
                     $reg_row['Registration.REG_ID'],
441 441
                     'Checkin'
442 442
                 );
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                     );
466 466
                     $checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
467 467
                     $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
468
-                    $reg_csv_array[ (string) $datetime_name ] = $checkin_value;
468
+                    $reg_csv_array[(string) $datetime_name] = $checkin_value;
469 469
                 }
470 470
             }
471 471
             /**
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                 $model = EE_Registry::instance()->load_model($model_name);
493 493
                 foreach ($field_list as $field_name) {
494 494
                     $field = $model->field_settings_for($field_name);
495
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
495
+                    $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = null;
496 496
                 }
497 497
             }
498 498
             $registrations_csv_ready_array[] = $reg_csv_array;
Please login to merge, or discard this patch.
core/domain/services/admin/registrations/list_table/QueryBuilder.php 2 patches
Indentation   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -22,384 +22,384 @@
 block discarded – undo
22 22
 class QueryBuilder
23 23
 {
24 24
 
25
-    /**
26
-     * @var RequestInterface $request
27
-     */
28
-    protected $request;
29
-
30
-    /**
31
-     * @var EEM_Registration $registration_model
32
-     */
33
-    protected $registration_model;
34
-
35
-    /**
36
-     * @var string $view
37
-     */
38
-    protected $view;
39
-
40
-    /**
41
-     * @var array $where_params
42
-     */
43
-    protected $where_params;
44
-
45
-
46
-    /**
47
-     * QueryBuilder constructor.
48
-     *
49
-     * @param RequestInterface $request
50
-     * @param EEM_Registration $registration_model
51
-     * @param array            $extra_request_params
52
-     */
53
-    public function __construct(
54
-        RequestInterface $request,
55
-        EEM_Registration $registration_model,
56
-        array $extra_request_params = []
57
-    ) {
58
-        $this->request = $request;
59
-        $this->registration_model = $registration_model;
60
-        foreach ($extra_request_params as $key => $value) {
61
-            if (! $this->request->requestParamIsSet($key)) {
62
-                $this->request->setRequestParam($key, $value);
63
-            }
64
-        }
65
-        $this->view = $this->request->getRequestParam('status', '');
66
-        $this->where_params = [];
67
-    }
68
-
69
-
70
-    /**
71
-     * Sets up the where conditions for the registrations query.
72
-     *
73
-     * @param int  $per_page
74
-     * @param bool $count_query
75
-     * @return array
76
-     * @throws EE_Error
77
-     * @throws InvalidArgumentException
78
-     * @throws InvalidDataTypeException
79
-     * @throws InvalidInterfaceException
80
-     */
81
-    public function getQueryParams($per_page = 10, $count_query = false)
82
-    {
83
-        $query_params = [
84
-            0                          => $this->getWhereClause(),
85
-            'caps'                     => EEM_Base::caps_read_admin,
86
-            'default_where_conditions' => 'this_model_only',
87
-        ];
88
-        if (! $count_query) {
89
-            $query_params = array_merge(
90
-                $query_params,
91
-                $this->getOrderbyClause(),
92
-                $this->getLimitClause($per_page)
93
-            );
94
-        }
95
-
96
-        return $query_params;
97
-    }
98
-
99
-
100
-    /**
101
-     * Sets up the where conditions for the registrations query.
102
-     *
103
-     * @return array
104
-     * @throws EE_Error
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     */
109
-    protected function getWhereClause()
110
-    {
111
-        $this->addAttendeeIdToWhereConditions();
112
-        $this->addEventIdToWhereConditions();
113
-        $this->addCategoryIdToWhereConditions();
114
-        $this->addDatetimeIdToWhereConditions();
115
-        $this->addTicketIdToWhereConditions();
116
-        $this->addRegistrationStatusToWhereConditions();
117
-        $this->addDateToWhereConditions();
118
-        $this->addSearchToWhereConditions();
119
-        return apply_filters(
120
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
121
-            $this->where_params,
122
-            $this->request->requestParams()
123
-        );
124
-    }
125
-
126
-
127
-    /**
128
-     * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
129
-     */
130
-    protected function addAttendeeIdToWhereConditions()
131
-    {
132
-        $ATT_ID = $this->request->getRequestParam('attendee_id');
133
-        $ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID, 'int');
134
-        if ($ATT_ID) {
135
-            $this->where_params['ATT_ID'] = $ATT_ID;
136
-        }
137
-    }
138
-
139
-
140
-    /**
141
-     * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
142
-     */
143
-    protected function addEventIdToWhereConditions()
144
-    {
145
-        $EVT_ID = $this->request->getRequestParam('event_id');
146
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID, 'int');
147
-        if ($EVT_ID) {
148
-            $this->where_params['EVT_ID'] = $EVT_ID;
149
-        }
150
-    }
151
-
152
-
153
-    /**
154
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
155
-     */
156
-    protected function addCategoryIdToWhereConditions()
157
-    {
158
-        $EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT', 0, 'int');
159
-        if ($EVT_CAT > 0) {
160
-            $this->where_params['Event.Term_Taxonomy.term_id'] = $EVT_CAT;
161
-        }
162
-    }
163
-
164
-
165
-    /**
166
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
167
-     */
168
-    protected function addDatetimeIdToWhereConditions()
169
-    {
170
-        // first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
171
-        $DTT_ID = $this->request->getRequestParam('datetime_id');
172
-        $DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID, 'int');
173
-        if ($DTT_ID) {
174
-            $this->where_params['Ticket.Datetime.DTT_ID'] = $DTT_ID;
175
-        }
176
-    }
177
-
178
-
179
-    /**
180
-     * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
181
-     */
182
-    protected function addTicketIdToWhereConditions()
183
-    {
184
-        // first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
185
-        $TKT_ID = $this->request->getRequestParam('ticket_id');
186
-        $TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID, 'int');
187
-        if ($TKT_ID) {
188
-            $this->where_params['TKT_ID'] = $TKT_ID;
189
-        }
190
-    }
191
-
192
-
193
-    /**
194
-     * Adds the correct registration status to the where conditions for the registrations query.
195
-     * If filtering by registration status, then we show registrations matching that status.
196
-     * If not filtering by specified status, then we show all registrations excluding incomplete registrations
197
-     * UNLESS viewing trashed registrations.
198
-     */
199
-    protected function addRegistrationStatusToWhereConditions()
200
-    {
201
-        $registration_status = $this->request->getRequestParam('_reg_status');
202
-        if ($registration_status) {
203
-            $this->where_params['STS_ID'] = sanitize_text_field($registration_status);
204
-            return;
205
-        }
206
-        // make sure we exclude incomplete registrations, but only if not trashed.
207
-        if ($this->view === 'trash') {
208
-            $this->where_params['REG_deleted'] = true;
209
-            return;
210
-        }
211
-        $this->where_params['STS_ID'] = $this->view === 'incomplete'
212
-            ? EEM_Registration::status_id_incomplete
213
-            : ['!=', EEM_Registration::status_id_incomplete];
214
-    }
215
-
216
-
217
-    /**
218
-     * Adds any provided date restraints to the where conditions for the registrations query.
219
-     *
220
-     * @throws EE_Error
221
-     * @throws InvalidArgumentException
222
-     * @throws InvalidDataTypeException
223
-     * @throws InvalidInterfaceException
224
-     */
225
-    protected function addDateToWhereConditions()
226
-    {
227
-        if ($this->view === 'today') {
228
-            $now = date('Y-m-d', current_time('timestamp'));
229
-            $this->where_params['REG_date'] = [
230
-                'BETWEEN',
231
-                [
232
-                    $this->registration_model->convert_datetime_for_query(
233
-                        'REG_date',
234
-                        $now . ' 00:00:00',
235
-                        'Y-m-d H:i:s'
236
-                    ),
237
-                    $this->registration_model->convert_datetime_for_query(
238
-                        'REG_date',
239
-                        $now . ' 23:59:59',
240
-                        'Y-m-d H:i:s'
241
-                    ),
242
-                ],
243
-            ];
244
-            return;
245
-        }
246
-        if ($this->view === 'month') {
247
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
248
-            $days_this_month = date('t', current_time('timestamp'));
249
-            $this->where_params['REG_date'] = [
250
-                'BETWEEN',
251
-                [
252
-                    $this->registration_model->convert_datetime_for_query(
253
-                        'REG_date',
254
-                        $current_year_and_month . '-01 00:00:00',
255
-                        'Y-m-d H:i:s'
256
-                    ),
257
-                    $this->registration_model->convert_datetime_for_query(
258
-                        'REG_date',
259
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
260
-                        'Y-m-d H:i:s'
261
-                    ),
262
-                ],
263
-            ];
264
-            return;
265
-        }
266
-        $month_range = $this->request->getRequestParam('month_range');
267
-        if ($month_range) {
268
-            $month_range = sanitize_text_field($month_range);
269
-            $pieces = explode(' ', $month_range, 3);
270
-            $month_requested = ! empty($pieces[0])
271
-                ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
272
-                : '';
273
-            $year_requested = ! empty($pieces[1])
274
-                ? $pieces[1]
275
-                : '';
276
-            // if there is not a month or year then we can't go further
277
-            if ($month_requested && $year_requested) {
278
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
279
-                $this->where_params['REG_date'] = [
280
-                    'BETWEEN',
281
-                    [
282
-                        $this->registration_model->convert_datetime_for_query(
283
-                            'REG_date',
284
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
285
-                            'Y-m-d H:i:s'
286
-                        ),
287
-                        $this->registration_model->convert_datetime_for_query(
288
-                            'REG_date',
289
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
290
-                            'Y-m-d H:i:s'
291
-                        ),
292
-                    ],
293
-                ];
294
-            }
295
-        }
296
-    }
297
-
298
-
299
-    /**
300
-     * Adds any provided search restraints to the where conditions for the registrations query
301
-     */
302
-    protected function addSearchToWhereConditions()
303
-    {
304
-        $search = $this->request->getRequestParam('s');
305
-        if ($search) {
306
-            $search_string = '%' . sanitize_text_field($search) . '%';
307
-            $this->where_params['OR*search_conditions'] = [
308
-                'Event.EVT_name'                          => ['LIKE', $search_string],
309
-                'Event.EVT_desc'                          => ['LIKE', $search_string],
310
-                'Event.EVT_short_desc'                    => ['LIKE', $search_string],
311
-                'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
312
-                'Attendee.ATT_fname'                      => ['LIKE', $search_string],
313
-                'Attendee.ATT_lname'                      => ['LIKE', $search_string],
314
-                'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
315
-                'Attendee.ATT_email'                      => ['LIKE', $search_string],
316
-                'Attendee.ATT_address'                    => ['LIKE', $search_string],
317
-                'Attendee.ATT_address2'                   => ['LIKE', $search_string],
318
-                'Attendee.ATT_city'                       => ['LIKE', $search_string],
319
-                'REG_final_price'                         => ['LIKE', $search_string],
320
-                'REG_code'                                => ['LIKE', $search_string],
321
-                'REG_count'                               => ['LIKE', $search_string],
322
-                'REG_group_size'                          => ['LIKE', $search_string],
323
-                'Ticket.TKT_name'                         => ['LIKE', $search_string],
324
-                'Ticket.TKT_description'                  => ['LIKE', $search_string],
325
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
326
-            ];
327
-        }
328
-    }
329
-
330
-
331
-    /**
332
-     * Sets up the orderby for the registrations query.
333
-     *
334
-     * @return array
335
-     */
336
-    protected function getOrderbyClause()
337
-    {
338
-        $orderby_field = $this->request->getRequestParam('orderby');
339
-        $orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
340
-        switch ($orderby_field) {
341
-            case '_REG_ID':
342
-                $orderby = ['REG_ID'];
343
-                break;
344
-            case '_Reg_status':
345
-                $orderby = ['STS_ID'];
346
-                break;
347
-            case 'ATT_fname':
348
-                $orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
349
-                break;
350
-            case 'ATT_lname':
351
-                $orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
352
-                break;
353
-            case 'event_name':
354
-                $orderby = ['Event.EVT_name'];
355
-                break;
356
-            case 'DTT_EVT_start':
357
-                $orderby = ['Event.Datetime.DTT_EVT_start'];
358
-                break;
359
-            case '_REG_date':
360
-                $orderby = ['REG_date'];
361
-                break;
362
-            default:
363
-                $orderby = [$orderby_field];
364
-                break;
365
-        }
366
-        $order = $this->request->getRequestParam('order');
367
-        $order = $order ? sanitize_text_field($order) : 'DESC';
368
-
369
-        $orderby = array_combine(
370
-            $orderby,
371
-            array_fill(0, count($orderby), $order)
372
-        );
373
-        // because there are many registrations with the same date, define
374
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
375
-        if (empty($orderby['REG_ID'])) {
376
-            $orderby['REG_ID'] = $order;
377
-        }
378
-
379
-        $orderby = apply_filters(
380
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
381
-            $orderby,
382
-            $this->request->requestParams()
383
-        );
384
-        return ['order_by' => $orderby];
385
-    }
386
-
387
-
388
-    /**
389
-     * Sets up the limit for the registrations query.
390
-     *
391
-     * @param $per_page
392
-     * @return array
393
-     */
394
-    protected function getLimitClause($per_page)
395
-    {
396
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
397
-        $per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
398
-        // -1 means return all results so get out if that's set.
399
-        if ($per_page === -1) {
400
-            return [];
401
-        }
402
-        $offset = ($current_page - 1) * $per_page;
403
-        return ['limit' => [$offset, $per_page]];
404
-    }
25
+	/**
26
+	 * @var RequestInterface $request
27
+	 */
28
+	protected $request;
29
+
30
+	/**
31
+	 * @var EEM_Registration $registration_model
32
+	 */
33
+	protected $registration_model;
34
+
35
+	/**
36
+	 * @var string $view
37
+	 */
38
+	protected $view;
39
+
40
+	/**
41
+	 * @var array $where_params
42
+	 */
43
+	protected $where_params;
44
+
45
+
46
+	/**
47
+	 * QueryBuilder constructor.
48
+	 *
49
+	 * @param RequestInterface $request
50
+	 * @param EEM_Registration $registration_model
51
+	 * @param array            $extra_request_params
52
+	 */
53
+	public function __construct(
54
+		RequestInterface $request,
55
+		EEM_Registration $registration_model,
56
+		array $extra_request_params = []
57
+	) {
58
+		$this->request = $request;
59
+		$this->registration_model = $registration_model;
60
+		foreach ($extra_request_params as $key => $value) {
61
+			if (! $this->request->requestParamIsSet($key)) {
62
+				$this->request->setRequestParam($key, $value);
63
+			}
64
+		}
65
+		$this->view = $this->request->getRequestParam('status', '');
66
+		$this->where_params = [];
67
+	}
68
+
69
+
70
+	/**
71
+	 * Sets up the where conditions for the registrations query.
72
+	 *
73
+	 * @param int  $per_page
74
+	 * @param bool $count_query
75
+	 * @return array
76
+	 * @throws EE_Error
77
+	 * @throws InvalidArgumentException
78
+	 * @throws InvalidDataTypeException
79
+	 * @throws InvalidInterfaceException
80
+	 */
81
+	public function getQueryParams($per_page = 10, $count_query = false)
82
+	{
83
+		$query_params = [
84
+			0                          => $this->getWhereClause(),
85
+			'caps'                     => EEM_Base::caps_read_admin,
86
+			'default_where_conditions' => 'this_model_only',
87
+		];
88
+		if (! $count_query) {
89
+			$query_params = array_merge(
90
+				$query_params,
91
+				$this->getOrderbyClause(),
92
+				$this->getLimitClause($per_page)
93
+			);
94
+		}
95
+
96
+		return $query_params;
97
+	}
98
+
99
+
100
+	/**
101
+	 * Sets up the where conditions for the registrations query.
102
+	 *
103
+	 * @return array
104
+	 * @throws EE_Error
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 */
109
+	protected function getWhereClause()
110
+	{
111
+		$this->addAttendeeIdToWhereConditions();
112
+		$this->addEventIdToWhereConditions();
113
+		$this->addCategoryIdToWhereConditions();
114
+		$this->addDatetimeIdToWhereConditions();
115
+		$this->addTicketIdToWhereConditions();
116
+		$this->addRegistrationStatusToWhereConditions();
117
+		$this->addDateToWhereConditions();
118
+		$this->addSearchToWhereConditions();
119
+		return apply_filters(
120
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
121
+			$this->where_params,
122
+			$this->request->requestParams()
123
+		);
124
+	}
125
+
126
+
127
+	/**
128
+	 * This will add ATT_ID to the provided $this->where_clause array for EE model query parameters.
129
+	 */
130
+	protected function addAttendeeIdToWhereConditions()
131
+	{
132
+		$ATT_ID = $this->request->getRequestParam('attendee_id');
133
+		$ATT_ID = $this->request->getRequestParam('ATT_ID', $ATT_ID, 'int');
134
+		if ($ATT_ID) {
135
+			$this->where_params['ATT_ID'] = $ATT_ID;
136
+		}
137
+	}
138
+
139
+
140
+	/**
141
+	 * This will add EVT_ID to the provided $this->where_clause array for EE model query parameters.
142
+	 */
143
+	protected function addEventIdToWhereConditions()
144
+	{
145
+		$EVT_ID = $this->request->getRequestParam('event_id');
146
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', $EVT_ID, 'int');
147
+		if ($EVT_ID) {
148
+			$this->where_params['EVT_ID'] = $EVT_ID;
149
+		}
150
+	}
151
+
152
+
153
+	/**
154
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
155
+	 */
156
+	protected function addCategoryIdToWhereConditions()
157
+	{
158
+		$EVT_CAT = (int) $this->request->getRequestParam('EVT_CAT', 0, 'int');
159
+		if ($EVT_CAT > 0) {
160
+			$this->where_params['Event.Term_Taxonomy.term_id'] = $EVT_CAT;
161
+		}
162
+	}
163
+
164
+
165
+	/**
166
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
167
+	 */
168
+	protected function addDatetimeIdToWhereConditions()
169
+	{
170
+		// first look for 'datetime_id' then 'DTT_ID' using first result as fallback default value
171
+		$DTT_ID = $this->request->getRequestParam('datetime_id');
172
+		$DTT_ID = $this->request->getRequestParam('DTT_ID', $DTT_ID, 'int');
173
+		if ($DTT_ID) {
174
+			$this->where_params['Ticket.Datetime.DTT_ID'] = $DTT_ID;
175
+		}
176
+	}
177
+
178
+
179
+	/**
180
+	 * Adds the ticket ID if it exists in the request to the where conditions for the registrations query.
181
+	 */
182
+	protected function addTicketIdToWhereConditions()
183
+	{
184
+		// first look for 'ticket_id' then 'TKT_ID' using first result as fallback default value
185
+		$TKT_ID = $this->request->getRequestParam('ticket_id');
186
+		$TKT_ID = $this->request->getRequestParam('TKT_ID', $TKT_ID, 'int');
187
+		if ($TKT_ID) {
188
+			$this->where_params['TKT_ID'] = $TKT_ID;
189
+		}
190
+	}
191
+
192
+
193
+	/**
194
+	 * Adds the correct registration status to the where conditions for the registrations query.
195
+	 * If filtering by registration status, then we show registrations matching that status.
196
+	 * If not filtering by specified status, then we show all registrations excluding incomplete registrations
197
+	 * UNLESS viewing trashed registrations.
198
+	 */
199
+	protected function addRegistrationStatusToWhereConditions()
200
+	{
201
+		$registration_status = $this->request->getRequestParam('_reg_status');
202
+		if ($registration_status) {
203
+			$this->where_params['STS_ID'] = sanitize_text_field($registration_status);
204
+			return;
205
+		}
206
+		// make sure we exclude incomplete registrations, but only if not trashed.
207
+		if ($this->view === 'trash') {
208
+			$this->where_params['REG_deleted'] = true;
209
+			return;
210
+		}
211
+		$this->where_params['STS_ID'] = $this->view === 'incomplete'
212
+			? EEM_Registration::status_id_incomplete
213
+			: ['!=', EEM_Registration::status_id_incomplete];
214
+	}
215
+
216
+
217
+	/**
218
+	 * Adds any provided date restraints to the where conditions for the registrations query.
219
+	 *
220
+	 * @throws EE_Error
221
+	 * @throws InvalidArgumentException
222
+	 * @throws InvalidDataTypeException
223
+	 * @throws InvalidInterfaceException
224
+	 */
225
+	protected function addDateToWhereConditions()
226
+	{
227
+		if ($this->view === 'today') {
228
+			$now = date('Y-m-d', current_time('timestamp'));
229
+			$this->where_params['REG_date'] = [
230
+				'BETWEEN',
231
+				[
232
+					$this->registration_model->convert_datetime_for_query(
233
+						'REG_date',
234
+						$now . ' 00:00:00',
235
+						'Y-m-d H:i:s'
236
+					),
237
+					$this->registration_model->convert_datetime_for_query(
238
+						'REG_date',
239
+						$now . ' 23:59:59',
240
+						'Y-m-d H:i:s'
241
+					),
242
+				],
243
+			];
244
+			return;
245
+		}
246
+		if ($this->view === 'month') {
247
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
248
+			$days_this_month = date('t', current_time('timestamp'));
249
+			$this->where_params['REG_date'] = [
250
+				'BETWEEN',
251
+				[
252
+					$this->registration_model->convert_datetime_for_query(
253
+						'REG_date',
254
+						$current_year_and_month . '-01 00:00:00',
255
+						'Y-m-d H:i:s'
256
+					),
257
+					$this->registration_model->convert_datetime_for_query(
258
+						'REG_date',
259
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
260
+						'Y-m-d H:i:s'
261
+					),
262
+				],
263
+			];
264
+			return;
265
+		}
266
+		$month_range = $this->request->getRequestParam('month_range');
267
+		if ($month_range) {
268
+			$month_range = sanitize_text_field($month_range);
269
+			$pieces = explode(' ', $month_range, 3);
270
+			$month_requested = ! empty($pieces[0])
271
+				? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
272
+				: '';
273
+			$year_requested = ! empty($pieces[1])
274
+				? $pieces[1]
275
+				: '';
276
+			// if there is not a month or year then we can't go further
277
+			if ($month_requested && $year_requested) {
278
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
279
+				$this->where_params['REG_date'] = [
280
+					'BETWEEN',
281
+					[
282
+						$this->registration_model->convert_datetime_for_query(
283
+							'REG_date',
284
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
285
+							'Y-m-d H:i:s'
286
+						),
287
+						$this->registration_model->convert_datetime_for_query(
288
+							'REG_date',
289
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
290
+							'Y-m-d H:i:s'
291
+						),
292
+					],
293
+				];
294
+			}
295
+		}
296
+	}
297
+
298
+
299
+	/**
300
+	 * Adds any provided search restraints to the where conditions for the registrations query
301
+	 */
302
+	protected function addSearchToWhereConditions()
303
+	{
304
+		$search = $this->request->getRequestParam('s');
305
+		if ($search) {
306
+			$search_string = '%' . sanitize_text_field($search) . '%';
307
+			$this->where_params['OR*search_conditions'] = [
308
+				'Event.EVT_name'                          => ['LIKE', $search_string],
309
+				'Event.EVT_desc'                          => ['LIKE', $search_string],
310
+				'Event.EVT_short_desc'                    => ['LIKE', $search_string],
311
+				'Attendee.ATT_full_name'                  => ['LIKE', $search_string],
312
+				'Attendee.ATT_fname'                      => ['LIKE', $search_string],
313
+				'Attendee.ATT_lname'                      => ['LIKE', $search_string],
314
+				'Attendee.ATT_short_bio'                  => ['LIKE', $search_string],
315
+				'Attendee.ATT_email'                      => ['LIKE', $search_string],
316
+				'Attendee.ATT_address'                    => ['LIKE', $search_string],
317
+				'Attendee.ATT_address2'                   => ['LIKE', $search_string],
318
+				'Attendee.ATT_city'                       => ['LIKE', $search_string],
319
+				'REG_final_price'                         => ['LIKE', $search_string],
320
+				'REG_code'                                => ['LIKE', $search_string],
321
+				'REG_count'                               => ['LIKE', $search_string],
322
+				'REG_group_size'                          => ['LIKE', $search_string],
323
+				'Ticket.TKT_name'                         => ['LIKE', $search_string],
324
+				'Ticket.TKT_description'                  => ['LIKE', $search_string],
325
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_string],
326
+			];
327
+		}
328
+	}
329
+
330
+
331
+	/**
332
+	 * Sets up the orderby for the registrations query.
333
+	 *
334
+	 * @return array
335
+	 */
336
+	protected function getOrderbyClause()
337
+	{
338
+		$orderby_field = $this->request->getRequestParam('orderby');
339
+		$orderby_field = $orderby_field ? sanitize_text_field($orderby_field) : '_REG_date';
340
+		switch ($orderby_field) {
341
+			case '_REG_ID':
342
+				$orderby = ['REG_ID'];
343
+				break;
344
+			case '_Reg_status':
345
+				$orderby = ['STS_ID'];
346
+				break;
347
+			case 'ATT_fname':
348
+				$orderby = ['Attendee.ATT_fname', 'Attendee.ATT_lname'];
349
+				break;
350
+			case 'ATT_lname':
351
+				$orderby = ['Attendee.ATT_lname', 'Attendee.ATT_fname'];
352
+				break;
353
+			case 'event_name':
354
+				$orderby = ['Event.EVT_name'];
355
+				break;
356
+			case 'DTT_EVT_start':
357
+				$orderby = ['Event.Datetime.DTT_EVT_start'];
358
+				break;
359
+			case '_REG_date':
360
+				$orderby = ['REG_date'];
361
+				break;
362
+			default:
363
+				$orderby = [$orderby_field];
364
+				break;
365
+		}
366
+		$order = $this->request->getRequestParam('order');
367
+		$order = $order ? sanitize_text_field($order) : 'DESC';
368
+
369
+		$orderby = array_combine(
370
+			$orderby,
371
+			array_fill(0, count($orderby), $order)
372
+		);
373
+		// because there are many registrations with the same date, define
374
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
375
+		if (empty($orderby['REG_ID'])) {
376
+			$orderby['REG_ID'] = $order;
377
+		}
378
+
379
+		$orderby = apply_filters(
380
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
381
+			$orderby,
382
+			$this->request->requestParams()
383
+		);
384
+		return ['order_by' => $orderby];
385
+	}
386
+
387
+
388
+	/**
389
+	 * Sets up the limit for the registrations query.
390
+	 *
391
+	 * @param $per_page
392
+	 * @return array
393
+	 */
394
+	protected function getLimitClause($per_page)
395
+	{
396
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
397
+		$per_page = $this->request->getRequestParam('perpage', $per_page, 'int');
398
+		// -1 means return all results so get out if that's set.
399
+		if ($per_page === -1) {
400
+			return [];
401
+		}
402
+		$offset = ($current_page - 1) * $per_page;
403
+		return ['limit' => [$offset, $per_page]];
404
+	}
405 405
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $this->request = $request;
59 59
         $this->registration_model = $registration_model;
60 60
         foreach ($extra_request_params as $key => $value) {
61
-            if (! $this->request->requestParamIsSet($key)) {
61
+            if ( ! $this->request->requestParamIsSet($key)) {
62 62
                 $this->request->setRequestParam($key, $value);
63 63
             }
64 64
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             'caps'                     => EEM_Base::caps_read_admin,
86 86
             'default_where_conditions' => 'this_model_only',
87 87
         ];
88
-        if (! $count_query) {
88
+        if ( ! $count_query) {
89 89
             $query_params = array_merge(
90 90
                 $query_params,
91 91
                 $this->getOrderbyClause(),
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
                 [
232 232
                     $this->registration_model->convert_datetime_for_query(
233 233
                         'REG_date',
234
-                        $now . ' 00:00:00',
234
+                        $now.' 00:00:00',
235 235
                         'Y-m-d H:i:s'
236 236
                     ),
237 237
                     $this->registration_model->convert_datetime_for_query(
238 238
                         'REG_date',
239
-                        $now . ' 23:59:59',
239
+                        $now.' 23:59:59',
240 240
                         'Y-m-d H:i:s'
241 241
                     ),
242 242
                 ],
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
                 [
252 252
                     $this->registration_model->convert_datetime_for_query(
253 253
                         'REG_date',
254
-                        $current_year_and_month . '-01 00:00:00',
254
+                        $current_year_and_month.'-01 00:00:00',
255 255
                         'Y-m-d H:i:s'
256 256
                     ),
257 257
                     $this->registration_model->convert_datetime_for_query(
258 258
                         'REG_date',
259
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
259
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
260 260
                         'Y-m-d H:i:s'
261 261
                     ),
262 262
                 ],
@@ -275,18 +275,18 @@  discard block
 block discarded – undo
275 275
                 : '';
276 276
             // if there is not a month or year then we can't go further
277 277
             if ($month_requested && $year_requested) {
278
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
278
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
279 279
                 $this->where_params['REG_date'] = [
280 280
                     'BETWEEN',
281 281
                     [
282 282
                         $this->registration_model->convert_datetime_for_query(
283 283
                             'REG_date',
284
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
284
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
285 285
                             'Y-m-d H:i:s'
286 286
                         ),
287 287
                         $this->registration_model->convert_datetime_for_query(
288 288
                             'REG_date',
289
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
289
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
290 290
                             'Y-m-d H:i:s'
291 291
                         ),
292 292
                     ],
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
     {
304 304
         $search = $this->request->getRequestParam('s');
305 305
         if ($search) {
306
-            $search_string = '%' . sanitize_text_field($search) . '%';
306
+            $search_string = '%'.sanitize_text_field($search).'%';
307 307
             $this->where_params['OR*search_conditions'] = [
308 308
                 'Event.EVT_name'                          => ['LIKE', $search_string],
309 309
                 'Event.EVT_desc'                          => ['LIKE', $search_string],
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 1 patch
Indentation   +1218 added lines, -1218 removed lines patch added patch discarded remove patch
@@ -16,1276 +16,1276 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * This is used to hold the reports template data which is setup early in the request.
21
-     *
22
-     * @type array
23
-     */
24
-    protected $_reports_template_data = array();
19
+	/**
20
+	 * This is used to hold the reports template data which is setup early in the request.
21
+	 *
22
+	 * @type array
23
+	 */
24
+	protected $_reports_template_data = array();
25 25
 
26 26
 
27
-    /**
28
-     * Extend_Registrations_Admin_Page constructor.
29
-     *
30
-     * @param bool $routing
31
-     */
32
-    public function __construct($routing = true)
33
-    {
34
-        parent::__construct($routing);
35
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
-        }
40
-    }
27
+	/**
28
+	 * Extend_Registrations_Admin_Page constructor.
29
+	 *
30
+	 * @param bool $routing
31
+	 */
32
+	public function __construct($routing = true)
33
+	{
34
+		parent::__construct($routing);
35
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
+		}
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Extending page configuration.
45
-     */
46
-    protected function _extend_page_config()
47
-    {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
-            ? $this->_req_data['_REG_ID']
51
-            : 0;
52
-        $new_page_routes = array(
53
-            'reports'                      => array(
54
-                'func'       => '_registration_reports',
55
-                'capability' => 'ee_read_registrations',
56
-            ),
57
-            'registration_checkins'        => array(
58
-                'func'       => '_registration_checkin_list_table',
59
-                'capability' => 'ee_read_checkins',
60
-            ),
61
-            'newsletter_selected_send'     => array(
62
-                'func'       => '_newsletter_selected_send',
63
-                'noheader'   => true,
64
-                'capability' => 'ee_send_message',
65
-            ),
66
-            'delete_checkin_rows'          => array(
67
-                'func'       => '_delete_checkin_rows',
68
-                'noheader'   => true,
69
-                'capability' => 'ee_delete_checkins',
70
-            ),
71
-            'delete_checkin_row'           => array(
72
-                'func'       => '_delete_checkin_row',
73
-                'noheader'   => true,
74
-                'capability' => 'ee_delete_checkin',
75
-                'obj_id'     => $reg_id,
76
-            ),
77
-            'toggle_checkin_status'        => array(
78
-                'func'       => '_toggle_checkin_status',
79
-                'noheader'   => true,
80
-                'capability' => 'ee_edit_checkin',
81
-                'obj_id'     => $reg_id,
82
-            ),
83
-            'toggle_checkin_status_bulk'   => array(
84
-                'func'       => '_toggle_checkin_status',
85
-                'noheader'   => true,
86
-                'capability' => 'ee_edit_checkins',
87
-            ),
88
-            'event_registrations'          => array(
89
-                'func'       => '_event_registrations_list_table',
90
-                'capability' => 'ee_read_checkins',
91
-            ),
92
-            'registrations_checkin_report' => array(
93
-                'func'       => '_registrations_checkin_report',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_read_registrations',
96
-            ),
97
-        );
98
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
-        $new_page_config = array(
100
-            'reports'               => array(
101
-                'nav'           => array(
102
-                    'label' => esc_html__('Reports', 'event_espresso'),
103
-                    'order' => 30,
104
-                ),
105
-                'help_tabs'     => array(
106
-                    'registrations_reports_help_tab' => array(
107
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
-                        'filename' => 'registrations_reports',
109
-                    ),
110
-                ),
111
-                'require_nonce' => false,
112
-            ),
113
-            'event_registrations'   => array(
114
-                'nav'           => array(
115
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
116
-                    'order'      => 10,
117
-                    'persistent' => true,
118
-                ),
119
-                'help_tabs'     => array(
120
-                    'registrations_event_checkin_help_tab'                       => array(
121
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
122
-                        'filename' => 'registrations_event_checkin',
123
-                    ),
124
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
125
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
126
-                        'filename' => 'registrations_event_checkin_table_column_headings',
127
-                    ),
128
-                    'registrations_event_checkin_filters_help_tab'               => array(
129
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
130
-                        'filename' => 'registrations_event_checkin_filters',
131
-                    ),
132
-                    'registrations_event_checkin_views_help_tab'                 => array(
133
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
134
-                        'filename' => 'registrations_event_checkin_views',
135
-                    ),
136
-                    'registrations_event_checkin_other_help_tab'                 => array(
137
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
138
-                        'filename' => 'registrations_event_checkin_other',
139
-                    ),
140
-                ),
141
-                'qtips'         => array('Registration_List_Table_Tips'),
142
-                'list_table'    => 'EE_Event_Registrations_List_Table',
143
-                'metaboxes'     => array(),
144
-                'require_nonce' => false,
145
-            ),
146
-            'registration_checkins' => array(
147
-                'nav'           => array(
148
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
149
-                    'order'      => 15,
150
-                    'persistent' => false,
151
-                    'url'        => '',
152
-                ),
153
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
154
-                'metaboxes'     => array(),
155
-                'require_nonce' => false,
156
-            ),
157
-        );
158
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
159
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
-    }
43
+	/**
44
+	 * Extending page configuration.
45
+	 */
46
+	protected function _extend_page_config()
47
+	{
48
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
+			? $this->_req_data['_REG_ID']
51
+			: 0;
52
+		$new_page_routes = array(
53
+			'reports'                      => array(
54
+				'func'       => '_registration_reports',
55
+				'capability' => 'ee_read_registrations',
56
+			),
57
+			'registration_checkins'        => array(
58
+				'func'       => '_registration_checkin_list_table',
59
+				'capability' => 'ee_read_checkins',
60
+			),
61
+			'newsletter_selected_send'     => array(
62
+				'func'       => '_newsletter_selected_send',
63
+				'noheader'   => true,
64
+				'capability' => 'ee_send_message',
65
+			),
66
+			'delete_checkin_rows'          => array(
67
+				'func'       => '_delete_checkin_rows',
68
+				'noheader'   => true,
69
+				'capability' => 'ee_delete_checkins',
70
+			),
71
+			'delete_checkin_row'           => array(
72
+				'func'       => '_delete_checkin_row',
73
+				'noheader'   => true,
74
+				'capability' => 'ee_delete_checkin',
75
+				'obj_id'     => $reg_id,
76
+			),
77
+			'toggle_checkin_status'        => array(
78
+				'func'       => '_toggle_checkin_status',
79
+				'noheader'   => true,
80
+				'capability' => 'ee_edit_checkin',
81
+				'obj_id'     => $reg_id,
82
+			),
83
+			'toggle_checkin_status_bulk'   => array(
84
+				'func'       => '_toggle_checkin_status',
85
+				'noheader'   => true,
86
+				'capability' => 'ee_edit_checkins',
87
+			),
88
+			'event_registrations'          => array(
89
+				'func'       => '_event_registrations_list_table',
90
+				'capability' => 'ee_read_checkins',
91
+			),
92
+			'registrations_checkin_report' => array(
93
+				'func'       => '_registrations_checkin_report',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_read_registrations',
96
+			),
97
+		);
98
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
+		$new_page_config = array(
100
+			'reports'               => array(
101
+				'nav'           => array(
102
+					'label' => esc_html__('Reports', 'event_espresso'),
103
+					'order' => 30,
104
+				),
105
+				'help_tabs'     => array(
106
+					'registrations_reports_help_tab' => array(
107
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
+						'filename' => 'registrations_reports',
109
+					),
110
+				),
111
+				'require_nonce' => false,
112
+			),
113
+			'event_registrations'   => array(
114
+				'nav'           => array(
115
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
116
+					'order'      => 10,
117
+					'persistent' => true,
118
+				),
119
+				'help_tabs'     => array(
120
+					'registrations_event_checkin_help_tab'                       => array(
121
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
122
+						'filename' => 'registrations_event_checkin',
123
+					),
124
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
125
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
126
+						'filename' => 'registrations_event_checkin_table_column_headings',
127
+					),
128
+					'registrations_event_checkin_filters_help_tab'               => array(
129
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
130
+						'filename' => 'registrations_event_checkin_filters',
131
+					),
132
+					'registrations_event_checkin_views_help_tab'                 => array(
133
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
134
+						'filename' => 'registrations_event_checkin_views',
135
+					),
136
+					'registrations_event_checkin_other_help_tab'                 => array(
137
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
138
+						'filename' => 'registrations_event_checkin_other',
139
+					),
140
+				),
141
+				'qtips'         => array('Registration_List_Table_Tips'),
142
+				'list_table'    => 'EE_Event_Registrations_List_Table',
143
+				'metaboxes'     => array(),
144
+				'require_nonce' => false,
145
+			),
146
+			'registration_checkins' => array(
147
+				'nav'           => array(
148
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
149
+					'order'      => 15,
150
+					'persistent' => false,
151
+					'url'        => '',
152
+				),
153
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
154
+				'metaboxes'     => array(),
155
+				'require_nonce' => false,
156
+			),
157
+		);
158
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
159
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * Ajax hooks for all routes in this page.
166
-     */
167
-    protected function _ajax_hooks()
168
-    {
169
-        parent::_ajax_hooks();
170
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
171
-    }
164
+	/**
165
+	 * Ajax hooks for all routes in this page.
166
+	 */
167
+	protected function _ajax_hooks()
168
+	{
169
+		parent::_ajax_hooks();
170
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
171
+	}
172 172
 
173 173
 
174
-    /**
175
-     * Global scripts for all routes in this page.
176
-     */
177
-    public function load_scripts_styles()
178
-    {
179
-        parent::load_scripts_styles();
180
-        // if newsletter message type is active then let's add filter and load js for it.
181
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
182
-            // enqueue newsletter js
183
-            wp_enqueue_script(
184
-                'ee-newsletter-trigger',
185
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
186
-                array('ee-dialog'),
187
-                EVENT_ESPRESSO_VERSION,
188
-                true
189
-            );
190
-            wp_enqueue_style(
191
-                'ee-newsletter-trigger-css',
192
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
193
-                array(),
194
-                EVENT_ESPRESSO_VERSION
195
-            );
196
-            // hook in buttons for newsletter message type trigger.
197
-            add_action(
198
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
199
-                array($this, 'add_newsletter_action_buttons'),
200
-                10
201
-            );
202
-        }
203
-    }
174
+	/**
175
+	 * Global scripts for all routes in this page.
176
+	 */
177
+	public function load_scripts_styles()
178
+	{
179
+		parent::load_scripts_styles();
180
+		// if newsletter message type is active then let's add filter and load js for it.
181
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
182
+			// enqueue newsletter js
183
+			wp_enqueue_script(
184
+				'ee-newsletter-trigger',
185
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
186
+				array('ee-dialog'),
187
+				EVENT_ESPRESSO_VERSION,
188
+				true
189
+			);
190
+			wp_enqueue_style(
191
+				'ee-newsletter-trigger-css',
192
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
193
+				array(),
194
+				EVENT_ESPRESSO_VERSION
195
+			);
196
+			// hook in buttons for newsletter message type trigger.
197
+			add_action(
198
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
199
+				array($this, 'add_newsletter_action_buttons'),
200
+				10
201
+			);
202
+		}
203
+	}
204 204
 
205 205
 
206
-    /**
207
-     * Scripts and styles for just the reports route.
208
-     */
209
-    public function load_scripts_styles_reports()
210
-    {
211
-        wp_register_script(
212
-            'ee-reg-reports-js',
213
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
214
-            array('google-charts'),
215
-            EVENT_ESPRESSO_VERSION,
216
-            true
217
-        );
218
-        wp_enqueue_script('ee-reg-reports-js');
219
-        $this->_registration_reports_js_setup();
220
-    }
206
+	/**
207
+	 * Scripts and styles for just the reports route.
208
+	 */
209
+	public function load_scripts_styles_reports()
210
+	{
211
+		wp_register_script(
212
+			'ee-reg-reports-js',
213
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
214
+			array('google-charts'),
215
+			EVENT_ESPRESSO_VERSION,
216
+			true
217
+		);
218
+		wp_enqueue_script('ee-reg-reports-js');
219
+		$this->_registration_reports_js_setup();
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * Register screen options for event_registrations route.
225
-     */
226
-    protected function _add_screen_options_event_registrations()
227
-    {
228
-        $this->_per_page_screen_option();
229
-    }
223
+	/**
224
+	 * Register screen options for event_registrations route.
225
+	 */
226
+	protected function _add_screen_options_event_registrations()
227
+	{
228
+		$this->_per_page_screen_option();
229
+	}
230 230
 
231 231
 
232
-    /**
233
-     * Register screen options for registration_checkins route
234
-     */
235
-    protected function _add_screen_options_registration_checkins()
236
-    {
237
-        $page_title = $this->_admin_page_title;
238
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
239
-        $this->_per_page_screen_option();
240
-        $this->_admin_page_title = $page_title;
241
-    }
232
+	/**
233
+	 * Register screen options for registration_checkins route
234
+	 */
235
+	protected function _add_screen_options_registration_checkins()
236
+	{
237
+		$page_title = $this->_admin_page_title;
238
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
239
+		$this->_per_page_screen_option();
240
+		$this->_admin_page_title = $page_title;
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     * Set views property for event_registrations route.
246
-     */
247
-    protected function _set_list_table_views_event_registrations()
248
-    {
249
-        $this->_views = array(
250
-            'all' => array(
251
-                'slug'        => 'all',
252
-                'label'       => esc_html__('All', 'event_espresso'),
253
-                'count'       => 0,
254
-                'bulk_action' => ! isset($this->_req_data['event_id'])
255
-                    ? array()
256
-                    : array(
257
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
258
-                    ),
259
-            ),
260
-        );
261
-    }
244
+	/**
245
+	 * Set views property for event_registrations route.
246
+	 */
247
+	protected function _set_list_table_views_event_registrations()
248
+	{
249
+		$this->_views = array(
250
+			'all' => array(
251
+				'slug'        => 'all',
252
+				'label'       => esc_html__('All', 'event_espresso'),
253
+				'count'       => 0,
254
+				'bulk_action' => ! isset($this->_req_data['event_id'])
255
+					? array()
256
+					: array(
257
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
258
+					),
259
+			),
260
+		);
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Set views property for registration_checkins route.
266
-     */
267
-    protected function _set_list_table_views_registration_checkins()
268
-    {
269
-        $this->_views = array(
270
-            'all' => array(
271
-                'slug'        => 'all',
272
-                'label'       => esc_html__('All', 'event_espresso'),
273
-                'count'       => 0,
274
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
275
-            ),
276
-        );
277
-    }
264
+	/**
265
+	 * Set views property for registration_checkins route.
266
+	 */
267
+	protected function _set_list_table_views_registration_checkins()
268
+	{
269
+		$this->_views = array(
270
+			'all' => array(
271
+				'slug'        => 'all',
272
+				'label'       => esc_html__('All', 'event_espresso'),
273
+				'count'       => 0,
274
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
275
+			),
276
+		);
277
+	}
278 278
 
279 279
 
280
-    /**
281
-     * callback for ajax action.
282
-     *
283
-     * @since 4.3.0
284
-     * @return void (JSON)
285
-     * @throws EE_Error
286
-     * @throws InvalidArgumentException
287
-     * @throws InvalidDataTypeException
288
-     * @throws InvalidInterfaceException
289
-     */
290
-    public function get_newsletter_form_content()
291
-    {
292
-        // do a nonce check cause we're not coming in from an normal route here.
293
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
294
-            $this->_req_data['get_newsletter_form_content_nonce']
295
-        ) : '';
296
-        $nonce_ref = 'get_newsletter_form_content_nonce';
297
-        $this->_verify_nonce($nonce, $nonce_ref);
298
-        // let's get the mtp for the incoming MTP_ ID
299
-        if (! isset($this->_req_data['GRP_ID'])) {
300
-            EE_Error::add_error(
301
-                esc_html__(
302
-                    '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).',
303
-                    'event_espresso'
304
-                ),
305
-                __FILE__,
306
-                __FUNCTION__,
307
-                __LINE__
308
-            );
309
-            $this->_template_args['success'] = false;
310
-            $this->_template_args['error'] = true;
311
-            $this->_return_json();
312
-        }
313
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
314
-        if (! $MTPG instanceof EE_Message_Template_Group) {
315
-            EE_Error::add_error(
316
-                sprintf(
317
-                    esc_html__(
318
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
319
-                        'event_espresso'
320
-                    ),
321
-                    $this->_req_data['GRP_ID']
322
-                ),
323
-                __FILE__,
324
-                __FUNCTION__,
325
-                __LINE__
326
-            );
327
-            $this->_template_args['success'] = false;
328
-            $this->_template_args['error'] = true;
329
-            $this->_return_json();
330
-        }
331
-        $MTPs = $MTPG->context_templates();
332
-        $MTPs = $MTPs['attendee'];
333
-        $template_fields = array();
334
-        /** @var EE_Message_Template $MTP */
335
-        foreach ($MTPs as $MTP) {
336
-            $field = $MTP->get('MTP_template_field');
337
-            if ($field === 'content') {
338
-                $content = $MTP->get('MTP_content');
339
-                if (! empty($content['newsletter_content'])) {
340
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
341
-                }
342
-                continue;
343
-            }
344
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
345
-        }
346
-        $this->_template_args['success'] = true;
347
-        $this->_template_args['error'] = false;
348
-        $this->_template_args['data'] = array(
349
-            'batch_message_from'    => isset($template_fields['from'])
350
-                ? $template_fields['from']
351
-                : '',
352
-            'batch_message_subject' => isset($template_fields['subject'])
353
-                ? $template_fields['subject']
354
-                : '',
355
-            'batch_message_content' => isset($template_fields['newsletter_content'])
356
-                ? $template_fields['newsletter_content']
357
-                : '',
358
-        );
359
-        $this->_return_json();
360
-    }
280
+	/**
281
+	 * callback for ajax action.
282
+	 *
283
+	 * @since 4.3.0
284
+	 * @return void (JSON)
285
+	 * @throws EE_Error
286
+	 * @throws InvalidArgumentException
287
+	 * @throws InvalidDataTypeException
288
+	 * @throws InvalidInterfaceException
289
+	 */
290
+	public function get_newsletter_form_content()
291
+	{
292
+		// do a nonce check cause we're not coming in from an normal route here.
293
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
294
+			$this->_req_data['get_newsletter_form_content_nonce']
295
+		) : '';
296
+		$nonce_ref = 'get_newsletter_form_content_nonce';
297
+		$this->_verify_nonce($nonce, $nonce_ref);
298
+		// let's get the mtp for the incoming MTP_ ID
299
+		if (! isset($this->_req_data['GRP_ID'])) {
300
+			EE_Error::add_error(
301
+				esc_html__(
302
+					'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).',
303
+					'event_espresso'
304
+				),
305
+				__FILE__,
306
+				__FUNCTION__,
307
+				__LINE__
308
+			);
309
+			$this->_template_args['success'] = false;
310
+			$this->_template_args['error'] = true;
311
+			$this->_return_json();
312
+		}
313
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
314
+		if (! $MTPG instanceof EE_Message_Template_Group) {
315
+			EE_Error::add_error(
316
+				sprintf(
317
+					esc_html__(
318
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
319
+						'event_espresso'
320
+					),
321
+					$this->_req_data['GRP_ID']
322
+				),
323
+				__FILE__,
324
+				__FUNCTION__,
325
+				__LINE__
326
+			);
327
+			$this->_template_args['success'] = false;
328
+			$this->_template_args['error'] = true;
329
+			$this->_return_json();
330
+		}
331
+		$MTPs = $MTPG->context_templates();
332
+		$MTPs = $MTPs['attendee'];
333
+		$template_fields = array();
334
+		/** @var EE_Message_Template $MTP */
335
+		foreach ($MTPs as $MTP) {
336
+			$field = $MTP->get('MTP_template_field');
337
+			if ($field === 'content') {
338
+				$content = $MTP->get('MTP_content');
339
+				if (! empty($content['newsletter_content'])) {
340
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
341
+				}
342
+				continue;
343
+			}
344
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
345
+		}
346
+		$this->_template_args['success'] = true;
347
+		$this->_template_args['error'] = false;
348
+		$this->_template_args['data'] = array(
349
+			'batch_message_from'    => isset($template_fields['from'])
350
+				? $template_fields['from']
351
+				: '',
352
+			'batch_message_subject' => isset($template_fields['subject'])
353
+				? $template_fields['subject']
354
+				: '',
355
+			'batch_message_content' => isset($template_fields['newsletter_content'])
356
+				? $template_fields['newsletter_content']
357
+				: '',
358
+		);
359
+		$this->_return_json();
360
+	}
361 361
 
362 362
 
363
-    /**
364
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
365
-     *
366
-     * @since 4.3.0
367
-     * @param EE_Admin_List_Table $list_table
368
-     * @return void
369
-     * @throws InvalidArgumentException
370
-     * @throws InvalidDataTypeException
371
-     * @throws InvalidInterfaceException
372
-     */
373
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
374
-    {
375
-        if (
376
-            ! EE_Registry::instance()->CAP->current_user_can(
377
-                'ee_send_message',
378
-                'espresso_registrations_newsletter_selected_send'
379
-            )
380
-        ) {
381
-            return;
382
-        }
383
-        $routes_to_add_to = array(
384
-            'contact_list',
385
-            'event_registrations',
386
-            'default',
387
-        );
388
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
389
-            if (
390
-                ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
391
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
392
-            ) {
393
-                echo '';
394
-            } else {
395
-                $button_text = sprintf(
396
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
397
-                    '<span class="send-selected-newsletter-count">0</span>'
398
-                );
399
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
400
-                     . '<span class="dashicons dashicons-email "></span>'
401
-                     . $button_text
402
-                     . '</button>';
403
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
404
-            }
405
-        }
406
-    }
363
+	/**
364
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
365
+	 *
366
+	 * @since 4.3.0
367
+	 * @param EE_Admin_List_Table $list_table
368
+	 * @return void
369
+	 * @throws InvalidArgumentException
370
+	 * @throws InvalidDataTypeException
371
+	 * @throws InvalidInterfaceException
372
+	 */
373
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
374
+	{
375
+		if (
376
+			! EE_Registry::instance()->CAP->current_user_can(
377
+				'ee_send_message',
378
+				'espresso_registrations_newsletter_selected_send'
379
+			)
380
+		) {
381
+			return;
382
+		}
383
+		$routes_to_add_to = array(
384
+			'contact_list',
385
+			'event_registrations',
386
+			'default',
387
+		);
388
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
389
+			if (
390
+				($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
391
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
392
+			) {
393
+				echo '';
394
+			} else {
395
+				$button_text = sprintf(
396
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
397
+					'<span class="send-selected-newsletter-count">0</span>'
398
+				);
399
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
400
+					 . '<span class="dashicons dashicons-email "></span>'
401
+					 . $button_text
402
+					 . '</button>';
403
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
404
+			}
405
+		}
406
+	}
407 407
 
408 408
 
409
-    /**
410
-     * @throws DomainException
411
-     * @throws EE_Error
412
-     * @throws InvalidArgumentException
413
-     * @throws InvalidDataTypeException
414
-     * @throws InvalidInterfaceException
415
-     */
416
-    public function newsletter_send_form_skeleton()
417
-    {
418
-        $list_table = $this->_list_table_object;
419
-        $codes = array();
420
-        // need to templates for the newsletter message type for the template selector.
421
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
422
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
423
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
424
-        );
425
-        foreach ($mtps as $mtp) {
426
-            $name = $mtp->name();
427
-            $values[] = array(
428
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
429
-                'id'   => $mtp->ID(),
430
-            );
431
-        }
432
-        // need to get a list of shortcodes that are available for the newsletter message type.
433
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
434
-            'newsletter',
435
-            'email',
436
-            array(),
437
-            'attendee',
438
-            false
439
-        );
440
-        foreach ($shortcodes as $field => $shortcode_array) {
441
-            $available_shortcodes = array();
442
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
443
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
444
-                    ? 'content'
445
-                    : $field;
446
-                $field_id = 'batch-message-' . strtolower($field_id);
447
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
448
-                                          . $shortcode
449
-                                          . '" data-linked-input-id="' . $field_id . '">'
450
-                                          . $shortcode
451
-                                          . '</span>';
452
-            }
453
-            $codes[ $field ] = implode(', ', $available_shortcodes);
454
-        }
455
-        $shortcodes = $codes;
456
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
457
-        $form_template_args = array(
458
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
459
-            'form_route'        => 'newsletter_selected_send',
460
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
461
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
462
-            'redirect_back_to'  => $this->_req_action,
463
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
464
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
465
-            'shortcodes'        => $shortcodes,
466
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
467
-        );
468
-        EEH_Template::display_template($form_template, $form_template_args);
469
-    }
409
+	/**
410
+	 * @throws DomainException
411
+	 * @throws EE_Error
412
+	 * @throws InvalidArgumentException
413
+	 * @throws InvalidDataTypeException
414
+	 * @throws InvalidInterfaceException
415
+	 */
416
+	public function newsletter_send_form_skeleton()
417
+	{
418
+		$list_table = $this->_list_table_object;
419
+		$codes = array();
420
+		// need to templates for the newsletter message type for the template selector.
421
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
422
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
423
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
424
+		);
425
+		foreach ($mtps as $mtp) {
426
+			$name = $mtp->name();
427
+			$values[] = array(
428
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
429
+				'id'   => $mtp->ID(),
430
+			);
431
+		}
432
+		// need to get a list of shortcodes that are available for the newsletter message type.
433
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
434
+			'newsletter',
435
+			'email',
436
+			array(),
437
+			'attendee',
438
+			false
439
+		);
440
+		foreach ($shortcodes as $field => $shortcode_array) {
441
+			$available_shortcodes = array();
442
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
443
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
444
+					? 'content'
445
+					: $field;
446
+				$field_id = 'batch-message-' . strtolower($field_id);
447
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
448
+										  . $shortcode
449
+										  . '" data-linked-input-id="' . $field_id . '">'
450
+										  . $shortcode
451
+										  . '</span>';
452
+			}
453
+			$codes[ $field ] = implode(', ', $available_shortcodes);
454
+		}
455
+		$shortcodes = $codes;
456
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
457
+		$form_template_args = array(
458
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
459
+			'form_route'        => 'newsletter_selected_send',
460
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
461
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
462
+			'redirect_back_to'  => $this->_req_action,
463
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
464
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
465
+			'shortcodes'        => $shortcodes,
466
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
467
+		);
468
+		EEH_Template::display_template($form_template, $form_template_args);
469
+	}
470 470
 
471 471
 
472
-    /**
473
-     * Handles sending selected registrations/contacts a newsletter.
474
-     *
475
-     * @since  4.3.0
476
-     * @return void
477
-     * @throws EE_Error
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidDataTypeException
480
-     * @throws InvalidInterfaceException
481
-     */
482
-    protected function _newsletter_selected_send()
483
-    {
484
-        $success = true;
485
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
486
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
487
-            EE_Error::add_error(
488
-                esc_html__(
489
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
490
-                    'event_espresso'
491
-                ),
492
-                __FILE__,
493
-                __FUNCTION__,
494
-                __LINE__
495
-            );
496
-            $success = false;
497
-        }
498
-        if ($success) {
499
-            // update Message template in case there are any changes
500
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
501
-                $this->_req_data['newsletter_mtp_selected']
502
-            );
503
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
504
-                ? $Message_Template_Group->context_templates()
505
-                : array();
506
-            if (empty($Message_Templates)) {
507
-                EE_Error::add_error(
508
-                    esc_html__(
509
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
510
-                        'event_espresso'
511
-                    ),
512
-                    __FILE__,
513
-                    __FUNCTION__,
514
-                    __LINE__
515
-                );
516
-            }
517
-            // let's just update the specific fields
518
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
519
-                if ($Message_Template instanceof EE_Message_Template) {
520
-                    $field = $Message_Template->get('MTP_template_field');
521
-                    $content = $Message_Template->get('MTP_content');
522
-                    $new_content = $content;
523
-                    switch ($field) {
524
-                        case 'from':
525
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
526
-                                ? $this->_req_data['batch_message']['from']
527
-                                : $content;
528
-                            break;
529
-                        case 'subject':
530
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
531
-                                ? $this->_req_data['batch_message']['subject']
532
-                                : $content;
533
-                            break;
534
-                        case 'content':
535
-                            $new_content = $content;
536
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
537
-                                ? $this->_req_data['batch_message']['content']
538
-                                : $content['newsletter_content'];
539
-                            break;
540
-                        default:
541
-                            // continue the foreach loop, we don't want to set $new_content nor save.
542
-                            continue 2;
543
-                    }
544
-                    $Message_Template->set('MTP_content', $new_content);
545
-                    $Message_Template->save();
546
-                }
547
-            }
548
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
549
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
550
-                ? $this->_req_data['batch_message']['id_type']
551
-                : 'registration';
552
-            // id_type will affect how we assemble the ids.
553
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
554
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
555
-                : array();
556
-            $registrations_used_for_contact_data = array();
557
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
558
-            switch ($id_type) {
559
-                case 'registration':
560
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
561
-                        array(
562
-                            array(
563
-                                'REG_ID' => array('IN', $ids),
564
-                            ),
565
-                        )
566
-                    );
567
-                    break;
568
-                case 'contact':
569
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
570
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
571
-                                                                               $ids
572
-                                                                           );
573
-                    break;
574
-            }
575
-            do_action_ref_array(
576
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
577
-                array(
578
-                    $registrations_used_for_contact_data,
579
-                    $Message_Template_Group->ID(),
580
-                )
581
-            );
582
-            // kept for backward compat, internally we no longer use this action.
583
-            // @deprecated 4.8.36.rc.002
584
-            $contacts = $id_type === 'registration'
585
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
586
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
587
-            do_action_ref_array(
588
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
589
-                array(
590
-                    $contacts,
591
-                    $Message_Template_Group->ID(),
592
-                )
593
-            );
594
-        }
595
-        $query_args = array(
596
-            'action' => ! empty($this->_req_data['redirect_back_to'])
597
-                ? $this->_req_data['redirect_back_to']
598
-                : 'default',
599
-        );
600
-        $this->_redirect_after_action(false, '', '', $query_args, true);
601
-    }
472
+	/**
473
+	 * Handles sending selected registrations/contacts a newsletter.
474
+	 *
475
+	 * @since  4.3.0
476
+	 * @return void
477
+	 * @throws EE_Error
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidDataTypeException
480
+	 * @throws InvalidInterfaceException
481
+	 */
482
+	protected function _newsletter_selected_send()
483
+	{
484
+		$success = true;
485
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
486
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
487
+			EE_Error::add_error(
488
+				esc_html__(
489
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
490
+					'event_espresso'
491
+				),
492
+				__FILE__,
493
+				__FUNCTION__,
494
+				__LINE__
495
+			);
496
+			$success = false;
497
+		}
498
+		if ($success) {
499
+			// update Message template in case there are any changes
500
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
501
+				$this->_req_data['newsletter_mtp_selected']
502
+			);
503
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
504
+				? $Message_Template_Group->context_templates()
505
+				: array();
506
+			if (empty($Message_Templates)) {
507
+				EE_Error::add_error(
508
+					esc_html__(
509
+						'Unable to retrieve message template fields from the db. Messages not sent.',
510
+						'event_espresso'
511
+					),
512
+					__FILE__,
513
+					__FUNCTION__,
514
+					__LINE__
515
+				);
516
+			}
517
+			// let's just update the specific fields
518
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
519
+				if ($Message_Template instanceof EE_Message_Template) {
520
+					$field = $Message_Template->get('MTP_template_field');
521
+					$content = $Message_Template->get('MTP_content');
522
+					$new_content = $content;
523
+					switch ($field) {
524
+						case 'from':
525
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
526
+								? $this->_req_data['batch_message']['from']
527
+								: $content;
528
+							break;
529
+						case 'subject':
530
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
531
+								? $this->_req_data['batch_message']['subject']
532
+								: $content;
533
+							break;
534
+						case 'content':
535
+							$new_content = $content;
536
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
537
+								? $this->_req_data['batch_message']['content']
538
+								: $content['newsletter_content'];
539
+							break;
540
+						default:
541
+							// continue the foreach loop, we don't want to set $new_content nor save.
542
+							continue 2;
543
+					}
544
+					$Message_Template->set('MTP_content', $new_content);
545
+					$Message_Template->save();
546
+				}
547
+			}
548
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
549
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
550
+				? $this->_req_data['batch_message']['id_type']
551
+				: 'registration';
552
+			// id_type will affect how we assemble the ids.
553
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
554
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
555
+				: array();
556
+			$registrations_used_for_contact_data = array();
557
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
558
+			switch ($id_type) {
559
+				case 'registration':
560
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
561
+						array(
562
+							array(
563
+								'REG_ID' => array('IN', $ids),
564
+							),
565
+						)
566
+					);
567
+					break;
568
+				case 'contact':
569
+					$registrations_used_for_contact_data = EEM_Registration::instance()
570
+																		   ->get_latest_registration_for_each_of_given_contacts(
571
+																			   $ids
572
+																		   );
573
+					break;
574
+			}
575
+			do_action_ref_array(
576
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
577
+				array(
578
+					$registrations_used_for_contact_data,
579
+					$Message_Template_Group->ID(),
580
+				)
581
+			);
582
+			// kept for backward compat, internally we no longer use this action.
583
+			// @deprecated 4.8.36.rc.002
584
+			$contacts = $id_type === 'registration'
585
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
586
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
587
+			do_action_ref_array(
588
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
589
+				array(
590
+					$contacts,
591
+					$Message_Template_Group->ID(),
592
+				)
593
+			);
594
+		}
595
+		$query_args = array(
596
+			'action' => ! empty($this->_req_data['redirect_back_to'])
597
+				? $this->_req_data['redirect_back_to']
598
+				: 'default',
599
+		);
600
+		$this->_redirect_after_action(false, '', '', $query_args, true);
601
+	}
602 602
 
603 603
 
604
-    /**
605
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
606
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
607
-     */
608
-    protected function _registration_reports_js_setup()
609
-    {
610
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
611
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
612
-    }
604
+	/**
605
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
606
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
607
+	 */
608
+	protected function _registration_reports_js_setup()
609
+	{
610
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
611
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
612
+	}
613 613
 
614 614
 
615
-    /**
616
-     *        generates Business Reports regarding Registrations
617
-     *
618
-     * @access protected
619
-     * @return void
620
-     * @throws DomainException
621
-     */
622
-    protected function _registration_reports()
623
-    {
624
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
625
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
626
-            $template_path,
627
-            $this->_reports_template_data,
628
-            true
629
-        );
630
-        // the final template wrapper
631
-        $this->display_admin_page_with_no_sidebar();
632
-    }
615
+	/**
616
+	 *        generates Business Reports regarding Registrations
617
+	 *
618
+	 * @access protected
619
+	 * @return void
620
+	 * @throws DomainException
621
+	 */
622
+	protected function _registration_reports()
623
+	{
624
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
625
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
626
+			$template_path,
627
+			$this->_reports_template_data,
628
+			true
629
+		);
630
+		// the final template wrapper
631
+		$this->display_admin_page_with_no_sidebar();
632
+	}
633 633
 
634 634
 
635
-    /**
636
-     * Generates Business Report showing total registrations per day.
637
-     *
638
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
639
-     * @return string
640
-     * @throws EE_Error
641
-     * @throws InvalidArgumentException
642
-     * @throws InvalidDataTypeException
643
-     * @throws InvalidInterfaceException
644
-     */
645
-    private function _registrations_per_day_report($period = '-1 month')
646
-    {
647
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
648
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
649
-        $results = (array) $results;
650
-        $regs = array();
651
-        $subtitle = '';
652
-        if ($results) {
653
-            $column_titles = array();
654
-            $tracker = 0;
655
-            foreach ($results as $result) {
656
-                $report_column_values = array();
657
-                foreach ($result as $property_name => $property_value) {
658
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
659
-                        : (int) $property_value;
660
-                    $report_column_values[] = $property_value;
661
-                    if ($tracker === 0) {
662
-                        if ($property_name === 'Registration_REG_date') {
663
-                            $column_titles[] = esc_html__(
664
-                                'Date (only days with registrations are shown)',
665
-                                'event_espresso'
666
-                            );
667
-                        } else {
668
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
669
-                        }
670
-                    }
671
-                }
672
-                $tracker++;
673
-                $regs[] = $report_column_values;
674
-            }
675
-            // make sure the column_titles is pushed to the beginning of the array
676
-            array_unshift($regs, $column_titles);
677
-            // setup the date range.
678
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
679
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
680
-            $ending_date = new DateTime("now", $DateTimeZone);
681
-            $subtitle = sprintf(
682
-                wp_strip_all_tags(
683
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
684
-                ),
685
-                $beginning_date->format('Y-m-d'),
686
-                $ending_date->format('Y-m-d')
687
-            );
688
-        }
689
-        $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
690
-        $report_params = array(
691
-            'title'     => $report_title,
692
-            'subtitle'  => $subtitle,
693
-            'id'        => $report_ID,
694
-            'regs'      => $regs,
695
-            'noResults' => empty($regs),
696
-            'noRegsMsg' => sprintf(
697
-                wp_strip_all_tags(
698
-                    __(
699
-                        '%sThere are currently no registration records in the last month for this report.%s',
700
-                        'event_espresso'
701
-                    )
702
-                ),
703
-                '<h2>' . $report_title . '</h2><p>',
704
-                '</p>'
705
-            ),
706
-        );
707
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
708
-        return $report_ID;
709
-    }
635
+	/**
636
+	 * Generates Business Report showing total registrations per day.
637
+	 *
638
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
639
+	 * @return string
640
+	 * @throws EE_Error
641
+	 * @throws InvalidArgumentException
642
+	 * @throws InvalidDataTypeException
643
+	 * @throws InvalidInterfaceException
644
+	 */
645
+	private function _registrations_per_day_report($period = '-1 month')
646
+	{
647
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
648
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
649
+		$results = (array) $results;
650
+		$regs = array();
651
+		$subtitle = '';
652
+		if ($results) {
653
+			$column_titles = array();
654
+			$tracker = 0;
655
+			foreach ($results as $result) {
656
+				$report_column_values = array();
657
+				foreach ($result as $property_name => $property_value) {
658
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
659
+						: (int) $property_value;
660
+					$report_column_values[] = $property_value;
661
+					if ($tracker === 0) {
662
+						if ($property_name === 'Registration_REG_date') {
663
+							$column_titles[] = esc_html__(
664
+								'Date (only days with registrations are shown)',
665
+								'event_espresso'
666
+							);
667
+						} else {
668
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
669
+						}
670
+					}
671
+				}
672
+				$tracker++;
673
+				$regs[] = $report_column_values;
674
+			}
675
+			// make sure the column_titles is pushed to the beginning of the array
676
+			array_unshift($regs, $column_titles);
677
+			// setup the date range.
678
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
679
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
680
+			$ending_date = new DateTime("now", $DateTimeZone);
681
+			$subtitle = sprintf(
682
+				wp_strip_all_tags(
683
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
684
+				),
685
+				$beginning_date->format('Y-m-d'),
686
+				$ending_date->format('Y-m-d')
687
+			);
688
+		}
689
+		$report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso'));
690
+		$report_params = array(
691
+			'title'     => $report_title,
692
+			'subtitle'  => $subtitle,
693
+			'id'        => $report_ID,
694
+			'regs'      => $regs,
695
+			'noResults' => empty($regs),
696
+			'noRegsMsg' => sprintf(
697
+				wp_strip_all_tags(
698
+					__(
699
+						'%sThere are currently no registration records in the last month for this report.%s',
700
+						'event_espresso'
701
+					)
702
+				),
703
+				'<h2>' . $report_title . '</h2><p>',
704
+				'</p>'
705
+			),
706
+		);
707
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
708
+		return $report_ID;
709
+	}
710 710
 
711 711
 
712
-    /**
713
-     * Generates Business Report showing total registrations per event.
714
-     *
715
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
716
-     * @return string
717
-     * @throws EE_Error
718
-     * @throws InvalidArgumentException
719
-     * @throws InvalidDataTypeException
720
-     * @throws InvalidInterfaceException
721
-     */
722
-    private function _registrations_per_event_report($period = '-1 month')
723
-    {
724
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
725
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
726
-        $results = (array) $results;
727
-        $regs = array();
728
-        $subtitle = '';
729
-        if ($results) {
730
-            $column_titles = array();
731
-            $tracker = 0;
732
-            foreach ($results as $result) {
733
-                $report_column_values = array();
734
-                foreach ($result as $property_name => $property_value) {
735
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
736
-                        $property_value,
737
-                        4,
738
-                        '...'
739
-                    ) : (int) $property_value;
740
-                    $report_column_values[] = $property_value;
741
-                    if ($tracker === 0) {
742
-                        if ($property_name === 'Registration_Event') {
743
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
744
-                        } else {
745
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
746
-                        }
747
-                    }
748
-                }
749
-                $tracker++;
750
-                $regs[] = $report_column_values;
751
-            }
752
-            // make sure the column_titles is pushed to the beginning of the array
753
-            array_unshift($regs, $column_titles);
754
-            // setup the date range.
755
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
756
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
757
-            $ending_date = new DateTime("now", $DateTimeZone);
758
-            $subtitle = sprintf(
759
-                wp_strip_all_tags(
760
-                    _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
761
-                ),
762
-                $beginning_date->format('Y-m-d'),
763
-                $ending_date->format('Y-m-d')
764
-            );
765
-        }
766
-        $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
767
-        $report_params = array(
768
-            'title'     => $report_title,
769
-            'subtitle'  => $subtitle,
770
-            'id'        => $report_ID,
771
-            'regs'      => $regs,
772
-            'noResults' => empty($regs),
773
-            'noRegsMsg' => sprintf(
774
-                wp_strip_all_tags(
775
-                    __(
776
-                        '%sThere are currently no registration records in the last month for this report.%s',
777
-                        'event_espresso'
778
-                    )
779
-                ),
780
-                '<h2>' . $report_title . '</h2><p>',
781
-                '</p>'
782
-            ),
783
-        );
784
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
785
-        return $report_ID;
786
-    }
712
+	/**
713
+	 * Generates Business Report showing total registrations per event.
714
+	 *
715
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
716
+	 * @return string
717
+	 * @throws EE_Error
718
+	 * @throws InvalidArgumentException
719
+	 * @throws InvalidDataTypeException
720
+	 * @throws InvalidInterfaceException
721
+	 */
722
+	private function _registrations_per_event_report($period = '-1 month')
723
+	{
724
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
725
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
726
+		$results = (array) $results;
727
+		$regs = array();
728
+		$subtitle = '';
729
+		if ($results) {
730
+			$column_titles = array();
731
+			$tracker = 0;
732
+			foreach ($results as $result) {
733
+				$report_column_values = array();
734
+				foreach ($result as $property_name => $property_value) {
735
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
736
+						$property_value,
737
+						4,
738
+						'...'
739
+					) : (int) $property_value;
740
+					$report_column_values[] = $property_value;
741
+					if ($tracker === 0) {
742
+						if ($property_name === 'Registration_Event') {
743
+							$column_titles[] = esc_html__('Event', 'event_espresso');
744
+						} else {
745
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
746
+						}
747
+					}
748
+				}
749
+				$tracker++;
750
+				$regs[] = $report_column_values;
751
+			}
752
+			// make sure the column_titles is pushed to the beginning of the array
753
+			array_unshift($regs, $column_titles);
754
+			// setup the date range.
755
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
756
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
757
+			$ending_date = new DateTime("now", $DateTimeZone);
758
+			$subtitle = sprintf(
759
+				wp_strip_all_tags(
760
+					_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso')
761
+				),
762
+				$beginning_date->format('Y-m-d'),
763
+				$ending_date->format('Y-m-d')
764
+			);
765
+		}
766
+		$report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso'));
767
+		$report_params = array(
768
+			'title'     => $report_title,
769
+			'subtitle'  => $subtitle,
770
+			'id'        => $report_ID,
771
+			'regs'      => $regs,
772
+			'noResults' => empty($regs),
773
+			'noRegsMsg' => sprintf(
774
+				wp_strip_all_tags(
775
+					__(
776
+						'%sThere are currently no registration records in the last month for this report.%s',
777
+						'event_espresso'
778
+					)
779
+				),
780
+				'<h2>' . $report_title . '</h2><p>',
781
+				'</p>'
782
+			),
783
+		);
784
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
785
+		return $report_ID;
786
+	}
787 787
 
788 788
 
789
-    /**
790
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
791
-     *
792
-     * @access protected
793
-     * @return void
794
-     * @throws EE_Error
795
-     * @throws InvalidArgumentException
796
-     * @throws InvalidDataTypeException
797
-     * @throws InvalidInterfaceException
798
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
799
-     */
800
-    protected function _registration_checkin_list_table()
801
-    {
802
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
803
-        $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
804
-        /** @var EE_Registration $registration */
805
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
806
-        if (! $registration instanceof EE_Registration) {
807
-            throw new EE_Error(
808
-                sprintf(
809
-                    esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
810
-                    $reg_id
811
-                )
812
-            );
813
-        }
814
-        $attendee = $registration->attendee();
815
-        $this->_admin_page_title .= $this->get_action_link_or_button(
816
-            'new_registration',
817
-            'add-registrant',
818
-            array('event_id' => $registration->event_ID()),
819
-            'add-new-h2'
820
-        );
821
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
822
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
823
-        $legend_items = array(
824
-            'checkin'  => array(
825
-                'class' => $checked_in->cssClasses(),
826
-                'desc'  => $checked_in->legendLabel(),
827
-            ),
828
-            'checkout' => array(
829
-                'class' => $checked_out->cssClasses(),
830
-                'desc'  => $checked_out->legendLabel(),
831
-            ),
832
-        );
833
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
834
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
835
-        /** @var EE_Datetime $datetime */
836
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
837
-        $datetime_label = '';
838
-        if ($datetime instanceof EE_Datetime) {
839
-            $datetime_label = $datetime->get_dtt_display_name(true);
840
-            $datetime_label .= ! empty($datetime_label)
841
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
842
-                : $datetime->get_dtt_display_name();
843
-        }
844
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
845
-            ? EE_Admin_Page::add_query_args_and_nonce(
846
-                array(
847
-                    'action'   => 'event_registrations',
848
-                    'event_id' => $registration->event_ID(),
849
-                    'DTT_ID'   => $dtt_id,
850
-                ),
851
-                $this->_admin_base_url
852
-            )
853
-            : '';
854
-        $datetime_link = ! empty($datetime_link)
855
-            ? '<a href="' . $datetime_link . '">'
856
-              . '<span id="checkin-dtt">'
857
-              . $datetime_label
858
-              . '</span></a>'
859
-            : $datetime_label;
860
-        $attendee_name = $attendee instanceof EE_Attendee
861
-            ? $attendee->full_name()
862
-            : '';
863
-        $attendee_link = $attendee instanceof EE_Attendee
864
-            ? $attendee->get_admin_details_link()
865
-            : '';
866
-        $attendee_link = ! empty($attendee_link)
867
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
868
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
869
-              . '<span id="checkin-attendee-name">'
870
-              . $attendee_name
871
-              . '</span></a>'
872
-            : '';
873
-        $event_link = $registration->event() instanceof EE_Event
874
-            ? $registration->event()->get_admin_details_link()
875
-            : '';
876
-        $event_link = ! empty($event_link)
877
-            ? '<a href="' . $event_link . '"'
878
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
879
-              . '<span id="checkin-event-name">'
880
-              . $registration->event_name()
881
-              . '</span>'
882
-              . '</a>'
883
-            : '';
884
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
885
-            ? '<h2>' . sprintf(
886
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
887
-                $attendee_link,
888
-                $datetime_link,
889
-                $event_link
890
-            ) . '</h2>'
891
-            : '';
892
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
893
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
894
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
895
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
896
-        $this->display_admin_list_table_page_with_no_sidebar();
897
-    }
789
+	/**
790
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
791
+	 *
792
+	 * @access protected
793
+	 * @return void
794
+	 * @throws EE_Error
795
+	 * @throws InvalidArgumentException
796
+	 * @throws InvalidDataTypeException
797
+	 * @throws InvalidInterfaceException
798
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
799
+	 */
800
+	protected function _registration_checkin_list_table()
801
+	{
802
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
803
+		$reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
804
+		/** @var EE_Registration $registration */
805
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
806
+		if (! $registration instanceof EE_Registration) {
807
+			throw new EE_Error(
808
+				sprintf(
809
+					esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
810
+					$reg_id
811
+				)
812
+			);
813
+		}
814
+		$attendee = $registration->attendee();
815
+		$this->_admin_page_title .= $this->get_action_link_or_button(
816
+			'new_registration',
817
+			'add-registrant',
818
+			array('event_id' => $registration->event_ID()),
819
+			'add-new-h2'
820
+		);
821
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
822
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
823
+		$legend_items = array(
824
+			'checkin'  => array(
825
+				'class' => $checked_in->cssClasses(),
826
+				'desc'  => $checked_in->legendLabel(),
827
+			),
828
+			'checkout' => array(
829
+				'class' => $checked_out->cssClasses(),
830
+				'desc'  => $checked_out->legendLabel(),
831
+			),
832
+		);
833
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
834
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
835
+		/** @var EE_Datetime $datetime */
836
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
837
+		$datetime_label = '';
838
+		if ($datetime instanceof EE_Datetime) {
839
+			$datetime_label = $datetime->get_dtt_display_name(true);
840
+			$datetime_label .= ! empty($datetime_label)
841
+				? ' (' . $datetime->get_dtt_display_name() . ')'
842
+				: $datetime->get_dtt_display_name();
843
+		}
844
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
845
+			? EE_Admin_Page::add_query_args_and_nonce(
846
+				array(
847
+					'action'   => 'event_registrations',
848
+					'event_id' => $registration->event_ID(),
849
+					'DTT_ID'   => $dtt_id,
850
+				),
851
+				$this->_admin_base_url
852
+			)
853
+			: '';
854
+		$datetime_link = ! empty($datetime_link)
855
+			? '<a href="' . $datetime_link . '">'
856
+			  . '<span id="checkin-dtt">'
857
+			  . $datetime_label
858
+			  . '</span></a>'
859
+			: $datetime_label;
860
+		$attendee_name = $attendee instanceof EE_Attendee
861
+			? $attendee->full_name()
862
+			: '';
863
+		$attendee_link = $attendee instanceof EE_Attendee
864
+			? $attendee->get_admin_details_link()
865
+			: '';
866
+		$attendee_link = ! empty($attendee_link)
867
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
868
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
869
+			  . '<span id="checkin-attendee-name">'
870
+			  . $attendee_name
871
+			  . '</span></a>'
872
+			: '';
873
+		$event_link = $registration->event() instanceof EE_Event
874
+			? $registration->event()->get_admin_details_link()
875
+			: '';
876
+		$event_link = ! empty($event_link)
877
+			? '<a href="' . $event_link . '"'
878
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
879
+			  . '<span id="checkin-event-name">'
880
+			  . $registration->event_name()
881
+			  . '</span>'
882
+			  . '</a>'
883
+			: '';
884
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
885
+			? '<h2>' . sprintf(
886
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
887
+				$attendee_link,
888
+				$datetime_link,
889
+				$event_link
890
+			) . '</h2>'
891
+			: '';
892
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
893
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
894
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
895
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
896
+		$this->display_admin_list_table_page_with_no_sidebar();
897
+	}
898 898
 
899 899
 
900
-    /**
901
-     * toggle the Check-in status for the given registration (coming from ajax)
902
-     *
903
-     * @return void (JSON)
904
-     * @throws EE_Error
905
-     * @throws InvalidArgumentException
906
-     * @throws InvalidDataTypeException
907
-     * @throws InvalidInterfaceException
908
-     */
909
-    public function toggle_checkin_status()
910
-    {
911
-        // first make sure we have the necessary data
912
-        if (! isset($this->_req_data['_regid'])) {
913
-            EE_Error::add_error(
914
-                esc_html__(
915
-                    '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',
916
-                    'event_espresso'
917
-                ),
918
-                __FILE__,
919
-                __FUNCTION__,
920
-                __LINE__
921
-            );
922
-            $this->_template_args['success'] = false;
923
-            $this->_template_args['error'] = true;
924
-            $this->_return_json();
925
-        };
926
-        // do a nonce check cause we're not coming in from an normal route here.
927
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
928
-            : '';
929
-        $nonce_ref = 'checkin_nonce';
930
-        $this->_verify_nonce($nonce, $nonce_ref);
931
-        // beautiful! Made it this far so let's get the status.
932
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
933
-        // setup new class to return via ajax
934
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
935
-        $this->_template_args['success'] = true;
936
-        $this->_return_json();
937
-    }
900
+	/**
901
+	 * toggle the Check-in status for the given registration (coming from ajax)
902
+	 *
903
+	 * @return void (JSON)
904
+	 * @throws EE_Error
905
+	 * @throws InvalidArgumentException
906
+	 * @throws InvalidDataTypeException
907
+	 * @throws InvalidInterfaceException
908
+	 */
909
+	public function toggle_checkin_status()
910
+	{
911
+		// first make sure we have the necessary data
912
+		if (! isset($this->_req_data['_regid'])) {
913
+			EE_Error::add_error(
914
+				esc_html__(
915
+					'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',
916
+					'event_espresso'
917
+				),
918
+				__FILE__,
919
+				__FUNCTION__,
920
+				__LINE__
921
+			);
922
+			$this->_template_args['success'] = false;
923
+			$this->_template_args['error'] = true;
924
+			$this->_return_json();
925
+		};
926
+		// do a nonce check cause we're not coming in from an normal route here.
927
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
928
+			: '';
929
+		$nonce_ref = 'checkin_nonce';
930
+		$this->_verify_nonce($nonce, $nonce_ref);
931
+		// beautiful! Made it this far so let's get the status.
932
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
933
+		// setup new class to return via ajax
934
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
935
+		$this->_template_args['success'] = true;
936
+		$this->_return_json();
937
+	}
938 938
 
939 939
 
940
-    /**
941
-     * handles toggling the checkin status for the registration,
942
-     *
943
-     * @access protected
944
-     * @return int|void
945
-     * @throws EE_Error
946
-     * @throws InvalidArgumentException
947
-     * @throws InvalidDataTypeException
948
-     * @throws InvalidInterfaceException
949
-     */
950
-    protected function _toggle_checkin_status()
951
-    {
952
-        // first let's get the query args out of the way for the redirect
953
-        $query_args = array(
954
-            'action'   => 'event_registrations',
955
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
956
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
957
-        );
958
-        $new_status = false;
959
-        // bulk action check in toggle
960
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
961
-            // cycle thru checkboxes
962
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
963
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
964
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
965
-            }
966
-        } elseif (isset($this->_req_data['_regid'])) {
967
-            // coming from ajax request
968
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
969
-            $query_args['DTT_ID'] = $DTT_ID;
970
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
971
-        } else {
972
-            EE_Error::add_error(
973
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
974
-                __FILE__,
975
-                __FUNCTION__,
976
-                __LINE__
977
-            );
978
-        }
979
-        if (defined('DOING_AJAX')) {
980
-            return $new_status;
981
-        }
982
-        $this->_redirect_after_action(false, '', '', $query_args, true);
983
-    }
940
+	/**
941
+	 * handles toggling the checkin status for the registration,
942
+	 *
943
+	 * @access protected
944
+	 * @return int|void
945
+	 * @throws EE_Error
946
+	 * @throws InvalidArgumentException
947
+	 * @throws InvalidDataTypeException
948
+	 * @throws InvalidInterfaceException
949
+	 */
950
+	protected function _toggle_checkin_status()
951
+	{
952
+		// first let's get the query args out of the way for the redirect
953
+		$query_args = array(
954
+			'action'   => 'event_registrations',
955
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
956
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
957
+		);
958
+		$new_status = false;
959
+		// bulk action check in toggle
960
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
961
+			// cycle thru checkboxes
962
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
963
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
964
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
965
+			}
966
+		} elseif (isset($this->_req_data['_regid'])) {
967
+			// coming from ajax request
968
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
969
+			$query_args['DTT_ID'] = $DTT_ID;
970
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
971
+		} else {
972
+			EE_Error::add_error(
973
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
974
+				__FILE__,
975
+				__FUNCTION__,
976
+				__LINE__
977
+			);
978
+		}
979
+		if (defined('DOING_AJAX')) {
980
+			return $new_status;
981
+		}
982
+		$this->_redirect_after_action(false, '', '', $query_args, true);
983
+	}
984 984
 
985 985
 
986
-    /**
987
-     * This is toggles a single Check-in for the given registration and datetime.
988
-     *
989
-     * @param  int $REG_ID The registration we're toggling
990
-     * @param  int $DTT_ID The datetime we're toggling
991
-     * @return int The new status toggled to.
992
-     * @throws EE_Error
993
-     * @throws InvalidArgumentException
994
-     * @throws InvalidDataTypeException
995
-     * @throws InvalidInterfaceException
996
-     */
997
-    private function _toggle_checkin($REG_ID, $DTT_ID)
998
-    {
999
-        /** @var EE_Registration $REG */
1000
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1001
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
1002
-        if ($new_status !== false) {
1003
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1004
-        } else {
1005
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1006
-            $new_status = false;
1007
-        }
1008
-        return $new_status;
1009
-    }
986
+	/**
987
+	 * This is toggles a single Check-in for the given registration and datetime.
988
+	 *
989
+	 * @param  int $REG_ID The registration we're toggling
990
+	 * @param  int $DTT_ID The datetime we're toggling
991
+	 * @return int The new status toggled to.
992
+	 * @throws EE_Error
993
+	 * @throws InvalidArgumentException
994
+	 * @throws InvalidDataTypeException
995
+	 * @throws InvalidInterfaceException
996
+	 */
997
+	private function _toggle_checkin($REG_ID, $DTT_ID)
998
+	{
999
+		/** @var EE_Registration $REG */
1000
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1001
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
1002
+		if ($new_status !== false) {
1003
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
1004
+		} else {
1005
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1006
+			$new_status = false;
1007
+		}
1008
+		return $new_status;
1009
+	}
1010 1010
 
1011 1011
 
1012
-    /**
1013
-     * Takes care of deleting multiple EE_Checkin table rows
1014
-     *
1015
-     * @access protected
1016
-     * @return void
1017
-     * @throws EE_Error
1018
-     * @throws InvalidArgumentException
1019
-     * @throws InvalidDataTypeException
1020
-     * @throws InvalidInterfaceException
1021
-     */
1022
-    protected function _delete_checkin_rows()
1023
-    {
1024
-        $query_args = array(
1025
-            'action'  => 'registration_checkins',
1026
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1027
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1028
-        );
1029
-        $errors = 0;
1030
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1031
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1032
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1033
-                    $errors++;
1034
-                }
1035
-            }
1036
-        } else {
1037
-            EE_Error::add_error(
1038
-                esc_html__(
1039
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1040
-                    'event_espresso'
1041
-                ),
1042
-                __FILE__,
1043
-                __FUNCTION__,
1044
-                __LINE__
1045
-            );
1046
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1047
-        }
1048
-        if ($errors > 0) {
1049
-            EE_Error::add_error(
1050
-                sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1051
-                __FILE__,
1052
-                __FUNCTION__,
1053
-                __LINE__
1054
-            );
1055
-        } else {
1056
-            EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1057
-        }
1058
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1059
-    }
1012
+	/**
1013
+	 * Takes care of deleting multiple EE_Checkin table rows
1014
+	 *
1015
+	 * @access protected
1016
+	 * @return void
1017
+	 * @throws EE_Error
1018
+	 * @throws InvalidArgumentException
1019
+	 * @throws InvalidDataTypeException
1020
+	 * @throws InvalidInterfaceException
1021
+	 */
1022
+	protected function _delete_checkin_rows()
1023
+	{
1024
+		$query_args = array(
1025
+			'action'  => 'registration_checkins',
1026
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1027
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1028
+		);
1029
+		$errors = 0;
1030
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1031
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1032
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1033
+					$errors++;
1034
+				}
1035
+			}
1036
+		} else {
1037
+			EE_Error::add_error(
1038
+				esc_html__(
1039
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1040
+					'event_espresso'
1041
+				),
1042
+				__FILE__,
1043
+				__FUNCTION__,
1044
+				__LINE__
1045
+			);
1046
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1047
+		}
1048
+		if ($errors > 0) {
1049
+			EE_Error::add_error(
1050
+				sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1051
+				__FILE__,
1052
+				__FUNCTION__,
1053
+				__LINE__
1054
+			);
1055
+		} else {
1056
+			EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso'));
1057
+		}
1058
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1059
+	}
1060 1060
 
1061 1061
 
1062
-    /**
1063
-     * Deletes a single EE_Checkin row
1064
-     *
1065
-     * @return void
1066
-     * @throws EE_Error
1067
-     * @throws InvalidArgumentException
1068
-     * @throws InvalidDataTypeException
1069
-     * @throws InvalidInterfaceException
1070
-     */
1071
-    protected function _delete_checkin_row()
1072
-    {
1073
-        $query_args = array(
1074
-            'action'  => 'registration_checkins',
1075
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1076
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1077
-        );
1078
-        if (! empty($this->_req_data['CHK_ID'])) {
1079
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1080
-                EE_Error::add_error(
1081
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1082
-                    __FILE__,
1083
-                    __FUNCTION__,
1084
-                    __LINE__
1085
-                );
1086
-            } else {
1087
-                EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1088
-            }
1089
-        } else {
1090
-            EE_Error::add_error(
1091
-                esc_html__(
1092
-                    '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',
1093
-                    'event_espresso'
1094
-                ),
1095
-                __FILE__,
1096
-                __FUNCTION__,
1097
-                __LINE__
1098
-            );
1099
-        }
1100
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1101
-    }
1062
+	/**
1063
+	 * Deletes a single EE_Checkin row
1064
+	 *
1065
+	 * @return void
1066
+	 * @throws EE_Error
1067
+	 * @throws InvalidArgumentException
1068
+	 * @throws InvalidDataTypeException
1069
+	 * @throws InvalidInterfaceException
1070
+	 */
1071
+	protected function _delete_checkin_row()
1072
+	{
1073
+		$query_args = array(
1074
+			'action'  => 'registration_checkins',
1075
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1076
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1077
+		);
1078
+		if (! empty($this->_req_data['CHK_ID'])) {
1079
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1080
+				EE_Error::add_error(
1081
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1082
+					__FILE__,
1083
+					__FUNCTION__,
1084
+					__LINE__
1085
+				);
1086
+			} else {
1087
+				EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso'));
1088
+			}
1089
+		} else {
1090
+			EE_Error::add_error(
1091
+				esc_html__(
1092
+					'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',
1093
+					'event_espresso'
1094
+				),
1095
+				__FILE__,
1096
+				__FUNCTION__,
1097
+				__LINE__
1098
+			);
1099
+		}
1100
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1101
+	}
1102 1102
 
1103 1103
 
1104
-    /**
1105
-     *        generates HTML for the Event Registrations List Table
1106
-     *
1107
-     * @access protected
1108
-     * @return void
1109
-     * @throws EE_Error
1110
-     * @throws InvalidArgumentException
1111
-     * @throws InvalidDataTypeException
1112
-     * @throws InvalidInterfaceException
1113
-     */
1114
-    protected function _event_registrations_list_table()
1115
-    {
1116
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1117
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1118
-            ? $this->get_action_link_or_button(
1119
-                'new_registration',
1120
-                'add-registrant',
1121
-                array('event_id' => $this->_req_data['event_id']),
1122
-                'add-new-h2',
1123
-                '',
1124
-                false
1125
-            )
1126
-            : '';
1127
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1128
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1129
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1130
-        $legend_items = array(
1131
-            'star-icon'        => array(
1132
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1133
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1134
-            ),
1135
-            'checkin'          => array(
1136
-                'class' => $checked_in->cssClasses(),
1137
-                'desc'  => $checked_in->legendLabel(),
1138
-            ),
1139
-            'checkout'         => array(
1140
-                'class' => $checked_out->cssClasses(),
1141
-                'desc'  => $checked_out->legendLabel(),
1142
-            ),
1143
-            'nocheckinrecord'  => array(
1144
-                'class' => $checked_never->cssClasses(),
1145
-                'desc'  => $checked_never->legendLabel(),
1146
-            ),
1147
-            'approved_status'  => array(
1148
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1149
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1150
-            ),
1151
-            'cancelled_status' => array(
1152
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1153
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1154
-            ),
1155
-            'declined_status'  => array(
1156
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1157
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1158
-            ),
1159
-            'not_approved'     => array(
1160
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1161
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1162
-            ),
1163
-            'pending_status'   => array(
1164
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1165
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1166
-            ),
1167
-            'wait_list'        => array(
1168
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1169
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1170
-            ),
1171
-        );
1172
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1173
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1174
-        /** @var EE_Event $event */
1175
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1176
-        $this->_template_args['before_list_table'] = $event instanceof EE_Event
1177
-            ? '<h2>' . sprintf(
1178
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1179
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1180
-            ) . '</h2>'
1181
-            : '';
1182
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1183
-        // the event.
1184
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1185
-        $datetime = null;
1186
-        if ($event instanceof EE_Event) {
1187
-            $datetimes_on_event = $event->datetimes();
1188
-            if (count($datetimes_on_event) === 1) {
1189
-                $datetime = reset($datetimes_on_event);
1190
-            }
1191
-        }
1192
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1193
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1194
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1195
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1196
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1197
-            $this->_template_args['before_list_table'] .= $datetime->name();
1198
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1199
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1200
-        }
1201
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1202
-        // column represents
1203
-        if (! $datetime instanceof EE_Datetime) {
1204
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1205
-                                                          . esc_html__(
1206
-                                                              'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1207
-                                                              'event_espresso'
1208
-                                                          )
1209
-                                                          . '</p>';
1210
-        }
1211
-        $this->display_admin_list_table_page_with_no_sidebar();
1212
-    }
1104
+	/**
1105
+	 *        generates HTML for the Event Registrations List Table
1106
+	 *
1107
+	 * @access protected
1108
+	 * @return void
1109
+	 * @throws EE_Error
1110
+	 * @throws InvalidArgumentException
1111
+	 * @throws InvalidDataTypeException
1112
+	 * @throws InvalidInterfaceException
1113
+	 */
1114
+	protected function _event_registrations_list_table()
1115
+	{
1116
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1117
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1118
+			? $this->get_action_link_or_button(
1119
+				'new_registration',
1120
+				'add-registrant',
1121
+				array('event_id' => $this->_req_data['event_id']),
1122
+				'add-new-h2',
1123
+				'',
1124
+				false
1125
+			)
1126
+			: '';
1127
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1128
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1129
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1130
+		$legend_items = array(
1131
+			'star-icon'        => array(
1132
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1133
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1134
+			),
1135
+			'checkin'          => array(
1136
+				'class' => $checked_in->cssClasses(),
1137
+				'desc'  => $checked_in->legendLabel(),
1138
+			),
1139
+			'checkout'         => array(
1140
+				'class' => $checked_out->cssClasses(),
1141
+				'desc'  => $checked_out->legendLabel(),
1142
+			),
1143
+			'nocheckinrecord'  => array(
1144
+				'class' => $checked_never->cssClasses(),
1145
+				'desc'  => $checked_never->legendLabel(),
1146
+			),
1147
+			'approved_status'  => array(
1148
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1149
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1150
+			),
1151
+			'cancelled_status' => array(
1152
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1153
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1154
+			),
1155
+			'declined_status'  => array(
1156
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1157
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1158
+			),
1159
+			'not_approved'     => array(
1160
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1161
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1162
+			),
1163
+			'pending_status'   => array(
1164
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1165
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1166
+			),
1167
+			'wait_list'        => array(
1168
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1169
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1170
+			),
1171
+		);
1172
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1173
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1174
+		/** @var EE_Event $event */
1175
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1176
+		$this->_template_args['before_list_table'] = $event instanceof EE_Event
1177
+			? '<h2>' . sprintf(
1178
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1179
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1180
+			) . '</h2>'
1181
+			: '';
1182
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1183
+		// the event.
1184
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1185
+		$datetime = null;
1186
+		if ($event instanceof EE_Event) {
1187
+			$datetimes_on_event = $event->datetimes();
1188
+			if (count($datetimes_on_event) === 1) {
1189
+				$datetime = reset($datetimes_on_event);
1190
+			}
1191
+		}
1192
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1193
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1194
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1195
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1196
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1197
+			$this->_template_args['before_list_table'] .= $datetime->name();
1198
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1199
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1200
+		}
1201
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1202
+		// column represents
1203
+		if (! $datetime instanceof EE_Datetime) {
1204
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1205
+														  . esc_html__(
1206
+															  'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1207
+															  'event_espresso'
1208
+														  )
1209
+														  . '</p>';
1210
+		}
1211
+		$this->display_admin_list_table_page_with_no_sidebar();
1212
+	}
1213 1213
 
1214
-    /**
1215
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1216
-     * conditions)
1217
-     *
1218
-     * @return void ends the request by a redirect or download
1219
-     */
1220
-    public function _registrations_checkin_report()
1221
-    {
1222
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1223
-    }
1214
+	/**
1215
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1216
+	 * conditions)
1217
+	 *
1218
+	 * @return void ends the request by a redirect or download
1219
+	 */
1220
+	public function _registrations_checkin_report()
1221
+	{
1222
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1223
+	}
1224 1224
 
1225
-    /**
1226
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1227
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1228
-     *
1229
-     * @param array $request
1230
-     * @param int   $per_page
1231
-     * @param bool  $count
1232
-     * @return array
1233
-     * @throws EE_Error
1234
-     */
1235
-    protected function _get_checkin_query_params_from_request(
1236
-        $request,
1237
-        $per_page = 10,
1238
-        $count = false
1239
-    ) {
1240
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1241
-        // unlike the regular registrations list table,
1242
-        $status_ids_array = apply_filters(
1243
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1244
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1245
-        );
1246
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1247
-        return $query_params;
1248
-    }
1225
+	/**
1226
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1227
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1228
+	 *
1229
+	 * @param array $request
1230
+	 * @param int   $per_page
1231
+	 * @param bool  $count
1232
+	 * @return array
1233
+	 * @throws EE_Error
1234
+	 */
1235
+	protected function _get_checkin_query_params_from_request(
1236
+		$request,
1237
+		$per_page = 10,
1238
+		$count = false
1239
+	) {
1240
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1241
+		// unlike the regular registrations list table,
1242
+		$status_ids_array = apply_filters(
1243
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1244
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1245
+		);
1246
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1247
+		return $query_params;
1248
+	}
1249 1249
 
1250 1250
 
1251
-    /**
1252
-     * Gets registrations for an event
1253
-     *
1254
-     * @param int    $per_page
1255
-     * @param bool   $count whether to return count or data.
1256
-     * @param bool   $trash
1257
-     * @param string $orderby
1258
-     * @return EE_Registration[]|int
1259
-     * @throws EE_Error
1260
-     * @throws InvalidArgumentException
1261
-     * @throws InvalidDataTypeException
1262
-     * @throws InvalidInterfaceException
1263
-     */
1264
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1265
-    {
1266
-        // set some defaults, these will get overridden if included in the actual request parameters
1267
-        $defaults = [
1268
-            'orderby' => $orderby,
1269
-            'order' => 'ASC',
1270
-        ];
1271
-        if ($trash) {
1272
-            $defaults['status'] = 'trash';
1273
-        }
1274
-        $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count);
1251
+	/**
1252
+	 * Gets registrations for an event
1253
+	 *
1254
+	 * @param int    $per_page
1255
+	 * @param bool   $count whether to return count or data.
1256
+	 * @param bool   $trash
1257
+	 * @param string $orderby
1258
+	 * @return EE_Registration[]|int
1259
+	 * @throws EE_Error
1260
+	 * @throws InvalidArgumentException
1261
+	 * @throws InvalidDataTypeException
1262
+	 * @throws InvalidInterfaceException
1263
+	 */
1264
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1265
+	{
1266
+		// set some defaults, these will get overridden if included in the actual request parameters
1267
+		$defaults = [
1268
+			'orderby' => $orderby,
1269
+			'order' => 'ASC',
1270
+		];
1271
+		if ($trash) {
1272
+			$defaults['status'] = 'trash';
1273
+		}
1274
+		$query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count);
1275 1275
 
1276
-        /**
1277
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1278
-         *
1279
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1280
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1281
-         *                             or if you have the development copy of EE you can view this at the path:
1282
-         *                             /docs/G--Model-System/model-query-params.md
1283
-         */
1284
-        $query_params['group_by'] = '';
1276
+		/**
1277
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1278
+		 *
1279
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1280
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1281
+		 *                             or if you have the development copy of EE you can view this at the path:
1282
+		 *                             /docs/G--Model-System/model-query-params.md
1283
+		 */
1284
+		$query_params['group_by'] = '';
1285 1285
 
1286
-        return $count
1287
-            ? EEM_Registration::instance()->count($query_params)
1288
-            /** @type EE_Registration[] */
1289
-            : EEM_Registration::instance()->get_all($query_params);
1290
-    }
1286
+		return $count
1287
+			? EEM_Registration::instance()->count($query_params)
1288
+			/** @type EE_Registration[] */
1289
+			: EEM_Registration::instance()->get_all($query_params);
1290
+	}
1291 1291
 }
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             'ajax'     => true,
92 92
             'screen'   => $this->_admin_page->get_current_screen()->id,
93 93
         ];
94
-        $columns             = [];
94
+        $columns = [];
95 95
         // $columns['_Reg_Status'] = '';
96 96
         $this->_columns = [
97 97
             '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             'TXN_total'           => esc_html__('Total', 'event_espresso'),
105 105
         ];
106 106
         // Add/remove columns when an event has been selected
107
-        if (! empty($EVT_ID)) {
107
+        if ( ! empty($EVT_ID)) {
108 108
             // Render a checkbox column
109 109
             $columns['cb']              = '<input type="checkbox" />';
110 110
             $this->_has_checkbox_column = true;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $this->_primary_column = '_REG_att_checked_in';
116 116
 
117 117
         $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
118
-        if (! empty($csv_report)) {
118
+        if ( ! empty($csv_report)) {
119 119
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
120 120
         }
121 121
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $class = parent::_get_row_class($item);
153 153
         // add status class
154
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
154
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
155 155
         if ($this->_has_checkbox_column) {
156 156
             $class .= ' has-checkbox-column';
157 157
         }
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
         if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
172 172
             // this means we don't have an event so let's setup a filter dropdown for all the events to select
173 173
             // note possible capability restrictions
174
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
174
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
175 175
                 $where['status**'] = ['!=', 'private'];
176 176
             }
177
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
177
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
178 178
                 $where['EVT_wp_user'] = get_current_user_id();
179 179
             }
180
-            $events          = EEM_Event::instance()->get_all(
180
+            $events = EEM_Event::instance()->get_all(
181 181
                 [
182 182
                     $where,
183 183
                     'order_by' => ['Datetime.DTT_EVT_start' => 'DESC'],
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
                 'id'   => 0,
188 188
                 'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'),
189 189
             ];
190
-            $checked         = 'checked';
190
+            $checked = 'checked';
191 191
             /** @var EE_Event $event */
192 192
             foreach ($events as $event) {
193 193
                 // any registrations for this event?
194
-                if (! $event->get_count_of_all_registrations()) {
194
+                if ( ! $event->get_count_of_all_registrations()) {
195 195
                     continue;
196 196
                 }
197 197
                 $event_options[] = [
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
             $event_filter = '<div class="ee-event-filter">';
211 211
             $event_filter .= EEH_Form_Fields::select_input('event_id', $event_options, $current_EVT_ID);
212 212
             $event_filter .= '<span class="ee-event-filter-toggle">';
213
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
213
+            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> ';
214 214
             $event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
215 215
             $event_filter .= '</span>';
216 216
             $event_filter .= '</div>';
217
-            $filters[]    = $event_filter;
217
+            $filters[] = $event_filter;
218 218
         }
219
-        if (! empty($this->_dtts_for_event)) {
219
+        if ( ! empty($this->_dtts_for_event)) {
220 220
             // DTT datetimes filter
221 221
             $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
222 222
             if (count($this->_dtts_for_event) > 1) {
223 223
                 $datetimes[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
224 224
                 foreach ($this->_dtts_for_event as $datetime) {
225 225
                     $datetime_string              = $datetime->name();
226
-                    $datetime_string              = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
226
+                    $datetime_string              = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
227 227
                     $datetime_string              =
228
-                        $datetime->start_date_and_time() . ' - ' . $datetime->end_date_and_time() . $datetime_string;
229
-                    $datetimes[ $datetime->ID() ] = $datetime_string;
228
+                        $datetime->start_date_and_time().' - '.$datetime->end_date_and_time().$datetime_string;
229
+                    $datetimes[$datetime->ID()] = $datetime_string;
230 230
                 }
231
-                $input     = new EE_Select_Input(
231
+                $input = new EE_Select_Input(
232 232
                     $datetimes,
233 233
                     [
234 234
                         'html_name' => 'DTT_ID',
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                     ]
238 238
                 );
239 239
                 $filters[] = $input->get_html_for_input();
240
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
240
+                $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
241 241
             }
242 242
         }
243 243
         return $filters;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         if ($DTT_ID) {
270 270
             $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
271 271
         }
272
-        $status_ids_array          = apply_filters(
272
+        $status_ids_array = apply_filters(
273 273
             'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
274 274
             [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
275 275
         );
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function column__Reg_Status(EE_Registration $item)
286 286
     {
287
-        return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
287
+        return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
288 288
     }
289 289
 
290 290
 
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
         )
335 335
             ? ' clickable trigger-checkin'
336 336
             : '';
337
-        $mobile_view_content     = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
338
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
339
-               . ' data-_regid="' . $item->ID() . '"'
340
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
341
-               . ' data-nonce="' . $nonce . '">'
337
+        $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
338
+        return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"'
339
+               . ' data-_regid="'.$item->ID().'"'
340
+               . ' data-dttid="'.$this->_cur_dtt_id.'"'
341
+               . ' data-nonce="'.$nonce.'">'
342 342
                . '</span>'
343 343
                . $mobile_view_content;
344 344
     }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     public function column_ATT_name(EE_Registration $item)
354 354
     {
355 355
         $attendee = $item->attendee();
356
-        if (! $attendee instanceof EE_Attendee) {
356
+        if ( ! $attendee instanceof EE_Attendee) {
357 357
             return esc_html__('No contact record for this registration.', 'event_espresso');
358 358
         }
359 359
         // edit attendee link
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             ['action' => 'view_registration', '_REG_ID' => $item->ID()],
362 362
             REG_ADMIN_URL
363 363
         );
364
-        $name_link    = EE_Registry::instance()->CAP->current_user_can(
364
+        $name_link = EE_Registry::instance()->CAP->current_user_can(
365 365
             'ee_edit_contacts',
366 366
             'espresso_registrations_edit_attendee'
367 367
         )
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
               . $item->attendee()->full_name()
374 374
               . '</a>'
375 375
             : $item->attendee()->full_name();
376
-        $name_link    .= $item->count() === 1
376
+        $name_link .= $item->count() === 1
377 377
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
378 378
             : '';
379 379
         // add group details
380
-        $name_link .= '&nbsp;' . sprintf(
380
+        $name_link .= '&nbsp;'.sprintf(
381 381
             esc_html__('(%s of %s)', 'event_espresso'),
382 382
             $item->count(),
383 383
             $item->group_size()
384 384
         );
385 385
         // add regcode
386
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
386
+        $link = EE_Admin_Page::add_query_args_and_nonce(
387 387
             ['action' => 'view_registration', '_REG_ID' => $item->ID()],
388 388
             REG_ADMIN_URL
389 389
         );
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
             'view_registration',
394 394
             $item->ID()
395 395
         )
396
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
396
+            ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
397 397
               . $item->reg_code()
398 398
               . '</a>'
399 399
             : $item->reg_code();
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             empty($DTT_ID) && ! empty($this->_req_data['event_id'])
408 408
                 ? $item->get_latest_related_datetime()
409 409
                 : null;
410
-        $DTT_ID                  = $latest_related_datetime instanceof EE_Datetime
410
+        $DTT_ID = $latest_related_datetime instanceof EE_Datetime
411 411
             ? $latest_related_datetime->ID()
412 412
             : $DTT_ID;
413 413
         if (
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             );
424 424
             // get the timestamps for this registration's checkins, related to the selected datetime
425 425
             $timestamps = $item->get_many_related('Checkin', [['DTT_ID' => $DTT_ID]]);
426
-            if (! empty($timestamps)) {
426
+            if ( ! empty($timestamps)) {
427 427
                 // get the last timestamp
428 428
                 $last_timestamp = end($timestamps);
429 429
                 // checked in or checked out?
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
                     : esc_html__('Checked Out', 'event_espresso');
433 433
                 // get timestamp string
434 434
                 $timestamp_string   = $last_timestamp->get_datetime('CHK_timestamp');
435
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
435
+                $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'
436 436
                                       . esc_attr__(
437 437
                                           'View this registrant\'s check-ins/checkouts for the datetime',
438 438
                                           'event_espresso'
439
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
439
+                                      ).'">'.$checkin_status.': '.$timestamp_string.'</a>';
440 440
             }
441 441
         }
442
-        return (! empty($DTT_ID) && ! empty($timestamps))
442
+        return ( ! empty($DTT_ID) && ! empty($timestamps))
443 443
             ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
444 444
             : $name_link;
445 445
     }
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
                 ['action' => 'event_registrations', 'event_id' => $event->ID()],
473 473
                 REG_ADMIN_URL
474 474
             );
475
-            $event_label   = EE_Registry::instance()->CAP->current_user_can(
475
+            $event_label = EE_Registry::instance()->CAP->current_user_can(
476 476
                 'ee_read_checkins',
477 477
                 'espresso_registrations_registration_checkins'
478
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
478
+            ) ? '<a href="'.$chkin_lnk_url.'" title="'
479 479
                 . esc_attr__(
480 480
                     'View Checkins for this Event',
481 481
                     'event_espresso'
482
-                ) . '">' . $event->name() . '</a>' : $event->name();
482
+                ).'">'.$event->name().'</a>' : $event->name();
483 483
         } catch (EntityNotFoundException $e) {
484 484
             $event_label = esc_html__('Unknown', 'event_espresso');
485 485
         }
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
      */
510 510
     public function column__REG_final_price(EE_Registration $item)
511 511
     {
512
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
512
+        return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
513 513
     }
514 514
 
515 515
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                     . $item->transaction()->pretty_paid()
548 548
                     . '
549 549
 					</a>
550
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
550
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
551 551
             }
552 552
         } else {
553 553
             return '<span class="reg-pad-rght"></span>';
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
                 . esc_attr__('View Transaction', 'event_espresso')
585 585
                 . '"><span class="reg-pad-rght">'
586 586
                 . $txn_total
587
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
587
+                . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
588 588
         } else {
589 589
             return '<span class="reg-pad-rght"></span>';
590 590
         }
Please login to merge, or discard this patch.
Indentation   +571 added lines, -571 removed lines patch added patch discarded remove patch
@@ -13,580 +13,580 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Event_Registrations_List_Table extends EE_Admin_List_Table
15 15
 {
16
-    /**
17
-     * @var Extend_Registrations_Admin_Page
18
-     */
19
-    protected $_admin_page;
20
-
21
-    /**
22
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
23
-     *
24
-     * @var EE_Datetime[]
25
-     */
26
-    protected $_dtts_for_event = [];
27
-
28
-
29
-    /**
30
-     * The event if one is specified in the request
31
-     *
32
-     * @var EE_Event
33
-     */
34
-    protected $_evt = null;
35
-
36
-
37
-    /**
38
-     * The DTT_ID if the current view has a specified datetime.
39
-     *
40
-     * @var int $_cur_dtt_id
41
-     */
42
-    protected $_cur_dtt_id = 0;
43
-
44
-    /**
45
-     * @var   array
46
-     * @since 4.10.31.p
47
-     */
48
-    protected $_status;
49
-
50
-
51
-    /**
52
-     * EE_Event_Registrations_List_Table constructor.
53
-     *
54
-     * @param Registrations_Admin_Page $admin_page
55
-     */
56
-    public function __construct($admin_page)
57
-    {
58
-        parent::__construct($admin_page);
59
-        $this->_status = $this->_admin_page->get_registration_status_array();
60
-    }
61
-
62
-
63
-    /**
64
-     * @throws EE_Error
65
-     */
66
-    protected function _setup_data()
67
-    {
68
-        $this->_data           = $this->_view !== 'trash'
69
-            ? $this->_admin_page->get_event_attendees($this->_per_page)
70
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
71
-        $this->_all_data_count = $this->_view !== 'trash'
72
-            ? $this->_admin_page->get_event_attendees($this->_per_page, true)
73
-            : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
74
-    }
75
-
76
-
77
-    /**
78
-     * @throws ReflectionException
79
-     * @throws EE_Error
80
-     */
81
-    protected function _set_properties()
82
-    {
83
-        $return_url = $this->getReturnUrl();
84
-
85
-        $EVT_ID = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : 0;
86
-        $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
87
-
88
-        $this->_wp_list_args = [
89
-            'singular' => esc_html__('registrant', 'event_espresso'),
90
-            'plural'   => esc_html__('registrants', 'event_espresso'),
91
-            'ajax'     => true,
92
-            'screen'   => $this->_admin_page->get_current_screen()->id,
93
-        ];
94
-        $columns             = [];
95
-        // $columns['_Reg_Status'] = '';
96
-        $this->_columns = [
97
-            '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
98
-            'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
99
-            'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
100
-            'Event'               => esc_html__('Event', 'event_espresso'),
101
-            'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
102
-            '_REG_final_price'    => esc_html__('Price', 'event_espresso'),
103
-            'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
104
-            'TXN_total'           => esc_html__('Total', 'event_espresso'),
105
-        ];
106
-        // Add/remove columns when an event has been selected
107
-        if (! empty($EVT_ID)) {
108
-            // Render a checkbox column
109
-            $columns['cb']              = '<input type="checkbox" />';
110
-            $this->_has_checkbox_column = true;
111
-            // Remove the 'Event' column
112
-            unset($this->_columns['Event']);
113
-        }
114
-        $this->_columns        = array_merge($columns, $this->_columns);
115
-        $this->_primary_column = '_REG_att_checked_in';
116
-
117
-        $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
118
-        if (! empty($csv_report)) {
119
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
120
-        }
121
-
122
-        $this->_sortable_columns = [
123
-            /**
124
-             * Allows users to change the default sort if they wish.
125
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
126
-             *
127
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
128
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
129
-             * for a specific list table you can use the provided reference to this object instance.
130
-             */
131
-            'ATT_name' => [
132
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
133
-                true,
134
-                $this,
135
-            ]
136
-                ? ['ATT_lname' => true]
137
-                : ['ATT_fname' => true],
138
-            'Event'    => ['Event.EVT_name' => false],
139
-        ];
140
-        $this->_hidden_columns   = [];
141
-        $this->_evt              = EEM_Event::instance()->get_one_by_ID($EVT_ID);
142
-        $this->_dtts_for_event   = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : [];
143
-    }
144
-
145
-
146
-    /**
147
-     * @param EE_Registration $item
148
-     * @return string
149
-     */
150
-    protected function _get_row_class($item)
151
-    {
152
-        $class = parent::_get_row_class($item);
153
-        // add status class
154
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
155
-        if ($this->_has_checkbox_column) {
156
-            $class .= ' has-checkbox-column';
157
-        }
158
-        return $class;
159
-    }
160
-
161
-
162
-    /**
163
-     * @return array
164
-     * @throws EE_Error
165
-     * @throws ReflectionException
166
-     */
167
-    protected function _get_table_filters()
168
-    {
169
-        $filters        = $where = [];
170
-        $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
171
-        if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
172
-            // this means we don't have an event so let's setup a filter dropdown for all the events to select
173
-            // note possible capability restrictions
174
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
175
-                $where['status**'] = ['!=', 'private'];
176
-            }
177
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
178
-                $where['EVT_wp_user'] = get_current_user_id();
179
-            }
180
-            $events          = EEM_Event::instance()->get_all(
181
-                [
182
-                    $where,
183
-                    'order_by' => ['Datetime.DTT_EVT_start' => 'DESC'],
184
-                ]
185
-            );
186
-            $event_options[] = [
187
-                'id'   => 0,
188
-                'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'),
189
-            ];
190
-            $checked         = 'checked';
191
-            /** @var EE_Event $event */
192
-            foreach ($events as $event) {
193
-                // any registrations for this event?
194
-                if (! $event->get_count_of_all_registrations()) {
195
-                    continue;
196
-                }
197
-                $event_options[] = [
198
-                    'id'    => $event->ID(),
199
-                    'text'  => apply_filters(
200
-                        'FHEE__EE_Event_Registrations___get_table_filters__event_name',
201
-                        $event->get('EVT_name'),
202
-                        $event
203
-                    ),
204
-                    'class' => $event->is_expired() ? 'ee-expired-event' : '',
205
-                ];
206
-                if ($event->ID() === $current_EVT_ID && $event->is_expired()) {
207
-                    $checked = '';
208
-                }
209
-            }
210
-            $event_filter = '<div class="ee-event-filter">';
211
-            $event_filter .= EEH_Form_Fields::select_input('event_id', $event_options, $current_EVT_ID);
212
-            $event_filter .= '<span class="ee-event-filter-toggle">';
213
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
214
-            $event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
215
-            $event_filter .= '</span>';
216
-            $event_filter .= '</div>';
217
-            $filters[]    = $event_filter;
218
-        }
219
-        if (! empty($this->_dtts_for_event)) {
220
-            // DTT datetimes filter
221
-            $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
222
-            if (count($this->_dtts_for_event) > 1) {
223
-                $datetimes[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
224
-                foreach ($this->_dtts_for_event as $datetime) {
225
-                    $datetime_string              = $datetime->name();
226
-                    $datetime_string              = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
227
-                    $datetime_string              =
228
-                        $datetime->start_date_and_time() . ' - ' . $datetime->end_date_and_time() . $datetime_string;
229
-                    $datetimes[ $datetime->ID() ] = $datetime_string;
230
-                }
231
-                $input     = new EE_Select_Input(
232
-                    $datetimes,
233
-                    [
234
-                        'html_name' => 'DTT_ID',
235
-                        'html_id'   => 'DTT_ID',
236
-                        'default'   => $this->_cur_dtt_id,
237
-                    ]
238
-                );
239
-                $filters[] = $input->get_html_for_input();
240
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
241
-            }
242
-        }
243
-        return $filters;
244
-    }
245
-
246
-
247
-    /**
248
-     * @throws EE_Error
249
-     */
250
-    protected function _add_view_counts()
251
-    {
252
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
253
-    }
254
-
255
-
256
-    /**
257
-     * @return int
258
-     * @throws EE_Error
259
-     */
260
-    protected function _get_total_event_attendees()
261
-    {
262
-        $EVT_ID       = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
263
-        $DTT_ID       = $this->_cur_dtt_id;
264
-        $query_params = [];
265
-        if ($EVT_ID) {
266
-            $query_params[0]['EVT_ID'] = $EVT_ID;
267
-        }
268
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
269
-        if ($DTT_ID) {
270
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
271
-        }
272
-        $status_ids_array          = apply_filters(
273
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
274
-            [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
275
-        );
276
-        $query_params[0]['STS_ID'] = ['IN', $status_ids_array];
277
-        return EEM_Registration::instance()->count($query_params);
278
-    }
279
-
280
-
281
-    /**
282
-     * @param EE_Registration $item
283
-     * @return string
284
-     */
285
-    public function column__Reg_Status(EE_Registration $item)
286
-    {
287
-        return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
288
-    }
289
-
290
-
291
-    /**
292
-     * @param EE_Registration $item
293
-     * @return string
294
-     * @throws EE_Error
295
-     * @throws ReflectionException
296
-     */
297
-    public function column_cb($item)
298
-    {
299
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
300
-    }
301
-
302
-
303
-    /**
304
-     * column_REG_att_checked_in
305
-     *
306
-     * @param EE_Registration $item
307
-     * @return string
308
-     * @throws EE_Error
309
-     * @throws InvalidArgumentException
310
-     * @throws InvalidDataTypeException
311
-     * @throws InvalidInterfaceException
312
-     * @throws ReflectionException
313
-     */
314
-    public function column__REG_att_checked_in(EE_Registration $item)
315
-    {
316
-        $attendee      = $item->attendee();
317
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
318
-
319
-        if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
320
-            $latest_related_datetime = $item->get_latest_related_datetime();
321
-            if ($latest_related_datetime instanceof EE_Datetime) {
322
-                $this->_cur_dtt_id = $latest_related_datetime->ID();
323
-            }
324
-        }
325
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
326
-            $item,
327
-            $this->_cur_dtt_id
328
-        );
329
-        $nonce         = wp_create_nonce('checkin_nonce');
330
-        $toggle_active = ! empty($this->_cur_dtt_id) && EE_Registry::instance()->CAP->current_user_can(
331
-            'ee_edit_checkin',
332
-            'espresso_registrations_toggle_checkin_status',
333
-            $item->ID()
334
-        )
335
-            ? ' clickable trigger-checkin'
336
-            : '';
337
-        $mobile_view_content     = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
338
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
339
-               . ' data-_regid="' . $item->ID() . '"'
340
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
341
-               . ' data-nonce="' . $nonce . '">'
342
-               . '</span>'
343
-               . $mobile_view_content;
344
-    }
345
-
346
-
347
-    /**
348
-     * @param EE_Registration $item
349
-     * @return string
350
-     * @throws EE_Error
351
-     * @throws ReflectionException
352
-     */
353
-    public function column_ATT_name(EE_Registration $item)
354
-    {
355
-        $attendee = $item->attendee();
356
-        if (! $attendee instanceof EE_Attendee) {
357
-            return esc_html__('No contact record for this registration.', 'event_espresso');
358
-        }
359
-        // edit attendee link
360
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
361
-            ['action' => 'view_registration', '_REG_ID' => $item->ID()],
362
-            REG_ADMIN_URL
363
-        );
364
-        $name_link    = EE_Registry::instance()->CAP->current_user_can(
365
-            'ee_edit_contacts',
366
-            'espresso_registrations_edit_attendee'
367
-        )
368
-            ? '<a href="'
369
-              . $edit_lnk_url
370
-              . '" title="'
371
-              . esc_attr__('View Registration Details', 'event_espresso')
372
-              . '">'
373
-              . $item->attendee()->full_name()
374
-              . '</a>'
375
-            : $item->attendee()->full_name();
376
-        $name_link    .= $item->count() === 1
377
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
378
-            : '';
379
-        // add group details
380
-        $name_link .= '&nbsp;' . sprintf(
381
-            esc_html__('(%s of %s)', 'event_espresso'),
382
-            $item->count(),
383
-            $item->group_size()
384
-        );
385
-        // add regcode
386
-        $link      = EE_Admin_Page::add_query_args_and_nonce(
387
-            ['action' => 'view_registration', '_REG_ID' => $item->ID()],
388
-            REG_ADMIN_URL
389
-        );
390
-        $name_link .= '<br>';
391
-        $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
392
-            'ee_read_registration',
393
-            'view_registration',
394
-            $item->ID()
395
-        )
396
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
397
-              . $item->reg_code()
398
-              . '</a>'
399
-            : $item->reg_code();
400
-        // status
401
-        $name_link               .= '<br><span class="ee-status-text-small">';
402
-        $name_link               .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
403
-        $name_link               .= '</span>';
404
-        $actions                 = [];
405
-        $DTT_ID                  = $this->_cur_dtt_id;
406
-        $latest_related_datetime =
407
-            empty($DTT_ID) && ! empty($this->_req_data['event_id'])
408
-                ? $item->get_latest_related_datetime()
409
-                : null;
410
-        $DTT_ID                  = $latest_related_datetime instanceof EE_Datetime
411
-            ? $latest_related_datetime->ID()
412
-            : $DTT_ID;
413
-        if (
414
-            ! empty($DTT_ID)
415
-            && EE_Registry::instance()->CAP->current_user_can(
416
-                'ee_read_checkins',
417
-                'espresso_registrations_registration_checkins'
418
-            )
419
-        ) {
420
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
421
-                ['action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID],
422
-                REG_ADMIN_URL
423
-            );
424
-            // get the timestamps for this registration's checkins, related to the selected datetime
425
-            $timestamps = $item->get_many_related('Checkin', [['DTT_ID' => $DTT_ID]]);
426
-            if (! empty($timestamps)) {
427
-                // get the last timestamp
428
-                $last_timestamp = end($timestamps);
429
-                // checked in or checked out?
430
-                $checkin_status = $last_timestamp->get('CHK_in')
431
-                    ? esc_html__('Checked In', 'event_espresso')
432
-                    : esc_html__('Checked Out', 'event_espresso');
433
-                // get timestamp string
434
-                $timestamp_string   = $last_timestamp->get_datetime('CHK_timestamp');
435
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
436
-                                      . esc_attr__(
437
-                                          'View this registrant\'s check-ins/checkouts for the datetime',
438
-                                          'event_espresso'
439
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
440
-            }
441
-        }
442
-        return (! empty($DTT_ID) && ! empty($timestamps))
443
-            ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
444
-            : $name_link;
445
-    }
446
-
447
-
448
-    /**
449
-     * @param EE_Registration $item
450
-     * @return string
451
-     * @throws EE_Error
452
-     * @throws EE_Error
453
-     */
454
-    public function column_ATT_email(EE_Registration $item)
455
-    {
456
-        $attendee = $item->attendee();
457
-        return $attendee instanceof EE_Attendee ? $attendee->email() : '';
458
-    }
459
-
460
-
461
-    /**
462
-     * @param EE_Registration $item
463
-     * @return bool|string
464
-     * @throws EE_Error
465
-     * @throws ReflectionException
466
-     */
467
-    public function column_Event(EE_Registration $item)
468
-    {
469
-        try {
470
-            $event         = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
471
-            $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
472
-                ['action' => 'event_registrations', 'event_id' => $event->ID()],
473
-                REG_ADMIN_URL
474
-            );
475
-            $event_label   = EE_Registry::instance()->CAP->current_user_can(
476
-                'ee_read_checkins',
477
-                'espresso_registrations_registration_checkins'
478
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
479
-                . esc_attr__(
480
-                    'View Checkins for this Event',
481
-                    'event_espresso'
482
-                ) . '">' . $event->name() . '</a>' : $event->name();
483
-        } catch (EntityNotFoundException $e) {
484
-            $event_label = esc_html__('Unknown', 'event_espresso');
485
-        }
486
-        return $event_label;
487
-    }
488
-
489
-
490
-    /**
491
-     * @param EE_Registration $item
492
-     * @return string
493
-     * @throws EE_Error
494
-     * @throws ReflectionException
495
-     */
496
-    public function column_PRC_name(EE_Registration $item)
497
-    {
498
-        return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso");
499
-    }
500
-
501
-
502
-    /**
503
-     * column_REG_final_price
504
-     *
505
-     * @param EE_Registration $item
506
-     * @return string
507
-     * @throws EE_Error
508
-     * @throws EE_Error
509
-     */
510
-    public function column__REG_final_price(EE_Registration $item)
511
-    {
512
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
513
-    }
514
-
515
-
516
-    /**
517
-     * column_TXN_paid
518
-     *
519
-     * @param EE_Registration $item
520
-     * @return string
521
-     * @throws EE_Error
522
-     * @throws ReflectionException
523
-     */
524
-    public function column_TXN_paid(EE_Registration $item)
525
-    {
526
-        if ($item->count() === 1) {
527
-            if ($item->transaction()->paid() >= $item->transaction()->total()) {
528
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
529
-            } else {
530
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
531
-                    ['action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()],
532
-                    TXN_ADMIN_URL
533
-                );
534
-                return EE_Registry::instance()->CAP->current_user_can(
535
-                    'ee_read_transaction',
536
-                    'espresso_transactions_view_transaction'
537
-                ) ? '
16
+	/**
17
+	 * @var Extend_Registrations_Admin_Page
18
+	 */
19
+	protected $_admin_page;
20
+
21
+	/**
22
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
23
+	 *
24
+	 * @var EE_Datetime[]
25
+	 */
26
+	protected $_dtts_for_event = [];
27
+
28
+
29
+	/**
30
+	 * The event if one is specified in the request
31
+	 *
32
+	 * @var EE_Event
33
+	 */
34
+	protected $_evt = null;
35
+
36
+
37
+	/**
38
+	 * The DTT_ID if the current view has a specified datetime.
39
+	 *
40
+	 * @var int $_cur_dtt_id
41
+	 */
42
+	protected $_cur_dtt_id = 0;
43
+
44
+	/**
45
+	 * @var   array
46
+	 * @since 4.10.31.p
47
+	 */
48
+	protected $_status;
49
+
50
+
51
+	/**
52
+	 * EE_Event_Registrations_List_Table constructor.
53
+	 *
54
+	 * @param Registrations_Admin_Page $admin_page
55
+	 */
56
+	public function __construct($admin_page)
57
+	{
58
+		parent::__construct($admin_page);
59
+		$this->_status = $this->_admin_page->get_registration_status_array();
60
+	}
61
+
62
+
63
+	/**
64
+	 * @throws EE_Error
65
+	 */
66
+	protected function _setup_data()
67
+	{
68
+		$this->_data           = $this->_view !== 'trash'
69
+			? $this->_admin_page->get_event_attendees($this->_per_page)
70
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
71
+		$this->_all_data_count = $this->_view !== 'trash'
72
+			? $this->_admin_page->get_event_attendees($this->_per_page, true)
73
+			: $this->_admin_page->get_event_attendees($this->_per_page, true, true);
74
+	}
75
+
76
+
77
+	/**
78
+	 * @throws ReflectionException
79
+	 * @throws EE_Error
80
+	 */
81
+	protected function _set_properties()
82
+	{
83
+		$return_url = $this->getReturnUrl();
84
+
85
+		$EVT_ID = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : 0;
86
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
87
+
88
+		$this->_wp_list_args = [
89
+			'singular' => esc_html__('registrant', 'event_espresso'),
90
+			'plural'   => esc_html__('registrants', 'event_espresso'),
91
+			'ajax'     => true,
92
+			'screen'   => $this->_admin_page->get_current_screen()->id,
93
+		];
94
+		$columns             = [];
95
+		// $columns['_Reg_Status'] = '';
96
+		$this->_columns = [
97
+			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
98
+			'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
99
+			'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
100
+			'Event'               => esc_html__('Event', 'event_espresso'),
101
+			'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
102
+			'_REG_final_price'    => esc_html__('Price', 'event_espresso'),
103
+			'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
104
+			'TXN_total'           => esc_html__('Total', 'event_espresso'),
105
+		];
106
+		// Add/remove columns when an event has been selected
107
+		if (! empty($EVT_ID)) {
108
+			// Render a checkbox column
109
+			$columns['cb']              = '<input type="checkbox" />';
110
+			$this->_has_checkbox_column = true;
111
+			// Remove the 'Event' column
112
+			unset($this->_columns['Event']);
113
+		}
114
+		$this->_columns        = array_merge($columns, $this->_columns);
115
+		$this->_primary_column = '_REG_att_checked_in';
116
+
117
+		$csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
118
+		if (! empty($csv_report)) {
119
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
120
+		}
121
+
122
+		$this->_sortable_columns = [
123
+			/**
124
+			 * Allows users to change the default sort if they wish.
125
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
126
+			 *
127
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
128
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
129
+			 * for a specific list table you can use the provided reference to this object instance.
130
+			 */
131
+			'ATT_name' => [
132
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
133
+				true,
134
+				$this,
135
+			]
136
+				? ['ATT_lname' => true]
137
+				: ['ATT_fname' => true],
138
+			'Event'    => ['Event.EVT_name' => false],
139
+		];
140
+		$this->_hidden_columns   = [];
141
+		$this->_evt              = EEM_Event::instance()->get_one_by_ID($EVT_ID);
142
+		$this->_dtts_for_event   = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : [];
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param EE_Registration $item
148
+	 * @return string
149
+	 */
150
+	protected function _get_row_class($item)
151
+	{
152
+		$class = parent::_get_row_class($item);
153
+		// add status class
154
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
155
+		if ($this->_has_checkbox_column) {
156
+			$class .= ' has-checkbox-column';
157
+		}
158
+		return $class;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @return array
164
+	 * @throws EE_Error
165
+	 * @throws ReflectionException
166
+	 */
167
+	protected function _get_table_filters()
168
+	{
169
+		$filters        = $where = [];
170
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
171
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
172
+			// this means we don't have an event so let's setup a filter dropdown for all the events to select
173
+			// note possible capability restrictions
174
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
175
+				$where['status**'] = ['!=', 'private'];
176
+			}
177
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
178
+				$where['EVT_wp_user'] = get_current_user_id();
179
+			}
180
+			$events          = EEM_Event::instance()->get_all(
181
+				[
182
+					$where,
183
+					'order_by' => ['Datetime.DTT_EVT_start' => 'DESC'],
184
+				]
185
+			);
186
+			$event_options[] = [
187
+				'id'   => 0,
188
+				'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'),
189
+			];
190
+			$checked         = 'checked';
191
+			/** @var EE_Event $event */
192
+			foreach ($events as $event) {
193
+				// any registrations for this event?
194
+				if (! $event->get_count_of_all_registrations()) {
195
+					continue;
196
+				}
197
+				$event_options[] = [
198
+					'id'    => $event->ID(),
199
+					'text'  => apply_filters(
200
+						'FHEE__EE_Event_Registrations___get_table_filters__event_name',
201
+						$event->get('EVT_name'),
202
+						$event
203
+					),
204
+					'class' => $event->is_expired() ? 'ee-expired-event' : '',
205
+				];
206
+				if ($event->ID() === $current_EVT_ID && $event->is_expired()) {
207
+					$checked = '';
208
+				}
209
+			}
210
+			$event_filter = '<div class="ee-event-filter">';
211
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $event_options, $current_EVT_ID);
212
+			$event_filter .= '<span class="ee-event-filter-toggle">';
213
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
214
+			$event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
215
+			$event_filter .= '</span>';
216
+			$event_filter .= '</div>';
217
+			$filters[]    = $event_filter;
218
+		}
219
+		if (! empty($this->_dtts_for_event)) {
220
+			// DTT datetimes filter
221
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
222
+			if (count($this->_dtts_for_event) > 1) {
223
+				$datetimes[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
224
+				foreach ($this->_dtts_for_event as $datetime) {
225
+					$datetime_string              = $datetime->name();
226
+					$datetime_string              = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
227
+					$datetime_string              =
228
+						$datetime->start_date_and_time() . ' - ' . $datetime->end_date_and_time() . $datetime_string;
229
+					$datetimes[ $datetime->ID() ] = $datetime_string;
230
+				}
231
+				$input     = new EE_Select_Input(
232
+					$datetimes,
233
+					[
234
+						'html_name' => 'DTT_ID',
235
+						'html_id'   => 'DTT_ID',
236
+						'default'   => $this->_cur_dtt_id,
237
+					]
238
+				);
239
+				$filters[] = $input->get_html_for_input();
240
+				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
241
+			}
242
+		}
243
+		return $filters;
244
+	}
245
+
246
+
247
+	/**
248
+	 * @throws EE_Error
249
+	 */
250
+	protected function _add_view_counts()
251
+	{
252
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
253
+	}
254
+
255
+
256
+	/**
257
+	 * @return int
258
+	 * @throws EE_Error
259
+	 */
260
+	protected function _get_total_event_attendees()
261
+	{
262
+		$EVT_ID       = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
263
+		$DTT_ID       = $this->_cur_dtt_id;
264
+		$query_params = [];
265
+		if ($EVT_ID) {
266
+			$query_params[0]['EVT_ID'] = $EVT_ID;
267
+		}
268
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
269
+		if ($DTT_ID) {
270
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
271
+		}
272
+		$status_ids_array          = apply_filters(
273
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
274
+			[EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved]
275
+		);
276
+		$query_params[0]['STS_ID'] = ['IN', $status_ids_array];
277
+		return EEM_Registration::instance()->count($query_params);
278
+	}
279
+
280
+
281
+	/**
282
+	 * @param EE_Registration $item
283
+	 * @return string
284
+	 */
285
+	public function column__Reg_Status(EE_Registration $item)
286
+	{
287
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
288
+	}
289
+
290
+
291
+	/**
292
+	 * @param EE_Registration $item
293
+	 * @return string
294
+	 * @throws EE_Error
295
+	 * @throws ReflectionException
296
+	 */
297
+	public function column_cb($item)
298
+	{
299
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
300
+	}
301
+
302
+
303
+	/**
304
+	 * column_REG_att_checked_in
305
+	 *
306
+	 * @param EE_Registration $item
307
+	 * @return string
308
+	 * @throws EE_Error
309
+	 * @throws InvalidArgumentException
310
+	 * @throws InvalidDataTypeException
311
+	 * @throws InvalidInterfaceException
312
+	 * @throws ReflectionException
313
+	 */
314
+	public function column__REG_att_checked_in(EE_Registration $item)
315
+	{
316
+		$attendee      = $item->attendee();
317
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
318
+
319
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
320
+			$latest_related_datetime = $item->get_latest_related_datetime();
321
+			if ($latest_related_datetime instanceof EE_Datetime) {
322
+				$this->_cur_dtt_id = $latest_related_datetime->ID();
323
+			}
324
+		}
325
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
326
+			$item,
327
+			$this->_cur_dtt_id
328
+		);
329
+		$nonce         = wp_create_nonce('checkin_nonce');
330
+		$toggle_active = ! empty($this->_cur_dtt_id) && EE_Registry::instance()->CAP->current_user_can(
331
+			'ee_edit_checkin',
332
+			'espresso_registrations_toggle_checkin_status',
333
+			$item->ID()
334
+		)
335
+			? ' clickable trigger-checkin'
336
+			: '';
337
+		$mobile_view_content     = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
338
+		return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
339
+			   . ' data-_regid="' . $item->ID() . '"'
340
+			   . ' data-dttid="' . $this->_cur_dtt_id . '"'
341
+			   . ' data-nonce="' . $nonce . '">'
342
+			   . '</span>'
343
+			   . $mobile_view_content;
344
+	}
345
+
346
+
347
+	/**
348
+	 * @param EE_Registration $item
349
+	 * @return string
350
+	 * @throws EE_Error
351
+	 * @throws ReflectionException
352
+	 */
353
+	public function column_ATT_name(EE_Registration $item)
354
+	{
355
+		$attendee = $item->attendee();
356
+		if (! $attendee instanceof EE_Attendee) {
357
+			return esc_html__('No contact record for this registration.', 'event_espresso');
358
+		}
359
+		// edit attendee link
360
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
361
+			['action' => 'view_registration', '_REG_ID' => $item->ID()],
362
+			REG_ADMIN_URL
363
+		);
364
+		$name_link    = EE_Registry::instance()->CAP->current_user_can(
365
+			'ee_edit_contacts',
366
+			'espresso_registrations_edit_attendee'
367
+		)
368
+			? '<a href="'
369
+			  . $edit_lnk_url
370
+			  . '" title="'
371
+			  . esc_attr__('View Registration Details', 'event_espresso')
372
+			  . '">'
373
+			  . $item->attendee()->full_name()
374
+			  . '</a>'
375
+			: $item->attendee()->full_name();
376
+		$name_link    .= $item->count() === 1
377
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
378
+			: '';
379
+		// add group details
380
+		$name_link .= '&nbsp;' . sprintf(
381
+			esc_html__('(%s of %s)', 'event_espresso'),
382
+			$item->count(),
383
+			$item->group_size()
384
+		);
385
+		// add regcode
386
+		$link      = EE_Admin_Page::add_query_args_and_nonce(
387
+			['action' => 'view_registration', '_REG_ID' => $item->ID()],
388
+			REG_ADMIN_URL
389
+		);
390
+		$name_link .= '<br>';
391
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
392
+			'ee_read_registration',
393
+			'view_registration',
394
+			$item->ID()
395
+		)
396
+			? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
397
+			  . $item->reg_code()
398
+			  . '</a>'
399
+			: $item->reg_code();
400
+		// status
401
+		$name_link               .= '<br><span class="ee-status-text-small">';
402
+		$name_link               .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
403
+		$name_link               .= '</span>';
404
+		$actions                 = [];
405
+		$DTT_ID                  = $this->_cur_dtt_id;
406
+		$latest_related_datetime =
407
+			empty($DTT_ID) && ! empty($this->_req_data['event_id'])
408
+				? $item->get_latest_related_datetime()
409
+				: null;
410
+		$DTT_ID                  = $latest_related_datetime instanceof EE_Datetime
411
+			? $latest_related_datetime->ID()
412
+			: $DTT_ID;
413
+		if (
414
+			! empty($DTT_ID)
415
+			&& EE_Registry::instance()->CAP->current_user_can(
416
+				'ee_read_checkins',
417
+				'espresso_registrations_registration_checkins'
418
+			)
419
+		) {
420
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
421
+				['action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID],
422
+				REG_ADMIN_URL
423
+			);
424
+			// get the timestamps for this registration's checkins, related to the selected datetime
425
+			$timestamps = $item->get_many_related('Checkin', [['DTT_ID' => $DTT_ID]]);
426
+			if (! empty($timestamps)) {
427
+				// get the last timestamp
428
+				$last_timestamp = end($timestamps);
429
+				// checked in or checked out?
430
+				$checkin_status = $last_timestamp->get('CHK_in')
431
+					? esc_html__('Checked In', 'event_espresso')
432
+					: esc_html__('Checked Out', 'event_espresso');
433
+				// get timestamp string
434
+				$timestamp_string   = $last_timestamp->get_datetime('CHK_timestamp');
435
+				$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
436
+									  . esc_attr__(
437
+										  'View this registrant\'s check-ins/checkouts for the datetime',
438
+										  'event_espresso'
439
+									  ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
440
+			}
441
+		}
442
+		return (! empty($DTT_ID) && ! empty($timestamps))
443
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
444
+			: $name_link;
445
+	}
446
+
447
+
448
+	/**
449
+	 * @param EE_Registration $item
450
+	 * @return string
451
+	 * @throws EE_Error
452
+	 * @throws EE_Error
453
+	 */
454
+	public function column_ATT_email(EE_Registration $item)
455
+	{
456
+		$attendee = $item->attendee();
457
+		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
458
+	}
459
+
460
+
461
+	/**
462
+	 * @param EE_Registration $item
463
+	 * @return bool|string
464
+	 * @throws EE_Error
465
+	 * @throws ReflectionException
466
+	 */
467
+	public function column_Event(EE_Registration $item)
468
+	{
469
+		try {
470
+			$event         = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
471
+			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
472
+				['action' => 'event_registrations', 'event_id' => $event->ID()],
473
+				REG_ADMIN_URL
474
+			);
475
+			$event_label   = EE_Registry::instance()->CAP->current_user_can(
476
+				'ee_read_checkins',
477
+				'espresso_registrations_registration_checkins'
478
+			) ? '<a href="' . $chkin_lnk_url . '" title="'
479
+				. esc_attr__(
480
+					'View Checkins for this Event',
481
+					'event_espresso'
482
+				) . '">' . $event->name() . '</a>' : $event->name();
483
+		} catch (EntityNotFoundException $e) {
484
+			$event_label = esc_html__('Unknown', 'event_espresso');
485
+		}
486
+		return $event_label;
487
+	}
488
+
489
+
490
+	/**
491
+	 * @param EE_Registration $item
492
+	 * @return string
493
+	 * @throws EE_Error
494
+	 * @throws ReflectionException
495
+	 */
496
+	public function column_PRC_name(EE_Registration $item)
497
+	{
498
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso");
499
+	}
500
+
501
+
502
+	/**
503
+	 * column_REG_final_price
504
+	 *
505
+	 * @param EE_Registration $item
506
+	 * @return string
507
+	 * @throws EE_Error
508
+	 * @throws EE_Error
509
+	 */
510
+	public function column__REG_final_price(EE_Registration $item)
511
+	{
512
+		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
513
+	}
514
+
515
+
516
+	/**
517
+	 * column_TXN_paid
518
+	 *
519
+	 * @param EE_Registration $item
520
+	 * @return string
521
+	 * @throws EE_Error
522
+	 * @throws ReflectionException
523
+	 */
524
+	public function column_TXN_paid(EE_Registration $item)
525
+	{
526
+		if ($item->count() === 1) {
527
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
528
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
529
+			} else {
530
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
531
+					['action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()],
532
+					TXN_ADMIN_URL
533
+				);
534
+				return EE_Registry::instance()->CAP->current_user_can(
535
+					'ee_read_transaction',
536
+					'espresso_transactions_view_transaction'
537
+				) ? '
538 538
 				<span class="reg-pad-rght">
539 539
 					<a class="status-'
540
-                    . $item->transaction()->status_ID()
541
-                    . '" href="'
542
-                    . $view_txn_lnk_url
543
-                    . '"  title="'
544
-                    . esc_attr__('View Transaction', 'event_espresso')
545
-                    . '">
540
+					. $item->transaction()->status_ID()
541
+					. '" href="'
542
+					. $view_txn_lnk_url
543
+					. '"  title="'
544
+					. esc_attr__('View Transaction', 'event_espresso')
545
+					. '">
546 546
 						'
547
-                    . $item->transaction()->pretty_paid()
548
-                    . '
547
+					. $item->transaction()->pretty_paid()
548
+					. '
549 549
 					</a>
550 550
 				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
551
-            }
552
-        } else {
553
-            return '<span class="reg-pad-rght"></span>';
554
-        }
555
-    }
556
-
557
-
558
-    /**
559
-     *        column_TXN_total
560
-     *
561
-     * @param EE_Registration $item
562
-     * @return string
563
-     * @throws EE_Error
564
-     * @throws ReflectionException
565
-     */
566
-    public function column_TXN_total(EE_Registration $item)
567
-    {
568
-        $txn          = $item->transaction();
569
-        $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL);
570
-        if ($item->get('REG_count') === 1) {
571
-            $line_total_obj = $txn->total_line_item();
572
-            $txn_total      = $line_total_obj instanceof EE_Line_Item
573
-                ? $line_total_obj->get_pretty('LIN_total')
574
-                : esc_html__(
575
-                    'View Transaction',
576
-                    'event_espresso'
577
-                );
578
-            return EE_Registry::instance()->CAP->current_user_can(
579
-                'ee_read_transaction',
580
-                'espresso_transactions_view_transaction'
581
-            ) ? '<a href="'
582
-                . $view_txn_url
583
-                . '" title="'
584
-                . esc_attr__('View Transaction', 'event_espresso')
585
-                . '"><span class="reg-pad-rght">'
586
-                . $txn_total
587
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
588
-        } else {
589
-            return '<span class="reg-pad-rght"></span>';
590
-        }
591
-    }
551
+			}
552
+		} else {
553
+			return '<span class="reg-pad-rght"></span>';
554
+		}
555
+	}
556
+
557
+
558
+	/**
559
+	 *        column_TXN_total
560
+	 *
561
+	 * @param EE_Registration $item
562
+	 * @return string
563
+	 * @throws EE_Error
564
+	 * @throws ReflectionException
565
+	 */
566
+	public function column_TXN_total(EE_Registration $item)
567
+	{
568
+		$txn          = $item->transaction();
569
+		$view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL);
570
+		if ($item->get('REG_count') === 1) {
571
+			$line_total_obj = $txn->total_line_item();
572
+			$txn_total      = $line_total_obj instanceof EE_Line_Item
573
+				? $line_total_obj->get_pretty('LIN_total')
574
+				: esc_html__(
575
+					'View Transaction',
576
+					'event_espresso'
577
+				);
578
+			return EE_Registry::instance()->CAP->current_user_can(
579
+				'ee_read_transaction',
580
+				'espresso_transactions_view_transaction'
581
+			) ? '<a href="'
582
+				. $view_txn_url
583
+				. '" title="'
584
+				. esc_attr__('View Transaction', 'event_espresso')
585
+				. '"><span class="reg-pad-rght">'
586
+				. $txn_total
587
+				. '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
588
+		} else {
589
+			return '<span class="reg-pad-rght"></span>';
590
+		}
591
+	}
592 592
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +1001 added lines, -1001 removed lines patch added patch discarded remove patch
@@ -16,1035 +16,1035 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var Registrations_Admin_Page
21
-     */
22
-    protected $_admin_page;
23
-
24
-    /**
25
-     * @var array
26
-     */
27
-    private $_status;
28
-
29
-    /**
30
-     * An array of transaction details for the related transaction to the registration being processed.
31
-     * This is set via the _set_related_details method.
32
-     *
33
-     * @var array
34
-     */
35
-    protected $_transaction_details = [];
36
-
37
-    /**
38
-     * An array of event details for the related event to the registration being processed.
39
-     * This is set via the _set_related_details method.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $_event_details = [];
44
-
45
-
46
-    /**
47
-     * @param Registrations_Admin_Page $admin_page
48
-     */
49
-    public function __construct(Registrations_Admin_Page $admin_page)
50
-    {
51
-        $req_data = $admin_page->get_request_data();
52
-        if (! empty($req_data['event_id'])) {
53
-            $extra_query_args = [];
54
-            foreach ($admin_page->get_views() as $view_details) {
55
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
56
-            }
57
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
58
-        }
59
-        parent::__construct($admin_page);
60
-        $this->_status = $this->_admin_page->get_registration_status_array();
61
-    }
62
-
63
-
64
-    /**
65
-     * @return void
66
-     * @throws EE_Error
67
-     */
68
-    protected function _setup_data()
69
-    {
70
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
71
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
72
-    }
73
-
74
-
75
-    /**
76
-     * @return void
77
-     */
78
-    protected function _set_properties()
79
-    {
80
-        $return_url          = $this->getReturnUrl();
81
-        $this->_wp_list_args = [
82
-            'singular' => esc_html__('registration', 'event_espresso'),
83
-            'plural'   => esc_html__('registrations', 'event_espresso'),
84
-            'ajax'     => true,
85
-            'screen'   => $this->_admin_page->get_current_screen()->id,
86
-        ];
87
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
88
-        $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
89
-        $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
90
-        $ID_column_name      .= '</span> ';
91
-
92
-        $EVT_ID = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : 0;
93
-        $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
94
-
95
-        if ($EVT_ID) {
96
-            $this->_columns        = [
97
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
98
-                '_REG_ID'          => $ID_column_name,
99
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
100
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
101
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
102
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
103
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
104
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
105
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
106
-                'actions'          => esc_html__('Actions', 'event_espresso'),
107
-            ];
108
-        } else {
109
-            $this->_columns        = [
110
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
111
-                '_REG_ID'          => $ID_column_name,
112
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
113
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
114
-                'event_name'       => esc_html__('Event', 'event_espresso'),
115
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
116
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
117
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
118
-                'actions'          => esc_html__('Actions', 'event_espresso'),
119
-            ];
120
-        }
121
-
122
-        $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
123
-        if (! empty($csv_report)) {
124
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
125
-        }
126
-
127
-        $this->_primary_column   = '_REG_ID';
128
-        $this->_sortable_columns = [
129
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
130
-            /**
131
-             * Allows users to change the default sort if they wish.
132
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
133
-             * name.
134
-             */
135
-            'ATT_fname'     => [
136
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
137
-                true,
138
-                $this,
139
-            ]
140
-                ? ['ATT_lname' => false]
141
-                : ['ATT_fname' => false],
142
-            'event_name'    => ['event_name' => false],
143
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
144
-            '_REG_ID'       => ['_REG_ID' => false],
145
-        ];
146
-        $this->_hidden_columns   = [];
147
-    }
148
-
149
-
150
-    /**
151
-     * This simply sets up the row class for the table rows.
152
-     * Allows for easier overriding of child methods for setting up sorting.
153
-     *
154
-     * @param EE_Registration $item the current item
155
-     * @return string
156
-     */
157
-    protected function _get_row_class($item)
158
-    {
159
-        $class = parent::_get_row_class($item);
160
-        // add status class
161
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
162
-        if ($this->_has_checkbox_column) {
163
-            $class .= ' has-checkbox-column';
164
-        }
165
-        return $class;
166
-    }
167
-
168
-
169
-    /**
170
-     * Set the $_transaction_details property if not set yet.
171
-     *
172
-     * @param EE_Registration $registration
173
-     * @throws EE_Error
174
-     * @throws InvalidArgumentException
175
-     * @throws ReflectionException
176
-     * @throws InvalidDataTypeException
177
-     * @throws InvalidInterfaceException
178
-     */
179
-    protected function _set_related_details(EE_Registration $registration)
180
-    {
181
-        $transaction                = $registration->get_first_related('Transaction');
182
-        $status                     = $transaction instanceof EE_Transaction
183
-            ? $transaction->status_ID()
184
-            : EEM_Transaction::failed_status_code;
185
-        $this->_transaction_details = [
186
-            'transaction' => $transaction,
187
-            'status'      => $status,
188
-            'id'          => $transaction instanceof EE_Transaction
189
-                ? $transaction->ID()
190
-                : 0,
191
-            'title_attr'  => sprintf(
192
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
193
-                EEH_Template::pretty_status($status, false, 'sentence')
194
-            ),
195
-        ];
196
-        try {
197
-            $event = $registration->event();
198
-        } catch (EntityNotFoundException $e) {
199
-            $event = null;
200
-        }
201
-        $status               = $event instanceof EE_Event
202
-            ? $event->get_active_status()
203
-            : EE_Datetime::inactive;
204
-        $this->_event_details = [
205
-            'event'      => $event,
206
-            'status'     => $status,
207
-            'id'         => $event instanceof EE_Event
208
-                ? $event->ID()
209
-                : 0,
210
-            'title_attr' => sprintf(
211
-                esc_html__('Edit Event (%s)', 'event_espresso'),
212
-                EEH_Template::pretty_status($status, false, 'sentence')
213
-            ),
214
-        ];
215
-    }
216
-
217
-
218
-    /**
219
-     *    _get_table_filters
220
-     *
221
-     * @return array
222
-     * @throws EE_Error
223
-     * @throws ReflectionException
224
-     */
225
-    protected function _get_table_filters()
226
-    {
227
-        $filters = [];
228
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
229
-        // methods.
230
-        $cur_date     = isset($this->_req_data['month_range'])
231
-            ? $this->_req_data['month_range']
232
-            : '';
233
-        $cur_category = isset($this->_req_data['EVT_CAT'])
234
-            ? $this->_req_data['EVT_CAT']
235
-            : -1;
236
-        $reg_status   = isset($this->_req_data['_reg_status'])
237
-            ? $this->_req_data['_reg_status']
238
-            : '';
239
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
240
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
241
-        $status       = [];
242
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
243
-        foreach ($this->_status as $key => $value) {
244
-            $status[] = ['id' => $key, 'text' => $value];
245
-        }
246
-        if ($this->_view !== 'incomplete') {
247
-            $filters[] = EEH_Form_Fields::select_input(
248
-                '_reg_status',
249
-                $status,
250
-                isset($this->_req_data['_reg_status'])
251
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
252
-                    : ''
253
-            );
254
-        }
255
-        if (isset($this->_req_data['event_id'])) {
256
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
257
-        }
258
-        return $filters;
259
-    }
260
-
261
-
262
-    /**
263
-     * @return void
264
-     * @throws EE_Error
265
-     * @throws InvalidArgumentException
266
-     * @throws InvalidDataTypeException
267
-     * @throws InvalidInterfaceException
268
-     */
269
-    protected function _add_view_counts()
270
-    {
271
-        $this->_views['all']['count']   = $this->_total_registrations();
272
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
273
-        $this->_views['today']['count'] = $this->_total_registrations_today();
274
-        if (
275
-            EE_Registry::instance()->CAP->current_user_can(
276
-                'ee_delete_registrations',
277
-                'espresso_registrations_trash_registrations'
278
-            )
279
-        ) {
280
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
281
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
282
-        }
283
-    }
284
-
285
-
286
-    /**
287
-     * @param string $view
288
-     * @return int
289
-     * @throws EE_Error
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidDataTypeException
292
-     * @throws InvalidInterfaceException
293
-     */
294
-    protected function _total_registrations($view = '')
295
-    {
296
-        $_where = [];
297
-        $EVT_ID = isset($this->_req_data['event_id'])
298
-            ? absint($this->_req_data['event_id'])
299
-            : false;
300
-        if ($EVT_ID) {
301
-            $_where['EVT_ID'] = $EVT_ID;
302
-        }
303
-        switch ($view) {
304
-            case 'trash':
305
-                return EEM_Registration::instance()->count_deleted([$_where]);
306
-            case 'incomplete':
307
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
308
-                break;
309
-            default:
310
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
311
-        }
312
-        return EEM_Registration::instance()->count([$_where]);
313
-    }
314
-
315
-
316
-    /**
317
-     * @return int
318
-     * @throws EE_Error
319
-     * @throws InvalidArgumentException
320
-     * @throws InvalidDataTypeException
321
-     * @throws InvalidInterfaceException
322
-     */
323
-    protected function _total_registrations_this_month()
324
-    {
325
-        $EVT_ID          = isset($this->_req_data['event_id'])
326
-            ? absint($this->_req_data['event_id'])
327
-            : false;
328
-        $_where          = $EVT_ID
329
-            ? ['EVT_ID' => $EVT_ID]
330
-            : [];
331
-        $this_year_r     = date('Y', current_time('timestamp'));
332
-        $time_start      = ' 00:00:00';
333
-        $time_end        = ' 23:59:59';
334
-        $this_month_r    = date('m', current_time('timestamp'));
335
-        $days_this_month = date('t', current_time('timestamp'));
336
-        // setup date query.
337
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
338
-            'REG_date',
339
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
340
-            'Y-m-d H:i:s'
341
-        );
342
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
343
-            'REG_date',
344
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
345
-            'Y-m-d H:i:s'
346
-        );
347
-        $_where['REG_date'] = [
348
-            'BETWEEN',
349
-            [
350
-                $beginning_string,
351
-                $end_string,
352
-            ],
353
-        ];
354
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
355
-        return EEM_Registration::instance()->count([$_where]);
356
-    }
357
-
358
-
359
-    /**
360
-     * @return int
361
-     * @throws EE_Error
362
-     * @throws InvalidArgumentException
363
-     * @throws InvalidDataTypeException
364
-     * @throws InvalidInterfaceException
365
-     */
366
-    protected function _total_registrations_today()
367
-    {
368
-        $EVT_ID             = isset($this->_req_data['event_id'])
369
-            ? absint($this->_req_data['event_id'])
370
-            : false;
371
-        $_where             = $EVT_ID
372
-            ? ['EVT_ID' => $EVT_ID]
373
-            : [];
374
-        $current_date       = date('Y-m-d', current_time('timestamp'));
375
-        $time_start         = ' 00:00:00';
376
-        $time_end           = ' 23:59:59';
377
-        $_where['REG_date'] = [
378
-            'BETWEEN',
379
-            [
380
-                EEM_Registration::instance()->convert_datetime_for_query(
381
-                    'REG_date',
382
-                    $current_date . $time_start,
383
-                    'Y-m-d H:i:s'
384
-                ),
385
-                EEM_Registration::instance()->convert_datetime_for_query(
386
-                    'REG_date',
387
-                    $current_date . $time_end,
388
-                    'Y-m-d H:i:s'
389
-                ),
390
-            ],
391
-        ];
392
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
393
-        return EEM_Registration::instance()->count([$_where]);
394
-    }
395
-
396
-
397
-    /**
398
-     * @param EE_Registration $item
399
-     * @return string
400
-     * @throws EE_Error
401
-     * @throws InvalidArgumentException
402
-     * @throws InvalidDataTypeException
403
-     * @throws InvalidInterfaceException
404
-     * @throws ReflectionException
405
-     */
406
-    public function column_cb($item)
407
-    {
408
-        /** checkbox/lock **/
409
-        $transaction   = $item->get_first_related('Transaction');
410
-        $payment_count = $transaction instanceof EE_Transaction
411
-            ? $transaction->count_related('Payment')
412
-            : 0;
413
-        return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
414
-            'ee_edit_registration',
415
-            'registration_list_table_checkbox_input',
416
-            $item->ID()
417
-        )
418
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
419
-              . '<span class="ee-lock-icon"></span>'
420
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
421
-    }
422
-
423
-
424
-    /**
425
-     * @param EE_Registration $item
426
-     * @return string
427
-     * @throws EE_Error
428
-     * @throws InvalidArgumentException
429
-     * @throws InvalidDataTypeException
430
-     * @throws InvalidInterfaceException
431
-     * @throws ReflectionException
432
-     */
433
-    public function column__REG_ID(EE_Registration $item)
434
-    {
435
-        $attendee = $item->attendee();
436
-        $content  = $item->ID();
437
-        $content  .= '<div class="show-on-mobile-view-only">';
438
-        $content  .= '<br>';
439
-        $content  .= $attendee instanceof EE_Attendee
440
-            ? $attendee->full_name()
441
-            : '';
442
-        $content  .= '&nbsp;';
443
-        $content  .= sprintf(
444
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
445
-            $item->count(),
446
-            $item->group_size()
447
-        );
448
-        $content  .= '<br>';
449
-        $content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
450
-        $content  .= '</div>';
451
-        return $content;
452
-    }
453
-
454
-
455
-    /**
456
-     * @param EE_Registration $item
457
-     * @return string
458
-     * @throws EE_Error
459
-     * @throws InvalidArgumentException
460
-     * @throws InvalidDataTypeException
461
-     * @throws InvalidInterfaceException
462
-     * @throws ReflectionException
463
-     */
464
-    public function column__REG_date(EE_Registration $item)
465
-    {
466
-        $this->_set_related_details($item);
467
-        // Build row actions
468
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
469
-            [
470
-                'action' => 'view_transaction',
471
-                'TXN_ID' => $this->_transaction_details['id'],
472
-            ],
473
-            TXN_ADMIN_URL
474
-        );
475
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
476
-            'ee_read_transaction',
477
-            'espresso_transactions_view_transaction'
478
-        )
479
-            ? '<a class="ee-status-color-'
480
-              . $this->_transaction_details['status']
481
-              . '" href="'
482
-              . $view_lnk_url
483
-              . '" title="'
484
-              . esc_attr($this->_transaction_details['title_attr'])
485
-              . '">'
486
-              . $item->get_i18n_datetime('REG_date')
487
-              . '</a>'
488
-            : $item->get_i18n_datetime('REG_date');
489
-        $view_link    .= '<br><span class="ee-status-text-small">'
490
-                         . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
491
-                         . '</span>';
492
-        return $view_link;
493
-    }
494
-
495
-
496
-    /**
497
-     * @param EE_Registration $item
498
-     * @return string
499
-     * @throws EE_Error
500
-     * @throws InvalidArgumentException
501
-     * @throws InvalidDataTypeException
502
-     * @throws InvalidInterfaceException
503
-     * @throws ReflectionException
504
-     */
505
-    public function column_event_name(EE_Registration $item)
506
-    {
507
-        $this->_set_related_details($item);
508
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
509
-        $EVT_ID     = $item->event_ID();
510
-        $event_name = $item->event_name();
511
-        $event_name =
512
-            $event_name
513
-                ?: esc_html__("No Associated Event", 'event_espresso');
514
-        $event_name = wp_trim_words($event_name, 30, '...');
515
-        if ($EVT_ID) {
516
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
517
-                ['action' => 'edit', 'post' => $EVT_ID],
518
-                EVENTS_ADMIN_URL
519
-            );
520
-            $edit_event              =
521
-                EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
522
-                    ? '<a class="ee-status-color-'
523
-                      . $this->_event_details['status']
524
-                      . '" href="'
525
-                      . $edit_event_url
526
-                      . '" title="'
527
-                      . esc_attr($this->_event_details['title_attr'])
528
-                      . '">'
529
-                      . $event_name
530
-                      . '</a>'
531
-                    : $event_name;
532
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
533
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
534
-            $actions['event_filter'] .= sprintf(
535
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
536
-                $event_name
537
-            );
538
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
539
-        } else {
540
-            $edit_event              = $event_name;
541
-            $actions['event_filter'] = '';
542
-        }
543
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
544
-    }
545
-
546
-
547
-    /**
548
-     * @param EE_Registration $item
549
-     * @return string
550
-     * @throws EE_Error
551
-     * @throws InvalidArgumentException
552
-     * @throws InvalidDataTypeException
553
-     * @throws InvalidInterfaceException
554
-     * @throws ReflectionException
555
-     */
556
-    public function column_DTT_EVT_start(EE_Registration $item)
557
-    {
558
-        $datetime_strings = [];
559
-        $ticket           = $item->ticket();
560
-        if ($ticket instanceof EE_Ticket) {
561
-            $remove_defaults = ['default_where_conditions' => 'none'];
562
-            $datetimes       = $ticket->datetimes($remove_defaults);
563
-            foreach ($datetimes as $datetime) {
564
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
565
-            }
566
-            return $this->generateDisplayForDatetimes($datetime_strings);
567
-        }
568
-        return esc_html__('There is no ticket on this registration', 'event_espresso');
569
-    }
570
-
571
-
572
-    /**
573
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
574
-     *
575
-     * @param array $datetime_strings
576
-     * @return string
577
-     */
578
-    public function generateDisplayForDateTimes(array $datetime_strings)
579
-    {
580
-        $content       = '<div class="ee-registration-event-datetimes-container">';
581
-        $expand_toggle = count($datetime_strings) > 1
582
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
583
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
584
-            : '';
585
-        // get first item for initial visibility
586
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
587
-        $content .= $expand_toggle;
588
-        if ($datetime_strings) {
589
-            $content .= '<div style="clear:both"></div>';
590
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
591
-            $content .= implode("<br />", $datetime_strings);
592
-            $content .= '</div>';
593
-        }
594
-        $content .= '</div>';
595
-        return $content;
596
-    }
597
-
598
-
599
-    /**
600
-     * @param EE_Registration $item
601
-     * @return string
602
-     * @throws EE_Error
603
-     * @throws InvalidArgumentException
604
-     * @throws InvalidDataTypeException
605
-     * @throws InvalidInterfaceException
606
-     * @throws ReflectionException
607
-     */
608
-    public function column_ATT_fname(EE_Registration $item)
609
-    {
610
-        $attendee      = $item->attendee();
611
-        $edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
612
-            [
613
-                'action'  => 'view_registration',
614
-                '_REG_ID' => $item->ID(),
615
-            ],
616
-            REG_ADMIN_URL
617
-        );
618
-        $attendee_name = $attendee instanceof EE_Attendee
619
-            ? $attendee->full_name()
620
-            : '';
621
-        $link          = EE_Registry::instance()->CAP->current_user_can(
622
-            'ee_read_registration',
623
-            'espresso_registrations_view_registration',
624
-            $item->ID()
625
-        )
626
-            ? '<a href="'
627
-              . $edit_lnk_url
628
-              . '" title="'
629
-              . esc_attr__('View Registration Details', 'event_espresso')
630
-              . '">'
631
-              . $attendee_name
632
-              . '</a>'
633
-            : $attendee_name;
634
-        $link          .= $item->count() === 1
635
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
636
-            : '';
637
-        $t             = $item->get_first_related('Transaction');
638
-        $payment_count = $t instanceof EE_Transaction
639
-            ? $t->count_related('Payment')
640
-            : 0;
641
-        // append group count to name
642
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
643
-        // append reg_code
644
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
645
-        // reg status text for accessibility
646
-        $link   .= '<br><span class="ee-status-text-small">'
647
-                   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
648
-                   . '</span>';
649
-        $action = ['_REG_ID' => $item->ID()];
650
-        if (isset($this->_req_data['event_id'])) {
651
-            $action['event_id'] = $item->event_ID();
652
-        }
653
-        // trash/restore/delete actions
654
-        $actions = [];
655
-        if (
656
-            $this->_view !== 'trash'
657
-            && $payment_count === 0
658
-            && EE_Registry::instance()->CAP->current_user_can(
659
-                'ee_delete_registration',
660
-                'espresso_registrations_trash_registrations',
661
-                $item->ID()
662
-            )
663
-        ) {
664
-            $action['action'] = 'trash_registrations';
665
-            $trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
666
-                $action,
667
-                REG_ADMIN_URL
668
-            );
669
-            $actions['trash'] = '<a href="'
670
-                                . $trash_lnk_url
671
-                                . '" title="'
672
-                                . esc_attr__('Trash Registration', 'event_espresso')
673
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
674
-        } elseif ($this->_view === 'trash') {
675
-            // restore registration link
676
-            if (
677
-                EE_Registry::instance()->CAP->current_user_can(
678
-                    'ee_delete_registration',
679
-                    'espresso_registrations_restore_registrations',
680
-                    $item->ID()
681
-                )
682
-            ) {
683
-                $action['action']   = 'restore_registrations';
684
-                $restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
685
-                    $action,
686
-                    REG_ADMIN_URL
687
-                );
688
-                $actions['restore'] = '<a href="'
689
-                                      . $restore_lnk_url
690
-                                      . '" title="'
691
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
692
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
693
-            }
694
-            if (
695
-                EE_Registry::instance()->CAP->current_user_can(
696
-                    'ee_delete_registration',
697
-                    'espresso_registrations_ee_delete_registrations',
698
-                    $item->ID()
699
-                )
700
-            ) {
701
-                $action['action']  = 'delete_registrations';
702
-                $delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
703
-                    $action,
704
-                    REG_ADMIN_URL
705
-                );
706
-                $actions['delete'] = '<a href="'
707
-                                     . $delete_lnk_url
708
-                                     . '" title="'
709
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
710
-                                     . '">'
711
-                                     . esc_html__('Delete', 'event_espresso')
712
-                                     . '</a>';
713
-            }
714
-        }
715
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
716
-    }
717
-
718
-
719
-    /**
720
-     * @param EE_Registration $item
721
-     * @return string
722
-     * @throws EE_Error
723
-     * @throws InvalidArgumentException
724
-     * @throws InvalidDataTypeException
725
-     * @throws InvalidInterfaceException
726
-     * @throws ReflectionException
727
-     */
728
-    public function column_ATT_email(EE_Registration $item)
729
-    {
730
-        $attendee = $item->get_first_related('Attendee');
731
-        return ! $attendee instanceof EE_Attendee
732
-            ? esc_html__('No attached contact record.', 'event_espresso')
733
-            : $attendee->email();
734
-    }
735
-
736
-
737
-    /**
738
-     * @param EE_Registration $item
739
-     * @return string
740
-     */
741
-    public function column__REG_count(EE_Registration $item)
742
-    {
743
-        return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
744
-    }
745
-
746
-
747
-    /**
748
-     * @param EE_Registration $item
749
-     * @return string
750
-     * @throws EE_Error
751
-     * @throws ReflectionException
752
-     */
753
-    public function column_PRC_amount(EE_Registration $item)
754
-    {
755
-        $ticket   = $item->ticket();
756
-        $req_data = $this->_admin_page->get_request_data();
757
-        $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
758
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
759
-            : '';
760
-        if ($item->final_price() > 0) {
761
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
762
-        } else {
763
-            // free event
764
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
765
-                        . esc_html__('free', 'event_espresso')
766
-                        . '</span>';
767
-        }
768
-        return $content;
769
-    }
770
-
771
-
772
-    /**
773
-     * @param EE_Registration $item
774
-     * @return string
775
-     * @throws EE_Error
776
-     * @throws ReflectionException
777
-     */
778
-    public function column__REG_final_price(EE_Registration $item)
779
-    {
780
-        $ticket   = $item->ticket();
781
-        $req_data = $this->_admin_page->get_request_data();
782
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
783
-            ? ''
784
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
785
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
786
-        return $content;
787
-    }
788
-
789
-
790
-    /**
791
-     * @param EE_Registration $item
792
-     * @return string
793
-     * @throws EE_Error
794
-     */
795
-    public function column__REG_paid(EE_Registration $item)
796
-    {
797
-        $payment_method      = $item->payment_method();
798
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
799
-            ? $payment_method->admin_name()
800
-            : esc_html__('Unknown', 'event_espresso');
801
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
802
-        if ($item->paid() > 0) {
803
-            $content .= '<br><span class="ee-status-text-small">'
804
-                        . sprintf(
805
-                            esc_html__('...via %s', 'event_espresso'),
806
-                            $payment_method_name
807
-                        )
808
-                        . '</span>';
809
-        }
810
-        return $content;
811
-    }
812
-
813
-
814
-    /**
815
-     * @param EE_Registration $item
816
-     * @return string
817
-     * @throws EE_Error
818
-     * @throws EntityNotFoundException
819
-     * @throws InvalidArgumentException
820
-     * @throws InvalidDataTypeException
821
-     * @throws InvalidInterfaceException
822
-     * @throws ReflectionException
823
-     */
824
-    public function column_TXN_total(EE_Registration $item)
825
-    {
826
-        if ($item->transaction()) {
827
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
828
-                [
829
-                    'action' => 'view_transaction',
830
-                    'TXN_ID' => $item->transaction_ID(),
831
-                ],
832
-                TXN_ADMIN_URL
833
-            );
834
-            return EE_Registry::instance()->CAP->current_user_can(
835
-                'ee_read_transaction',
836
-                'espresso_transactions_view_transaction',
837
-                $item->transaction_ID()
838
-            )
839
-                ? '<span class="reg-pad-rght"><a class="status-'
840
-                  . $item->transaction()->status_ID()
841
-                  . '" href="'
842
-                  . $view_txn_lnk_url
843
-                  . '"  title="'
844
-                  . esc_attr__('View Transaction', 'event_espresso')
845
-                  . '">'
846
-                  . $item->transaction()->pretty_total()
847
-                  . '</a></span>'
848
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
849
-        } else {
850
-            return esc_html__("None", "event_espresso");
851
-        }
852
-    }
853
-
854
-
855
-    /**
856
-     * @param EE_Registration $item
857
-     * @return string
858
-     * @throws EE_Error
859
-     * @throws EntityNotFoundException
860
-     * @throws InvalidArgumentException
861
-     * @throws InvalidDataTypeException
862
-     * @throws InvalidInterfaceException
863
-     * @throws ReflectionException
864
-     */
865
-    public function column_TXN_paid(EE_Registration $item)
866
-    {
867
-        if ($item->count() === 1) {
868
-            $transaction = $item->transaction()
869
-                ? $item->transaction()
870
-                : EE_Transaction::new_instance();
871
-            if ($transaction->paid() >= $transaction->total()) {
872
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
873
-            } else {
874
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
875
-                    [
876
-                        'action' => 'view_transaction',
877
-                        'TXN_ID' => $item->transaction_ID(),
878
-                    ],
879
-                    TXN_ADMIN_URL
880
-                );
881
-                return EE_Registry::instance()->CAP->current_user_can(
882
-                    'ee_read_transaction',
883
-                    'espresso_transactions_view_transaction',
884
-                    $item->transaction_ID()
885
-                )
886
-                    ? '<span class="reg-pad-rght"><a class="status-'
887
-                      . $transaction->status_ID()
888
-                      . '" href="'
889
-                      . $view_txn_lnk_url
890
-                      . '"  title="'
891
-                      . esc_attr__('View Transaction', 'event_espresso')
892
-                      . '">'
893
-                      . $item->transaction()->pretty_paid()
894
-                      . '</a><span>'
895
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
896
-            }
897
-        }
898
-        return '&nbsp;';
899
-    }
900
-
901
-
902
-    /**
903
-     * column_actions
904
-     *
905
-     * @param EE_Registration $item
906
-     * @return string
907
-     * @throws EE_Error
908
-     * @throws InvalidArgumentException
909
-     * @throws InvalidDataTypeException
910
-     * @throws InvalidInterfaceException
911
-     * @throws ReflectionException
912
-     */
913
-    public function column_actions(EE_Registration $item)
914
-    {
915
-        $actions  = [];
916
-        $attendee = $item->attendee();
917
-        $this->_set_related_details($item);
918
-
919
-        // Build row actions
920
-        if (
921
-            EE_Registry::instance()->CAP->current_user_can(
922
-                'ee_read_registration',
923
-                'espresso_registrations_view_registration',
924
-                $item->ID()
925
-            )
926
-        ) {
927
-            $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
928
-                [
929
-                    'action'  => 'view_registration',
930
-                    '_REG_ID' => $item->ID(),
931
-                ],
932
-                REG_ADMIN_URL
933
-            );
934
-            $actions['view_lnk'] = '
19
+	/**
20
+	 * @var Registrations_Admin_Page
21
+	 */
22
+	protected $_admin_page;
23
+
24
+	/**
25
+	 * @var array
26
+	 */
27
+	private $_status;
28
+
29
+	/**
30
+	 * An array of transaction details for the related transaction to the registration being processed.
31
+	 * This is set via the _set_related_details method.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $_transaction_details = [];
36
+
37
+	/**
38
+	 * An array of event details for the related event to the registration being processed.
39
+	 * This is set via the _set_related_details method.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $_event_details = [];
44
+
45
+
46
+	/**
47
+	 * @param Registrations_Admin_Page $admin_page
48
+	 */
49
+	public function __construct(Registrations_Admin_Page $admin_page)
50
+	{
51
+		$req_data = $admin_page->get_request_data();
52
+		if (! empty($req_data['event_id'])) {
53
+			$extra_query_args = [];
54
+			foreach ($admin_page->get_views() as $view_details) {
55
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
56
+			}
57
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
58
+		}
59
+		parent::__construct($admin_page);
60
+		$this->_status = $this->_admin_page->get_registration_status_array();
61
+	}
62
+
63
+
64
+	/**
65
+	 * @return void
66
+	 * @throws EE_Error
67
+	 */
68
+	protected function _setup_data()
69
+	{
70
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
71
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return void
77
+	 */
78
+	protected function _set_properties()
79
+	{
80
+		$return_url          = $this->getReturnUrl();
81
+		$this->_wp_list_args = [
82
+			'singular' => esc_html__('registration', 'event_espresso'),
83
+			'plural'   => esc_html__('registrations', 'event_espresso'),
84
+			'ajax'     => true,
85
+			'screen'   => $this->_admin_page->get_current_screen()->id,
86
+		];
87
+		$ID_column_name      = esc_html__('ID', 'event_espresso');
88
+		$ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
89
+		$ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
90
+		$ID_column_name      .= '</span> ';
91
+
92
+		$EVT_ID = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : 0;
93
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
94
+
95
+		if ($EVT_ID) {
96
+			$this->_columns        = [
97
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
98
+				'_REG_ID'          => $ID_column_name,
99
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
100
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
101
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
102
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
103
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
104
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
105
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
106
+				'actions'          => esc_html__('Actions', 'event_espresso'),
107
+			];
108
+		} else {
109
+			$this->_columns        = [
110
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
111
+				'_REG_ID'          => $ID_column_name,
112
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
113
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
114
+				'event_name'       => esc_html__('Event', 'event_espresso'),
115
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
116
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
117
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
118
+				'actions'          => esc_html__('Actions', 'event_espresso'),
119
+			];
120
+		}
121
+
122
+		$csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
123
+		if (! empty($csv_report)) {
124
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
125
+		}
126
+
127
+		$this->_primary_column   = '_REG_ID';
128
+		$this->_sortable_columns = [
129
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
130
+			/**
131
+			 * Allows users to change the default sort if they wish.
132
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
133
+			 * name.
134
+			 */
135
+			'ATT_fname'     => [
136
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
137
+				true,
138
+				$this,
139
+			]
140
+				? ['ATT_lname' => false]
141
+				: ['ATT_fname' => false],
142
+			'event_name'    => ['event_name' => false],
143
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
144
+			'_REG_ID'       => ['_REG_ID' => false],
145
+		];
146
+		$this->_hidden_columns   = [];
147
+	}
148
+
149
+
150
+	/**
151
+	 * This simply sets up the row class for the table rows.
152
+	 * Allows for easier overriding of child methods for setting up sorting.
153
+	 *
154
+	 * @param EE_Registration $item the current item
155
+	 * @return string
156
+	 */
157
+	protected function _get_row_class($item)
158
+	{
159
+		$class = parent::_get_row_class($item);
160
+		// add status class
161
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
162
+		if ($this->_has_checkbox_column) {
163
+			$class .= ' has-checkbox-column';
164
+		}
165
+		return $class;
166
+	}
167
+
168
+
169
+	/**
170
+	 * Set the $_transaction_details property if not set yet.
171
+	 *
172
+	 * @param EE_Registration $registration
173
+	 * @throws EE_Error
174
+	 * @throws InvalidArgumentException
175
+	 * @throws ReflectionException
176
+	 * @throws InvalidDataTypeException
177
+	 * @throws InvalidInterfaceException
178
+	 */
179
+	protected function _set_related_details(EE_Registration $registration)
180
+	{
181
+		$transaction                = $registration->get_first_related('Transaction');
182
+		$status                     = $transaction instanceof EE_Transaction
183
+			? $transaction->status_ID()
184
+			: EEM_Transaction::failed_status_code;
185
+		$this->_transaction_details = [
186
+			'transaction' => $transaction,
187
+			'status'      => $status,
188
+			'id'          => $transaction instanceof EE_Transaction
189
+				? $transaction->ID()
190
+				: 0,
191
+			'title_attr'  => sprintf(
192
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
193
+				EEH_Template::pretty_status($status, false, 'sentence')
194
+			),
195
+		];
196
+		try {
197
+			$event = $registration->event();
198
+		} catch (EntityNotFoundException $e) {
199
+			$event = null;
200
+		}
201
+		$status               = $event instanceof EE_Event
202
+			? $event->get_active_status()
203
+			: EE_Datetime::inactive;
204
+		$this->_event_details = [
205
+			'event'      => $event,
206
+			'status'     => $status,
207
+			'id'         => $event instanceof EE_Event
208
+				? $event->ID()
209
+				: 0,
210
+			'title_attr' => sprintf(
211
+				esc_html__('Edit Event (%s)', 'event_espresso'),
212
+				EEH_Template::pretty_status($status, false, 'sentence')
213
+			),
214
+		];
215
+	}
216
+
217
+
218
+	/**
219
+	 *    _get_table_filters
220
+	 *
221
+	 * @return array
222
+	 * @throws EE_Error
223
+	 * @throws ReflectionException
224
+	 */
225
+	protected function _get_table_filters()
226
+	{
227
+		$filters = [];
228
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
229
+		// methods.
230
+		$cur_date     = isset($this->_req_data['month_range'])
231
+			? $this->_req_data['month_range']
232
+			: '';
233
+		$cur_category = isset($this->_req_data['EVT_CAT'])
234
+			? $this->_req_data['EVT_CAT']
235
+			: -1;
236
+		$reg_status   = isset($this->_req_data['_reg_status'])
237
+			? $this->_req_data['_reg_status']
238
+			: '';
239
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
240
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
241
+		$status       = [];
242
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
243
+		foreach ($this->_status as $key => $value) {
244
+			$status[] = ['id' => $key, 'text' => $value];
245
+		}
246
+		if ($this->_view !== 'incomplete') {
247
+			$filters[] = EEH_Form_Fields::select_input(
248
+				'_reg_status',
249
+				$status,
250
+				isset($this->_req_data['_reg_status'])
251
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
252
+					: ''
253
+			);
254
+		}
255
+		if (isset($this->_req_data['event_id'])) {
256
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
257
+		}
258
+		return $filters;
259
+	}
260
+
261
+
262
+	/**
263
+	 * @return void
264
+	 * @throws EE_Error
265
+	 * @throws InvalidArgumentException
266
+	 * @throws InvalidDataTypeException
267
+	 * @throws InvalidInterfaceException
268
+	 */
269
+	protected function _add_view_counts()
270
+	{
271
+		$this->_views['all']['count']   = $this->_total_registrations();
272
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
273
+		$this->_views['today']['count'] = $this->_total_registrations_today();
274
+		if (
275
+			EE_Registry::instance()->CAP->current_user_can(
276
+				'ee_delete_registrations',
277
+				'espresso_registrations_trash_registrations'
278
+			)
279
+		) {
280
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
281
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
282
+		}
283
+	}
284
+
285
+
286
+	/**
287
+	 * @param string $view
288
+	 * @return int
289
+	 * @throws EE_Error
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws InvalidInterfaceException
293
+	 */
294
+	protected function _total_registrations($view = '')
295
+	{
296
+		$_where = [];
297
+		$EVT_ID = isset($this->_req_data['event_id'])
298
+			? absint($this->_req_data['event_id'])
299
+			: false;
300
+		if ($EVT_ID) {
301
+			$_where['EVT_ID'] = $EVT_ID;
302
+		}
303
+		switch ($view) {
304
+			case 'trash':
305
+				return EEM_Registration::instance()->count_deleted([$_where]);
306
+			case 'incomplete':
307
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
308
+				break;
309
+			default:
310
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
311
+		}
312
+		return EEM_Registration::instance()->count([$_where]);
313
+	}
314
+
315
+
316
+	/**
317
+	 * @return int
318
+	 * @throws EE_Error
319
+	 * @throws InvalidArgumentException
320
+	 * @throws InvalidDataTypeException
321
+	 * @throws InvalidInterfaceException
322
+	 */
323
+	protected function _total_registrations_this_month()
324
+	{
325
+		$EVT_ID          = isset($this->_req_data['event_id'])
326
+			? absint($this->_req_data['event_id'])
327
+			: false;
328
+		$_where          = $EVT_ID
329
+			? ['EVT_ID' => $EVT_ID]
330
+			: [];
331
+		$this_year_r     = date('Y', current_time('timestamp'));
332
+		$time_start      = ' 00:00:00';
333
+		$time_end        = ' 23:59:59';
334
+		$this_month_r    = date('m', current_time('timestamp'));
335
+		$days_this_month = date('t', current_time('timestamp'));
336
+		// setup date query.
337
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
338
+			'REG_date',
339
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
340
+			'Y-m-d H:i:s'
341
+		);
342
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
343
+			'REG_date',
344
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
345
+			'Y-m-d H:i:s'
346
+		);
347
+		$_where['REG_date'] = [
348
+			'BETWEEN',
349
+			[
350
+				$beginning_string,
351
+				$end_string,
352
+			],
353
+		];
354
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
355
+		return EEM_Registration::instance()->count([$_where]);
356
+	}
357
+
358
+
359
+	/**
360
+	 * @return int
361
+	 * @throws EE_Error
362
+	 * @throws InvalidArgumentException
363
+	 * @throws InvalidDataTypeException
364
+	 * @throws InvalidInterfaceException
365
+	 */
366
+	protected function _total_registrations_today()
367
+	{
368
+		$EVT_ID             = isset($this->_req_data['event_id'])
369
+			? absint($this->_req_data['event_id'])
370
+			: false;
371
+		$_where             = $EVT_ID
372
+			? ['EVT_ID' => $EVT_ID]
373
+			: [];
374
+		$current_date       = date('Y-m-d', current_time('timestamp'));
375
+		$time_start         = ' 00:00:00';
376
+		$time_end           = ' 23:59:59';
377
+		$_where['REG_date'] = [
378
+			'BETWEEN',
379
+			[
380
+				EEM_Registration::instance()->convert_datetime_for_query(
381
+					'REG_date',
382
+					$current_date . $time_start,
383
+					'Y-m-d H:i:s'
384
+				),
385
+				EEM_Registration::instance()->convert_datetime_for_query(
386
+					'REG_date',
387
+					$current_date . $time_end,
388
+					'Y-m-d H:i:s'
389
+				),
390
+			],
391
+		];
392
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
393
+		return EEM_Registration::instance()->count([$_where]);
394
+	}
395
+
396
+
397
+	/**
398
+	 * @param EE_Registration $item
399
+	 * @return string
400
+	 * @throws EE_Error
401
+	 * @throws InvalidArgumentException
402
+	 * @throws InvalidDataTypeException
403
+	 * @throws InvalidInterfaceException
404
+	 * @throws ReflectionException
405
+	 */
406
+	public function column_cb($item)
407
+	{
408
+		/** checkbox/lock **/
409
+		$transaction   = $item->get_first_related('Transaction');
410
+		$payment_count = $transaction instanceof EE_Transaction
411
+			? $transaction->count_related('Payment')
412
+			: 0;
413
+		return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
414
+			'ee_edit_registration',
415
+			'registration_list_table_checkbox_input',
416
+			$item->ID()
417
+		)
418
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
419
+			  . '<span class="ee-lock-icon"></span>'
420
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
421
+	}
422
+
423
+
424
+	/**
425
+	 * @param EE_Registration $item
426
+	 * @return string
427
+	 * @throws EE_Error
428
+	 * @throws InvalidArgumentException
429
+	 * @throws InvalidDataTypeException
430
+	 * @throws InvalidInterfaceException
431
+	 * @throws ReflectionException
432
+	 */
433
+	public function column__REG_ID(EE_Registration $item)
434
+	{
435
+		$attendee = $item->attendee();
436
+		$content  = $item->ID();
437
+		$content  .= '<div class="show-on-mobile-view-only">';
438
+		$content  .= '<br>';
439
+		$content  .= $attendee instanceof EE_Attendee
440
+			? $attendee->full_name()
441
+			: '';
442
+		$content  .= '&nbsp;';
443
+		$content  .= sprintf(
444
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
445
+			$item->count(),
446
+			$item->group_size()
447
+		);
448
+		$content  .= '<br>';
449
+		$content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
450
+		$content  .= '</div>';
451
+		return $content;
452
+	}
453
+
454
+
455
+	/**
456
+	 * @param EE_Registration $item
457
+	 * @return string
458
+	 * @throws EE_Error
459
+	 * @throws InvalidArgumentException
460
+	 * @throws InvalidDataTypeException
461
+	 * @throws InvalidInterfaceException
462
+	 * @throws ReflectionException
463
+	 */
464
+	public function column__REG_date(EE_Registration $item)
465
+	{
466
+		$this->_set_related_details($item);
467
+		// Build row actions
468
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
469
+			[
470
+				'action' => 'view_transaction',
471
+				'TXN_ID' => $this->_transaction_details['id'],
472
+			],
473
+			TXN_ADMIN_URL
474
+		);
475
+		$view_link    = EE_Registry::instance()->CAP->current_user_can(
476
+			'ee_read_transaction',
477
+			'espresso_transactions_view_transaction'
478
+		)
479
+			? '<a class="ee-status-color-'
480
+			  . $this->_transaction_details['status']
481
+			  . '" href="'
482
+			  . $view_lnk_url
483
+			  . '" title="'
484
+			  . esc_attr($this->_transaction_details['title_attr'])
485
+			  . '">'
486
+			  . $item->get_i18n_datetime('REG_date')
487
+			  . '</a>'
488
+			: $item->get_i18n_datetime('REG_date');
489
+		$view_link    .= '<br><span class="ee-status-text-small">'
490
+						 . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
491
+						 . '</span>';
492
+		return $view_link;
493
+	}
494
+
495
+
496
+	/**
497
+	 * @param EE_Registration $item
498
+	 * @return string
499
+	 * @throws EE_Error
500
+	 * @throws InvalidArgumentException
501
+	 * @throws InvalidDataTypeException
502
+	 * @throws InvalidInterfaceException
503
+	 * @throws ReflectionException
504
+	 */
505
+	public function column_event_name(EE_Registration $item)
506
+	{
507
+		$this->_set_related_details($item);
508
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
509
+		$EVT_ID     = $item->event_ID();
510
+		$event_name = $item->event_name();
511
+		$event_name =
512
+			$event_name
513
+				?: esc_html__("No Associated Event", 'event_espresso');
514
+		$event_name = wp_trim_words($event_name, 30, '...');
515
+		if ($EVT_ID) {
516
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
517
+				['action' => 'edit', 'post' => $EVT_ID],
518
+				EVENTS_ADMIN_URL
519
+			);
520
+			$edit_event              =
521
+				EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
522
+					? '<a class="ee-status-color-'
523
+					  . $this->_event_details['status']
524
+					  . '" href="'
525
+					  . $edit_event_url
526
+					  . '" title="'
527
+					  . esc_attr($this->_event_details['title_attr'])
528
+					  . '">'
529
+					  . $event_name
530
+					  . '</a>'
531
+					: $event_name;
532
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
533
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
534
+			$actions['event_filter'] .= sprintf(
535
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
536
+				$event_name
537
+			);
538
+			$actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
539
+		} else {
540
+			$edit_event              = $event_name;
541
+			$actions['event_filter'] = '';
542
+		}
543
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
544
+	}
545
+
546
+
547
+	/**
548
+	 * @param EE_Registration $item
549
+	 * @return string
550
+	 * @throws EE_Error
551
+	 * @throws InvalidArgumentException
552
+	 * @throws InvalidDataTypeException
553
+	 * @throws InvalidInterfaceException
554
+	 * @throws ReflectionException
555
+	 */
556
+	public function column_DTT_EVT_start(EE_Registration $item)
557
+	{
558
+		$datetime_strings = [];
559
+		$ticket           = $item->ticket();
560
+		if ($ticket instanceof EE_Ticket) {
561
+			$remove_defaults = ['default_where_conditions' => 'none'];
562
+			$datetimes       = $ticket->datetimes($remove_defaults);
563
+			foreach ($datetimes as $datetime) {
564
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
565
+			}
566
+			return $this->generateDisplayForDatetimes($datetime_strings);
567
+		}
568
+		return esc_html__('There is no ticket on this registration', 'event_espresso');
569
+	}
570
+
571
+
572
+	/**
573
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
574
+	 *
575
+	 * @param array $datetime_strings
576
+	 * @return string
577
+	 */
578
+	public function generateDisplayForDateTimes(array $datetime_strings)
579
+	{
580
+		$content       = '<div class="ee-registration-event-datetimes-container">';
581
+		$expand_toggle = count($datetime_strings) > 1
582
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
583
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
584
+			: '';
585
+		// get first item for initial visibility
586
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
587
+		$content .= $expand_toggle;
588
+		if ($datetime_strings) {
589
+			$content .= '<div style="clear:both"></div>';
590
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
591
+			$content .= implode("<br />", $datetime_strings);
592
+			$content .= '</div>';
593
+		}
594
+		$content .= '</div>';
595
+		return $content;
596
+	}
597
+
598
+
599
+	/**
600
+	 * @param EE_Registration $item
601
+	 * @return string
602
+	 * @throws EE_Error
603
+	 * @throws InvalidArgumentException
604
+	 * @throws InvalidDataTypeException
605
+	 * @throws InvalidInterfaceException
606
+	 * @throws ReflectionException
607
+	 */
608
+	public function column_ATT_fname(EE_Registration $item)
609
+	{
610
+		$attendee      = $item->attendee();
611
+		$edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
612
+			[
613
+				'action'  => 'view_registration',
614
+				'_REG_ID' => $item->ID(),
615
+			],
616
+			REG_ADMIN_URL
617
+		);
618
+		$attendee_name = $attendee instanceof EE_Attendee
619
+			? $attendee->full_name()
620
+			: '';
621
+		$link          = EE_Registry::instance()->CAP->current_user_can(
622
+			'ee_read_registration',
623
+			'espresso_registrations_view_registration',
624
+			$item->ID()
625
+		)
626
+			? '<a href="'
627
+			  . $edit_lnk_url
628
+			  . '" title="'
629
+			  . esc_attr__('View Registration Details', 'event_espresso')
630
+			  . '">'
631
+			  . $attendee_name
632
+			  . '</a>'
633
+			: $attendee_name;
634
+		$link          .= $item->count() === 1
635
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
636
+			: '';
637
+		$t             = $item->get_first_related('Transaction');
638
+		$payment_count = $t instanceof EE_Transaction
639
+			? $t->count_related('Payment')
640
+			: 0;
641
+		// append group count to name
642
+		$link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
643
+		// append reg_code
644
+		$link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
645
+		// reg status text for accessibility
646
+		$link   .= '<br><span class="ee-status-text-small">'
647
+				   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
648
+				   . '</span>';
649
+		$action = ['_REG_ID' => $item->ID()];
650
+		if (isset($this->_req_data['event_id'])) {
651
+			$action['event_id'] = $item->event_ID();
652
+		}
653
+		// trash/restore/delete actions
654
+		$actions = [];
655
+		if (
656
+			$this->_view !== 'trash'
657
+			&& $payment_count === 0
658
+			&& EE_Registry::instance()->CAP->current_user_can(
659
+				'ee_delete_registration',
660
+				'espresso_registrations_trash_registrations',
661
+				$item->ID()
662
+			)
663
+		) {
664
+			$action['action'] = 'trash_registrations';
665
+			$trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
666
+				$action,
667
+				REG_ADMIN_URL
668
+			);
669
+			$actions['trash'] = '<a href="'
670
+								. $trash_lnk_url
671
+								. '" title="'
672
+								. esc_attr__('Trash Registration', 'event_espresso')
673
+								. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
674
+		} elseif ($this->_view === 'trash') {
675
+			// restore registration link
676
+			if (
677
+				EE_Registry::instance()->CAP->current_user_can(
678
+					'ee_delete_registration',
679
+					'espresso_registrations_restore_registrations',
680
+					$item->ID()
681
+				)
682
+			) {
683
+				$action['action']   = 'restore_registrations';
684
+				$restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
685
+					$action,
686
+					REG_ADMIN_URL
687
+				);
688
+				$actions['restore'] = '<a href="'
689
+									  . $restore_lnk_url
690
+									  . '" title="'
691
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
692
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
693
+			}
694
+			if (
695
+				EE_Registry::instance()->CAP->current_user_can(
696
+					'ee_delete_registration',
697
+					'espresso_registrations_ee_delete_registrations',
698
+					$item->ID()
699
+				)
700
+			) {
701
+				$action['action']  = 'delete_registrations';
702
+				$delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
703
+					$action,
704
+					REG_ADMIN_URL
705
+				);
706
+				$actions['delete'] = '<a href="'
707
+									 . $delete_lnk_url
708
+									 . '" title="'
709
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
710
+									 . '">'
711
+									 . esc_html__('Delete', 'event_espresso')
712
+									 . '</a>';
713
+			}
714
+		}
715
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
716
+	}
717
+
718
+
719
+	/**
720
+	 * @param EE_Registration $item
721
+	 * @return string
722
+	 * @throws EE_Error
723
+	 * @throws InvalidArgumentException
724
+	 * @throws InvalidDataTypeException
725
+	 * @throws InvalidInterfaceException
726
+	 * @throws ReflectionException
727
+	 */
728
+	public function column_ATT_email(EE_Registration $item)
729
+	{
730
+		$attendee = $item->get_first_related('Attendee');
731
+		return ! $attendee instanceof EE_Attendee
732
+			? esc_html__('No attached contact record.', 'event_espresso')
733
+			: $attendee->email();
734
+	}
735
+
736
+
737
+	/**
738
+	 * @param EE_Registration $item
739
+	 * @return string
740
+	 */
741
+	public function column__REG_count(EE_Registration $item)
742
+	{
743
+		return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
744
+	}
745
+
746
+
747
+	/**
748
+	 * @param EE_Registration $item
749
+	 * @return string
750
+	 * @throws EE_Error
751
+	 * @throws ReflectionException
752
+	 */
753
+	public function column_PRC_amount(EE_Registration $item)
754
+	{
755
+		$ticket   = $item->ticket();
756
+		$req_data = $this->_admin_page->get_request_data();
757
+		$content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
758
+			? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
759
+			: '';
760
+		if ($item->final_price() > 0) {
761
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
762
+		} else {
763
+			// free event
764
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
765
+						. esc_html__('free', 'event_espresso')
766
+						. '</span>';
767
+		}
768
+		return $content;
769
+	}
770
+
771
+
772
+	/**
773
+	 * @param EE_Registration $item
774
+	 * @return string
775
+	 * @throws EE_Error
776
+	 * @throws ReflectionException
777
+	 */
778
+	public function column__REG_final_price(EE_Registration $item)
779
+	{
780
+		$ticket   = $item->ticket();
781
+		$req_data = $this->_admin_page->get_request_data();
782
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
783
+			? ''
784
+			: '<span class="TKT_name">' . $ticket->name() . '</span><br />';
785
+		$content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
786
+		return $content;
787
+	}
788
+
789
+
790
+	/**
791
+	 * @param EE_Registration $item
792
+	 * @return string
793
+	 * @throws EE_Error
794
+	 */
795
+	public function column__REG_paid(EE_Registration $item)
796
+	{
797
+		$payment_method      = $item->payment_method();
798
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
799
+			? $payment_method->admin_name()
800
+			: esc_html__('Unknown', 'event_espresso');
801
+		$content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
802
+		if ($item->paid() > 0) {
803
+			$content .= '<br><span class="ee-status-text-small">'
804
+						. sprintf(
805
+							esc_html__('...via %s', 'event_espresso'),
806
+							$payment_method_name
807
+						)
808
+						. '</span>';
809
+		}
810
+		return $content;
811
+	}
812
+
813
+
814
+	/**
815
+	 * @param EE_Registration $item
816
+	 * @return string
817
+	 * @throws EE_Error
818
+	 * @throws EntityNotFoundException
819
+	 * @throws InvalidArgumentException
820
+	 * @throws InvalidDataTypeException
821
+	 * @throws InvalidInterfaceException
822
+	 * @throws ReflectionException
823
+	 */
824
+	public function column_TXN_total(EE_Registration $item)
825
+	{
826
+		if ($item->transaction()) {
827
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
828
+				[
829
+					'action' => 'view_transaction',
830
+					'TXN_ID' => $item->transaction_ID(),
831
+				],
832
+				TXN_ADMIN_URL
833
+			);
834
+			return EE_Registry::instance()->CAP->current_user_can(
835
+				'ee_read_transaction',
836
+				'espresso_transactions_view_transaction',
837
+				$item->transaction_ID()
838
+			)
839
+				? '<span class="reg-pad-rght"><a class="status-'
840
+				  . $item->transaction()->status_ID()
841
+				  . '" href="'
842
+				  . $view_txn_lnk_url
843
+				  . '"  title="'
844
+				  . esc_attr__('View Transaction', 'event_espresso')
845
+				  . '">'
846
+				  . $item->transaction()->pretty_total()
847
+				  . '</a></span>'
848
+				: '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
849
+		} else {
850
+			return esc_html__("None", "event_espresso");
851
+		}
852
+	}
853
+
854
+
855
+	/**
856
+	 * @param EE_Registration $item
857
+	 * @return string
858
+	 * @throws EE_Error
859
+	 * @throws EntityNotFoundException
860
+	 * @throws InvalidArgumentException
861
+	 * @throws InvalidDataTypeException
862
+	 * @throws InvalidInterfaceException
863
+	 * @throws ReflectionException
864
+	 */
865
+	public function column_TXN_paid(EE_Registration $item)
866
+	{
867
+		if ($item->count() === 1) {
868
+			$transaction = $item->transaction()
869
+				? $item->transaction()
870
+				: EE_Transaction::new_instance();
871
+			if ($transaction->paid() >= $transaction->total()) {
872
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
873
+			} else {
874
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
875
+					[
876
+						'action' => 'view_transaction',
877
+						'TXN_ID' => $item->transaction_ID(),
878
+					],
879
+					TXN_ADMIN_URL
880
+				);
881
+				return EE_Registry::instance()->CAP->current_user_can(
882
+					'ee_read_transaction',
883
+					'espresso_transactions_view_transaction',
884
+					$item->transaction_ID()
885
+				)
886
+					? '<span class="reg-pad-rght"><a class="status-'
887
+					  . $transaction->status_ID()
888
+					  . '" href="'
889
+					  . $view_txn_lnk_url
890
+					  . '"  title="'
891
+					  . esc_attr__('View Transaction', 'event_espresso')
892
+					  . '">'
893
+					  . $item->transaction()->pretty_paid()
894
+					  . '</a><span>'
895
+					: '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
896
+			}
897
+		}
898
+		return '&nbsp;';
899
+	}
900
+
901
+
902
+	/**
903
+	 * column_actions
904
+	 *
905
+	 * @param EE_Registration $item
906
+	 * @return string
907
+	 * @throws EE_Error
908
+	 * @throws InvalidArgumentException
909
+	 * @throws InvalidDataTypeException
910
+	 * @throws InvalidInterfaceException
911
+	 * @throws ReflectionException
912
+	 */
913
+	public function column_actions(EE_Registration $item)
914
+	{
915
+		$actions  = [];
916
+		$attendee = $item->attendee();
917
+		$this->_set_related_details($item);
918
+
919
+		// Build row actions
920
+		if (
921
+			EE_Registry::instance()->CAP->current_user_can(
922
+				'ee_read_registration',
923
+				'espresso_registrations_view_registration',
924
+				$item->ID()
925
+			)
926
+		) {
927
+			$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
928
+				[
929
+					'action'  => 'view_registration',
930
+					'_REG_ID' => $item->ID(),
931
+				],
932
+				REG_ADMIN_URL
933
+			);
934
+			$actions['view_lnk'] = '
935 935
             <li>
936 936
                 <a href="' . $view_lnk_url . '" title="'
937
-                . esc_attr__('View Registration Details', 'event_espresso')
938
-                . '" class="tiny-text">
937
+				. esc_attr__('View Registration Details', 'event_espresso')
938
+				. '" class="tiny-text">
939 939
 				    <div class="dashicons dashicons-clipboard"></div>
940 940
 			    </a>
941 941
 			</li>';
942
-        }
943
-
944
-        if (
945
-            $attendee instanceof EE_Attendee
946
-            && EE_Registry::instance()->CAP->current_user_can(
947
-                'ee_edit_contacts',
948
-                'espresso_registrations_edit_attendee'
949
-            )
950
-        ) {
951
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
952
-                [
953
-                    'action' => 'edit_attendee',
954
-                    'post'   => $item->attendee_ID(),
955
-                ],
956
-                REG_ADMIN_URL
957
-            );
958
-            $actions['edit_lnk'] = '
942
+		}
943
+
944
+		if (
945
+			$attendee instanceof EE_Attendee
946
+			&& EE_Registry::instance()->CAP->current_user_can(
947
+				'ee_edit_contacts',
948
+				'espresso_registrations_edit_attendee'
949
+			)
950
+		) {
951
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
952
+				[
953
+					'action' => 'edit_attendee',
954
+					'post'   => $item->attendee_ID(),
955
+				],
956
+				REG_ADMIN_URL
957
+			);
958
+			$actions['edit_lnk'] = '
959 959
 			<li>
960 960
                 <a href="' . $edit_lnk_url . '" title="'
961
-                . esc_attr__('Edit Contact Details', 'event_espresso')
962
-                . '" class="tiny-text">
961
+				. esc_attr__('Edit Contact Details', 'event_espresso')
962
+				. '" class="tiny-text">
963 963
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
964 964
                 </a>
965 965
 			</li>';
966
-        }
967
-
968
-        if (
969
-            $attendee instanceof EE_Attendee
970
-            && EE_Registry::instance()->CAP->current_user_can(
971
-                'ee_send_message',
972
-                'espresso_registrations_resend_registration',
973
-                $item->ID()
974
-            )
975
-        ) {
976
-            $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
977
-                [
978
-                    'action'  => 'resend_registration',
979
-                    '_REG_ID' => $item->ID(),
980
-                ],
981
-                REG_ADMIN_URL,
982
-                true
983
-            );
984
-            $actions['resend_reg_lnk'] = '
966
+		}
967
+
968
+		if (
969
+			$attendee instanceof EE_Attendee
970
+			&& EE_Registry::instance()->CAP->current_user_can(
971
+				'ee_send_message',
972
+				'espresso_registrations_resend_registration',
973
+				$item->ID()
974
+			)
975
+		) {
976
+			$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
977
+				[
978
+					'action'  => 'resend_registration',
979
+					'_REG_ID' => $item->ID(),
980
+				],
981
+				REG_ADMIN_URL,
982
+				true
983
+			);
984
+			$actions['resend_reg_lnk'] = '
985 985
 			<li>
986 986
 			    <a href="' . $resend_reg_lnk_url . '" title="'
987
-                . esc_attr__('Resend Registration Details', 'event_espresso')
988
-                . '" class="tiny-text">
987
+				. esc_attr__('Resend Registration Details', 'event_espresso')
988
+				. '" class="tiny-text">
989 989
 			        <div class="dashicons dashicons-email-alt"></div>
990 990
 			    </a>
991 991
             </li>';
992
-        }
993
-
994
-        if (
995
-            EE_Registry::instance()->CAP->current_user_can(
996
-                'ee_read_transaction',
997
-                'espresso_transactions_view_transaction',
998
-                $this->_transaction_details['id']
999
-            )
1000
-        ) {
1001
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1002
-                [
1003
-                    'action' => 'view_transaction',
1004
-                    'TXN_ID' => $this->_transaction_details['id'],
1005
-                ],
1006
-                TXN_ADMIN_URL
1007
-            );
1008
-            $actions['view_txn_lnk'] = '
992
+		}
993
+
994
+		if (
995
+			EE_Registry::instance()->CAP->current_user_can(
996
+				'ee_read_transaction',
997
+				'espresso_transactions_view_transaction',
998
+				$this->_transaction_details['id']
999
+			)
1000
+		) {
1001
+			$view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1002
+				[
1003
+					'action' => 'view_transaction',
1004
+					'TXN_ID' => $this->_transaction_details['id'],
1005
+				],
1006
+				TXN_ADMIN_URL
1007
+			);
1008
+			$actions['view_txn_lnk'] = '
1009 1009
 			<li>
1010 1010
                 <a class="ee-status-color-' . $this->_transaction_details['status']
1011
-                . ' tiny-text" href="' . $view_txn_lnk_url
1012
-                . '"  title="' . $this->_transaction_details['title_attr'] . '">
1011
+				. ' tiny-text" href="' . $view_txn_lnk_url
1012
+				. '"  title="' . $this->_transaction_details['title_attr'] . '">
1013 1013
                     <div class="dashicons dashicons-cart"></div>
1014 1014
                 </a>
1015 1015
 			</li>';
1016
-        }
1017
-
1018
-        // only show invoice link if message type is active.
1019
-        if (
1020
-            $attendee instanceof EE_Attendee
1021
-            && $item->is_primary_registrant()
1022
-            && EEH_MSG_Template::is_mt_active('invoice')
1023
-        ) {
1024
-            $actions['dl_invoice_lnk'] = '
1016
+		}
1017
+
1018
+		// only show invoice link if message type is active.
1019
+		if (
1020
+			$attendee instanceof EE_Attendee
1021
+			&& $item->is_primary_registrant()
1022
+			&& EEH_MSG_Template::is_mt_active('invoice')
1023
+		) {
1024
+			$actions['dl_invoice_lnk'] = '
1025 1025
             <li>
1026 1026
                 <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1027
-                . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1027
+				. '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1028 1028
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1029 1029
                 </a>
1030 1030
             </li>';
1031
-        }
1031
+		}
1032 1032
 
1033
-        // message list table link (filtered by REG_ID
1034
-        if (
1035
-            EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1036
-        ) {
1037
-            $actions['filtered_messages_link'] = '
1033
+		// message list table link (filtered by REG_ID
1034
+		if (
1035
+			EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1036
+		) {
1037
+			$actions['filtered_messages_link'] = '
1038 1038
             <li>
1039 1039
                 ' . EEH_MSG_Template::get_message_action_link(
1040
-                'see_notifications_for',
1041
-                null,
1042
-                ['_REG_ID' => $item->ID()]
1043
-            ) . '
1040
+				'see_notifications_for',
1041
+				null,
1042
+				['_REG_ID' => $item->ID()]
1043
+			) . '
1044 1044
             </li>';
1045
-        }
1045
+		}
1046 1046
 
1047
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1048
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1049
-    }
1047
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1048
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1049
+	}
1050 1050
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     public function __construct(Registrations_Admin_Page $admin_page)
50 50
     {
51 51
         $req_data = $admin_page->get_request_data();
52
-        if (! empty($req_data['event_id'])) {
52
+        if ( ! empty($req_data['event_id'])) {
53 53
             $extra_query_args = [];
54 54
             foreach ($admin_page->get_views() as $view_details) {
55
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
55
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
56 56
             }
57 57
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
58 58
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             'ajax'     => true,
85 85
             'screen'   => $this->_admin_page->get_current_screen()->id,
86 86
         ];
87
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
87
+        $ID_column_name = esc_html__('ID', 'event_espresso');
88 88
         $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
89 89
         $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
90 90
         $ID_column_name      .= '</span> ';
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
94 94
 
95 95
         if ($EVT_ID) {
96
-            $this->_columns        = [
96
+            $this->_columns = [
97 97
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
98 98
                 '_REG_ID'          => $ID_column_name,
99 99
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 'actions'          => esc_html__('Actions', 'event_espresso'),
107 107
             ];
108 108
         } else {
109
-            $this->_columns        = [
109
+            $this->_columns = [
110 110
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
111 111
                 '_REG_ID'          => $ID_column_name,
112 112
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         }
121 121
 
122 122
         $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
123
-        if (! empty($csv_report)) {
123
+        if ( ! empty($csv_report)) {
124 124
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
125 125
         }
126 126
 
127 127
         $this->_primary_column   = '_REG_ID';
128 128
         $this->_sortable_columns = [
129
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
129
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
130 130
             /**
131 131
              * Allows users to change the default sort if they wish.
132 132
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
144 144
             '_REG_ID'       => ['_REG_ID' => false],
145 145
         ];
146
-        $this->_hidden_columns   = [];
146
+        $this->_hidden_columns = [];
147 147
     }
148 148
 
149 149
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $class = parent::_get_row_class($item);
160 160
         // add status class
161
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
161
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
162 162
         if ($this->_has_checkbox_column) {
163 163
             $class .= ' has-checkbox-column';
164 164
         }
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
         $this_month_r    = date('m', current_time('timestamp'));
335 335
         $days_this_month = date('t', current_time('timestamp'));
336 336
         // setup date query.
337
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
337
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
338 338
             'REG_date',
339
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
339
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
340 340
             'Y-m-d H:i:s'
341 341
         );
342
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
342
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
343 343
             'REG_date',
344
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
344
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
345 345
             'Y-m-d H:i:s'
346 346
         );
347 347
         $_where['REG_date'] = [
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
                 $end_string,
352 352
             ],
353 353
         ];
354
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
354
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
355 355
         return EEM_Registration::instance()->count([$_where]);
356 356
     }
357 357
 
@@ -379,17 +379,17 @@  discard block
 block discarded – undo
379 379
             [
380 380
                 EEM_Registration::instance()->convert_datetime_for_query(
381 381
                     'REG_date',
382
-                    $current_date . $time_start,
382
+                    $current_date.$time_start,
383 383
                     'Y-m-d H:i:s'
384 384
                 ),
385 385
                 EEM_Registration::instance()->convert_datetime_for_query(
386 386
                     'REG_date',
387
-                    $current_date . $time_end,
387
+                    $current_date.$time_end,
388 388
                     'Y-m-d H:i:s'
389 389
                 ),
390 390
             ],
391 391
         ];
392
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
392
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
393 393
         return EEM_Registration::instance()->count([$_where]);
394 394
     }
395 395
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             ],
473 473
             TXN_ADMIN_URL
474 474
         );
475
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
475
+        $view_link = EE_Registry::instance()->CAP->current_user_can(
476 476
             'ee_read_transaction',
477 477
             'espresso_transactions_view_transaction'
478 478
         )
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
               . $item->get_i18n_datetime('REG_date')
487 487
               . '</a>'
488 488
             : $item->get_i18n_datetime('REG_date');
489
-        $view_link    .= '<br><span class="ee-status-text-small">'
489
+        $view_link .= '<br><span class="ee-status-text-small">'
490 490
                          . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
491 491
                          . '</span>';
492 492
         return $view_link;
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
                 ?: esc_html__("No Associated Event", 'event_espresso');
514 514
         $event_name = wp_trim_words($event_name, 30, '...');
515 515
         if ($EVT_ID) {
516
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
516
+            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
517 517
                 ['action' => 'edit', 'post' => $EVT_ID],
518 518
                 EVENTS_ADMIN_URL
519 519
             );
520
-            $edit_event              =
520
+            $edit_event =
521 521
                 EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
522 522
                     ? '<a class="ee-status-color-'
523 523
                       . $this->_event_details['status']
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
                       . '</a>'
531 531
                     : $event_name;
532 532
             $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
533
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
533
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
534 534
             $actions['event_filter'] .= sprintf(
535 535
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
536 536
                 $event_name
537 537
             );
538
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
538
+            $actions['event_filter'] .= '">'.esc_html__('View Registrations', 'event_espresso').'</a>';
539 539
         } else {
540 540
             $edit_event              = $event_name;
541 541
             $actions['event_filter'] = '';
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
     {
580 580
         $content       = '<div class="ee-registration-event-datetimes-container">';
581 581
         $expand_toggle = count($datetime_strings) > 1
582
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
582
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
583 583
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
584 584
             : '';
585 585
         // get first item for initial visibility
586
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
586
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
587 587
         $content .= $expand_toggle;
588 588
         if ($datetime_strings) {
589 589
             $content .= '<div style="clear:both"></div>';
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
               . $attendee_name
632 632
               . '</a>'
633 633
             : $attendee_name;
634
-        $link          .= $item->count() === 1
634
+        $link .= $item->count() === 1
635 635
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
636 636
             : '';
637 637
         $t             = $item->get_first_related('Transaction');
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
             ? $t->count_related('Payment')
640 640
             : 0;
641 641
         // append group count to name
642
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
642
+        $link .= '&nbsp;'.sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
643 643
         // append reg_code
644
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
644
+        $link .= '<br>'.sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
645 645
         // reg status text for accessibility
646
-        $link   .= '<br><span class="ee-status-text-small">'
646
+        $link .= '<br><span class="ee-status-text-small">'
647 647
                    . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
648 648
                    . '</span>';
649 649
         $action = ['_REG_ID' => $item->ID()];
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                                 . $trash_lnk_url
671 671
                                 . '" title="'
672 672
                                 . esc_attr__('Trash Registration', 'event_espresso')
673
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
673
+                                . '">'.esc_html__('Trash', 'event_espresso').'</a>';
674 674
         } elseif ($this->_view === 'trash') {
675 675
             // restore registration link
676 676
             if (
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
                 $actions['restore'] = '<a href="'
689 689
                                       . $restore_lnk_url
690 690
                                       . '" title="'
691
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
692
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
691
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
692
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
693 693
             }
694 694
             if (
695 695
                 EE_Registry::instance()->CAP->current_user_can(
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
         $ticket   = $item->ticket();
756 756
         $req_data = $this->_admin_page->get_request_data();
757 757
         $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
758
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
758
+            ? '<span class="TKT_name">'.$ticket->name().'</span><br />'
759 759
             : '';
760 760
         if ($item->final_price() > 0) {
761
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
761
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
762 762
         } else {
763 763
             // free event
764 764
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
         $req_data = $this->_admin_page->get_request_data();
782 782
         $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
783 783
             ? ''
784
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
785
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
784
+            : '<span class="TKT_name">'.$ticket->name().'</span><br />';
785
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
786 786
         return $content;
787 787
     }
788 788
 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
         $payment_method_name = $payment_method instanceof EE_Payment_Method
799 799
             ? $payment_method->admin_name()
800 800
             : esc_html__('Unknown', 'event_espresso');
801
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
801
+        $content             = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
802 802
         if ($item->paid() > 0) {
803 803
             $content .= '<br><span class="ee-status-text-small">'
804 804
                         . sprintf(
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
                   . '">'
846 846
                   . $item->transaction()->pretty_total()
847 847
                   . '</a></span>'
848
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
848
+                : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
849 849
         } else {
850 850
             return esc_html__("None", "event_espresso");
851 851
         }
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
                       . '">'
893 893
                       . $item->transaction()->pretty_paid()
894 894
                       . '</a><span>'
895
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
895
+                    : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
896 896
             }
897 897
         }
898 898
         return '&nbsp;';
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
             );
934 934
             $actions['view_lnk'] = '
935 935
             <li>
936
-                <a href="' . $view_lnk_url . '" title="'
936
+                <a href="' . $view_lnk_url.'" title="'
937 937
                 . esc_attr__('View Registration Details', 'event_espresso')
938 938
                 . '" class="tiny-text">
939 939
 				    <div class="dashicons dashicons-clipboard"></div>
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
             );
958 958
             $actions['edit_lnk'] = '
959 959
 			<li>
960
-                <a href="' . $edit_lnk_url . '" title="'
960
+                <a href="' . $edit_lnk_url.'" title="'
961 961
                 . esc_attr__('Edit Contact Details', 'event_espresso')
962 962
                 . '" class="tiny-text">
963 963
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
             );
984 984
             $actions['resend_reg_lnk'] = '
985 985
 			<li>
986
-			    <a href="' . $resend_reg_lnk_url . '" title="'
986
+			    <a href="' . $resend_reg_lnk_url.'" title="'
987 987
                 . esc_attr__('Resend Registration Details', 'event_espresso')
988 988
                 . '" class="tiny-text">
989 989
 			        <div class="dashicons dashicons-email-alt"></div>
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
                 $this->_transaction_details['id']
999 999
             )
1000 1000
         ) {
1001
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1001
+            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1002 1002
                 [
1003 1003
                     'action' => 'view_transaction',
1004 1004
                     'TXN_ID' => $this->_transaction_details['id'],
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
             $actions['view_txn_lnk'] = '
1009 1009
 			<li>
1010 1010
                 <a class="ee-status-color-' . $this->_transaction_details['status']
1011
-                . ' tiny-text" href="' . $view_txn_lnk_url
1012
-                . '"  title="' . $this->_transaction_details['title_attr'] . '">
1011
+                . ' tiny-text" href="'.$view_txn_lnk_url
1012
+                . '"  title="'.$this->_transaction_details['title_attr'].'">
1013 1013
                     <div class="dashicons dashicons-cart"></div>
1014 1014
                 </a>
1015 1015
 			</li>';
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
             $actions['dl_invoice_lnk'] = '
1025 1025
             <li>
1026 1026
                 <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1027
-                . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1027
+                . '" target="_blank" href="'.$item->invoice_url().'" class="tiny-text">
1028 1028
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1029 1029
                 </a>
1030 1030
             </li>';
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
                 'see_notifications_for',
1041 1041
                 null,
1042 1042
                 ['_REG_ID' => $item->ID()]
1043
-            ) . '
1043
+            ).'
1044 1044
             </li>';
1045 1045
         }
1046 1046
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3682 added lines, -3682 removed lines patch added patch discarded remove patch
@@ -21,2225 +21,2225 @@  discard block
 block discarded – undo
21 21
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Registration
26
-     */
27
-    private $_registration;
28
-
29
-    /**
30
-     * @var EE_Event
31
-     */
32
-    private $_reg_event;
33
-
34
-    /**
35
-     * @var EE_Session
36
-     */
37
-    private $_session;
38
-
39
-    /**
40
-     * @var array
41
-     */
42
-    private static $_reg_status;
43
-
44
-    /**
45
-     * Form for displaying the custom questions for this registration.
46
-     * This gets used a few times throughout the request so its best to cache it
47
-     *
48
-     * @var EE_Registration_Custom_Questions_Form
49
-     */
50
-    protected $_reg_custom_questions_form = null;
51
-
52
-    /**
53
-     * @var EEM_Registration $registration_model
54
-     */
55
-    private $registration_model;
56
-
57
-    /**
58
-     * @var EEM_Attendee $attendee_model
59
-     */
60
-    private $attendee_model;
61
-
62
-    /**
63
-     * @var EEM_Event $event_model
64
-     */
65
-    private $event_model;
66
-
67
-    /**
68
-     * @var EEM_Status $status_model
69
-     */
70
-    private $status_model;
71
-
72
-
73
-    /**
74
-     * @param bool $routing
75
-     * @throws EE_Error
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws InvalidInterfaceException
79
-     * @throws ReflectionException
80
-     */
81
-    public function __construct($routing = true)
82
-    {
83
-        parent::__construct($routing);
84
-        add_action('wp_loaded', [$this, 'wp_loaded']);
85
-    }
86
-
87
-
88
-    /**
89
-     * @return EEM_Registration
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     * @since 4.10.2.p
94
-     */
95
-    protected function getRegistrationModel()
96
-    {
97
-        if (! $this->registration_model instanceof EEM_Registration) {
98
-            $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
99
-        }
100
-        return $this->registration_model;
101
-    }
102
-
103
-
104
-    /**
105
-     * @return EEM_Attendee
106
-     * @throws InvalidArgumentException
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     * @since 4.10.2.p
110
-     */
111
-    protected function getAttendeeModel()
112
-    {
113
-        if (! $this->attendee_model instanceof EEM_Attendee) {
114
-            $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
115
-        }
116
-        return $this->attendee_model;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return EEM_Event
122
-     * @throws InvalidArgumentException
123
-     * @throws InvalidDataTypeException
124
-     * @throws InvalidInterfaceException
125
-     * @since 4.10.2.p
126
-     */
127
-    protected function getEventModel()
128
-    {
129
-        if (! $this->event_model instanceof EEM_Event) {
130
-            $this->event_model = $this->getLoader()->getShared('EEM_Event');
131
-        }
132
-        return $this->event_model;
133
-    }
134
-
135
-
136
-    /**
137
-     * @return EEM_Status
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidInterfaceException
141
-     * @since 4.10.2.p
142
-     */
143
-    protected function getStatusModel()
144
-    {
145
-        if (! $this->status_model instanceof EEM_Status) {
146
-            $this->status_model = $this->getLoader()->getShared('EEM_Status');
147
-        }
148
-        return $this->status_model;
149
-    }
150
-
151
-
152
-    public function wp_loaded()
153
-    {
154
-        // when adding a new registration...
155
-        $action = $this->request->getRequestParam('action');
156
-        if ($action === 'new_registration') {
157
-            EE_System::do_not_cache();
158
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
159
-                // and it's NOT the attendee information reg step
160
-                // force cookie expiration by setting time to last week
161
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
162
-                // and update the global
163
-                $_COOKIE['ee_registration_added'] = 0;
164
-            }
165
-        }
166
-    }
167
-
168
-
169
-    protected function _init_page_props()
170
-    {
171
-        $this->page_slug        = REG_PG_SLUG;
172
-        $this->_admin_base_url  = REG_ADMIN_URL;
173
-        $this->_admin_base_path = REG_ADMIN;
174
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
175
-        $this->_cpt_routes      = [
176
-            'add_new_attendee' => 'espresso_attendees',
177
-            'edit_attendee'    => 'espresso_attendees',
178
-            'insert_attendee'  => 'espresso_attendees',
179
-            'update_attendee'  => 'espresso_attendees',
180
-        ];
181
-        $this->_cpt_model_names = [
182
-            'add_new_attendee' => 'EEM_Attendee',
183
-            'edit_attendee'    => 'EEM_Attendee',
184
-        ];
185
-        $this->_cpt_edit_routes = [
186
-            'espresso_attendees' => 'edit_attendee',
187
-        ];
188
-        $this->_pagenow_map     = [
189
-            'add_new_attendee' => 'post-new.php',
190
-            'edit_attendee'    => 'post.php',
191
-            'trash'            => 'post.php',
192
-        ];
193
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
194
-        // add filters so that the comment urls don't take users to a confusing 404 page
195
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
196
-    }
197
-
198
-
199
-    /**
200
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
201
-     * @param WP_Comment $comment The current comment object.
202
-     * @return string
203
-     */
204
-    public function clear_comment_link($link, WP_Comment $comment)
205
-    {
206
-        // gotta make sure this only happens on this route
207
-        $post_type = get_post_type($comment->comment_post_ID);
208
-        if ($post_type === 'espresso_attendees') {
209
-            return '#commentsdiv';
210
-        }
211
-        return $link;
212
-    }
213
-
214
-
215
-    protected function _ajax_hooks()
216
-    {
217
-        // todo: all hooks for registrations ajax goes in here
218
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
219
-    }
220
-
221
-
222
-    protected function _define_page_props()
223
-    {
224
-        $this->_admin_page_title = $this->page_label;
225
-        $this->_labels           = [
226
-            'buttons'                      => [
227
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
228
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
229
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
230
-                'csv_reg_report'      => esc_html__('Registrations CSV Report', 'event_espresso'),
231
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
232
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
233
-            ],
234
-            'publishbox'                   => [
235
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
236
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
237
-            ],
238
-            'hide_add_button_on_cpt_route' => [
239
-                'edit_attendee' => true,
240
-            ],
241
-        ];
242
-    }
243
-
244
-
245
-    /**
246
-     * grab url requests and route them
247
-     *
248
-     * @return void
249
-     * @throws EE_Error
250
-     */
251
-    public function _set_page_routes()
252
-    {
253
-        $this->_get_registration_status_array();
254
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
255
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
256
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
257
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
258
-        $this->_page_routes = [
259
-            'default'                             => [
260
-                'func'       => [$this, '_registrations_overview_list_table'],
261
-                'capability' => 'ee_read_registrations',
262
-            ],
263
-            'view_registration'                   => [
264
-                'func'       => '_registration_details',
265
-                'capability' => 'ee_read_registration',
266
-                'obj_id'     => $REG_ID,
267
-            ],
268
-            'edit_registration'                   => [
269
-                'func'               => '_update_attendee_registration_form',
270
-                'noheader'           => true,
271
-                'headers_sent_route' => 'view_registration',
272
-                'capability'         => 'ee_edit_registration',
273
-                'obj_id'             => $REG_ID,
274
-                '_REG_ID'            => $REG_ID,
275
-            ],
276
-            'trash_registrations'                 => [
277
-                'func'       => '_trash_or_restore_registrations',
278
-                'args'       => ['trash' => true],
279
-                'noheader'   => true,
280
-                'capability' => 'ee_delete_registrations',
281
-            ],
282
-            'restore_registrations'               => [
283
-                'func'       => '_trash_or_restore_registrations',
284
-                'args'       => ['trash' => false],
285
-                'noheader'   => true,
286
-                'capability' => 'ee_delete_registrations',
287
-            ],
288
-            'delete_registrations'                => [
289
-                'func'       => '_delete_registrations',
290
-                'noheader'   => true,
291
-                'capability' => 'ee_delete_registrations',
292
-            ],
293
-            'new_registration'                    => [
294
-                'func'       => 'new_registration',
295
-                'capability' => 'ee_edit_registrations',
296
-            ],
297
-            'process_reg_step'                    => [
298
-                'func'       => 'process_reg_step',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-            ],
302
-            'redirect_to_txn'                     => [
303
-                'func'       => 'redirect_to_txn',
304
-                'noheader'   => true,
305
-                'capability' => 'ee_edit_registrations',
306
-            ],
307
-            'change_reg_status'                   => [
308
-                'func'       => '_change_reg_status',
309
-                'noheader'   => true,
310
-                'capability' => 'ee_edit_registration',
311
-                'obj_id'     => $REG_ID,
312
-            ],
313
-            'approve_registration'                => [
314
-                'func'       => 'approve_registration',
315
-                'noheader'   => true,
316
-                'capability' => 'ee_edit_registration',
317
-                'obj_id'     => $REG_ID,
318
-            ],
319
-            'approve_and_notify_registration'     => [
320
-                'func'       => 'approve_registration',
321
-                'noheader'   => true,
322
-                'args'       => [true],
323
-                'capability' => 'ee_edit_registration',
324
-                'obj_id'     => $REG_ID,
325
-            ],
326
-            'approve_registrations'               => [
327
-                'func'       => 'bulk_action_on_registrations',
328
-                'noheader'   => true,
329
-                'capability' => 'ee_edit_registrations',
330
-                'args'       => ['approve'],
331
-            ],
332
-            'approve_and_notify_registrations'    => [
333
-                'func'       => 'bulk_action_on_registrations',
334
-                'noheader'   => true,
335
-                'capability' => 'ee_edit_registrations',
336
-                'args'       => ['approve', true],
337
-            ],
338
-            'decline_registration'                => [
339
-                'func'       => 'decline_registration',
340
-                'noheader'   => true,
341
-                'capability' => 'ee_edit_registration',
342
-                'obj_id'     => $REG_ID,
343
-            ],
344
-            'decline_and_notify_registration'     => [
345
-                'func'       => 'decline_registration',
346
-                'noheader'   => true,
347
-                'args'       => [true],
348
-                'capability' => 'ee_edit_registration',
349
-                'obj_id'     => $REG_ID,
350
-            ],
351
-            'decline_registrations'               => [
352
-                'func'       => 'bulk_action_on_registrations',
353
-                'noheader'   => true,
354
-                'capability' => 'ee_edit_registrations',
355
-                'args'       => ['decline'],
356
-            ],
357
-            'decline_and_notify_registrations'    => [
358
-                'func'       => 'bulk_action_on_registrations',
359
-                'noheader'   => true,
360
-                'capability' => 'ee_edit_registrations',
361
-                'args'       => ['decline', true],
362
-            ],
363
-            'pending_registration'                => [
364
-                'func'       => 'pending_registration',
365
-                'noheader'   => true,
366
-                'capability' => 'ee_edit_registration',
367
-                'obj_id'     => $REG_ID,
368
-            ],
369
-            'pending_and_notify_registration'     => [
370
-                'func'       => 'pending_registration',
371
-                'noheader'   => true,
372
-                'args'       => [true],
373
-                'capability' => 'ee_edit_registration',
374
-                'obj_id'     => $REG_ID,
375
-            ],
376
-            'pending_registrations'               => [
377
-                'func'       => 'bulk_action_on_registrations',
378
-                'noheader'   => true,
379
-                'capability' => 'ee_edit_registrations',
380
-                'args'       => ['pending'],
381
-            ],
382
-            'pending_and_notify_registrations'    => [
383
-                'func'       => 'bulk_action_on_registrations',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_registrations',
386
-                'args'       => ['pending', true],
387
-            ],
388
-            'no_approve_registration'             => [
389
-                'func'       => 'not_approve_registration',
390
-                'noheader'   => true,
391
-                'capability' => 'ee_edit_registration',
392
-                'obj_id'     => $REG_ID,
393
-            ],
394
-            'no_approve_and_notify_registration'  => [
395
-                'func'       => 'not_approve_registration',
396
-                'noheader'   => true,
397
-                'args'       => [true],
398
-                'capability' => 'ee_edit_registration',
399
-                'obj_id'     => $REG_ID,
400
-            ],
401
-            'no_approve_registrations'            => [
402
-                'func'       => 'bulk_action_on_registrations',
403
-                'noheader'   => true,
404
-                'capability' => 'ee_edit_registrations',
405
-                'args'       => ['not_approve'],
406
-            ],
407
-            'no_approve_and_notify_registrations' => [
408
-                'func'       => 'bulk_action_on_registrations',
409
-                'noheader'   => true,
410
-                'capability' => 'ee_edit_registrations',
411
-                'args'       => ['not_approve', true],
412
-            ],
413
-            'cancel_registration'                 => [
414
-                'func'       => 'cancel_registration',
415
-                'noheader'   => true,
416
-                'capability' => 'ee_edit_registration',
417
-                'obj_id'     => $REG_ID,
418
-            ],
419
-            'cancel_and_notify_registration'      => [
420
-                'func'       => 'cancel_registration',
421
-                'noheader'   => true,
422
-                'args'       => [true],
423
-                'capability' => 'ee_edit_registration',
424
-                'obj_id'     => $REG_ID,
425
-            ],
426
-            'cancel_registrations'                => [
427
-                'func'       => 'bulk_action_on_registrations',
428
-                'noheader'   => true,
429
-                'capability' => 'ee_edit_registrations',
430
-                'args'       => ['cancel'],
431
-            ],
432
-            'cancel_and_notify_registrations'     => [
433
-                'func'       => 'bulk_action_on_registrations',
434
-                'noheader'   => true,
435
-                'capability' => 'ee_edit_registrations',
436
-                'args'       => ['cancel', true],
437
-            ],
438
-            'wait_list_registration'              => [
439
-                'func'       => 'wait_list_registration',
440
-                'noheader'   => true,
441
-                'capability' => 'ee_edit_registration',
442
-                'obj_id'     => $REG_ID,
443
-            ],
444
-            'wait_list_and_notify_registration'   => [
445
-                'func'       => 'wait_list_registration',
446
-                'noheader'   => true,
447
-                'args'       => [true],
448
-                'capability' => 'ee_edit_registration',
449
-                'obj_id'     => $REG_ID,
450
-            ],
451
-            'contact_list'                        => [
452
-                'func'       => '_attendee_contact_list_table',
453
-                'capability' => 'ee_read_contacts',
454
-            ],
455
-            'add_new_attendee'                    => [
456
-                'func' => '_create_new_cpt_item',
457
-                'args' => [
458
-                    'new_attendee' => true,
459
-                    'capability'   => 'ee_edit_contacts',
460
-                ],
461
-            ],
462
-            'edit_attendee'                       => [
463
-                'func'       => '_edit_cpt_item',
464
-                'capability' => 'ee_edit_contacts',
465
-                'obj_id'     => $ATT_ID,
466
-            ],
467
-            'duplicate_attendee'                  => [
468
-                'func'       => '_duplicate_attendee',
469
-                'noheader'   => true,
470
-                'capability' => 'ee_edit_contacts',
471
-                'obj_id'     => $ATT_ID,
472
-            ],
473
-            'insert_attendee'                     => [
474
-                'func'       => '_insert_or_update_attendee',
475
-                'args'       => [
476
-                    'new_attendee' => true,
477
-                ],
478
-                'noheader'   => true,
479
-                'capability' => 'ee_edit_contacts',
480
-            ],
481
-            'update_attendee'                     => [
482
-                'func'       => '_insert_or_update_attendee',
483
-                'args'       => [
484
-                    'new_attendee' => false,
485
-                ],
486
-                'noheader'   => true,
487
-                'capability' => 'ee_edit_contacts',
488
-                'obj_id'     => $ATT_ID,
489
-            ],
490
-            'trash_attendees'                     => [
491
-                'func'       => '_trash_or_restore_attendees',
492
-                'args'       => [
493
-                    'trash' => 'true',
494
-                ],
495
-                'noheader'   => true,
496
-                'capability' => 'ee_delete_contacts',
497
-            ],
498
-            'trash_attendee'                      => [
499
-                'func'       => '_trash_or_restore_attendees',
500
-                'args'       => [
501
-                    'trash' => true,
502
-                ],
503
-                'noheader'   => true,
504
-                'capability' => 'ee_delete_contacts',
505
-                'obj_id'     => $ATT_ID,
506
-            ],
507
-            'restore_attendees'                   => [
508
-                'func'       => '_trash_or_restore_attendees',
509
-                'args'       => [
510
-                    'trash' => false,
511
-                ],
512
-                'noheader'   => true,
513
-                'capability' => 'ee_delete_contacts',
514
-                'obj_id'     => $ATT_ID,
515
-            ],
516
-            'resend_registration'                 => [
517
-                'func'       => '_resend_registration',
518
-                'noheader'   => true,
519
-                'capability' => 'ee_send_message',
520
-            ],
521
-            'registrations_report'                => [
522
-                'func'       => [$this, '_registrations_report'],
523
-                'noheader'   => true,
524
-                'capability' => 'ee_read_registrations',
525
-            ],
526
-            'contact_list_export'                 => [
527
-                'func'       => '_contact_list_export',
528
-                'noheader'   => true,
529
-                'capability' => 'export',
530
-            ],
531
-            'contact_list_report'                 => [
532
-                'func'       => '_contact_list_report',
533
-                'noheader'   => true,
534
-                'capability' => 'ee_read_contacts',
535
-            ],
536
-        ];
537
-    }
538
-
539
-
540
-    protected function _set_page_config()
541
-    {
542
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
543
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
544
-        $this->_page_config = [
545
-            'default'           => [
546
-                'nav'           => [
547
-                    'label' => esc_html__('Overview', 'event_espresso'),
548
-                    'order' => 5,
549
-                ],
550
-                'help_tabs'     => [
551
-                    'registrations_overview_help_tab'                       => [
552
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
-                        'filename' => 'registrations_overview',
554
-                    ],
555
-                    'registrations_overview_table_column_headings_help_tab' => [
556
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
-                        'filename' => 'registrations_overview_table_column_headings',
558
-                    ],
559
-                    'registrations_overview_filters_help_tab'               => [
560
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
-                        'filename' => 'registrations_overview_filters',
562
-                    ],
563
-                    'registrations_overview_views_help_tab'                 => [
564
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
565
-                        'filename' => 'registrations_overview_views',
566
-                    ],
567
-                    'registrations_regoverview_other_help_tab'              => [
568
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
-                        'filename' => 'registrations_overview_other',
570
-                    ],
571
-                ],
572
-                'qtips'         => ['Registration_List_Table_Tips'],
573
-                'list_table'    => 'EE_Registrations_List_Table',
574
-                'require_nonce' => false,
575
-            ],
576
-            'view_registration' => [
577
-                'nav'           => [
578
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
579
-                    'order'      => 15,
580
-                    'url'        => $REG_ID
581
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
-                        : $this->_admin_base_url,
583
-                    'persistent' => false,
584
-                ],
585
-                'help_tabs'     => [
586
-                    'registrations_details_help_tab'                    => [
587
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
588
-                        'filename' => 'registrations_details',
589
-                    ],
590
-                    'registrations_details_table_help_tab'              => [
591
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
-                        'filename' => 'registrations_details_table',
593
-                    ],
594
-                    'registrations_details_form_answers_help_tab'       => [
595
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
-                        'filename' => 'registrations_details_form_answers',
597
-                    ],
598
-                    'registrations_details_registrant_details_help_tab' => [
599
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
600
-                        'filename' => 'registrations_details_registrant_details',
601
-                    ],
602
-                ],
603
-                'metaboxes'     => array_merge(
604
-                    $this->_default_espresso_metaboxes,
605
-                    ['_registration_details_metaboxes']
606
-                ),
607
-                'require_nonce' => false,
608
-            ],
609
-            'new_registration'  => [
610
-                'nav'           => [
611
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
-                    'url'        => '#',
613
-                    'order'      => 15,
614
-                    'persistent' => false,
615
-                ],
616
-                'metaboxes'     => $this->_default_espresso_metaboxes,
617
-                'labels'        => [
618
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
619
-                ],
620
-                'require_nonce' => false,
621
-            ],
622
-            'add_new_attendee'  => [
623
-                'nav'           => [
624
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
625
-                    'order'      => 15,
626
-                    'persistent' => false,
627
-                ],
628
-                'metaboxes'     => array_merge(
629
-                    $this->_default_espresso_metaboxes,
630
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
631
-                ),
632
-                'require_nonce' => false,
633
-            ],
634
-            'edit_attendee'     => [
635
-                'nav'           => [
636
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
637
-                    'order'      => 15,
638
-                    'persistent' => false,
639
-                    'url'        => $ATT_ID
640
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
641
-                        : $this->_admin_base_url,
642
-                ],
643
-                'metaboxes'     => ['attendee_editor_metaboxes'],
644
-                'require_nonce' => false,
645
-            ],
646
-            'contact_list'      => [
647
-                'nav'           => [
648
-                    'label' => esc_html__('Contact List', 'event_espresso'),
649
-                    'order' => 20,
650
-                ],
651
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
652
-                'help_tabs'     => [
653
-                    'registrations_contact_list_help_tab'                       => [
654
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
655
-                        'filename' => 'registrations_contact_list',
656
-                    ],
657
-                    'registrations_contact-list_table_column_headings_help_tab' => [
658
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
659
-                        'filename' => 'registrations_contact_list_table_column_headings',
660
-                    ],
661
-                    'registrations_contact_list_views_help_tab'                 => [
662
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
663
-                        'filename' => 'registrations_contact_list_views',
664
-                    ],
665
-                    'registrations_contact_list_other_help_tab'                 => [
666
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
667
-                        'filename' => 'registrations_contact_list_other',
668
-                    ],
669
-                ],
670
-                'metaboxes'     => [],
671
-                'require_nonce' => false,
672
-            ],
673
-            // override default cpt routes
674
-            'create_new'        => '',
675
-            'edit'              => '',
676
-        ];
677
-    }
678
-
679
-
680
-    /**
681
-     * The below methods aren't used by this class currently
682
-     */
683
-    protected function _add_screen_options()
684
-    {
685
-    }
686
-
687
-
688
-    protected function _add_feature_pointers()
689
-    {
690
-    }
691
-
692
-
693
-    public function admin_init()
694
-    {
695
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
696
-            'click "Update Registration Questions" to save your changes',
697
-            'event_espresso'
698
-        );
699
-    }
700
-
701
-
702
-    public function admin_notices()
703
-    {
704
-    }
705
-
706
-
707
-    public function admin_footer_scripts()
708
-    {
709
-    }
710
-
711
-
712
-    /**
713
-     * get list of registration statuses
714
-     *
715
-     * @return void
716
-     * @throws EE_Error
717
-     */
718
-    private function _get_registration_status_array()
719
-    {
720
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
721
-    }
722
-
723
-
724
-    /**
725
-     * @throws InvalidArgumentException
726
-     * @throws InvalidDataTypeException
727
-     * @throws InvalidInterfaceException
728
-     * @since 4.10.2.p
729
-     */
730
-    protected function _add_screen_options_default()
731
-    {
732
-        $this->_per_page_screen_option();
733
-    }
734
-
735
-
736
-    /**
737
-     * @throws InvalidArgumentException
738
-     * @throws InvalidDataTypeException
739
-     * @throws InvalidInterfaceException
740
-     * @since 4.10.2.p
741
-     */
742
-    protected function _add_screen_options_contact_list()
743
-    {
744
-        $page_title              = $this->_admin_page_title;
745
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
746
-        $this->_per_page_screen_option();
747
-        $this->_admin_page_title = $page_title;
748
-    }
749
-
750
-
751
-    public function load_scripts_styles()
752
-    {
753
-        // style
754
-        wp_register_style(
755
-            'espresso_reg',
756
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
757
-            ['ee-admin-css'],
758
-            EVENT_ESPRESSO_VERSION
759
-        );
760
-        wp_enqueue_style('espresso_reg');
761
-        // script
762
-        wp_register_script(
763
-            'espresso_reg',
764
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
765
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
766
-            EVENT_ESPRESSO_VERSION,
767
-            true
768
-        );
769
-        wp_enqueue_script('espresso_reg');
770
-    }
771
-
772
-
773
-    /**
774
-     * @throws EE_Error
775
-     * @throws InvalidArgumentException
776
-     * @throws InvalidDataTypeException
777
-     * @throws InvalidInterfaceException
778
-     * @throws ReflectionException
779
-     * @since 4.10.2.p
780
-     */
781
-    public function load_scripts_styles_edit_attendee()
782
-    {
783
-        // stuff to only show up on our attendee edit details page.
784
-        $attendee_details_translations = [
785
-            'att_publish_text' => sprintf(
786
-            /* translators: The date and time */
787
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
788
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
789
-            ),
790
-        ];
791
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
792
-        wp_enqueue_script('jquery-validate');
793
-    }
794
-
795
-
796
-    /**
797
-     * @throws EE_Error
798
-     * @throws InvalidArgumentException
799
-     * @throws InvalidDataTypeException
800
-     * @throws InvalidInterfaceException
801
-     * @throws ReflectionException
802
-     * @since 4.10.2.p
803
-     */
804
-    public function load_scripts_styles_view_registration()
805
-    {
806
-        // styles
807
-        wp_enqueue_style('espresso-ui-theme');
808
-        // scripts
809
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
810
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
811
-    }
812
-
813
-
814
-    public function load_scripts_styles_contact_list()
815
-    {
816
-        wp_dequeue_style('espresso_reg');
817
-        wp_register_style(
818
-            'espresso_att',
819
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
820
-            ['ee-admin-css'],
821
-            EVENT_ESPRESSO_VERSION
822
-        );
823
-        wp_enqueue_style('espresso_att');
824
-    }
825
-
826
-
827
-    public function load_scripts_styles_new_registration()
828
-    {
829
-        wp_register_script(
830
-            'ee-spco-for-admin',
831
-            REG_ASSETS_URL . 'spco_for_admin.js',
832
-            ['underscore', 'jquery'],
833
-            EVENT_ESPRESSO_VERSION,
834
-            true
835
-        );
836
-        wp_enqueue_script('ee-spco-for-admin');
837
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
838
-        EE_Form_Section_Proper::wp_enqueue_scripts();
839
-        EED_Ticket_Selector::load_tckt_slctr_assets();
840
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
841
-    }
842
-
843
-
844
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
845
-    {
846
-        add_filter('FHEE_load_EE_messages', '__return_true');
847
-    }
848
-
849
-
850
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
851
-    {
852
-        add_filter('FHEE_load_EE_messages', '__return_true');
853
-    }
854
-
855
-
856
-    /**
857
-     * @throws EE_Error
858
-     * @throws InvalidArgumentException
859
-     * @throws InvalidDataTypeException
860
-     * @throws InvalidInterfaceException
861
-     * @throws ReflectionException
862
-     * @since 4.10.2.p
863
-     */
864
-    protected function _set_list_table_views_default()
865
-    {
866
-        // for notification related bulk actions we need to make sure only active messengers have an option.
867
-        EED_Messages::set_autoloaders();
868
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
869
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
870
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
871
-        // key= bulk_action_slug, value= message type.
872
-        $match_array = [
873
-            'approve_registrations'    => 'registration',
874
-            'decline_registrations'    => 'declined_registration',
875
-            'pending_registrations'    => 'pending_approval',
876
-            'no_approve_registrations' => 'not_approved_registration',
877
-            'cancel_registrations'     => 'cancelled_registration',
878
-        ];
879
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
880
-            'ee_send_message',
881
-            'batch_send_messages'
882
-        );
883
-        /** setup reg status bulk actions **/
884
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
885
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
886
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
887
-                'Approve and Notify Registrations',
888
-                'event_espresso'
889
-            );
890
-        }
891
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
892
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
893
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
894
-                'Decline and Notify Registrations',
895
-                'event_espresso'
896
-            );
897
-        }
898
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
899
-            'Set Registrations to Pending Payment',
900
-            'event_espresso'
901
-        );
902
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
903
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
904
-                'Set Registrations to Pending Payment and Notify',
905
-                'event_espresso'
906
-            );
907
-        }
908
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
909
-            'Set Registrations to Not Approved',
910
-            'event_espresso'
911
-        );
912
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
913
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
914
-                'Set Registrations to Not Approved and Notify',
915
-                'event_espresso'
916
-            );
917
-        }
918
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
919
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
920
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
921
-                'Cancel Registrations and Notify',
922
-                'event_espresso'
923
-            );
924
-        }
925
-        $def_reg_status_actions = apply_filters(
926
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
927
-            $def_reg_status_actions,
928
-            $active_mts,
929
-            $can_send
930
-        );
931
-
932
-        $this->_views = [
933
-            'all'   => [
934
-                'slug'        => 'all',
935
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
936
-                'count'       => 0,
937
-                'bulk_action' => array_merge(
938
-                    $def_reg_status_actions,
939
-                    [
940
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
941
-                    ]
942
-                ),
943
-            ],
944
-            'month' => [
945
-                'slug'        => 'month',
946
-                'label'       => esc_html__('This Month', 'event_espresso'),
947
-                'count'       => 0,
948
-                'bulk_action' => array_merge(
949
-                    $def_reg_status_actions,
950
-                    [
951
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
952
-                    ]
953
-                ),
954
-            ],
955
-            'today' => [
956
-                'slug'        => 'today',
957
-                'label'       => sprintf(
958
-                    esc_html__('Today - %s', 'event_espresso'),
959
-                    date('M d, Y', current_time('timestamp'))
960
-                ),
961
-                'count'       => 0,
962
-                'bulk_action' => array_merge(
963
-                    $def_reg_status_actions,
964
-                    [
965
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
966
-                    ]
967
-                ),
968
-            ],
969
-        ];
970
-        if (
971
-            EE_Registry::instance()->CAP->current_user_can(
972
-                'ee_delete_registrations',
973
-                'espresso_registrations_delete_registration'
974
-            )
975
-        ) {
976
-            $this->_views['incomplete'] = [
977
-                'slug'        => 'incomplete',
978
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
979
-                'count'       => 0,
980
-                'bulk_action' => [
981
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
982
-                ],
983
-            ];
984
-            $this->_views['trash']      = [
985
-                'slug'        => 'trash',
986
-                'label'       => esc_html__('Trash', 'event_espresso'),
987
-                'count'       => 0,
988
-                'bulk_action' => [
989
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
990
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
991
-                ],
992
-            ];
993
-        }
994
-    }
995
-
996
-
997
-    protected function _set_list_table_views_contact_list()
998
-    {
999
-        $this->_views = [
1000
-            'in_use' => [
1001
-                'slug'        => 'in_use',
1002
-                'label'       => esc_html__('In Use', 'event_espresso'),
1003
-                'count'       => 0,
1004
-                'bulk_action' => [
1005
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1006
-                ],
1007
-            ],
1008
-        ];
1009
-        if (
1010
-            EE_Registry::instance()->CAP->current_user_can(
1011
-                'ee_delete_contacts',
1012
-                'espresso_registrations_trash_attendees'
1013
-            )
1014
-        ) {
1015
-            $this->_views['trash'] = [
1016
-                'slug'        => 'trash',
1017
-                'label'       => esc_html__('Trash', 'event_espresso'),
1018
-                'count'       => 0,
1019
-                'bulk_action' => [
1020
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1021
-                ],
1022
-            ];
1023
-        }
1024
-    }
1025
-
1026
-
1027
-    /**
1028
-     * @return array
1029
-     * @throws EE_Error
1030
-     */
1031
-    protected function _registration_legend_items()
1032
-    {
1033
-        $fc_items = [
1034
-            'star-icon'        => [
1035
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1036
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1037
-            ],
1038
-            'view_details'     => [
1039
-                'class' => 'dashicons dashicons-clipboard',
1040
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1041
-            ],
1042
-            'edit_attendee'    => [
1043
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1044
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1045
-            ],
1046
-            'view_transaction' => [
1047
-                'class' => 'dashicons dashicons-cart',
1048
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1049
-            ],
1050
-            'view_invoice'     => [
1051
-                'class' => 'dashicons dashicons-media-spreadsheet',
1052
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1053
-            ],
1054
-        ];
1055
-        if (
1056
-            EE_Registry::instance()->CAP->current_user_can(
1057
-                'ee_send_message',
1058
-                'espresso_registrations_resend_registration'
1059
-            )
1060
-        ) {
1061
-            $fc_items['resend_registration'] = [
1062
-                'class' => 'dashicons dashicons-email-alt',
1063
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1064
-            ];
1065
-        } else {
1066
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1067
-        }
1068
-        if (
1069
-            EE_Registry::instance()->CAP->current_user_can(
1070
-                'ee_read_global_messages',
1071
-                'view_filtered_messages'
1072
-            )
1073
-        ) {
1074
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1075
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1076
-                $fc_items['view_related_messages'] = [
1077
-                    'class' => $related_for_icon['css_class'],
1078
-                    'desc'  => $related_for_icon['label'],
1079
-                ];
1080
-            }
1081
-        }
1082
-        $sc_items = [
1083
-            'approved_status'   => [
1084
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1085
-                'desc'  => EEH_Template::pretty_status(
1086
-                    EEM_Registration::status_id_approved,
1087
-                    false,
1088
-                    'sentence'
1089
-                ),
1090
-            ],
1091
-            'pending_status'    => [
1092
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1093
-                'desc'  => EEH_Template::pretty_status(
1094
-                    EEM_Registration::status_id_pending_payment,
1095
-                    false,
1096
-                    'sentence'
1097
-                ),
1098
-            ],
1099
-            'wait_list'         => [
1100
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1101
-                'desc'  => EEH_Template::pretty_status(
1102
-                    EEM_Registration::status_id_wait_list,
1103
-                    false,
1104
-                    'sentence'
1105
-                ),
1106
-            ],
1107
-            'incomplete_status' => [
1108
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1109
-                'desc'  => EEH_Template::pretty_status(
1110
-                    EEM_Registration::status_id_incomplete,
1111
-                    false,
1112
-                    'sentence'
1113
-                ),
1114
-            ],
1115
-            'not_approved'      => [
1116
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1117
-                'desc'  => EEH_Template::pretty_status(
1118
-                    EEM_Registration::status_id_not_approved,
1119
-                    false,
1120
-                    'sentence'
1121
-                ),
1122
-            ],
1123
-            'declined_status'   => [
1124
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1125
-                'desc'  => EEH_Template::pretty_status(
1126
-                    EEM_Registration::status_id_declined,
1127
-                    false,
1128
-                    'sentence'
1129
-                ),
1130
-            ],
1131
-            'cancelled_status'  => [
1132
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1133
-                'desc'  => EEH_Template::pretty_status(
1134
-                    EEM_Registration::status_id_cancelled,
1135
-                    false,
1136
-                    'sentence'
1137
-                ),
1138
-            ],
1139
-        ];
1140
-        return array_merge($fc_items, $sc_items);
1141
-    }
1142
-
1143
-
1144
-
1145
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1146
-
1147
-
1148
-    /**
1149
-     * @throws DomainException
1150
-     * @throws EE_Error
1151
-     * @throws InvalidArgumentException
1152
-     * @throws InvalidDataTypeException
1153
-     * @throws InvalidInterfaceException
1154
-     */
1155
-    protected function _registrations_overview_list_table()
1156
-    {
1157
-        $this->appendAddNewRegistrationButtonToPageTitle();
1158
-        $header_text                  = '';
1159
-        $admin_page_header_decorators = [
1160
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1161
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1162
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1163
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1164
-        ];
1165
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1166
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1167
-            $header_text             = $filter_header_decorator->getHeaderText($header_text);
1168
-        }
1169
-        $this->_template_args['admin_page_header'] = $header_text;
1170
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1171
-        $this->display_admin_list_table_page_with_no_sidebar();
1172
-    }
1173
-
1174
-
1175
-    /**
1176
-     * @throws EE_Error
1177
-     * @throws InvalidArgumentException
1178
-     * @throws InvalidDataTypeException
1179
-     * @throws InvalidInterfaceException
1180
-     */
1181
-    private function appendAddNewRegistrationButtonToPageTitle()
1182
-    {
1183
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1184
-        if (
1185
-            $EVT_ID
1186
-            && EE_Registry::instance()->CAP->current_user_can(
1187
-                'ee_edit_registrations',
1188
-                'espresso_registrations_new_registration',
1189
-                $EVT_ID
1190
-            )
1191
-        ) {
1192
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1193
-                'new_registration',
1194
-                'add-registrant',
1195
-                ['event_id' => $EVT_ID],
1196
-                'add-new-h2'
1197
-            );
1198
-        }
1199
-    }
1200
-
1201
-
1202
-    /**
1203
-     * This sets the _registration property for the registration details screen
1204
-     *
1205
-     * @return void
1206
-     * @throws EE_Error
1207
-     * @throws InvalidArgumentException
1208
-     * @throws InvalidDataTypeException
1209
-     * @throws InvalidInterfaceException
1210
-     */
1211
-    private function _set_registration_object()
1212
-    {
1213
-        // get out if we've already set the object
1214
-        if ($this->_registration instanceof EE_Registration) {
1215
-            return;
1216
-        }
1217
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1218
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1219
-            return;
1220
-        }
1221
-        $error_msg = sprintf(
1222
-            esc_html__(
1223
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1224
-                'event_espresso'
1225
-            ),
1226
-            $REG_ID
1227
-        );
1228
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1229
-        $this->_registration = null;
1230
-    }
1231
-
1232
-
1233
-    /**
1234
-     * Used to retrieve registrations for the list table.
1235
-     *
1236
-     * @param int  $per_page
1237
-     * @param bool $count
1238
-     * @param bool $this_month
1239
-     * @param bool $today
1240
-     * @return EE_Registration[]|int
1241
-     * @throws EE_Error
1242
-     * @throws InvalidArgumentException
1243
-     * @throws InvalidDataTypeException
1244
-     * @throws InvalidInterfaceException
1245
-     */
1246
-    public function get_registrations(
1247
-        $per_page = 10,
1248
-        $count = false,
1249
-        $this_month = false,
1250
-        $today = false
1251
-    ) {
1252
-        if ($this_month) {
1253
-            $this->request->setRequestParam('status', 'month');
1254
-        }
1255
-        if ($today) {
1256
-            $this->request->setRequestParam('status', 'today');
1257
-        }
1258
-        $query_params = $this->_get_registration_query_parameters([], $per_page, $count);
1259
-        /**
1260
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1261
-         *
1262
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1263
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1264
-         *                      or if you have the development copy of EE you can view this at the path:
1265
-         *                      /docs/G--Model-System/model-query-params.md
1266
-         */
1267
-        $query_params['group_by'] = '';
1268
-
1269
-        return $count
1270
-            ? $this->getRegistrationModel()->count($query_params)
1271
-            /** @type EE_Registration[] */
1272
-            : $this->getRegistrationModel()->get_all($query_params);
1273
-    }
1274
-
1275
-
1276
-    /**
1277
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1278
-     * Note: this listens to values on the request for some of the query parameters.
1279
-     *
1280
-     * @param array $request
1281
-     * @param int   $per_page
1282
-     * @param bool  $count
1283
-     * @return array
1284
-     * @throws EE_Error
1285
-     * @throws InvalidArgumentException
1286
-     * @throws InvalidDataTypeException
1287
-     * @throws InvalidInterfaceException
1288
-     */
1289
-    protected function _get_registration_query_parameters(
1290
-        $request = [],
1291
-        $per_page = 10,
1292
-        $count = false
1293
-    ) {
1294
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1295
-        $list_table_query_builder = $this->getLoader()->getNew(
1296
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1297
-            [null, null, $request]
1298
-        );
1299
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1300
-    }
1301
-
1302
-
1303
-    public function get_registration_status_array()
1304
-    {
1305
-        return self::$_reg_status;
1306
-    }
1307
-
1308
-
1309
-
1310
-
1311
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1312
-    /**
1313
-     * generates HTML for the View Registration Details Admin page
1314
-     *
1315
-     * @return void
1316
-     * @throws DomainException
1317
-     * @throws EE_Error
1318
-     * @throws InvalidArgumentException
1319
-     * @throws InvalidDataTypeException
1320
-     * @throws InvalidInterfaceException
1321
-     * @throws EntityNotFoundException
1322
-     * @throws ReflectionException
1323
-     */
1324
-    protected function _registration_details()
1325
-    {
1326
-        $this->_template_args = [];
1327
-        $this->_set_registration_object();
1328
-        if (is_object($this->_registration)) {
1329
-            $transaction                                   = $this->_registration->transaction()
1330
-                ? $this->_registration->transaction()
1331
-                : EE_Transaction::new_instance();
1332
-            $this->_session                                = $transaction->session_data();
1333
-            $event_id                                      = $this->_registration->event_ID();
1334
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1335
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1336
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1337
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1338
-            $this->_template_args['grand_total']           = $transaction->total();
1339
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1340
-            // link back to overview
1341
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1342
-            $this->_template_args['registration']                = $this->_registration;
1343
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1344
-                [
1345
-                    'action'   => 'default',
1346
-                    'event_id' => $event_id,
1347
-                ],
1348
-                REG_ADMIN_URL
1349
-            );
1350
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1351
-                [
1352
-                    'action' => 'default',
1353
-                    'EVT_ID' => $event_id,
1354
-                    'page'   => 'espresso_transactions',
1355
-                ],
1356
-                admin_url('admin.php')
1357
-            );
1358
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1359
-                [
1360
-                    'page'   => 'espresso_events',
1361
-                    'action' => 'edit',
1362
-                    'post'   => $event_id,
1363
-                ],
1364
-                admin_url('admin.php')
1365
-            );
1366
-            // next and previous links
1367
-            $next_reg                                      = $this->_registration->next(
1368
-                null,
1369
-                [],
1370
-                'REG_ID'
1371
-            );
1372
-            $this->_template_args['next_registration']     = $next_reg
1373
-                ? $this->_next_link(
1374
-                    EE_Admin_Page::add_query_args_and_nonce(
1375
-                        [
1376
-                            'action'  => 'view_registration',
1377
-                            '_REG_ID' => $next_reg['REG_ID'],
1378
-                        ],
1379
-                        REG_ADMIN_URL
1380
-                    ),
1381
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1382
-                )
1383
-                : '';
1384
-            $previous_reg                                  = $this->_registration->previous(
1385
-                null,
1386
-                [],
1387
-                'REG_ID'
1388
-            );
1389
-            $this->_template_args['previous_registration'] = $previous_reg
1390
-                ? $this->_previous_link(
1391
-                    EE_Admin_Page::add_query_args_and_nonce(
1392
-                        [
1393
-                            'action'  => 'view_registration',
1394
-                            '_REG_ID' => $previous_reg['REG_ID'],
1395
-                        ],
1396
-                        REG_ADMIN_URL
1397
-                    ),
1398
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1399
-                )
1400
-                : '';
1401
-            // grab header
1402
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1403
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1404
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1405
-                $template_path,
1406
-                $this->_template_args,
1407
-                true
1408
-            );
1409
-        } else {
1410
-            $this->_template_args['admin_page_header'] = '';
1411
-            $this->_display_espresso_notices();
1412
-        }
1413
-        // the details template wrapper
1414
-        $this->display_admin_page_with_sidebar();
1415
-    }
1416
-
1417
-
1418
-    /**
1419
-     * @throws EE_Error
1420
-     * @throws InvalidArgumentException
1421
-     * @throws InvalidDataTypeException
1422
-     * @throws InvalidInterfaceException
1423
-     * @throws ReflectionException
1424
-     * @since 4.10.2.p
1425
-     */
1426
-    protected function _registration_details_metaboxes()
1427
-    {
1428
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1429
-        $this->_set_registration_object();
1430
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1431
-        add_meta_box(
1432
-            'edit-reg-status-mbox',
1433
-            esc_html__('Registration Status', 'event_espresso'),
1434
-            [$this, 'set_reg_status_buttons_metabox'],
1435
-            $this->_wp_page_slug,
1436
-            'normal',
1437
-            'high'
1438
-        );
1439
-        add_meta_box(
1440
-            'edit-reg-details-mbox',
1441
-            esc_html__('Registration Details', 'event_espresso'),
1442
-            [$this, '_reg_details_meta_box'],
1443
-            $this->_wp_page_slug,
1444
-            'normal',
1445
-            'high'
1446
-        );
1447
-        if (
1448
-            $attendee instanceof EE_Attendee
1449
-            && EE_Registry::instance()->CAP->current_user_can(
1450
-                'ee_read_registration',
1451
-                'edit-reg-questions-mbox',
1452
-                $this->_registration->ID()
1453
-            )
1454
-        ) {
1455
-            add_meta_box(
1456
-                'edit-reg-questions-mbox',
1457
-                esc_html__('Registration Form Answers', 'event_espresso'),
1458
-                [$this, '_reg_questions_meta_box'],
1459
-                $this->_wp_page_slug,
1460
-                'normal',
1461
-                'high'
1462
-            );
1463
-        }
1464
-        add_meta_box(
1465
-            'edit-reg-registrant-mbox',
1466
-            esc_html__('Contact Details', 'event_espresso'),
1467
-            [$this, '_reg_registrant_side_meta_box'],
1468
-            $this->_wp_page_slug,
1469
-            'side',
1470
-            'high'
1471
-        );
1472
-        if ($this->_registration->group_size() > 1) {
1473
-            add_meta_box(
1474
-                'edit-reg-attendees-mbox',
1475
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1476
-                [$this, '_reg_attendees_meta_box'],
1477
-                $this->_wp_page_slug,
1478
-                'normal',
1479
-                'high'
1480
-            );
1481
-        }
1482
-    }
1483
-
1484
-
1485
-    /**
1486
-     * set_reg_status_buttons_metabox
1487
-     *
1488
-     * @return void
1489
-     * @throws EE_Error
1490
-     * @throws EntityNotFoundException
1491
-     * @throws InvalidArgumentException
1492
-     * @throws InvalidDataTypeException
1493
-     * @throws InvalidInterfaceException
1494
-     * @throws ReflectionException
1495
-     */
1496
-    public function set_reg_status_buttons_metabox()
1497
-    {
1498
-        $this->_set_registration_object();
1499
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1500
-        $output                 = $change_reg_status_form->form_open(
1501
-            self::add_query_args_and_nonce(
1502
-                [
1503
-                    'action' => 'change_reg_status',
1504
-                ],
1505
-                REG_ADMIN_URL
1506
-            )
1507
-        );
1508
-        $output                 .= $change_reg_status_form->get_html();
1509
-        $output                 .= $change_reg_status_form->form_close();
1510
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1511
-    }
1512
-
1513
-
1514
-    /**
1515
-     * @return EE_Form_Section_Proper
1516
-     * @throws EE_Error
1517
-     * @throws InvalidArgumentException
1518
-     * @throws InvalidDataTypeException
1519
-     * @throws InvalidInterfaceException
1520
-     * @throws EntityNotFoundException
1521
-     * @throws ReflectionException
1522
-     */
1523
-    protected function _generate_reg_status_change_form()
1524
-    {
1525
-        $reg_status_change_form_array = [
1526
-            'name'            => 'reg_status_change_form',
1527
-            'html_id'         => 'reg-status-change-form',
1528
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1529
-            'subsections'     => [
1530
-                'return'         => new EE_Hidden_Input(
1531
-                    [
1532
-                        'name'    => 'return',
1533
-                        'default' => 'view_registration',
1534
-                    ]
1535
-                ),
1536
-                'REG_ID'         => new EE_Hidden_Input(
1537
-                    [
1538
-                        'name'    => 'REG_ID',
1539
-                        'default' => $this->_registration->ID(),
1540
-                    ]
1541
-                ),
1542
-                'current_status' => new EE_Form_Section_HTML(
1543
-                    EEH_HTML::table(
1544
-                        EEH_HTML::tr(
1545
-                            EEH_HTML::th(
1546
-                                EEH_HTML::label(
1547
-                                    EEH_HTML::strong(
1548
-                                        esc_html__('Current Registration Status', 'event_espresso')
1549
-                                    )
1550
-                                )
1551
-                            )
1552
-                            . EEH_HTML::td(
1553
-                                EEH_HTML::strong(
1554
-                                    $this->_registration->pretty_status(),
1555
-                                    '',
1556
-                                    'status-' . $this->_registration->status_ID(),
1557
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1558
-                                )
1559
-                            )
1560
-                        )
1561
-                    )
1562
-                ),
1563
-            ],
1564
-        ];
1565
-        if (
1566
-            EE_Registry::instance()->CAP->current_user_can(
1567
-                'ee_edit_registration',
1568
-                'toggle_registration_status',
1569
-                $this->_registration->ID()
1570
-            )
1571
-        ) {
1572
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1573
-                $this->_get_reg_statuses(),
1574
-                [
1575
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1576
-                    'default'         => $this->_registration->status_ID(),
1577
-                ]
1578
-            );
1579
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1580
-                [
1581
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1582
-                    'default'         => false,
1583
-                    'html_help_text'  => esc_html__(
1584
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1585
-                        'event_espresso'
1586
-                    ),
1587
-                ]
1588
-            );
1589
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1590
-                [
1591
-                    'html_class'      => 'button-primary',
1592
-                    'html_label_text' => '&nbsp;',
1593
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1594
-                ]
1595
-            );
1596
-        }
1597
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1598
-    }
1599
-
1600
-
1601
-    /**
1602
-     * Returns an array of all the buttons for the various statuses and switch status actions
1603
-     *
1604
-     * @return array
1605
-     * @throws EE_Error
1606
-     * @throws InvalidArgumentException
1607
-     * @throws InvalidDataTypeException
1608
-     * @throws InvalidInterfaceException
1609
-     * @throws EntityNotFoundException
1610
-     */
1611
-    protected function _get_reg_statuses()
1612
-    {
1613
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1614
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1615
-        // get current reg status
1616
-        $current_status = $this->_registration->status_ID();
1617
-        // is registration for free event? This will determine whether to display the pending payment option
1618
-        if (
1619
-            $current_status !== EEM_Registration::status_id_pending_payment
1620
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1621
-        ) {
1622
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1623
-        }
1624
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1625
-    }
1626
-
1627
-
1628
-    /**
1629
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1630
-     *
1631
-     * @param bool $status REG status given for changing registrations to.
1632
-     * @param bool $notify Whether to send messages notifications or not.
1633
-     * @return array (array with reg_id(s) updated and whether update was successful.
1634
-     * @throws DomainException
1635
-     * @throws EE_Error
1636
-     * @throws EntityNotFoundException
1637
-     * @throws InvalidArgumentException
1638
-     * @throws InvalidDataTypeException
1639
-     * @throws InvalidInterfaceException
1640
-     * @throws ReflectionException
1641
-     * @throws RuntimeException
1642
-     */
1643
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1644
-    {
1645
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1646
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1647
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1648
-
1649
-        // sanitize $REG_IDs
1650
-        $REG_IDs = array_map('absint', $REG_IDs);
1651
-        // and remove empty entries
1652
-        $REG_IDs = array_filter($REG_IDs);
1653
-
1654
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1655
-
1656
-        /**
1657
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1658
-         * Currently this value is used downstream by the _process_resend_registration method.
1659
-         *
1660
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1661
-         * @param bool                     $status           The status registrations were changed to.
1662
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1663
-         * @param Registrations_Admin_Page $admin_page_object
1664
-         */
1665
-        $REG_ID = apply_filters(
1666
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1667
-            $result['REG_ID'],
1668
-            $status,
1669
-            $result['success'],
1670
-            $this
1671
-        );
1672
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1673
-
1674
-        // notify?
1675
-        if (
1676
-            $notify
1677
-            && $result['success']
1678
-            && ! empty($REG_ID)
1679
-            && EE_Registry::instance()->CAP->current_user_can(
1680
-                'ee_send_message',
1681
-                'espresso_registrations_resend_registration'
1682
-            )
1683
-        ) {
1684
-            $this->_process_resend_registration();
1685
-        }
1686
-        return $result;
1687
-    }
1688
-
1689
-
1690
-    /**
1691
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1692
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1693
-     *
1694
-     * @param array  $REG_IDs
1695
-     * @param string $status
1696
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1697
-     *                       slug sent with setting the registration status.
1698
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1699
-     * @throws EE_Error
1700
-     * @throws InvalidArgumentException
1701
-     * @throws InvalidDataTypeException
1702
-     * @throws InvalidInterfaceException
1703
-     * @throws ReflectionException
1704
-     * @throws RuntimeException
1705
-     * @throws EntityNotFoundException
1706
-     * @throws DomainException
1707
-     */
1708
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1709
-    {
1710
-        $success = false;
1711
-        // typecast $REG_IDs
1712
-        $REG_IDs = (array) $REG_IDs;
1713
-        if (! empty($REG_IDs)) {
1714
-            $success = true;
1715
-            // set default status if none is passed
1716
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1717
-            $status_context = $notify
1718
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1719
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1720
-            // loop through REG_ID's and change status
1721
-            foreach ($REG_IDs as $REG_ID) {
1722
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1723
-                if ($registration instanceof EE_Registration) {
1724
-                    $registration->set_status(
1725
-                        $status,
1726
-                        false,
1727
-                        new Context(
1728
-                            $status_context,
1729
-                            esc_html__(
1730
-                                'Manually triggered status change on a Registration Admin Page route.',
1731
-                                'event_espresso'
1732
-                            )
1733
-                        )
1734
-                    );
1735
-                    $result = $registration->save();
1736
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1737
-                    $success = $result !== false ? $success : false;
1738
-                }
1739
-            }
1740
-        }
1741
-
1742
-        // return $success and processed registrations
1743
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1744
-    }
1745
-
1746
-
1747
-    /**
1748
-     * Common logic for setting up success message and redirecting to appropriate route
1749
-     *
1750
-     * @param string $STS_ID status id for the registration changed to
1751
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1752
-     * @return void
1753
-     * @throws DomainException
1754
-     * @throws EE_Error
1755
-     * @throws EntityNotFoundException
1756
-     * @throws InvalidArgumentException
1757
-     * @throws InvalidDataTypeException
1758
-     * @throws InvalidInterfaceException
1759
-     * @throws ReflectionException
1760
-     * @throws RuntimeException
1761
-     */
1762
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1763
-    {
1764
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1765
-            : ['success' => false];
1766
-        $success = isset($result['success']) && $result['success'];
1767
-        // setup success message
1768
-        if ($success) {
1769
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1770
-                $msg = sprintf(
1771
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1772
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1773
-                );
1774
-            } else {
1775
-                $msg = sprintf(
1776
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1777
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1778
-                );
1779
-            }
1780
-            EE_Error::add_success($msg);
1781
-        } else {
1782
-            EE_Error::add_error(
1783
-                esc_html__(
1784
-                    'Something went wrong, and the status was not changed',
1785
-                    'event_espresso'
1786
-                ),
1787
-                __FILE__,
1788
-                __LINE__,
1789
-                __FUNCTION__
1790
-            );
1791
-        }
1792
-        $return = $this->request->getRequestParam('return');
1793
-        $route  = $return === 'view_registration'
1794
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1795
-            : ['action' => 'default'];
1796
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1797
-        $this->_redirect_after_action($success, '', '', $route, true);
1798
-    }
1799
-
1800
-
1801
-    /**
1802
-     * incoming reg status change from reg details page.
1803
-     *
1804
-     * @return void
1805
-     * @throws EE_Error
1806
-     * @throws EntityNotFoundException
1807
-     * @throws InvalidArgumentException
1808
-     * @throws InvalidDataTypeException
1809
-     * @throws InvalidInterfaceException
1810
-     * @throws ReflectionException
1811
-     * @throws RuntimeException
1812
-     * @throws DomainException
1813
-     */
1814
-    protected function _change_reg_status()
1815
-    {
1816
-        $this->request->setRequestParam('return', 'view_registration');
1817
-        // set notify based on whether the send notifications toggle is set or not
1818
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1819
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1820
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1821
-        switch ($reg_status) {
1822
-            case EEM_Registration::status_id_approved:
1823
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1824
-                $this->approve_registration($notify);
1825
-                break;
1826
-            case EEM_Registration::status_id_pending_payment:
1827
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1828
-                $this->pending_registration($notify);
1829
-                break;
1830
-            case EEM_Registration::status_id_not_approved:
1831
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1832
-                $this->not_approve_registration($notify);
1833
-                break;
1834
-            case EEM_Registration::status_id_declined:
1835
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1836
-                $this->decline_registration($notify);
1837
-                break;
1838
-            case EEM_Registration::status_id_cancelled:
1839
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1840
-                $this->cancel_registration($notify);
1841
-                break;
1842
-            case EEM_Registration::status_id_wait_list:
1843
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1844
-                $this->wait_list_registration($notify);
1845
-                break;
1846
-            case EEM_Registration::status_id_incomplete:
1847
-            default:
1848
-                $this->request->unSetRequestParam('return');
1849
-                $this->_reg_status_change_return('');
1850
-                break;
1851
-        }
1852
-    }
1853
-
1854
-
1855
-    /**
1856
-     * Callback for bulk action routes.
1857
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1858
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1859
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1860
-     * when an action is happening on just a single registration).
1861
-     *
1862
-     * @param      $action
1863
-     * @param bool $notify
1864
-     */
1865
-    protected function bulk_action_on_registrations($action, $notify = false)
1866
-    {
1867
-        do_action(
1868
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1869
-            $this,
1870
-            $action,
1871
-            $notify
1872
-        );
1873
-        $method = $action . '_registration';
1874
-        if (method_exists($this, $method)) {
1875
-            $this->$method($notify);
1876
-        }
1877
-    }
1878
-
1879
-
1880
-    /**
1881
-     * approve_registration
1882
-     *
1883
-     * @param bool $notify whether or not to notify the registrant about their approval.
1884
-     * @return void
1885
-     * @throws EE_Error
1886
-     * @throws EntityNotFoundException
1887
-     * @throws InvalidArgumentException
1888
-     * @throws InvalidDataTypeException
1889
-     * @throws InvalidInterfaceException
1890
-     * @throws ReflectionException
1891
-     * @throws RuntimeException
1892
-     * @throws DomainException
1893
-     */
1894
-    protected function approve_registration($notify = false)
1895
-    {
1896
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1897
-    }
1898
-
1899
-
1900
-    /**
1901
-     * decline_registration
1902
-     *
1903
-     * @param bool $notify whether or not to notify the registrant about their status change.
1904
-     * @return void
1905
-     * @throws EE_Error
1906
-     * @throws EntityNotFoundException
1907
-     * @throws InvalidArgumentException
1908
-     * @throws InvalidDataTypeException
1909
-     * @throws InvalidInterfaceException
1910
-     * @throws ReflectionException
1911
-     * @throws RuntimeException
1912
-     * @throws DomainException
1913
-     */
1914
-    protected function decline_registration($notify = false)
1915
-    {
1916
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1917
-    }
1918
-
1919
-
1920
-    /**
1921
-     * cancel_registration
1922
-     *
1923
-     * @param bool $notify whether or not to notify the registrant about their status change.
1924
-     * @return void
1925
-     * @throws EE_Error
1926
-     * @throws EntityNotFoundException
1927
-     * @throws InvalidArgumentException
1928
-     * @throws InvalidDataTypeException
1929
-     * @throws InvalidInterfaceException
1930
-     * @throws ReflectionException
1931
-     * @throws RuntimeException
1932
-     * @throws DomainException
1933
-     */
1934
-    protected function cancel_registration($notify = false)
1935
-    {
1936
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1937
-    }
1938
-
1939
-
1940
-    /**
1941
-     * not_approve_registration
1942
-     *
1943
-     * @param bool $notify whether or not to notify the registrant about their status change.
1944
-     * @return void
1945
-     * @throws EE_Error
1946
-     * @throws EntityNotFoundException
1947
-     * @throws InvalidArgumentException
1948
-     * @throws InvalidDataTypeException
1949
-     * @throws InvalidInterfaceException
1950
-     * @throws ReflectionException
1951
-     * @throws RuntimeException
1952
-     * @throws DomainException
1953
-     */
1954
-    protected function not_approve_registration($notify = false)
1955
-    {
1956
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1957
-    }
1958
-
1959
-
1960
-    /**
1961
-     * decline_registration
1962
-     *
1963
-     * @param bool $notify whether or not to notify the registrant about their status change.
1964
-     * @return void
1965
-     * @throws EE_Error
1966
-     * @throws EntityNotFoundException
1967
-     * @throws InvalidArgumentException
1968
-     * @throws InvalidDataTypeException
1969
-     * @throws InvalidInterfaceException
1970
-     * @throws ReflectionException
1971
-     * @throws RuntimeException
1972
-     * @throws DomainException
1973
-     */
1974
-    protected function pending_registration($notify = false)
1975
-    {
1976
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1977
-    }
1978
-
1979
-
1980
-    /**
1981
-     * waitlist_registration
1982
-     *
1983
-     * @param bool $notify whether or not to notify the registrant about their status change.
1984
-     * @return void
1985
-     * @throws EE_Error
1986
-     * @throws EntityNotFoundException
1987
-     * @throws InvalidArgumentException
1988
-     * @throws InvalidDataTypeException
1989
-     * @throws InvalidInterfaceException
1990
-     * @throws ReflectionException
1991
-     * @throws RuntimeException
1992
-     * @throws DomainException
1993
-     */
1994
-    protected function wait_list_registration($notify = false)
1995
-    {
1996
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1997
-    }
1998
-
1999
-
2000
-    /**
2001
-     * generates HTML for the Registration main meta box
2002
-     *
2003
-     * @return void
2004
-     * @throws DomainException
2005
-     * @throws EE_Error
2006
-     * @throws InvalidArgumentException
2007
-     * @throws InvalidDataTypeException
2008
-     * @throws InvalidInterfaceException
2009
-     * @throws ReflectionException
2010
-     * @throws EntityNotFoundException
2011
-     */
2012
-    public function _reg_details_meta_box()
2013
-    {
2014
-        EEH_Autoloader::register_line_item_display_autoloaders();
2015
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2016
-        EE_Registry::instance()->load_helper('Line_Item');
2017
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2018
-            : EE_Transaction::new_instance();
2019
-        $this->_session = $transaction->session_data();
2020
-        $filters        = new EE_Line_Item_Filter_Collection();
2021
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2022
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2023
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2024
-            $filters,
2025
-            $transaction->total_line_item()
2026
-        );
2027
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2028
-        $line_item_display                       = new EE_Line_Item_Display(
2029
-            'reg_admin_table',
2030
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2031
-        );
2032
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2033
-            $filtered_line_item_tree,
2034
-            ['EE_Registration' => $this->_registration]
2035
-        );
2036
-        $attendee                                = $this->_registration->attendee();
2037
-        if (
2038
-            EE_Registry::instance()->CAP->current_user_can(
2039
-                'ee_read_transaction',
2040
-                'espresso_transactions_view_transaction'
2041
-            )
2042
-        ) {
2043
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2044
-                EE_Admin_Page::add_query_args_and_nonce(
2045
-                    [
2046
-                        'action' => 'view_transaction',
2047
-                        'TXN_ID' => $transaction->ID(),
2048
-                    ],
2049
-                    TXN_ADMIN_URL
2050
-                ),
2051
-                esc_html__(' View Transaction', 'event_espresso'),
2052
-                'button secondary-button right',
2053
-                'dashicons dashicons-cart'
2054
-            );
2055
-        } else {
2056
-            $this->_template_args['view_transaction_button'] = '';
2057
-        }
2058
-        if (
2059
-            $attendee instanceof EE_Attendee
2060
-            && EE_Registry::instance()->CAP->current_user_can(
2061
-                'ee_send_message',
2062
-                'espresso_registrations_resend_registration'
2063
-            )
2064
-        ) {
2065
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2066
-                EE_Admin_Page::add_query_args_and_nonce(
2067
-                    [
2068
-                        'action'      => 'resend_registration',
2069
-                        '_REG_ID'     => $this->_registration->ID(),
2070
-                        'redirect_to' => 'view_registration',
2071
-                    ],
2072
-                    REG_ADMIN_URL
2073
-                ),
2074
-                esc_html__(' Resend Registration', 'event_espresso'),
2075
-                'button secondary-button right',
2076
-                'dashicons dashicons-email-alt'
2077
-            );
2078
-        } else {
2079
-            $this->_template_args['resend_registration_button'] = '';
2080
-        }
2081
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2082
-        $payment                               = $transaction->get_first_related('Payment');
2083
-        $payment                               = ! $payment instanceof EE_Payment
2084
-            ? EE_Payment::new_instance()
2085
-            : $payment;
2086
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2087
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2088
-            ? EE_Payment_Method::new_instance()
2089
-            : $payment_method;
2090
-        $reg_details                           = [
2091
-            'payment_method'       => $payment_method->name(),
2092
-            'response_msg'         => $payment->gateway_response(),
2093
-            'registration_id'      => $this->_registration->get('REG_code'),
2094
-            'registration_session' => $this->_registration->session_ID(),
2095
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2096
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2097
-        ];
2098
-        if (isset($reg_details['registration_id'])) {
2099
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2100
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2101
-                'Registration ID',
2102
-                'event_espresso'
2103
-            );
2104
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2105
-        }
2106
-        if (isset($reg_details['payment_method'])) {
2107
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2108
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2109
-                'Most Recent Payment Method',
2110
-                'event_espresso'
2111
-            );
2112
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2113
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2114
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2115
-                'Payment method response',
2116
-                'event_espresso'
2117
-            );
2118
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2119
-        }
2120
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2121
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2122
-            'Registration Session',
2123
-            'event_espresso'
2124
-        );
2125
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2126
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2127
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2128
-            'Registration placed from IP',
2129
-            'event_espresso'
2130
-        );
2131
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2132
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2133
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2134
-            'Registrant User Agent',
2135
-            'event_espresso'
2136
-        );
2137
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2138
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2139
-            [
2140
-                'action'   => 'default',
2141
-                'event_id' => $this->_registration->event_ID(),
2142
-            ],
2143
-            REG_ADMIN_URL
2144
-        );
2145
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2146
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2147
-        $template_path                                                        =
2148
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2149
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2150
-    }
2151
-
2152
-
2153
-    /**
2154
-     * generates HTML for the Registration Questions meta box.
2155
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2156
-     * otherwise uses new forms system
2157
-     *
2158
-     * @return void
2159
-     * @throws DomainException
2160
-     * @throws EE_Error
2161
-     * @throws InvalidArgumentException
2162
-     * @throws InvalidDataTypeException
2163
-     * @throws InvalidInterfaceException
2164
-     * @throws ReflectionException
2165
-     */
2166
-    public function _reg_questions_meta_box()
2167
-    {
2168
-        // allow someone to override this method entirely
2169
-        if (
2170
-            apply_filters(
2171
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2172
-                true,
2173
-                $this,
2174
-                $this->_registration
2175
-            )
2176
-        ) {
2177
-            $form                                              = $this->_get_reg_custom_questions_form(
2178
-                $this->_registration->ID()
2179
-            );
2180
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2181
-                ? $form->get_html_and_js()
2182
-                : '';
2183
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2184
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2185
-            $template_path                                     =
2186
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2187
-            EEH_Template::display_template($template_path, $this->_template_args);
2188
-        }
2189
-    }
2190
-
2191
-
2192
-    /**
2193
-     * form_before_question_group
2194
-     *
2195
-     * @param string $output
2196
-     * @return        string
2197
-     * @deprecated    as of 4.8.32.rc.000
2198
-     */
2199
-    public function form_before_question_group($output)
2200
-    {
2201
-        EE_Error::doing_it_wrong(
2202
-            __CLASS__ . '::' . __FUNCTION__,
2203
-            esc_html__(
2204
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2205
-                'event_espresso'
2206
-            ),
2207
-            '4.8.32.rc.000'
2208
-        );
2209
-        return '
24
+	/**
25
+	 * @var EE_Registration
26
+	 */
27
+	private $_registration;
28
+
29
+	/**
30
+	 * @var EE_Event
31
+	 */
32
+	private $_reg_event;
33
+
34
+	/**
35
+	 * @var EE_Session
36
+	 */
37
+	private $_session;
38
+
39
+	/**
40
+	 * @var array
41
+	 */
42
+	private static $_reg_status;
43
+
44
+	/**
45
+	 * Form for displaying the custom questions for this registration.
46
+	 * This gets used a few times throughout the request so its best to cache it
47
+	 *
48
+	 * @var EE_Registration_Custom_Questions_Form
49
+	 */
50
+	protected $_reg_custom_questions_form = null;
51
+
52
+	/**
53
+	 * @var EEM_Registration $registration_model
54
+	 */
55
+	private $registration_model;
56
+
57
+	/**
58
+	 * @var EEM_Attendee $attendee_model
59
+	 */
60
+	private $attendee_model;
61
+
62
+	/**
63
+	 * @var EEM_Event $event_model
64
+	 */
65
+	private $event_model;
66
+
67
+	/**
68
+	 * @var EEM_Status $status_model
69
+	 */
70
+	private $status_model;
71
+
72
+
73
+	/**
74
+	 * @param bool $routing
75
+	 * @throws EE_Error
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws InvalidInterfaceException
79
+	 * @throws ReflectionException
80
+	 */
81
+	public function __construct($routing = true)
82
+	{
83
+		parent::__construct($routing);
84
+		add_action('wp_loaded', [$this, 'wp_loaded']);
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return EEM_Registration
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 * @since 4.10.2.p
94
+	 */
95
+	protected function getRegistrationModel()
96
+	{
97
+		if (! $this->registration_model instanceof EEM_Registration) {
98
+			$this->registration_model = $this->getLoader()->getShared('EEM_Registration');
99
+		}
100
+		return $this->registration_model;
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return EEM_Attendee
106
+	 * @throws InvalidArgumentException
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 * @since 4.10.2.p
110
+	 */
111
+	protected function getAttendeeModel()
112
+	{
113
+		if (! $this->attendee_model instanceof EEM_Attendee) {
114
+			$this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
115
+		}
116
+		return $this->attendee_model;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return EEM_Event
122
+	 * @throws InvalidArgumentException
123
+	 * @throws InvalidDataTypeException
124
+	 * @throws InvalidInterfaceException
125
+	 * @since 4.10.2.p
126
+	 */
127
+	protected function getEventModel()
128
+	{
129
+		if (! $this->event_model instanceof EEM_Event) {
130
+			$this->event_model = $this->getLoader()->getShared('EEM_Event');
131
+		}
132
+		return $this->event_model;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @return EEM_Status
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidInterfaceException
141
+	 * @since 4.10.2.p
142
+	 */
143
+	protected function getStatusModel()
144
+	{
145
+		if (! $this->status_model instanceof EEM_Status) {
146
+			$this->status_model = $this->getLoader()->getShared('EEM_Status');
147
+		}
148
+		return $this->status_model;
149
+	}
150
+
151
+
152
+	public function wp_loaded()
153
+	{
154
+		// when adding a new registration...
155
+		$action = $this->request->getRequestParam('action');
156
+		if ($action === 'new_registration') {
157
+			EE_System::do_not_cache();
158
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
159
+				// and it's NOT the attendee information reg step
160
+				// force cookie expiration by setting time to last week
161
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
162
+				// and update the global
163
+				$_COOKIE['ee_registration_added'] = 0;
164
+			}
165
+		}
166
+	}
167
+
168
+
169
+	protected function _init_page_props()
170
+	{
171
+		$this->page_slug        = REG_PG_SLUG;
172
+		$this->_admin_base_url  = REG_ADMIN_URL;
173
+		$this->_admin_base_path = REG_ADMIN;
174
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
175
+		$this->_cpt_routes      = [
176
+			'add_new_attendee' => 'espresso_attendees',
177
+			'edit_attendee'    => 'espresso_attendees',
178
+			'insert_attendee'  => 'espresso_attendees',
179
+			'update_attendee'  => 'espresso_attendees',
180
+		];
181
+		$this->_cpt_model_names = [
182
+			'add_new_attendee' => 'EEM_Attendee',
183
+			'edit_attendee'    => 'EEM_Attendee',
184
+		];
185
+		$this->_cpt_edit_routes = [
186
+			'espresso_attendees' => 'edit_attendee',
187
+		];
188
+		$this->_pagenow_map     = [
189
+			'add_new_attendee' => 'post-new.php',
190
+			'edit_attendee'    => 'post.php',
191
+			'trash'            => 'post.php',
192
+		];
193
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
194
+		// add filters so that the comment urls don't take users to a confusing 404 page
195
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
196
+	}
197
+
198
+
199
+	/**
200
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
201
+	 * @param WP_Comment $comment The current comment object.
202
+	 * @return string
203
+	 */
204
+	public function clear_comment_link($link, WP_Comment $comment)
205
+	{
206
+		// gotta make sure this only happens on this route
207
+		$post_type = get_post_type($comment->comment_post_ID);
208
+		if ($post_type === 'espresso_attendees') {
209
+			return '#commentsdiv';
210
+		}
211
+		return $link;
212
+	}
213
+
214
+
215
+	protected function _ajax_hooks()
216
+	{
217
+		// todo: all hooks for registrations ajax goes in here
218
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
219
+	}
220
+
221
+
222
+	protected function _define_page_props()
223
+	{
224
+		$this->_admin_page_title = $this->page_label;
225
+		$this->_labels           = [
226
+			'buttons'                      => [
227
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
228
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
229
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
230
+				'csv_reg_report'      => esc_html__('Registrations CSV Report', 'event_espresso'),
231
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
232
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
233
+			],
234
+			'publishbox'                   => [
235
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
236
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
237
+			],
238
+			'hide_add_button_on_cpt_route' => [
239
+				'edit_attendee' => true,
240
+			],
241
+		];
242
+	}
243
+
244
+
245
+	/**
246
+	 * grab url requests and route them
247
+	 *
248
+	 * @return void
249
+	 * @throws EE_Error
250
+	 */
251
+	public function _set_page_routes()
252
+	{
253
+		$this->_get_registration_status_array();
254
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
255
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
256
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
257
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
258
+		$this->_page_routes = [
259
+			'default'                             => [
260
+				'func'       => [$this, '_registrations_overview_list_table'],
261
+				'capability' => 'ee_read_registrations',
262
+			],
263
+			'view_registration'                   => [
264
+				'func'       => '_registration_details',
265
+				'capability' => 'ee_read_registration',
266
+				'obj_id'     => $REG_ID,
267
+			],
268
+			'edit_registration'                   => [
269
+				'func'               => '_update_attendee_registration_form',
270
+				'noheader'           => true,
271
+				'headers_sent_route' => 'view_registration',
272
+				'capability'         => 'ee_edit_registration',
273
+				'obj_id'             => $REG_ID,
274
+				'_REG_ID'            => $REG_ID,
275
+			],
276
+			'trash_registrations'                 => [
277
+				'func'       => '_trash_or_restore_registrations',
278
+				'args'       => ['trash' => true],
279
+				'noheader'   => true,
280
+				'capability' => 'ee_delete_registrations',
281
+			],
282
+			'restore_registrations'               => [
283
+				'func'       => '_trash_or_restore_registrations',
284
+				'args'       => ['trash' => false],
285
+				'noheader'   => true,
286
+				'capability' => 'ee_delete_registrations',
287
+			],
288
+			'delete_registrations'                => [
289
+				'func'       => '_delete_registrations',
290
+				'noheader'   => true,
291
+				'capability' => 'ee_delete_registrations',
292
+			],
293
+			'new_registration'                    => [
294
+				'func'       => 'new_registration',
295
+				'capability' => 'ee_edit_registrations',
296
+			],
297
+			'process_reg_step'                    => [
298
+				'func'       => 'process_reg_step',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+			],
302
+			'redirect_to_txn'                     => [
303
+				'func'       => 'redirect_to_txn',
304
+				'noheader'   => true,
305
+				'capability' => 'ee_edit_registrations',
306
+			],
307
+			'change_reg_status'                   => [
308
+				'func'       => '_change_reg_status',
309
+				'noheader'   => true,
310
+				'capability' => 'ee_edit_registration',
311
+				'obj_id'     => $REG_ID,
312
+			],
313
+			'approve_registration'                => [
314
+				'func'       => 'approve_registration',
315
+				'noheader'   => true,
316
+				'capability' => 'ee_edit_registration',
317
+				'obj_id'     => $REG_ID,
318
+			],
319
+			'approve_and_notify_registration'     => [
320
+				'func'       => 'approve_registration',
321
+				'noheader'   => true,
322
+				'args'       => [true],
323
+				'capability' => 'ee_edit_registration',
324
+				'obj_id'     => $REG_ID,
325
+			],
326
+			'approve_registrations'               => [
327
+				'func'       => 'bulk_action_on_registrations',
328
+				'noheader'   => true,
329
+				'capability' => 'ee_edit_registrations',
330
+				'args'       => ['approve'],
331
+			],
332
+			'approve_and_notify_registrations'    => [
333
+				'func'       => 'bulk_action_on_registrations',
334
+				'noheader'   => true,
335
+				'capability' => 'ee_edit_registrations',
336
+				'args'       => ['approve', true],
337
+			],
338
+			'decline_registration'                => [
339
+				'func'       => 'decline_registration',
340
+				'noheader'   => true,
341
+				'capability' => 'ee_edit_registration',
342
+				'obj_id'     => $REG_ID,
343
+			],
344
+			'decline_and_notify_registration'     => [
345
+				'func'       => 'decline_registration',
346
+				'noheader'   => true,
347
+				'args'       => [true],
348
+				'capability' => 'ee_edit_registration',
349
+				'obj_id'     => $REG_ID,
350
+			],
351
+			'decline_registrations'               => [
352
+				'func'       => 'bulk_action_on_registrations',
353
+				'noheader'   => true,
354
+				'capability' => 'ee_edit_registrations',
355
+				'args'       => ['decline'],
356
+			],
357
+			'decline_and_notify_registrations'    => [
358
+				'func'       => 'bulk_action_on_registrations',
359
+				'noheader'   => true,
360
+				'capability' => 'ee_edit_registrations',
361
+				'args'       => ['decline', true],
362
+			],
363
+			'pending_registration'                => [
364
+				'func'       => 'pending_registration',
365
+				'noheader'   => true,
366
+				'capability' => 'ee_edit_registration',
367
+				'obj_id'     => $REG_ID,
368
+			],
369
+			'pending_and_notify_registration'     => [
370
+				'func'       => 'pending_registration',
371
+				'noheader'   => true,
372
+				'args'       => [true],
373
+				'capability' => 'ee_edit_registration',
374
+				'obj_id'     => $REG_ID,
375
+			],
376
+			'pending_registrations'               => [
377
+				'func'       => 'bulk_action_on_registrations',
378
+				'noheader'   => true,
379
+				'capability' => 'ee_edit_registrations',
380
+				'args'       => ['pending'],
381
+			],
382
+			'pending_and_notify_registrations'    => [
383
+				'func'       => 'bulk_action_on_registrations',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_registrations',
386
+				'args'       => ['pending', true],
387
+			],
388
+			'no_approve_registration'             => [
389
+				'func'       => 'not_approve_registration',
390
+				'noheader'   => true,
391
+				'capability' => 'ee_edit_registration',
392
+				'obj_id'     => $REG_ID,
393
+			],
394
+			'no_approve_and_notify_registration'  => [
395
+				'func'       => 'not_approve_registration',
396
+				'noheader'   => true,
397
+				'args'       => [true],
398
+				'capability' => 'ee_edit_registration',
399
+				'obj_id'     => $REG_ID,
400
+			],
401
+			'no_approve_registrations'            => [
402
+				'func'       => 'bulk_action_on_registrations',
403
+				'noheader'   => true,
404
+				'capability' => 'ee_edit_registrations',
405
+				'args'       => ['not_approve'],
406
+			],
407
+			'no_approve_and_notify_registrations' => [
408
+				'func'       => 'bulk_action_on_registrations',
409
+				'noheader'   => true,
410
+				'capability' => 'ee_edit_registrations',
411
+				'args'       => ['not_approve', true],
412
+			],
413
+			'cancel_registration'                 => [
414
+				'func'       => 'cancel_registration',
415
+				'noheader'   => true,
416
+				'capability' => 'ee_edit_registration',
417
+				'obj_id'     => $REG_ID,
418
+			],
419
+			'cancel_and_notify_registration'      => [
420
+				'func'       => 'cancel_registration',
421
+				'noheader'   => true,
422
+				'args'       => [true],
423
+				'capability' => 'ee_edit_registration',
424
+				'obj_id'     => $REG_ID,
425
+			],
426
+			'cancel_registrations'                => [
427
+				'func'       => 'bulk_action_on_registrations',
428
+				'noheader'   => true,
429
+				'capability' => 'ee_edit_registrations',
430
+				'args'       => ['cancel'],
431
+			],
432
+			'cancel_and_notify_registrations'     => [
433
+				'func'       => 'bulk_action_on_registrations',
434
+				'noheader'   => true,
435
+				'capability' => 'ee_edit_registrations',
436
+				'args'       => ['cancel', true],
437
+			],
438
+			'wait_list_registration'              => [
439
+				'func'       => 'wait_list_registration',
440
+				'noheader'   => true,
441
+				'capability' => 'ee_edit_registration',
442
+				'obj_id'     => $REG_ID,
443
+			],
444
+			'wait_list_and_notify_registration'   => [
445
+				'func'       => 'wait_list_registration',
446
+				'noheader'   => true,
447
+				'args'       => [true],
448
+				'capability' => 'ee_edit_registration',
449
+				'obj_id'     => $REG_ID,
450
+			],
451
+			'contact_list'                        => [
452
+				'func'       => '_attendee_contact_list_table',
453
+				'capability' => 'ee_read_contacts',
454
+			],
455
+			'add_new_attendee'                    => [
456
+				'func' => '_create_new_cpt_item',
457
+				'args' => [
458
+					'new_attendee' => true,
459
+					'capability'   => 'ee_edit_contacts',
460
+				],
461
+			],
462
+			'edit_attendee'                       => [
463
+				'func'       => '_edit_cpt_item',
464
+				'capability' => 'ee_edit_contacts',
465
+				'obj_id'     => $ATT_ID,
466
+			],
467
+			'duplicate_attendee'                  => [
468
+				'func'       => '_duplicate_attendee',
469
+				'noheader'   => true,
470
+				'capability' => 'ee_edit_contacts',
471
+				'obj_id'     => $ATT_ID,
472
+			],
473
+			'insert_attendee'                     => [
474
+				'func'       => '_insert_or_update_attendee',
475
+				'args'       => [
476
+					'new_attendee' => true,
477
+				],
478
+				'noheader'   => true,
479
+				'capability' => 'ee_edit_contacts',
480
+			],
481
+			'update_attendee'                     => [
482
+				'func'       => '_insert_or_update_attendee',
483
+				'args'       => [
484
+					'new_attendee' => false,
485
+				],
486
+				'noheader'   => true,
487
+				'capability' => 'ee_edit_contacts',
488
+				'obj_id'     => $ATT_ID,
489
+			],
490
+			'trash_attendees'                     => [
491
+				'func'       => '_trash_or_restore_attendees',
492
+				'args'       => [
493
+					'trash' => 'true',
494
+				],
495
+				'noheader'   => true,
496
+				'capability' => 'ee_delete_contacts',
497
+			],
498
+			'trash_attendee'                      => [
499
+				'func'       => '_trash_or_restore_attendees',
500
+				'args'       => [
501
+					'trash' => true,
502
+				],
503
+				'noheader'   => true,
504
+				'capability' => 'ee_delete_contacts',
505
+				'obj_id'     => $ATT_ID,
506
+			],
507
+			'restore_attendees'                   => [
508
+				'func'       => '_trash_or_restore_attendees',
509
+				'args'       => [
510
+					'trash' => false,
511
+				],
512
+				'noheader'   => true,
513
+				'capability' => 'ee_delete_contacts',
514
+				'obj_id'     => $ATT_ID,
515
+			],
516
+			'resend_registration'                 => [
517
+				'func'       => '_resend_registration',
518
+				'noheader'   => true,
519
+				'capability' => 'ee_send_message',
520
+			],
521
+			'registrations_report'                => [
522
+				'func'       => [$this, '_registrations_report'],
523
+				'noheader'   => true,
524
+				'capability' => 'ee_read_registrations',
525
+			],
526
+			'contact_list_export'                 => [
527
+				'func'       => '_contact_list_export',
528
+				'noheader'   => true,
529
+				'capability' => 'export',
530
+			],
531
+			'contact_list_report'                 => [
532
+				'func'       => '_contact_list_report',
533
+				'noheader'   => true,
534
+				'capability' => 'ee_read_contacts',
535
+			],
536
+		];
537
+	}
538
+
539
+
540
+	protected function _set_page_config()
541
+	{
542
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
543
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
544
+		$this->_page_config = [
545
+			'default'           => [
546
+				'nav'           => [
547
+					'label' => esc_html__('Overview', 'event_espresso'),
548
+					'order' => 5,
549
+				],
550
+				'help_tabs'     => [
551
+					'registrations_overview_help_tab'                       => [
552
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
+						'filename' => 'registrations_overview',
554
+					],
555
+					'registrations_overview_table_column_headings_help_tab' => [
556
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
+						'filename' => 'registrations_overview_table_column_headings',
558
+					],
559
+					'registrations_overview_filters_help_tab'               => [
560
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
+						'filename' => 'registrations_overview_filters',
562
+					],
563
+					'registrations_overview_views_help_tab'                 => [
564
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
565
+						'filename' => 'registrations_overview_views',
566
+					],
567
+					'registrations_regoverview_other_help_tab'              => [
568
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
+						'filename' => 'registrations_overview_other',
570
+					],
571
+				],
572
+				'qtips'         => ['Registration_List_Table_Tips'],
573
+				'list_table'    => 'EE_Registrations_List_Table',
574
+				'require_nonce' => false,
575
+			],
576
+			'view_registration' => [
577
+				'nav'           => [
578
+					'label'      => esc_html__('REG Details', 'event_espresso'),
579
+					'order'      => 15,
580
+					'url'        => $REG_ID
581
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
+						: $this->_admin_base_url,
583
+					'persistent' => false,
584
+				],
585
+				'help_tabs'     => [
586
+					'registrations_details_help_tab'                    => [
587
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
588
+						'filename' => 'registrations_details',
589
+					],
590
+					'registrations_details_table_help_tab'              => [
591
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
+						'filename' => 'registrations_details_table',
593
+					],
594
+					'registrations_details_form_answers_help_tab'       => [
595
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
+						'filename' => 'registrations_details_form_answers',
597
+					],
598
+					'registrations_details_registrant_details_help_tab' => [
599
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
600
+						'filename' => 'registrations_details_registrant_details',
601
+					],
602
+				],
603
+				'metaboxes'     => array_merge(
604
+					$this->_default_espresso_metaboxes,
605
+					['_registration_details_metaboxes']
606
+				),
607
+				'require_nonce' => false,
608
+			],
609
+			'new_registration'  => [
610
+				'nav'           => [
611
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
+					'url'        => '#',
613
+					'order'      => 15,
614
+					'persistent' => false,
615
+				],
616
+				'metaboxes'     => $this->_default_espresso_metaboxes,
617
+				'labels'        => [
618
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
619
+				],
620
+				'require_nonce' => false,
621
+			],
622
+			'add_new_attendee'  => [
623
+				'nav'           => [
624
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
625
+					'order'      => 15,
626
+					'persistent' => false,
627
+				],
628
+				'metaboxes'     => array_merge(
629
+					$this->_default_espresso_metaboxes,
630
+					['_publish_post_box', 'attendee_editor_metaboxes']
631
+				),
632
+				'require_nonce' => false,
633
+			],
634
+			'edit_attendee'     => [
635
+				'nav'           => [
636
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
637
+					'order'      => 15,
638
+					'persistent' => false,
639
+					'url'        => $ATT_ID
640
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
641
+						: $this->_admin_base_url,
642
+				],
643
+				'metaboxes'     => ['attendee_editor_metaboxes'],
644
+				'require_nonce' => false,
645
+			],
646
+			'contact_list'      => [
647
+				'nav'           => [
648
+					'label' => esc_html__('Contact List', 'event_espresso'),
649
+					'order' => 20,
650
+				],
651
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
652
+				'help_tabs'     => [
653
+					'registrations_contact_list_help_tab'                       => [
654
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
655
+						'filename' => 'registrations_contact_list',
656
+					],
657
+					'registrations_contact-list_table_column_headings_help_tab' => [
658
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
659
+						'filename' => 'registrations_contact_list_table_column_headings',
660
+					],
661
+					'registrations_contact_list_views_help_tab'                 => [
662
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
663
+						'filename' => 'registrations_contact_list_views',
664
+					],
665
+					'registrations_contact_list_other_help_tab'                 => [
666
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
667
+						'filename' => 'registrations_contact_list_other',
668
+					],
669
+				],
670
+				'metaboxes'     => [],
671
+				'require_nonce' => false,
672
+			],
673
+			// override default cpt routes
674
+			'create_new'        => '',
675
+			'edit'              => '',
676
+		];
677
+	}
678
+
679
+
680
+	/**
681
+	 * The below methods aren't used by this class currently
682
+	 */
683
+	protected function _add_screen_options()
684
+	{
685
+	}
686
+
687
+
688
+	protected function _add_feature_pointers()
689
+	{
690
+	}
691
+
692
+
693
+	public function admin_init()
694
+	{
695
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
696
+			'click "Update Registration Questions" to save your changes',
697
+			'event_espresso'
698
+		);
699
+	}
700
+
701
+
702
+	public function admin_notices()
703
+	{
704
+	}
705
+
706
+
707
+	public function admin_footer_scripts()
708
+	{
709
+	}
710
+
711
+
712
+	/**
713
+	 * get list of registration statuses
714
+	 *
715
+	 * @return void
716
+	 * @throws EE_Error
717
+	 */
718
+	private function _get_registration_status_array()
719
+	{
720
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
721
+	}
722
+
723
+
724
+	/**
725
+	 * @throws InvalidArgumentException
726
+	 * @throws InvalidDataTypeException
727
+	 * @throws InvalidInterfaceException
728
+	 * @since 4.10.2.p
729
+	 */
730
+	protected function _add_screen_options_default()
731
+	{
732
+		$this->_per_page_screen_option();
733
+	}
734
+
735
+
736
+	/**
737
+	 * @throws InvalidArgumentException
738
+	 * @throws InvalidDataTypeException
739
+	 * @throws InvalidInterfaceException
740
+	 * @since 4.10.2.p
741
+	 */
742
+	protected function _add_screen_options_contact_list()
743
+	{
744
+		$page_title              = $this->_admin_page_title;
745
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
746
+		$this->_per_page_screen_option();
747
+		$this->_admin_page_title = $page_title;
748
+	}
749
+
750
+
751
+	public function load_scripts_styles()
752
+	{
753
+		// style
754
+		wp_register_style(
755
+			'espresso_reg',
756
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
757
+			['ee-admin-css'],
758
+			EVENT_ESPRESSO_VERSION
759
+		);
760
+		wp_enqueue_style('espresso_reg');
761
+		// script
762
+		wp_register_script(
763
+			'espresso_reg',
764
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
765
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
766
+			EVENT_ESPRESSO_VERSION,
767
+			true
768
+		);
769
+		wp_enqueue_script('espresso_reg');
770
+	}
771
+
772
+
773
+	/**
774
+	 * @throws EE_Error
775
+	 * @throws InvalidArgumentException
776
+	 * @throws InvalidDataTypeException
777
+	 * @throws InvalidInterfaceException
778
+	 * @throws ReflectionException
779
+	 * @since 4.10.2.p
780
+	 */
781
+	public function load_scripts_styles_edit_attendee()
782
+	{
783
+		// stuff to only show up on our attendee edit details page.
784
+		$attendee_details_translations = [
785
+			'att_publish_text' => sprintf(
786
+			/* translators: The date and time */
787
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
788
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
789
+			),
790
+		];
791
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
792
+		wp_enqueue_script('jquery-validate');
793
+	}
794
+
795
+
796
+	/**
797
+	 * @throws EE_Error
798
+	 * @throws InvalidArgumentException
799
+	 * @throws InvalidDataTypeException
800
+	 * @throws InvalidInterfaceException
801
+	 * @throws ReflectionException
802
+	 * @since 4.10.2.p
803
+	 */
804
+	public function load_scripts_styles_view_registration()
805
+	{
806
+		// styles
807
+		wp_enqueue_style('espresso-ui-theme');
808
+		// scripts
809
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
810
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
811
+	}
812
+
813
+
814
+	public function load_scripts_styles_contact_list()
815
+	{
816
+		wp_dequeue_style('espresso_reg');
817
+		wp_register_style(
818
+			'espresso_att',
819
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
820
+			['ee-admin-css'],
821
+			EVENT_ESPRESSO_VERSION
822
+		);
823
+		wp_enqueue_style('espresso_att');
824
+	}
825
+
826
+
827
+	public function load_scripts_styles_new_registration()
828
+	{
829
+		wp_register_script(
830
+			'ee-spco-for-admin',
831
+			REG_ASSETS_URL . 'spco_for_admin.js',
832
+			['underscore', 'jquery'],
833
+			EVENT_ESPRESSO_VERSION,
834
+			true
835
+		);
836
+		wp_enqueue_script('ee-spco-for-admin');
837
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
838
+		EE_Form_Section_Proper::wp_enqueue_scripts();
839
+		EED_Ticket_Selector::load_tckt_slctr_assets();
840
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
841
+	}
842
+
843
+
844
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
845
+	{
846
+		add_filter('FHEE_load_EE_messages', '__return_true');
847
+	}
848
+
849
+
850
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
851
+	{
852
+		add_filter('FHEE_load_EE_messages', '__return_true');
853
+	}
854
+
855
+
856
+	/**
857
+	 * @throws EE_Error
858
+	 * @throws InvalidArgumentException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws InvalidInterfaceException
861
+	 * @throws ReflectionException
862
+	 * @since 4.10.2.p
863
+	 */
864
+	protected function _set_list_table_views_default()
865
+	{
866
+		// for notification related bulk actions we need to make sure only active messengers have an option.
867
+		EED_Messages::set_autoloaders();
868
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
869
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
870
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
871
+		// key= bulk_action_slug, value= message type.
872
+		$match_array = [
873
+			'approve_registrations'    => 'registration',
874
+			'decline_registrations'    => 'declined_registration',
875
+			'pending_registrations'    => 'pending_approval',
876
+			'no_approve_registrations' => 'not_approved_registration',
877
+			'cancel_registrations'     => 'cancelled_registration',
878
+		];
879
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
880
+			'ee_send_message',
881
+			'batch_send_messages'
882
+		);
883
+		/** setup reg status bulk actions **/
884
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
885
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
886
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
887
+				'Approve and Notify Registrations',
888
+				'event_espresso'
889
+			);
890
+		}
891
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
892
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
893
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
894
+				'Decline and Notify Registrations',
895
+				'event_espresso'
896
+			);
897
+		}
898
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
899
+			'Set Registrations to Pending Payment',
900
+			'event_espresso'
901
+		);
902
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
903
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
904
+				'Set Registrations to Pending Payment and Notify',
905
+				'event_espresso'
906
+			);
907
+		}
908
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
909
+			'Set Registrations to Not Approved',
910
+			'event_espresso'
911
+		);
912
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
913
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
914
+				'Set Registrations to Not Approved and Notify',
915
+				'event_espresso'
916
+			);
917
+		}
918
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
919
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
920
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
921
+				'Cancel Registrations and Notify',
922
+				'event_espresso'
923
+			);
924
+		}
925
+		$def_reg_status_actions = apply_filters(
926
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
927
+			$def_reg_status_actions,
928
+			$active_mts,
929
+			$can_send
930
+		);
931
+
932
+		$this->_views = [
933
+			'all'   => [
934
+				'slug'        => 'all',
935
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
936
+				'count'       => 0,
937
+				'bulk_action' => array_merge(
938
+					$def_reg_status_actions,
939
+					[
940
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
941
+					]
942
+				),
943
+			],
944
+			'month' => [
945
+				'slug'        => 'month',
946
+				'label'       => esc_html__('This Month', 'event_espresso'),
947
+				'count'       => 0,
948
+				'bulk_action' => array_merge(
949
+					$def_reg_status_actions,
950
+					[
951
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
952
+					]
953
+				),
954
+			],
955
+			'today' => [
956
+				'slug'        => 'today',
957
+				'label'       => sprintf(
958
+					esc_html__('Today - %s', 'event_espresso'),
959
+					date('M d, Y', current_time('timestamp'))
960
+				),
961
+				'count'       => 0,
962
+				'bulk_action' => array_merge(
963
+					$def_reg_status_actions,
964
+					[
965
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
966
+					]
967
+				),
968
+			],
969
+		];
970
+		if (
971
+			EE_Registry::instance()->CAP->current_user_can(
972
+				'ee_delete_registrations',
973
+				'espresso_registrations_delete_registration'
974
+			)
975
+		) {
976
+			$this->_views['incomplete'] = [
977
+				'slug'        => 'incomplete',
978
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
979
+				'count'       => 0,
980
+				'bulk_action' => [
981
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
982
+				],
983
+			];
984
+			$this->_views['trash']      = [
985
+				'slug'        => 'trash',
986
+				'label'       => esc_html__('Trash', 'event_espresso'),
987
+				'count'       => 0,
988
+				'bulk_action' => [
989
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
990
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
991
+				],
992
+			];
993
+		}
994
+	}
995
+
996
+
997
+	protected function _set_list_table_views_contact_list()
998
+	{
999
+		$this->_views = [
1000
+			'in_use' => [
1001
+				'slug'        => 'in_use',
1002
+				'label'       => esc_html__('In Use', 'event_espresso'),
1003
+				'count'       => 0,
1004
+				'bulk_action' => [
1005
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1006
+				],
1007
+			],
1008
+		];
1009
+		if (
1010
+			EE_Registry::instance()->CAP->current_user_can(
1011
+				'ee_delete_contacts',
1012
+				'espresso_registrations_trash_attendees'
1013
+			)
1014
+		) {
1015
+			$this->_views['trash'] = [
1016
+				'slug'        => 'trash',
1017
+				'label'       => esc_html__('Trash', 'event_espresso'),
1018
+				'count'       => 0,
1019
+				'bulk_action' => [
1020
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1021
+				],
1022
+			];
1023
+		}
1024
+	}
1025
+
1026
+
1027
+	/**
1028
+	 * @return array
1029
+	 * @throws EE_Error
1030
+	 */
1031
+	protected function _registration_legend_items()
1032
+	{
1033
+		$fc_items = [
1034
+			'star-icon'        => [
1035
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1036
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1037
+			],
1038
+			'view_details'     => [
1039
+				'class' => 'dashicons dashicons-clipboard',
1040
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1041
+			],
1042
+			'edit_attendee'    => [
1043
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1044
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1045
+			],
1046
+			'view_transaction' => [
1047
+				'class' => 'dashicons dashicons-cart',
1048
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1049
+			],
1050
+			'view_invoice'     => [
1051
+				'class' => 'dashicons dashicons-media-spreadsheet',
1052
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1053
+			],
1054
+		];
1055
+		if (
1056
+			EE_Registry::instance()->CAP->current_user_can(
1057
+				'ee_send_message',
1058
+				'espresso_registrations_resend_registration'
1059
+			)
1060
+		) {
1061
+			$fc_items['resend_registration'] = [
1062
+				'class' => 'dashicons dashicons-email-alt',
1063
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1064
+			];
1065
+		} else {
1066
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1067
+		}
1068
+		if (
1069
+			EE_Registry::instance()->CAP->current_user_can(
1070
+				'ee_read_global_messages',
1071
+				'view_filtered_messages'
1072
+			)
1073
+		) {
1074
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1075
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1076
+				$fc_items['view_related_messages'] = [
1077
+					'class' => $related_for_icon['css_class'],
1078
+					'desc'  => $related_for_icon['label'],
1079
+				];
1080
+			}
1081
+		}
1082
+		$sc_items = [
1083
+			'approved_status'   => [
1084
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1085
+				'desc'  => EEH_Template::pretty_status(
1086
+					EEM_Registration::status_id_approved,
1087
+					false,
1088
+					'sentence'
1089
+				),
1090
+			],
1091
+			'pending_status'    => [
1092
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1093
+				'desc'  => EEH_Template::pretty_status(
1094
+					EEM_Registration::status_id_pending_payment,
1095
+					false,
1096
+					'sentence'
1097
+				),
1098
+			],
1099
+			'wait_list'         => [
1100
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1101
+				'desc'  => EEH_Template::pretty_status(
1102
+					EEM_Registration::status_id_wait_list,
1103
+					false,
1104
+					'sentence'
1105
+				),
1106
+			],
1107
+			'incomplete_status' => [
1108
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1109
+				'desc'  => EEH_Template::pretty_status(
1110
+					EEM_Registration::status_id_incomplete,
1111
+					false,
1112
+					'sentence'
1113
+				),
1114
+			],
1115
+			'not_approved'      => [
1116
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1117
+				'desc'  => EEH_Template::pretty_status(
1118
+					EEM_Registration::status_id_not_approved,
1119
+					false,
1120
+					'sentence'
1121
+				),
1122
+			],
1123
+			'declined_status'   => [
1124
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1125
+				'desc'  => EEH_Template::pretty_status(
1126
+					EEM_Registration::status_id_declined,
1127
+					false,
1128
+					'sentence'
1129
+				),
1130
+			],
1131
+			'cancelled_status'  => [
1132
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1133
+				'desc'  => EEH_Template::pretty_status(
1134
+					EEM_Registration::status_id_cancelled,
1135
+					false,
1136
+					'sentence'
1137
+				),
1138
+			],
1139
+		];
1140
+		return array_merge($fc_items, $sc_items);
1141
+	}
1142
+
1143
+
1144
+
1145
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1146
+
1147
+
1148
+	/**
1149
+	 * @throws DomainException
1150
+	 * @throws EE_Error
1151
+	 * @throws InvalidArgumentException
1152
+	 * @throws InvalidDataTypeException
1153
+	 * @throws InvalidInterfaceException
1154
+	 */
1155
+	protected function _registrations_overview_list_table()
1156
+	{
1157
+		$this->appendAddNewRegistrationButtonToPageTitle();
1158
+		$header_text                  = '';
1159
+		$admin_page_header_decorators = [
1160
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1161
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1162
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1163
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1164
+		];
1165
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1166
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1167
+			$header_text             = $filter_header_decorator->getHeaderText($header_text);
1168
+		}
1169
+		$this->_template_args['admin_page_header'] = $header_text;
1170
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1171
+		$this->display_admin_list_table_page_with_no_sidebar();
1172
+	}
1173
+
1174
+
1175
+	/**
1176
+	 * @throws EE_Error
1177
+	 * @throws InvalidArgumentException
1178
+	 * @throws InvalidDataTypeException
1179
+	 * @throws InvalidInterfaceException
1180
+	 */
1181
+	private function appendAddNewRegistrationButtonToPageTitle()
1182
+	{
1183
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1184
+		if (
1185
+			$EVT_ID
1186
+			&& EE_Registry::instance()->CAP->current_user_can(
1187
+				'ee_edit_registrations',
1188
+				'espresso_registrations_new_registration',
1189
+				$EVT_ID
1190
+			)
1191
+		) {
1192
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1193
+				'new_registration',
1194
+				'add-registrant',
1195
+				['event_id' => $EVT_ID],
1196
+				'add-new-h2'
1197
+			);
1198
+		}
1199
+	}
1200
+
1201
+
1202
+	/**
1203
+	 * This sets the _registration property for the registration details screen
1204
+	 *
1205
+	 * @return void
1206
+	 * @throws EE_Error
1207
+	 * @throws InvalidArgumentException
1208
+	 * @throws InvalidDataTypeException
1209
+	 * @throws InvalidInterfaceException
1210
+	 */
1211
+	private function _set_registration_object()
1212
+	{
1213
+		// get out if we've already set the object
1214
+		if ($this->_registration instanceof EE_Registration) {
1215
+			return;
1216
+		}
1217
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1218
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1219
+			return;
1220
+		}
1221
+		$error_msg = sprintf(
1222
+			esc_html__(
1223
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1224
+				'event_espresso'
1225
+			),
1226
+			$REG_ID
1227
+		);
1228
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1229
+		$this->_registration = null;
1230
+	}
1231
+
1232
+
1233
+	/**
1234
+	 * Used to retrieve registrations for the list table.
1235
+	 *
1236
+	 * @param int  $per_page
1237
+	 * @param bool $count
1238
+	 * @param bool $this_month
1239
+	 * @param bool $today
1240
+	 * @return EE_Registration[]|int
1241
+	 * @throws EE_Error
1242
+	 * @throws InvalidArgumentException
1243
+	 * @throws InvalidDataTypeException
1244
+	 * @throws InvalidInterfaceException
1245
+	 */
1246
+	public function get_registrations(
1247
+		$per_page = 10,
1248
+		$count = false,
1249
+		$this_month = false,
1250
+		$today = false
1251
+	) {
1252
+		if ($this_month) {
1253
+			$this->request->setRequestParam('status', 'month');
1254
+		}
1255
+		if ($today) {
1256
+			$this->request->setRequestParam('status', 'today');
1257
+		}
1258
+		$query_params = $this->_get_registration_query_parameters([], $per_page, $count);
1259
+		/**
1260
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1261
+		 *
1262
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1263
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1264
+		 *                      or if you have the development copy of EE you can view this at the path:
1265
+		 *                      /docs/G--Model-System/model-query-params.md
1266
+		 */
1267
+		$query_params['group_by'] = '';
1268
+
1269
+		return $count
1270
+			? $this->getRegistrationModel()->count($query_params)
1271
+			/** @type EE_Registration[] */
1272
+			: $this->getRegistrationModel()->get_all($query_params);
1273
+	}
1274
+
1275
+
1276
+	/**
1277
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1278
+	 * Note: this listens to values on the request for some of the query parameters.
1279
+	 *
1280
+	 * @param array $request
1281
+	 * @param int   $per_page
1282
+	 * @param bool  $count
1283
+	 * @return array
1284
+	 * @throws EE_Error
1285
+	 * @throws InvalidArgumentException
1286
+	 * @throws InvalidDataTypeException
1287
+	 * @throws InvalidInterfaceException
1288
+	 */
1289
+	protected function _get_registration_query_parameters(
1290
+		$request = [],
1291
+		$per_page = 10,
1292
+		$count = false
1293
+	) {
1294
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1295
+		$list_table_query_builder = $this->getLoader()->getNew(
1296
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1297
+			[null, null, $request]
1298
+		);
1299
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1300
+	}
1301
+
1302
+
1303
+	public function get_registration_status_array()
1304
+	{
1305
+		return self::$_reg_status;
1306
+	}
1307
+
1308
+
1309
+
1310
+
1311
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1312
+	/**
1313
+	 * generates HTML for the View Registration Details Admin page
1314
+	 *
1315
+	 * @return void
1316
+	 * @throws DomainException
1317
+	 * @throws EE_Error
1318
+	 * @throws InvalidArgumentException
1319
+	 * @throws InvalidDataTypeException
1320
+	 * @throws InvalidInterfaceException
1321
+	 * @throws EntityNotFoundException
1322
+	 * @throws ReflectionException
1323
+	 */
1324
+	protected function _registration_details()
1325
+	{
1326
+		$this->_template_args = [];
1327
+		$this->_set_registration_object();
1328
+		if (is_object($this->_registration)) {
1329
+			$transaction                                   = $this->_registration->transaction()
1330
+				? $this->_registration->transaction()
1331
+				: EE_Transaction::new_instance();
1332
+			$this->_session                                = $transaction->session_data();
1333
+			$event_id                                      = $this->_registration->event_ID();
1334
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1335
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1336
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1337
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1338
+			$this->_template_args['grand_total']           = $transaction->total();
1339
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1340
+			// link back to overview
1341
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1342
+			$this->_template_args['registration']                = $this->_registration;
1343
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1344
+				[
1345
+					'action'   => 'default',
1346
+					'event_id' => $event_id,
1347
+				],
1348
+				REG_ADMIN_URL
1349
+			);
1350
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1351
+				[
1352
+					'action' => 'default',
1353
+					'EVT_ID' => $event_id,
1354
+					'page'   => 'espresso_transactions',
1355
+				],
1356
+				admin_url('admin.php')
1357
+			);
1358
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1359
+				[
1360
+					'page'   => 'espresso_events',
1361
+					'action' => 'edit',
1362
+					'post'   => $event_id,
1363
+				],
1364
+				admin_url('admin.php')
1365
+			);
1366
+			// next and previous links
1367
+			$next_reg                                      = $this->_registration->next(
1368
+				null,
1369
+				[],
1370
+				'REG_ID'
1371
+			);
1372
+			$this->_template_args['next_registration']     = $next_reg
1373
+				? $this->_next_link(
1374
+					EE_Admin_Page::add_query_args_and_nonce(
1375
+						[
1376
+							'action'  => 'view_registration',
1377
+							'_REG_ID' => $next_reg['REG_ID'],
1378
+						],
1379
+						REG_ADMIN_URL
1380
+					),
1381
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1382
+				)
1383
+				: '';
1384
+			$previous_reg                                  = $this->_registration->previous(
1385
+				null,
1386
+				[],
1387
+				'REG_ID'
1388
+			);
1389
+			$this->_template_args['previous_registration'] = $previous_reg
1390
+				? $this->_previous_link(
1391
+					EE_Admin_Page::add_query_args_and_nonce(
1392
+						[
1393
+							'action'  => 'view_registration',
1394
+							'_REG_ID' => $previous_reg['REG_ID'],
1395
+						],
1396
+						REG_ADMIN_URL
1397
+					),
1398
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1399
+				)
1400
+				: '';
1401
+			// grab header
1402
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1403
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1404
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1405
+				$template_path,
1406
+				$this->_template_args,
1407
+				true
1408
+			);
1409
+		} else {
1410
+			$this->_template_args['admin_page_header'] = '';
1411
+			$this->_display_espresso_notices();
1412
+		}
1413
+		// the details template wrapper
1414
+		$this->display_admin_page_with_sidebar();
1415
+	}
1416
+
1417
+
1418
+	/**
1419
+	 * @throws EE_Error
1420
+	 * @throws InvalidArgumentException
1421
+	 * @throws InvalidDataTypeException
1422
+	 * @throws InvalidInterfaceException
1423
+	 * @throws ReflectionException
1424
+	 * @since 4.10.2.p
1425
+	 */
1426
+	protected function _registration_details_metaboxes()
1427
+	{
1428
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1429
+		$this->_set_registration_object();
1430
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1431
+		add_meta_box(
1432
+			'edit-reg-status-mbox',
1433
+			esc_html__('Registration Status', 'event_espresso'),
1434
+			[$this, 'set_reg_status_buttons_metabox'],
1435
+			$this->_wp_page_slug,
1436
+			'normal',
1437
+			'high'
1438
+		);
1439
+		add_meta_box(
1440
+			'edit-reg-details-mbox',
1441
+			esc_html__('Registration Details', 'event_espresso'),
1442
+			[$this, '_reg_details_meta_box'],
1443
+			$this->_wp_page_slug,
1444
+			'normal',
1445
+			'high'
1446
+		);
1447
+		if (
1448
+			$attendee instanceof EE_Attendee
1449
+			&& EE_Registry::instance()->CAP->current_user_can(
1450
+				'ee_read_registration',
1451
+				'edit-reg-questions-mbox',
1452
+				$this->_registration->ID()
1453
+			)
1454
+		) {
1455
+			add_meta_box(
1456
+				'edit-reg-questions-mbox',
1457
+				esc_html__('Registration Form Answers', 'event_espresso'),
1458
+				[$this, '_reg_questions_meta_box'],
1459
+				$this->_wp_page_slug,
1460
+				'normal',
1461
+				'high'
1462
+			);
1463
+		}
1464
+		add_meta_box(
1465
+			'edit-reg-registrant-mbox',
1466
+			esc_html__('Contact Details', 'event_espresso'),
1467
+			[$this, '_reg_registrant_side_meta_box'],
1468
+			$this->_wp_page_slug,
1469
+			'side',
1470
+			'high'
1471
+		);
1472
+		if ($this->_registration->group_size() > 1) {
1473
+			add_meta_box(
1474
+				'edit-reg-attendees-mbox',
1475
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1476
+				[$this, '_reg_attendees_meta_box'],
1477
+				$this->_wp_page_slug,
1478
+				'normal',
1479
+				'high'
1480
+			);
1481
+		}
1482
+	}
1483
+
1484
+
1485
+	/**
1486
+	 * set_reg_status_buttons_metabox
1487
+	 *
1488
+	 * @return void
1489
+	 * @throws EE_Error
1490
+	 * @throws EntityNotFoundException
1491
+	 * @throws InvalidArgumentException
1492
+	 * @throws InvalidDataTypeException
1493
+	 * @throws InvalidInterfaceException
1494
+	 * @throws ReflectionException
1495
+	 */
1496
+	public function set_reg_status_buttons_metabox()
1497
+	{
1498
+		$this->_set_registration_object();
1499
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1500
+		$output                 = $change_reg_status_form->form_open(
1501
+			self::add_query_args_and_nonce(
1502
+				[
1503
+					'action' => 'change_reg_status',
1504
+				],
1505
+				REG_ADMIN_URL
1506
+			)
1507
+		);
1508
+		$output                 .= $change_reg_status_form->get_html();
1509
+		$output                 .= $change_reg_status_form->form_close();
1510
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1511
+	}
1512
+
1513
+
1514
+	/**
1515
+	 * @return EE_Form_Section_Proper
1516
+	 * @throws EE_Error
1517
+	 * @throws InvalidArgumentException
1518
+	 * @throws InvalidDataTypeException
1519
+	 * @throws InvalidInterfaceException
1520
+	 * @throws EntityNotFoundException
1521
+	 * @throws ReflectionException
1522
+	 */
1523
+	protected function _generate_reg_status_change_form()
1524
+	{
1525
+		$reg_status_change_form_array = [
1526
+			'name'            => 'reg_status_change_form',
1527
+			'html_id'         => 'reg-status-change-form',
1528
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1529
+			'subsections'     => [
1530
+				'return'         => new EE_Hidden_Input(
1531
+					[
1532
+						'name'    => 'return',
1533
+						'default' => 'view_registration',
1534
+					]
1535
+				),
1536
+				'REG_ID'         => new EE_Hidden_Input(
1537
+					[
1538
+						'name'    => 'REG_ID',
1539
+						'default' => $this->_registration->ID(),
1540
+					]
1541
+				),
1542
+				'current_status' => new EE_Form_Section_HTML(
1543
+					EEH_HTML::table(
1544
+						EEH_HTML::tr(
1545
+							EEH_HTML::th(
1546
+								EEH_HTML::label(
1547
+									EEH_HTML::strong(
1548
+										esc_html__('Current Registration Status', 'event_espresso')
1549
+									)
1550
+								)
1551
+							)
1552
+							. EEH_HTML::td(
1553
+								EEH_HTML::strong(
1554
+									$this->_registration->pretty_status(),
1555
+									'',
1556
+									'status-' . $this->_registration->status_ID(),
1557
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1558
+								)
1559
+							)
1560
+						)
1561
+					)
1562
+				),
1563
+			],
1564
+		];
1565
+		if (
1566
+			EE_Registry::instance()->CAP->current_user_can(
1567
+				'ee_edit_registration',
1568
+				'toggle_registration_status',
1569
+				$this->_registration->ID()
1570
+			)
1571
+		) {
1572
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1573
+				$this->_get_reg_statuses(),
1574
+				[
1575
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1576
+					'default'         => $this->_registration->status_ID(),
1577
+				]
1578
+			);
1579
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1580
+				[
1581
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1582
+					'default'         => false,
1583
+					'html_help_text'  => esc_html__(
1584
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1585
+						'event_espresso'
1586
+					),
1587
+				]
1588
+			);
1589
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1590
+				[
1591
+					'html_class'      => 'button-primary',
1592
+					'html_label_text' => '&nbsp;',
1593
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1594
+				]
1595
+			);
1596
+		}
1597
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1598
+	}
1599
+
1600
+
1601
+	/**
1602
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1603
+	 *
1604
+	 * @return array
1605
+	 * @throws EE_Error
1606
+	 * @throws InvalidArgumentException
1607
+	 * @throws InvalidDataTypeException
1608
+	 * @throws InvalidInterfaceException
1609
+	 * @throws EntityNotFoundException
1610
+	 */
1611
+	protected function _get_reg_statuses()
1612
+	{
1613
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1614
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1615
+		// get current reg status
1616
+		$current_status = $this->_registration->status_ID();
1617
+		// is registration for free event? This will determine whether to display the pending payment option
1618
+		if (
1619
+			$current_status !== EEM_Registration::status_id_pending_payment
1620
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1621
+		) {
1622
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1623
+		}
1624
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1625
+	}
1626
+
1627
+
1628
+	/**
1629
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1630
+	 *
1631
+	 * @param bool $status REG status given for changing registrations to.
1632
+	 * @param bool $notify Whether to send messages notifications or not.
1633
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1634
+	 * @throws DomainException
1635
+	 * @throws EE_Error
1636
+	 * @throws EntityNotFoundException
1637
+	 * @throws InvalidArgumentException
1638
+	 * @throws InvalidDataTypeException
1639
+	 * @throws InvalidInterfaceException
1640
+	 * @throws ReflectionException
1641
+	 * @throws RuntimeException
1642
+	 */
1643
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1644
+	{
1645
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1646
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1647
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1648
+
1649
+		// sanitize $REG_IDs
1650
+		$REG_IDs = array_map('absint', $REG_IDs);
1651
+		// and remove empty entries
1652
+		$REG_IDs = array_filter($REG_IDs);
1653
+
1654
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1655
+
1656
+		/**
1657
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1658
+		 * Currently this value is used downstream by the _process_resend_registration method.
1659
+		 *
1660
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1661
+		 * @param bool                     $status           The status registrations were changed to.
1662
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1663
+		 * @param Registrations_Admin_Page $admin_page_object
1664
+		 */
1665
+		$REG_ID = apply_filters(
1666
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1667
+			$result['REG_ID'],
1668
+			$status,
1669
+			$result['success'],
1670
+			$this
1671
+		);
1672
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1673
+
1674
+		// notify?
1675
+		if (
1676
+			$notify
1677
+			&& $result['success']
1678
+			&& ! empty($REG_ID)
1679
+			&& EE_Registry::instance()->CAP->current_user_can(
1680
+				'ee_send_message',
1681
+				'espresso_registrations_resend_registration'
1682
+			)
1683
+		) {
1684
+			$this->_process_resend_registration();
1685
+		}
1686
+		return $result;
1687
+	}
1688
+
1689
+
1690
+	/**
1691
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1692
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1693
+	 *
1694
+	 * @param array  $REG_IDs
1695
+	 * @param string $status
1696
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1697
+	 *                       slug sent with setting the registration status.
1698
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1699
+	 * @throws EE_Error
1700
+	 * @throws InvalidArgumentException
1701
+	 * @throws InvalidDataTypeException
1702
+	 * @throws InvalidInterfaceException
1703
+	 * @throws ReflectionException
1704
+	 * @throws RuntimeException
1705
+	 * @throws EntityNotFoundException
1706
+	 * @throws DomainException
1707
+	 */
1708
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1709
+	{
1710
+		$success = false;
1711
+		// typecast $REG_IDs
1712
+		$REG_IDs = (array) $REG_IDs;
1713
+		if (! empty($REG_IDs)) {
1714
+			$success = true;
1715
+			// set default status if none is passed
1716
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1717
+			$status_context = $notify
1718
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1719
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1720
+			// loop through REG_ID's and change status
1721
+			foreach ($REG_IDs as $REG_ID) {
1722
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1723
+				if ($registration instanceof EE_Registration) {
1724
+					$registration->set_status(
1725
+						$status,
1726
+						false,
1727
+						new Context(
1728
+							$status_context,
1729
+							esc_html__(
1730
+								'Manually triggered status change on a Registration Admin Page route.',
1731
+								'event_espresso'
1732
+							)
1733
+						)
1734
+					);
1735
+					$result = $registration->save();
1736
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1737
+					$success = $result !== false ? $success : false;
1738
+				}
1739
+			}
1740
+		}
1741
+
1742
+		// return $success and processed registrations
1743
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1744
+	}
1745
+
1746
+
1747
+	/**
1748
+	 * Common logic for setting up success message and redirecting to appropriate route
1749
+	 *
1750
+	 * @param string $STS_ID status id for the registration changed to
1751
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1752
+	 * @return void
1753
+	 * @throws DomainException
1754
+	 * @throws EE_Error
1755
+	 * @throws EntityNotFoundException
1756
+	 * @throws InvalidArgumentException
1757
+	 * @throws InvalidDataTypeException
1758
+	 * @throws InvalidInterfaceException
1759
+	 * @throws ReflectionException
1760
+	 * @throws RuntimeException
1761
+	 */
1762
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1763
+	{
1764
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1765
+			: ['success' => false];
1766
+		$success = isset($result['success']) && $result['success'];
1767
+		// setup success message
1768
+		if ($success) {
1769
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1770
+				$msg = sprintf(
1771
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1772
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1773
+				);
1774
+			} else {
1775
+				$msg = sprintf(
1776
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1777
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1778
+				);
1779
+			}
1780
+			EE_Error::add_success($msg);
1781
+		} else {
1782
+			EE_Error::add_error(
1783
+				esc_html__(
1784
+					'Something went wrong, and the status was not changed',
1785
+					'event_espresso'
1786
+				),
1787
+				__FILE__,
1788
+				__LINE__,
1789
+				__FUNCTION__
1790
+			);
1791
+		}
1792
+		$return = $this->request->getRequestParam('return');
1793
+		$route  = $return === 'view_registration'
1794
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1795
+			: ['action' => 'default'];
1796
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1797
+		$this->_redirect_after_action($success, '', '', $route, true);
1798
+	}
1799
+
1800
+
1801
+	/**
1802
+	 * incoming reg status change from reg details page.
1803
+	 *
1804
+	 * @return void
1805
+	 * @throws EE_Error
1806
+	 * @throws EntityNotFoundException
1807
+	 * @throws InvalidArgumentException
1808
+	 * @throws InvalidDataTypeException
1809
+	 * @throws InvalidInterfaceException
1810
+	 * @throws ReflectionException
1811
+	 * @throws RuntimeException
1812
+	 * @throws DomainException
1813
+	 */
1814
+	protected function _change_reg_status()
1815
+	{
1816
+		$this->request->setRequestParam('return', 'view_registration');
1817
+		// set notify based on whether the send notifications toggle is set or not
1818
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1819
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1820
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1821
+		switch ($reg_status) {
1822
+			case EEM_Registration::status_id_approved:
1823
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1824
+				$this->approve_registration($notify);
1825
+				break;
1826
+			case EEM_Registration::status_id_pending_payment:
1827
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1828
+				$this->pending_registration($notify);
1829
+				break;
1830
+			case EEM_Registration::status_id_not_approved:
1831
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1832
+				$this->not_approve_registration($notify);
1833
+				break;
1834
+			case EEM_Registration::status_id_declined:
1835
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1836
+				$this->decline_registration($notify);
1837
+				break;
1838
+			case EEM_Registration::status_id_cancelled:
1839
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1840
+				$this->cancel_registration($notify);
1841
+				break;
1842
+			case EEM_Registration::status_id_wait_list:
1843
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1844
+				$this->wait_list_registration($notify);
1845
+				break;
1846
+			case EEM_Registration::status_id_incomplete:
1847
+			default:
1848
+				$this->request->unSetRequestParam('return');
1849
+				$this->_reg_status_change_return('');
1850
+				break;
1851
+		}
1852
+	}
1853
+
1854
+
1855
+	/**
1856
+	 * Callback for bulk action routes.
1857
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1858
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1859
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1860
+	 * when an action is happening on just a single registration).
1861
+	 *
1862
+	 * @param      $action
1863
+	 * @param bool $notify
1864
+	 */
1865
+	protected function bulk_action_on_registrations($action, $notify = false)
1866
+	{
1867
+		do_action(
1868
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1869
+			$this,
1870
+			$action,
1871
+			$notify
1872
+		);
1873
+		$method = $action . '_registration';
1874
+		if (method_exists($this, $method)) {
1875
+			$this->$method($notify);
1876
+		}
1877
+	}
1878
+
1879
+
1880
+	/**
1881
+	 * approve_registration
1882
+	 *
1883
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1884
+	 * @return void
1885
+	 * @throws EE_Error
1886
+	 * @throws EntityNotFoundException
1887
+	 * @throws InvalidArgumentException
1888
+	 * @throws InvalidDataTypeException
1889
+	 * @throws InvalidInterfaceException
1890
+	 * @throws ReflectionException
1891
+	 * @throws RuntimeException
1892
+	 * @throws DomainException
1893
+	 */
1894
+	protected function approve_registration($notify = false)
1895
+	{
1896
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1897
+	}
1898
+
1899
+
1900
+	/**
1901
+	 * decline_registration
1902
+	 *
1903
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1904
+	 * @return void
1905
+	 * @throws EE_Error
1906
+	 * @throws EntityNotFoundException
1907
+	 * @throws InvalidArgumentException
1908
+	 * @throws InvalidDataTypeException
1909
+	 * @throws InvalidInterfaceException
1910
+	 * @throws ReflectionException
1911
+	 * @throws RuntimeException
1912
+	 * @throws DomainException
1913
+	 */
1914
+	protected function decline_registration($notify = false)
1915
+	{
1916
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1917
+	}
1918
+
1919
+
1920
+	/**
1921
+	 * cancel_registration
1922
+	 *
1923
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1924
+	 * @return void
1925
+	 * @throws EE_Error
1926
+	 * @throws EntityNotFoundException
1927
+	 * @throws InvalidArgumentException
1928
+	 * @throws InvalidDataTypeException
1929
+	 * @throws InvalidInterfaceException
1930
+	 * @throws ReflectionException
1931
+	 * @throws RuntimeException
1932
+	 * @throws DomainException
1933
+	 */
1934
+	protected function cancel_registration($notify = false)
1935
+	{
1936
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1937
+	}
1938
+
1939
+
1940
+	/**
1941
+	 * not_approve_registration
1942
+	 *
1943
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1944
+	 * @return void
1945
+	 * @throws EE_Error
1946
+	 * @throws EntityNotFoundException
1947
+	 * @throws InvalidArgumentException
1948
+	 * @throws InvalidDataTypeException
1949
+	 * @throws InvalidInterfaceException
1950
+	 * @throws ReflectionException
1951
+	 * @throws RuntimeException
1952
+	 * @throws DomainException
1953
+	 */
1954
+	protected function not_approve_registration($notify = false)
1955
+	{
1956
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1957
+	}
1958
+
1959
+
1960
+	/**
1961
+	 * decline_registration
1962
+	 *
1963
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1964
+	 * @return void
1965
+	 * @throws EE_Error
1966
+	 * @throws EntityNotFoundException
1967
+	 * @throws InvalidArgumentException
1968
+	 * @throws InvalidDataTypeException
1969
+	 * @throws InvalidInterfaceException
1970
+	 * @throws ReflectionException
1971
+	 * @throws RuntimeException
1972
+	 * @throws DomainException
1973
+	 */
1974
+	protected function pending_registration($notify = false)
1975
+	{
1976
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1977
+	}
1978
+
1979
+
1980
+	/**
1981
+	 * waitlist_registration
1982
+	 *
1983
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1984
+	 * @return void
1985
+	 * @throws EE_Error
1986
+	 * @throws EntityNotFoundException
1987
+	 * @throws InvalidArgumentException
1988
+	 * @throws InvalidDataTypeException
1989
+	 * @throws InvalidInterfaceException
1990
+	 * @throws ReflectionException
1991
+	 * @throws RuntimeException
1992
+	 * @throws DomainException
1993
+	 */
1994
+	protected function wait_list_registration($notify = false)
1995
+	{
1996
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1997
+	}
1998
+
1999
+
2000
+	/**
2001
+	 * generates HTML for the Registration main meta box
2002
+	 *
2003
+	 * @return void
2004
+	 * @throws DomainException
2005
+	 * @throws EE_Error
2006
+	 * @throws InvalidArgumentException
2007
+	 * @throws InvalidDataTypeException
2008
+	 * @throws InvalidInterfaceException
2009
+	 * @throws ReflectionException
2010
+	 * @throws EntityNotFoundException
2011
+	 */
2012
+	public function _reg_details_meta_box()
2013
+	{
2014
+		EEH_Autoloader::register_line_item_display_autoloaders();
2015
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2016
+		EE_Registry::instance()->load_helper('Line_Item');
2017
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2018
+			: EE_Transaction::new_instance();
2019
+		$this->_session = $transaction->session_data();
2020
+		$filters        = new EE_Line_Item_Filter_Collection();
2021
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2022
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2023
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2024
+			$filters,
2025
+			$transaction->total_line_item()
2026
+		);
2027
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2028
+		$line_item_display                       = new EE_Line_Item_Display(
2029
+			'reg_admin_table',
2030
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2031
+		);
2032
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2033
+			$filtered_line_item_tree,
2034
+			['EE_Registration' => $this->_registration]
2035
+		);
2036
+		$attendee                                = $this->_registration->attendee();
2037
+		if (
2038
+			EE_Registry::instance()->CAP->current_user_can(
2039
+				'ee_read_transaction',
2040
+				'espresso_transactions_view_transaction'
2041
+			)
2042
+		) {
2043
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2044
+				EE_Admin_Page::add_query_args_and_nonce(
2045
+					[
2046
+						'action' => 'view_transaction',
2047
+						'TXN_ID' => $transaction->ID(),
2048
+					],
2049
+					TXN_ADMIN_URL
2050
+				),
2051
+				esc_html__(' View Transaction', 'event_espresso'),
2052
+				'button secondary-button right',
2053
+				'dashicons dashicons-cart'
2054
+			);
2055
+		} else {
2056
+			$this->_template_args['view_transaction_button'] = '';
2057
+		}
2058
+		if (
2059
+			$attendee instanceof EE_Attendee
2060
+			&& EE_Registry::instance()->CAP->current_user_can(
2061
+				'ee_send_message',
2062
+				'espresso_registrations_resend_registration'
2063
+			)
2064
+		) {
2065
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2066
+				EE_Admin_Page::add_query_args_and_nonce(
2067
+					[
2068
+						'action'      => 'resend_registration',
2069
+						'_REG_ID'     => $this->_registration->ID(),
2070
+						'redirect_to' => 'view_registration',
2071
+					],
2072
+					REG_ADMIN_URL
2073
+				),
2074
+				esc_html__(' Resend Registration', 'event_espresso'),
2075
+				'button secondary-button right',
2076
+				'dashicons dashicons-email-alt'
2077
+			);
2078
+		} else {
2079
+			$this->_template_args['resend_registration_button'] = '';
2080
+		}
2081
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2082
+		$payment                               = $transaction->get_first_related('Payment');
2083
+		$payment                               = ! $payment instanceof EE_Payment
2084
+			? EE_Payment::new_instance()
2085
+			: $payment;
2086
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2087
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2088
+			? EE_Payment_Method::new_instance()
2089
+			: $payment_method;
2090
+		$reg_details                           = [
2091
+			'payment_method'       => $payment_method->name(),
2092
+			'response_msg'         => $payment->gateway_response(),
2093
+			'registration_id'      => $this->_registration->get('REG_code'),
2094
+			'registration_session' => $this->_registration->session_ID(),
2095
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2096
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2097
+		];
2098
+		if (isset($reg_details['registration_id'])) {
2099
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2100
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2101
+				'Registration ID',
2102
+				'event_espresso'
2103
+			);
2104
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2105
+		}
2106
+		if (isset($reg_details['payment_method'])) {
2107
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2108
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2109
+				'Most Recent Payment Method',
2110
+				'event_espresso'
2111
+			);
2112
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2113
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2114
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2115
+				'Payment method response',
2116
+				'event_espresso'
2117
+			);
2118
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2119
+		}
2120
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2121
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2122
+			'Registration Session',
2123
+			'event_espresso'
2124
+		);
2125
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2126
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2127
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2128
+			'Registration placed from IP',
2129
+			'event_espresso'
2130
+		);
2131
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2132
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2133
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2134
+			'Registrant User Agent',
2135
+			'event_espresso'
2136
+		);
2137
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2138
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2139
+			[
2140
+				'action'   => 'default',
2141
+				'event_id' => $this->_registration->event_ID(),
2142
+			],
2143
+			REG_ADMIN_URL
2144
+		);
2145
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2146
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2147
+		$template_path                                                        =
2148
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2149
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2150
+	}
2151
+
2152
+
2153
+	/**
2154
+	 * generates HTML for the Registration Questions meta box.
2155
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2156
+	 * otherwise uses new forms system
2157
+	 *
2158
+	 * @return void
2159
+	 * @throws DomainException
2160
+	 * @throws EE_Error
2161
+	 * @throws InvalidArgumentException
2162
+	 * @throws InvalidDataTypeException
2163
+	 * @throws InvalidInterfaceException
2164
+	 * @throws ReflectionException
2165
+	 */
2166
+	public function _reg_questions_meta_box()
2167
+	{
2168
+		// allow someone to override this method entirely
2169
+		if (
2170
+			apply_filters(
2171
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2172
+				true,
2173
+				$this,
2174
+				$this->_registration
2175
+			)
2176
+		) {
2177
+			$form                                              = $this->_get_reg_custom_questions_form(
2178
+				$this->_registration->ID()
2179
+			);
2180
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2181
+				? $form->get_html_and_js()
2182
+				: '';
2183
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2184
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2185
+			$template_path                                     =
2186
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2187
+			EEH_Template::display_template($template_path, $this->_template_args);
2188
+		}
2189
+	}
2190
+
2191
+
2192
+	/**
2193
+	 * form_before_question_group
2194
+	 *
2195
+	 * @param string $output
2196
+	 * @return        string
2197
+	 * @deprecated    as of 4.8.32.rc.000
2198
+	 */
2199
+	public function form_before_question_group($output)
2200
+	{
2201
+		EE_Error::doing_it_wrong(
2202
+			__CLASS__ . '::' . __FUNCTION__,
2203
+			esc_html__(
2204
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2205
+				'event_espresso'
2206
+			),
2207
+			'4.8.32.rc.000'
2208
+		);
2209
+		return '
2210 2210
 	<table class="form-table ee-width-100">
2211 2211
 		<tbody>
2212 2212
 			';
2213
-    }
2214
-
2215
-
2216
-    /**
2217
-     * form_after_question_group
2218
-     *
2219
-     * @param string $output
2220
-     * @return        string
2221
-     * @deprecated    as of 4.8.32.rc.000
2222
-     */
2223
-    public function form_after_question_group($output)
2224
-    {
2225
-        EE_Error::doing_it_wrong(
2226
-            __CLASS__ . '::' . __FUNCTION__,
2227
-            esc_html__(
2228
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2229
-                'event_espresso'
2230
-            ),
2231
-            '4.8.32.rc.000'
2232
-        );
2233
-        return '
2213
+	}
2214
+
2215
+
2216
+	/**
2217
+	 * form_after_question_group
2218
+	 *
2219
+	 * @param string $output
2220
+	 * @return        string
2221
+	 * @deprecated    as of 4.8.32.rc.000
2222
+	 */
2223
+	public function form_after_question_group($output)
2224
+	{
2225
+		EE_Error::doing_it_wrong(
2226
+			__CLASS__ . '::' . __FUNCTION__,
2227
+			esc_html__(
2228
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2229
+				'event_espresso'
2230
+			),
2231
+			'4.8.32.rc.000'
2232
+		);
2233
+		return '
2234 2234
 			<tr class="hide-if-no-js">
2235 2235
 				<th> </th>
2236 2236
 				<td class="reg-admin-edit-attendee-question-td">
2237 2237
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2238
-               . esc_attr__('click to edit question', 'event_espresso')
2239
-               . '">
2238
+			   . esc_attr__('click to edit question', 'event_espresso')
2239
+			   . '">
2240 2240
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2241
-               . esc_html__('edit the above question group', 'event_espresso')
2242
-               . '</span>
2241
+			   . esc_html__('edit the above question group', 'event_espresso')
2242
+			   . '</span>
2243 2243
 						<div class="dashicons dashicons-edit"></div>
2244 2244
 					</a>
2245 2245
 				</td>
@@ -2247,637 +2247,637 @@  discard block
 block discarded – undo
2247 2247
 		</tbody>
2248 2248
 	</table>
2249 2249
 ';
2250
-    }
2251
-
2252
-
2253
-    /**
2254
-     * form_form_field_label_wrap
2255
-     *
2256
-     * @param string $label
2257
-     * @return        string
2258
-     * @deprecated    as of 4.8.32.rc.000
2259
-     */
2260
-    public function form_form_field_label_wrap($label)
2261
-    {
2262
-        EE_Error::doing_it_wrong(
2263
-            __CLASS__ . '::' . __FUNCTION__,
2264
-            esc_html__(
2265
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266
-                'event_espresso'
2267
-            ),
2268
-            '4.8.32.rc.000'
2269
-        );
2270
-        return '
2250
+	}
2251
+
2252
+
2253
+	/**
2254
+	 * form_form_field_label_wrap
2255
+	 *
2256
+	 * @param string $label
2257
+	 * @return        string
2258
+	 * @deprecated    as of 4.8.32.rc.000
2259
+	 */
2260
+	public function form_form_field_label_wrap($label)
2261
+	{
2262
+		EE_Error::doing_it_wrong(
2263
+			__CLASS__ . '::' . __FUNCTION__,
2264
+			esc_html__(
2265
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266
+				'event_espresso'
2267
+			),
2268
+			'4.8.32.rc.000'
2269
+		);
2270
+		return '
2271 2271
 			<tr>
2272 2272
 				<th>
2273 2273
 					' . $label . '
2274 2274
 				</th>';
2275
-    }
2276
-
2277
-
2278
-    /**
2279
-     * form_form_field_input__wrap
2280
-     *
2281
-     * @param string $input
2282
-     * @return        string
2283
-     * @deprecated    as of 4.8.32.rc.000
2284
-     */
2285
-    public function form_form_field_input__wrap($input)
2286
-    {
2287
-        EE_Error::doing_it_wrong(
2288
-            __CLASS__ . '::' . __FUNCTION__,
2289
-            esc_html__(
2290
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2291
-                'event_espresso'
2292
-            ),
2293
-            '4.8.32.rc.000'
2294
-        );
2295
-        return '
2275
+	}
2276
+
2277
+
2278
+	/**
2279
+	 * form_form_field_input__wrap
2280
+	 *
2281
+	 * @param string $input
2282
+	 * @return        string
2283
+	 * @deprecated    as of 4.8.32.rc.000
2284
+	 */
2285
+	public function form_form_field_input__wrap($input)
2286
+	{
2287
+		EE_Error::doing_it_wrong(
2288
+			__CLASS__ . '::' . __FUNCTION__,
2289
+			esc_html__(
2290
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2291
+				'event_espresso'
2292
+			),
2293
+			'4.8.32.rc.000'
2294
+		);
2295
+		return '
2296 2296
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2297 2297
 					' . $input . '
2298 2298
 				</td>
2299 2299
 			</tr>';
2300
-    }
2301
-
2302
-
2303
-    /**
2304
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2305
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2306
-     * to display the page
2307
-     *
2308
-     * @return void
2309
-     * @throws EE_Error
2310
-     * @throws InvalidArgumentException
2311
-     * @throws InvalidDataTypeException
2312
-     * @throws InvalidInterfaceException
2313
-     * @throws ReflectionException
2314
-     */
2315
-    protected function _update_attendee_registration_form()
2316
-    {
2317
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2318
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2319
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2320
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2321
-            if ($success) {
2322
-                $what  = esc_html__('Registration Form', 'event_espresso');
2323
-                $route = $REG_ID
2324
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2325
-                    : ['action' => 'default'];
2326
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2327
-            }
2328
-        }
2329
-    }
2330
-
2331
-
2332
-    /**
2333
-     * Gets the form for saving registrations custom questions (if done
2334
-     * previously retrieves the cached form object, which may have validation errors in it)
2335
-     *
2336
-     * @param int $REG_ID
2337
-     * @return EE_Registration_Custom_Questions_Form
2338
-     * @throws EE_Error
2339
-     * @throws InvalidArgumentException
2340
-     * @throws InvalidDataTypeException
2341
-     * @throws InvalidInterfaceException
2342
-     * @throws ReflectionException
2343
-     */
2344
-    protected function _get_reg_custom_questions_form($REG_ID)
2345
-    {
2346
-        if (! $this->_reg_custom_questions_form) {
2347
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350
-            );
2351
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2352
-        }
2353
-        return $this->_reg_custom_questions_form;
2354
-    }
2355
-
2356
-
2357
-    /**
2358
-     * Saves
2359
-     *
2360
-     * @param bool $REG_ID
2361
-     * @return bool
2362
-     * @throws EE_Error
2363
-     * @throws InvalidArgumentException
2364
-     * @throws InvalidDataTypeException
2365
-     * @throws InvalidInterfaceException
2366
-     * @throws ReflectionException
2367
-     */
2368
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2369
-    {
2370
-        if (! $REG_ID) {
2371
-            EE_Error::add_error(
2372
-                esc_html__(
2373
-                    'An error occurred. No registration ID was received.',
2374
-                    'event_espresso'
2375
-                ),
2376
-                __FILE__,
2377
-                __FUNCTION__,
2378
-                __LINE__
2379
-            );
2380
-        }
2381
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2382
-        $form->receive_form_submission($this->request->requestParams());
2383
-        $success = false;
2384
-        if ($form->is_valid()) {
2385
-            foreach ($form->subforms() as $question_group_form) {
2386
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2387
-                    $where_conditions    = [
2388
-                        'QST_ID' => $question_id,
2389
-                        'REG_ID' => $REG_ID,
2390
-                    ];
2391
-                    $possibly_new_values = [
2392
-                        'ANS_value' => $input->normalized_value(),
2393
-                    ];
2394
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2395
-                    if ($answer instanceof EE_Answer) {
2396
-                        $success = $answer->save($possibly_new_values);
2397
-                    } else {
2398
-                        // insert it then
2399
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2400
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2401
-                        $success     = $answer->save();
2402
-                    }
2403
-                }
2404
-            }
2405
-        } else {
2406
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2407
-        }
2408
-        return $success;
2409
-    }
2410
-
2411
-
2412
-    /**
2413
-     * generates HTML for the Registration main meta box
2414
-     *
2415
-     * @return void
2416
-     * @throws DomainException
2417
-     * @throws EE_Error
2418
-     * @throws InvalidArgumentException
2419
-     * @throws InvalidDataTypeException
2420
-     * @throws InvalidInterfaceException
2421
-     * @throws ReflectionException
2422
-     */
2423
-    public function _reg_attendees_meta_box()
2424
-    {
2425
-        $REG = $this->getRegistrationModel();
2426
-        // get all other registrations on this transaction, and cache
2427
-        // the attendees for them so we don't have to run another query using force_join
2428
-        $registrations                           = $REG->get_all(
2429
-            [
2430
-                [
2431
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2432
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2433
-                ],
2434
-                'force_join'               => ['Attendee'],
2435
-                'default_where_conditions' => 'other_models_only',
2436
-            ]
2437
-        );
2438
-        $this->_template_args['attendees']       = [];
2439
-        $this->_template_args['attendee_notice'] = '';
2440
-        if (
2441
-            empty($registrations)
2442
-            || (is_array($registrations)
2443
-                && ! EEH_Array::get_one_item_from_array($registrations))
2444
-        ) {
2445
-            EE_Error::add_error(
2446
-                esc_html__(
2447
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2448
-                    'event_espresso'
2449
-                ),
2450
-                __FILE__,
2451
-                __FUNCTION__,
2452
-                __LINE__
2453
-            );
2454
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2455
-        } else {
2456
-            $att_nmbr = 1;
2457
-            foreach ($registrations as $registration) {
2458
-                /* @var $registration EE_Registration */
2459
-                $attendee                                                      = $registration->attendee()
2460
-                    ? $registration->attendee()
2461
-                    : $this->getAttendeeModel()->create_default_object();
2462
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2467
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2468
-                    ', ',
2469
-                    $attendee->full_address_as_array()
2470
-                );
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2472
-                    [
2473
-                        'action' => 'edit_attendee',
2474
-                        'post'   => $attendee->ID(),
2475
-                    ],
2476
-                    REG_ADMIN_URL
2477
-                );
2478
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2479
-                    $registration->event_obj() instanceof EE_Event
2480
-                        ? $registration->event_obj()->name()
2481
-                        : '';
2482
-                $att_nmbr++;
2483
-            }
2484
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485
-        }
2486
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2487
-        EEH_Template::display_template($template_path, $this->_template_args);
2488
-    }
2489
-
2490
-
2491
-    /**
2492
-     * generates HTML for the Edit Registration side meta box
2493
-     *
2494
-     * @return void
2495
-     * @throws DomainException
2496
-     * @throws EE_Error
2497
-     * @throws InvalidArgumentException
2498
-     * @throws InvalidDataTypeException
2499
-     * @throws InvalidInterfaceException
2500
-     * @throws ReflectionException
2501
-     */
2502
-    public function _reg_registrant_side_meta_box()
2503
-    {
2504
-        /*@var $attendee EE_Attendee */
2505
-        $att_check = $this->_registration->attendee();
2506
-        $attendee  = $att_check instanceof EE_Attendee
2507
-            ? $att_check
2508
-            : $this->getAttendeeModel()->create_default_object();
2509
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2510
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2511
-        // primary registration object (that way we know if we need to show create button or not)
2512
-        if (! $this->_registration->is_primary_registrant()) {
2513
-            $primary_registration = $this->_registration->get_primary_registration();
2514
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2515
-                : null;
2516
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2517
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2518
-                // custom attendee object so let's not worry about the primary reg.
2519
-                $primary_registration = null;
2520
-            }
2521
-        } else {
2522
-            $primary_registration = null;
2523
-        }
2524
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2525
-        $this->_template_args['fname']             = $attendee->fname();
2526
-        $this->_template_args['lname']             = $attendee->lname();
2527
-        $this->_template_args['email']             = $attendee->email();
2528
-        $this->_template_args['phone']             = $attendee->phone();
2529
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2530
-        // edit link
2531
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2532
-            [
2533
-                'action' => 'edit_attendee',
2534
-                'post'   => $attendee->ID(),
2535
-            ],
2536
-            REG_ADMIN_URL
2537
-        );
2538
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2539
-        // create link
2540
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2541
-            ? EE_Admin_Page::add_query_args_and_nonce(
2542
-                [
2543
-                    'action'  => 'duplicate_attendee',
2544
-                    '_REG_ID' => $this->_registration->ID(),
2545
-                ],
2546
-                REG_ADMIN_URL
2547
-            ) : '';
2548
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2549
-        $this->_template_args['att_check']    = $att_check;
2550
-        $template_path                        =
2551
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2552
-        EEH_Template::display_template($template_path, $this->_template_args);
2553
-    }
2554
-
2555
-
2556
-    /**
2557
-     * trash or restore registrations
2558
-     *
2559
-     * @param boolean $trash whether to archive or restore
2560
-     * @return void
2561
-     * @throws EE_Error
2562
-     * @throws InvalidArgumentException
2563
-     * @throws InvalidDataTypeException
2564
-     * @throws InvalidInterfaceException
2565
-     * @throws RuntimeException
2566
-     */
2567
-    protected function _trash_or_restore_registrations($trash = true)
2568
-    {
2569
-        // if empty _REG_ID then get out because there's nothing to do
2570
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2571
-        if (empty($REG_IDs)) {
2572
-            EE_Error::add_error(
2573
-                sprintf(
2574
-                    esc_html__(
2575
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2576
-                        'event_espresso'
2577
-                    ),
2578
-                    $trash ? 'trash' : 'restore'
2579
-                ),
2580
-                __FILE__,
2581
-                __LINE__,
2582
-                __FUNCTION__
2583
-            );
2584
-            $this->_redirect_after_action(false, '', '', [], true);
2585
-        }
2586
-        $success        = 0;
2587
-        $overwrite_msgs = false;
2588
-        // Checkboxes
2589
-        $reg_count = count($REG_IDs);
2590
-        // cycle thru checkboxes
2591
-        foreach ($REG_IDs as $REG_ID) {
2592
-            /** @var EE_Registration $REG */
2593
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2594
-            $payments = $REG->registration_payments();
2595
-            if (! empty($payments)) {
2596
-                $name           = $REG->attendee() instanceof EE_Attendee
2597
-                    ? $REG->attendee()->full_name()
2598
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2599
-                $overwrite_msgs = true;
2600
-                EE_Error::add_error(
2601
-                    sprintf(
2602
-                        esc_html__(
2603
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2604
-                            'event_espresso'
2605
-                        ),
2606
-                        $name
2607
-                    ),
2608
-                    __FILE__,
2609
-                    __FUNCTION__,
2610
-                    __LINE__
2611
-                );
2612
-                // can't trash this registration because it has payments.
2613
-                continue;
2614
-            }
2615
-            $updated = $trash ? $REG->delete() : $REG->restore();
2616
-            if ($updated) {
2617
-                $success++;
2618
-            }
2619
-        }
2620
-        $this->_redirect_after_action(
2621
-            $success === $reg_count, // were ALL registrations affected?
2622
-            $success > 1
2623
-                ? esc_html__('Registrations', 'event_espresso')
2624
-                : esc_html__('Registration', 'event_espresso'),
2625
-            $trash
2626
-                ? esc_html__('moved to the trash', 'event_espresso')
2627
-                : esc_html__('restored', 'event_espresso'),
2628
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2629
-            $overwrite_msgs
2630
-        );
2631
-    }
2632
-
2633
-
2634
-    /**
2635
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2636
-     * registration but also.
2637
-     * 1. Removing relations to EE_Attendee
2638
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2639
-     * ALSO trashed.
2640
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2641
-     * 4. Removing relationships between all tickets and the related registrations
2642
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2643
-     * 6. Deleting permanently any related Checkins.
2644
-     *
2645
-     * @return void
2646
-     * @throws EE_Error
2647
-     * @throws InvalidArgumentException
2648
-     * @throws InvalidDataTypeException
2649
-     * @throws InvalidInterfaceException
2650
-     * @throws ReflectionException
2651
-     */
2652
-    protected function _delete_registrations()
2653
-    {
2654
-        $REG_MDL = $this->getRegistrationModel();
2655
-        $success = 0;
2656
-        // Checkboxes
2657
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2658
-
2659
-        if (! empty($REG_IDs)) {
2660
-            // if array has more than one element than success message should be plural
2661
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2662
-            // cycle thru checkboxes
2663
-            foreach ($REG_IDs as $REG_ID) {
2664
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2665
-                if (! $REG instanceof EE_Registration) {
2666
-                    continue;
2667
-                }
2668
-                $deleted = $this->_delete_registration($REG);
2669
-                if (! $deleted) {
2670
-                    $success = 0;
2671
-                }
2672
-            }
2673
-        }
2674
-
2675
-        $what        = $success > 1
2676
-            ? esc_html__('Registrations', 'event_espresso')
2677
-            : esc_html__('Registration', 'event_espresso');
2678
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2679
-        $this->_redirect_after_action(
2680
-            $success,
2681
-            $what,
2682
-            $action_desc,
2683
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2684
-            true
2685
-        );
2686
-    }
2687
-
2688
-
2689
-    /**
2690
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2691
-     * models get affected.
2692
-     *
2693
-     * @param EE_Registration $REG registration to be deleted permanently
2694
-     * @return bool true = successful deletion, false = fail.
2695
-     * @throws EE_Error
2696
-     * @throws InvalidArgumentException
2697
-     * @throws InvalidDataTypeException
2698
-     * @throws InvalidInterfaceException
2699
-     * @throws ReflectionException
2700
-     */
2701
-    protected function _delete_registration(EE_Registration $REG)
2702
-    {
2703
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2704
-        // registrations on the transaction that are NOT trashed.
2705
-        $TXN = $REG->get_first_related('Transaction');
2706
-        if (! $TXN instanceof EE_Transaction) {
2707
-            EE_Error::add_error(
2708
-                sprintf(
2709
-                    esc_html__(
2710
-                        'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2711
-                        'event_espresso'
2712
-                    ),
2713
-                    $REG->id()
2714
-                ),
2715
-                __FILE__,
2716
-                __FUNCTION__,
2717
-                __LINE__
2718
-            );
2719
-            return false;
2720
-        }
2721
-        $REGS        = $TXN->get_many_related('Registration');
2722
-        $all_trashed = true;
2723
-        foreach ($REGS as $registration) {
2724
-            if (! $registration->get('REG_deleted')) {
2725
-                $all_trashed = false;
2726
-            }
2727
-        }
2728
-        if (! $all_trashed) {
2729
-            EE_Error::add_error(
2730
-                esc_html__(
2731
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2732
-                    'event_espresso'
2733
-                ),
2734
-                __FILE__,
2735
-                __FUNCTION__,
2736
-                __LINE__
2737
-            );
2738
-            return false;
2739
-        }
2740
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2741
-        // separately from THIS one).
2742
-        foreach ($REGS as $registration) {
2743
-            // delete related answers
2744
-            $registration->delete_related_permanently('Answer');
2745
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2746
-            $attendee = $registration->get_first_related('Attendee');
2747
-            if ($attendee instanceof EE_Attendee) {
2748
-                $registration->_remove_relation_to($attendee, 'Attendee');
2749
-            }
2750
-            // now remove relationships to tickets on this registration.
2751
-            $registration->_remove_relations('Ticket');
2752
-            // now delete permanently the checkins related to this registration.
2753
-            $registration->delete_related_permanently('Checkin');
2754
-            if ($registration->ID() === $REG->ID()) {
2755
-                continue;
2756
-            } //we don't want to delete permanently the existing registration just yet.
2757
-            // remove relation to transaction for these registrations if NOT the existing registrations
2758
-            $registration->_remove_relations('Transaction');
2759
-            // delete permanently any related messages.
2760
-            $registration->delete_related_permanently('Message');
2761
-            // now delete this registration permanently
2762
-            $registration->delete_permanently();
2763
-        }
2764
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2765
-        // (the transaction and line items should be all that's left).
2766
-        // delete the line items related to the transaction for this registration.
2767
-        $TXN->delete_related_permanently('Line_Item');
2768
-        // we need to remove all the relationships on the transaction
2769
-        $TXN->delete_related_permanently('Payment');
2770
-        $TXN->delete_related_permanently('Extra_Meta');
2771
-        $TXN->delete_related_permanently('Message');
2772
-        // now we can delete this REG permanently (and the transaction of course)
2773
-        $REG->delete_related_permanently('Transaction');
2774
-        return $REG->delete_permanently();
2775
-    }
2776
-
2777
-
2778
-    /**
2779
-     *    generates HTML for the Register New Attendee Admin page
2780
-     *
2781
-     * @throws DomainException
2782
-     * @throws EE_Error
2783
-     * @throws InvalidArgumentException
2784
-     * @throws InvalidDataTypeException
2785
-     * @throws InvalidInterfaceException
2786
-     * @throws ReflectionException
2787
-     */
2788
-    public function new_registration()
2789
-    {
2790
-        if (! $this->_set_reg_event()) {
2791
-            throw new EE_Error(
2792
-                esc_html__(
2793
-                    'Unable to continue with registering because there is no Event ID in the request',
2794
-                    'event_espresso'
2795
-                )
2796
-            );
2797
-        }
2798
-        /** @var CurrentPage $current_page */
2799
-        $current_page = $this->loader->getShared(CurrentPage::class);
2800
-        $current_page->setEspressoPage(true);
2801
-        // gotta start with a clean slate if we're not coming here via ajax
2802
-        if (
2803
-            ! $this->request->isAjax()
2804
-            && (
2805
-                ! $this->request->requestParamIsSet('processing_registration')
2806
-                || $this->request->requestParamIsSet('step_error')
2807
-            )
2808
-        ) {
2809
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2810
-        }
2811
-        $this->_template_args['event_name'] = '';
2812
-        // event name
2813
-        if ($this->_reg_event) {
2814
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2815
-            $edit_event_url                     = self::add_query_args_and_nonce(
2816
-                [
2817
-                    'action' => 'edit',
2818
-                    'post'   => $this->_reg_event->ID(),
2819
-                ],
2820
-                EVENTS_ADMIN_URL
2821
-            );
2822
-            $edit_event_lnk                     = '<a href="'
2823
-                                                  . $edit_event_url
2824
-                                                  . '" title="'
2825
-                                                  . esc_attr__('Edit ', 'event_espresso')
2826
-                                                  . $this->_reg_event->name()
2827
-                                                  . '">'
2828
-                                                  . esc_html__('Edit Event', 'event_espresso')
2829
-                                                  . '</a>';
2830
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2831
-                                                   . $edit_event_lnk
2832
-                                                   . '</span>';
2833
-        }
2834
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2835
-        if ($this->request->isAjax()) {
2836
-            $this->_return_json();
2837
-        }
2838
-        // grab header
2839
-        $template_path                              =
2840
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2841
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2842
-            $template_path,
2843
-            $this->_template_args,
2844
-            true
2845
-        );
2846
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2847
-        // the details template wrapper
2848
-        $this->display_admin_page_with_sidebar();
2849
-    }
2850
-
2851
-
2852
-    /**
2853
-     * This returns the content for a registration step
2854
-     *
2855
-     * @return string html
2856
-     * @throws DomainException
2857
-     * @throws EE_Error
2858
-     * @throws InvalidArgumentException
2859
-     * @throws InvalidDataTypeException
2860
-     * @throws InvalidInterfaceException
2861
-     * @throws ReflectionException
2862
-     */
2863
-    protected function _get_registration_step_content()
2864
-    {
2865
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2866
-            $warning_msg = sprintf(
2867
-                esc_html__(
2868
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2869
-                    'event_espresso'
2870
-                ),
2871
-                '<br />',
2872
-                '<h3 class="important-notice">',
2873
-                '</h3>',
2874
-                '<div class="float-right">',
2875
-                '<span id="redirect_timer" class="important-notice">30</span>',
2876
-                '</div>',
2877
-                '<b>',
2878
-                '</b>'
2879
-            );
2880
-            return '
2300
+	}
2301
+
2302
+
2303
+	/**
2304
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2305
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2306
+	 * to display the page
2307
+	 *
2308
+	 * @return void
2309
+	 * @throws EE_Error
2310
+	 * @throws InvalidArgumentException
2311
+	 * @throws InvalidDataTypeException
2312
+	 * @throws InvalidInterfaceException
2313
+	 * @throws ReflectionException
2314
+	 */
2315
+	protected function _update_attendee_registration_form()
2316
+	{
2317
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2318
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2319
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2320
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2321
+			if ($success) {
2322
+				$what  = esc_html__('Registration Form', 'event_espresso');
2323
+				$route = $REG_ID
2324
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2325
+					: ['action' => 'default'];
2326
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2327
+			}
2328
+		}
2329
+	}
2330
+
2331
+
2332
+	/**
2333
+	 * Gets the form for saving registrations custom questions (if done
2334
+	 * previously retrieves the cached form object, which may have validation errors in it)
2335
+	 *
2336
+	 * @param int $REG_ID
2337
+	 * @return EE_Registration_Custom_Questions_Form
2338
+	 * @throws EE_Error
2339
+	 * @throws InvalidArgumentException
2340
+	 * @throws InvalidDataTypeException
2341
+	 * @throws InvalidInterfaceException
2342
+	 * @throws ReflectionException
2343
+	 */
2344
+	protected function _get_reg_custom_questions_form($REG_ID)
2345
+	{
2346
+		if (! $this->_reg_custom_questions_form) {
2347
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350
+			);
2351
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2352
+		}
2353
+		return $this->_reg_custom_questions_form;
2354
+	}
2355
+
2356
+
2357
+	/**
2358
+	 * Saves
2359
+	 *
2360
+	 * @param bool $REG_ID
2361
+	 * @return bool
2362
+	 * @throws EE_Error
2363
+	 * @throws InvalidArgumentException
2364
+	 * @throws InvalidDataTypeException
2365
+	 * @throws InvalidInterfaceException
2366
+	 * @throws ReflectionException
2367
+	 */
2368
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2369
+	{
2370
+		if (! $REG_ID) {
2371
+			EE_Error::add_error(
2372
+				esc_html__(
2373
+					'An error occurred. No registration ID was received.',
2374
+					'event_espresso'
2375
+				),
2376
+				__FILE__,
2377
+				__FUNCTION__,
2378
+				__LINE__
2379
+			);
2380
+		}
2381
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2382
+		$form->receive_form_submission($this->request->requestParams());
2383
+		$success = false;
2384
+		if ($form->is_valid()) {
2385
+			foreach ($form->subforms() as $question_group_form) {
2386
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2387
+					$where_conditions    = [
2388
+						'QST_ID' => $question_id,
2389
+						'REG_ID' => $REG_ID,
2390
+					];
2391
+					$possibly_new_values = [
2392
+						'ANS_value' => $input->normalized_value(),
2393
+					];
2394
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2395
+					if ($answer instanceof EE_Answer) {
2396
+						$success = $answer->save($possibly_new_values);
2397
+					} else {
2398
+						// insert it then
2399
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2400
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2401
+						$success     = $answer->save();
2402
+					}
2403
+				}
2404
+			}
2405
+		} else {
2406
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2407
+		}
2408
+		return $success;
2409
+	}
2410
+
2411
+
2412
+	/**
2413
+	 * generates HTML for the Registration main meta box
2414
+	 *
2415
+	 * @return void
2416
+	 * @throws DomainException
2417
+	 * @throws EE_Error
2418
+	 * @throws InvalidArgumentException
2419
+	 * @throws InvalidDataTypeException
2420
+	 * @throws InvalidInterfaceException
2421
+	 * @throws ReflectionException
2422
+	 */
2423
+	public function _reg_attendees_meta_box()
2424
+	{
2425
+		$REG = $this->getRegistrationModel();
2426
+		// get all other registrations on this transaction, and cache
2427
+		// the attendees for them so we don't have to run another query using force_join
2428
+		$registrations                           = $REG->get_all(
2429
+			[
2430
+				[
2431
+					'TXN_ID' => $this->_registration->transaction_ID(),
2432
+					'REG_ID' => ['!=', $this->_registration->ID()],
2433
+				],
2434
+				'force_join'               => ['Attendee'],
2435
+				'default_where_conditions' => 'other_models_only',
2436
+			]
2437
+		);
2438
+		$this->_template_args['attendees']       = [];
2439
+		$this->_template_args['attendee_notice'] = '';
2440
+		if (
2441
+			empty($registrations)
2442
+			|| (is_array($registrations)
2443
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2444
+		) {
2445
+			EE_Error::add_error(
2446
+				esc_html__(
2447
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2448
+					'event_espresso'
2449
+				),
2450
+				__FILE__,
2451
+				__FUNCTION__,
2452
+				__LINE__
2453
+			);
2454
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2455
+		} else {
2456
+			$att_nmbr = 1;
2457
+			foreach ($registrations as $registration) {
2458
+				/* @var $registration EE_Registration */
2459
+				$attendee                                                      = $registration->attendee()
2460
+					? $registration->attendee()
2461
+					: $this->getAttendeeModel()->create_default_object();
2462
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2463
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2464
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2465
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2466
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2467
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2468
+					', ',
2469
+					$attendee->full_address_as_array()
2470
+				);
2471
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2472
+					[
2473
+						'action' => 'edit_attendee',
2474
+						'post'   => $attendee->ID(),
2475
+					],
2476
+					REG_ADMIN_URL
2477
+				);
2478
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2479
+					$registration->event_obj() instanceof EE_Event
2480
+						? $registration->event_obj()->name()
2481
+						: '';
2482
+				$att_nmbr++;
2483
+			}
2484
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485
+		}
2486
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2487
+		EEH_Template::display_template($template_path, $this->_template_args);
2488
+	}
2489
+
2490
+
2491
+	/**
2492
+	 * generates HTML for the Edit Registration side meta box
2493
+	 *
2494
+	 * @return void
2495
+	 * @throws DomainException
2496
+	 * @throws EE_Error
2497
+	 * @throws InvalidArgumentException
2498
+	 * @throws InvalidDataTypeException
2499
+	 * @throws InvalidInterfaceException
2500
+	 * @throws ReflectionException
2501
+	 */
2502
+	public function _reg_registrant_side_meta_box()
2503
+	{
2504
+		/*@var $attendee EE_Attendee */
2505
+		$att_check = $this->_registration->attendee();
2506
+		$attendee  = $att_check instanceof EE_Attendee
2507
+			? $att_check
2508
+			: $this->getAttendeeModel()->create_default_object();
2509
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2510
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2511
+		// primary registration object (that way we know if we need to show create button or not)
2512
+		if (! $this->_registration->is_primary_registrant()) {
2513
+			$primary_registration = $this->_registration->get_primary_registration();
2514
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2515
+				: null;
2516
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2517
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2518
+				// custom attendee object so let's not worry about the primary reg.
2519
+				$primary_registration = null;
2520
+			}
2521
+		} else {
2522
+			$primary_registration = null;
2523
+		}
2524
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2525
+		$this->_template_args['fname']             = $attendee->fname();
2526
+		$this->_template_args['lname']             = $attendee->lname();
2527
+		$this->_template_args['email']             = $attendee->email();
2528
+		$this->_template_args['phone']             = $attendee->phone();
2529
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2530
+		// edit link
2531
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2532
+			[
2533
+				'action' => 'edit_attendee',
2534
+				'post'   => $attendee->ID(),
2535
+			],
2536
+			REG_ADMIN_URL
2537
+		);
2538
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2539
+		// create link
2540
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2541
+			? EE_Admin_Page::add_query_args_and_nonce(
2542
+				[
2543
+					'action'  => 'duplicate_attendee',
2544
+					'_REG_ID' => $this->_registration->ID(),
2545
+				],
2546
+				REG_ADMIN_URL
2547
+			) : '';
2548
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2549
+		$this->_template_args['att_check']    = $att_check;
2550
+		$template_path                        =
2551
+			REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2552
+		EEH_Template::display_template($template_path, $this->_template_args);
2553
+	}
2554
+
2555
+
2556
+	/**
2557
+	 * trash or restore registrations
2558
+	 *
2559
+	 * @param boolean $trash whether to archive or restore
2560
+	 * @return void
2561
+	 * @throws EE_Error
2562
+	 * @throws InvalidArgumentException
2563
+	 * @throws InvalidDataTypeException
2564
+	 * @throws InvalidInterfaceException
2565
+	 * @throws RuntimeException
2566
+	 */
2567
+	protected function _trash_or_restore_registrations($trash = true)
2568
+	{
2569
+		// if empty _REG_ID then get out because there's nothing to do
2570
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2571
+		if (empty($REG_IDs)) {
2572
+			EE_Error::add_error(
2573
+				sprintf(
2574
+					esc_html__(
2575
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2576
+						'event_espresso'
2577
+					),
2578
+					$trash ? 'trash' : 'restore'
2579
+				),
2580
+				__FILE__,
2581
+				__LINE__,
2582
+				__FUNCTION__
2583
+			);
2584
+			$this->_redirect_after_action(false, '', '', [], true);
2585
+		}
2586
+		$success        = 0;
2587
+		$overwrite_msgs = false;
2588
+		// Checkboxes
2589
+		$reg_count = count($REG_IDs);
2590
+		// cycle thru checkboxes
2591
+		foreach ($REG_IDs as $REG_ID) {
2592
+			/** @var EE_Registration $REG */
2593
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2594
+			$payments = $REG->registration_payments();
2595
+			if (! empty($payments)) {
2596
+				$name           = $REG->attendee() instanceof EE_Attendee
2597
+					? $REG->attendee()->full_name()
2598
+					: esc_html__('Unknown Attendee', 'event_espresso');
2599
+				$overwrite_msgs = true;
2600
+				EE_Error::add_error(
2601
+					sprintf(
2602
+						esc_html__(
2603
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2604
+							'event_espresso'
2605
+						),
2606
+						$name
2607
+					),
2608
+					__FILE__,
2609
+					__FUNCTION__,
2610
+					__LINE__
2611
+				);
2612
+				// can't trash this registration because it has payments.
2613
+				continue;
2614
+			}
2615
+			$updated = $trash ? $REG->delete() : $REG->restore();
2616
+			if ($updated) {
2617
+				$success++;
2618
+			}
2619
+		}
2620
+		$this->_redirect_after_action(
2621
+			$success === $reg_count, // were ALL registrations affected?
2622
+			$success > 1
2623
+				? esc_html__('Registrations', 'event_espresso')
2624
+				: esc_html__('Registration', 'event_espresso'),
2625
+			$trash
2626
+				? esc_html__('moved to the trash', 'event_espresso')
2627
+				: esc_html__('restored', 'event_espresso'),
2628
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2629
+			$overwrite_msgs
2630
+		);
2631
+	}
2632
+
2633
+
2634
+	/**
2635
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2636
+	 * registration but also.
2637
+	 * 1. Removing relations to EE_Attendee
2638
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2639
+	 * ALSO trashed.
2640
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2641
+	 * 4. Removing relationships between all tickets and the related registrations
2642
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2643
+	 * 6. Deleting permanently any related Checkins.
2644
+	 *
2645
+	 * @return void
2646
+	 * @throws EE_Error
2647
+	 * @throws InvalidArgumentException
2648
+	 * @throws InvalidDataTypeException
2649
+	 * @throws InvalidInterfaceException
2650
+	 * @throws ReflectionException
2651
+	 */
2652
+	protected function _delete_registrations()
2653
+	{
2654
+		$REG_MDL = $this->getRegistrationModel();
2655
+		$success = 0;
2656
+		// Checkboxes
2657
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2658
+
2659
+		if (! empty($REG_IDs)) {
2660
+			// if array has more than one element than success message should be plural
2661
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2662
+			// cycle thru checkboxes
2663
+			foreach ($REG_IDs as $REG_ID) {
2664
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2665
+				if (! $REG instanceof EE_Registration) {
2666
+					continue;
2667
+				}
2668
+				$deleted = $this->_delete_registration($REG);
2669
+				if (! $deleted) {
2670
+					$success = 0;
2671
+				}
2672
+			}
2673
+		}
2674
+
2675
+		$what        = $success > 1
2676
+			? esc_html__('Registrations', 'event_espresso')
2677
+			: esc_html__('Registration', 'event_espresso');
2678
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2679
+		$this->_redirect_after_action(
2680
+			$success,
2681
+			$what,
2682
+			$action_desc,
2683
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2684
+			true
2685
+		);
2686
+	}
2687
+
2688
+
2689
+	/**
2690
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2691
+	 * models get affected.
2692
+	 *
2693
+	 * @param EE_Registration $REG registration to be deleted permanently
2694
+	 * @return bool true = successful deletion, false = fail.
2695
+	 * @throws EE_Error
2696
+	 * @throws InvalidArgumentException
2697
+	 * @throws InvalidDataTypeException
2698
+	 * @throws InvalidInterfaceException
2699
+	 * @throws ReflectionException
2700
+	 */
2701
+	protected function _delete_registration(EE_Registration $REG)
2702
+	{
2703
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2704
+		// registrations on the transaction that are NOT trashed.
2705
+		$TXN = $REG->get_first_related('Transaction');
2706
+		if (! $TXN instanceof EE_Transaction) {
2707
+			EE_Error::add_error(
2708
+				sprintf(
2709
+					esc_html__(
2710
+						'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2711
+						'event_espresso'
2712
+					),
2713
+					$REG->id()
2714
+				),
2715
+				__FILE__,
2716
+				__FUNCTION__,
2717
+				__LINE__
2718
+			);
2719
+			return false;
2720
+		}
2721
+		$REGS        = $TXN->get_many_related('Registration');
2722
+		$all_trashed = true;
2723
+		foreach ($REGS as $registration) {
2724
+			if (! $registration->get('REG_deleted')) {
2725
+				$all_trashed = false;
2726
+			}
2727
+		}
2728
+		if (! $all_trashed) {
2729
+			EE_Error::add_error(
2730
+				esc_html__(
2731
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2732
+					'event_espresso'
2733
+				),
2734
+				__FILE__,
2735
+				__FUNCTION__,
2736
+				__LINE__
2737
+			);
2738
+			return false;
2739
+		}
2740
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2741
+		// separately from THIS one).
2742
+		foreach ($REGS as $registration) {
2743
+			// delete related answers
2744
+			$registration->delete_related_permanently('Answer');
2745
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2746
+			$attendee = $registration->get_first_related('Attendee');
2747
+			if ($attendee instanceof EE_Attendee) {
2748
+				$registration->_remove_relation_to($attendee, 'Attendee');
2749
+			}
2750
+			// now remove relationships to tickets on this registration.
2751
+			$registration->_remove_relations('Ticket');
2752
+			// now delete permanently the checkins related to this registration.
2753
+			$registration->delete_related_permanently('Checkin');
2754
+			if ($registration->ID() === $REG->ID()) {
2755
+				continue;
2756
+			} //we don't want to delete permanently the existing registration just yet.
2757
+			// remove relation to transaction for these registrations if NOT the existing registrations
2758
+			$registration->_remove_relations('Transaction');
2759
+			// delete permanently any related messages.
2760
+			$registration->delete_related_permanently('Message');
2761
+			// now delete this registration permanently
2762
+			$registration->delete_permanently();
2763
+		}
2764
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2765
+		// (the transaction and line items should be all that's left).
2766
+		// delete the line items related to the transaction for this registration.
2767
+		$TXN->delete_related_permanently('Line_Item');
2768
+		// we need to remove all the relationships on the transaction
2769
+		$TXN->delete_related_permanently('Payment');
2770
+		$TXN->delete_related_permanently('Extra_Meta');
2771
+		$TXN->delete_related_permanently('Message');
2772
+		// now we can delete this REG permanently (and the transaction of course)
2773
+		$REG->delete_related_permanently('Transaction');
2774
+		return $REG->delete_permanently();
2775
+	}
2776
+
2777
+
2778
+	/**
2779
+	 *    generates HTML for the Register New Attendee Admin page
2780
+	 *
2781
+	 * @throws DomainException
2782
+	 * @throws EE_Error
2783
+	 * @throws InvalidArgumentException
2784
+	 * @throws InvalidDataTypeException
2785
+	 * @throws InvalidInterfaceException
2786
+	 * @throws ReflectionException
2787
+	 */
2788
+	public function new_registration()
2789
+	{
2790
+		if (! $this->_set_reg_event()) {
2791
+			throw new EE_Error(
2792
+				esc_html__(
2793
+					'Unable to continue with registering because there is no Event ID in the request',
2794
+					'event_espresso'
2795
+				)
2796
+			);
2797
+		}
2798
+		/** @var CurrentPage $current_page */
2799
+		$current_page = $this->loader->getShared(CurrentPage::class);
2800
+		$current_page->setEspressoPage(true);
2801
+		// gotta start with a clean slate if we're not coming here via ajax
2802
+		if (
2803
+			! $this->request->isAjax()
2804
+			&& (
2805
+				! $this->request->requestParamIsSet('processing_registration')
2806
+				|| $this->request->requestParamIsSet('step_error')
2807
+			)
2808
+		) {
2809
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2810
+		}
2811
+		$this->_template_args['event_name'] = '';
2812
+		// event name
2813
+		if ($this->_reg_event) {
2814
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2815
+			$edit_event_url                     = self::add_query_args_and_nonce(
2816
+				[
2817
+					'action' => 'edit',
2818
+					'post'   => $this->_reg_event->ID(),
2819
+				],
2820
+				EVENTS_ADMIN_URL
2821
+			);
2822
+			$edit_event_lnk                     = '<a href="'
2823
+												  . $edit_event_url
2824
+												  . '" title="'
2825
+												  . esc_attr__('Edit ', 'event_espresso')
2826
+												  . $this->_reg_event->name()
2827
+												  . '">'
2828
+												  . esc_html__('Edit Event', 'event_espresso')
2829
+												  . '</a>';
2830
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2831
+												   . $edit_event_lnk
2832
+												   . '</span>';
2833
+		}
2834
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2835
+		if ($this->request->isAjax()) {
2836
+			$this->_return_json();
2837
+		}
2838
+		// grab header
2839
+		$template_path                              =
2840
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2841
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2842
+			$template_path,
2843
+			$this->_template_args,
2844
+			true
2845
+		);
2846
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2847
+		// the details template wrapper
2848
+		$this->display_admin_page_with_sidebar();
2849
+	}
2850
+
2851
+
2852
+	/**
2853
+	 * This returns the content for a registration step
2854
+	 *
2855
+	 * @return string html
2856
+	 * @throws DomainException
2857
+	 * @throws EE_Error
2858
+	 * @throws InvalidArgumentException
2859
+	 * @throws InvalidDataTypeException
2860
+	 * @throws InvalidInterfaceException
2861
+	 * @throws ReflectionException
2862
+	 */
2863
+	protected function _get_registration_step_content()
2864
+	{
2865
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2866
+			$warning_msg = sprintf(
2867
+				esc_html__(
2868
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2869
+					'event_espresso'
2870
+				),
2871
+				'<br />',
2872
+				'<h3 class="important-notice">',
2873
+				'</h3>',
2874
+				'<div class="float-right">',
2875
+				'<span id="redirect_timer" class="important-notice">30</span>',
2876
+				'</div>',
2877
+				'<b>',
2878
+				'</b>'
2879
+			);
2880
+			return '
2881 2881
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2882 2882
 	<script >
2883 2883
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2890,852 +2890,852 @@  discard block
 block discarded – undo
2890 2890
 	        }
2891 2891
 	    }, 800 );
2892 2892
 	</script >';
2893
-        }
2894
-        $template_args = [
2895
-            'title'                    => '',
2896
-            'content'                  => '',
2897
-            'step_button_text'         => '',
2898
-            'show_notification_toggle' => false,
2899
-        ];
2900
-        // to indicate we're processing a new registration
2901
-        $hidden_fields = [
2902
-            'processing_registration' => [
2903
-                'type'  => 'hidden',
2904
-                'value' => 0,
2905
-            ],
2906
-            'event_id'                => [
2907
-                'type'  => 'hidden',
2908
-                'value' => $this->_reg_event->ID(),
2909
-            ],
2910
-        ];
2911
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2912
-        $cart = EE_Registry::instance()->SSN->cart();
2913
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2914
-        switch ($step) {
2915
-            case 'ticket':
2916
-                $hidden_fields['processing_registration']['value'] = 1;
2917
-                $template_args['title']                            = esc_html__(
2918
-                    'Step One: Select the Ticket for this registration',
2919
-                    'event_espresso'
2920
-                );
2921
-                $template_args['content']                          =
2922
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2923
-                $template_args['content']                          .= '</div>';
2924
-                $template_args['step_button_text']                 = esc_html__(
2925
-                    'Add Tickets and Continue to Registrant Details',
2926
-                    'event_espresso'
2927
-                );
2928
-                $template_args['show_notification_toggle']         = false;
2929
-                break;
2930
-            case 'questions':
2931
-                $hidden_fields['processing_registration']['value'] = 2;
2932
-                $template_args['title']                            = esc_html__(
2933
-                    'Step Two: Add Registrant Details for this Registration',
2934
-                    'event_espresso'
2935
-                );
2936
-                // in theory, we should be able to run EED_SPCO at this point
2937
-                // because the cart should have been set up properly by the first process_reg_step run.
2938
-                $template_args['content']                  =
2939
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2940
-                $template_args['step_button_text']         = esc_html__(
2941
-                    'Save Registration and Continue to Details',
2942
-                    'event_espresso'
2943
-                );
2944
-                $template_args['show_notification_toggle'] = true;
2945
-                break;
2946
-        }
2947
-        // we come back to the process_registration_step route.
2948
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2949
-        return EEH_Template::display_template(
2950
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2951
-            $template_args,
2952
-            true
2953
-        );
2954
-    }
2955
-
2956
-
2957
-    /**
2958
-     * set_reg_event
2959
-     *
2960
-     * @return bool
2961
-     * @throws EE_Error
2962
-     * @throws InvalidArgumentException
2963
-     * @throws InvalidDataTypeException
2964
-     * @throws InvalidInterfaceException
2965
-     */
2966
-    private function _set_reg_event()
2967
-    {
2968
-        if (is_object($this->_reg_event)) {
2969
-            return true;
2970
-        }
2971
-
2972
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2973
-        if (! $EVT_ID) {
2974
-            return false;
2975
-        }
2976
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2977
-        return true;
2978
-    }
2979
-
2980
-
2981
-    /**
2982
-     * process_reg_step
2983
-     *
2984
-     * @return void
2985
-     * @throws DomainException
2986
-     * @throws EE_Error
2987
-     * @throws InvalidArgumentException
2988
-     * @throws InvalidDataTypeException
2989
-     * @throws InvalidInterfaceException
2990
-     * @throws ReflectionException
2991
-     * @throws RuntimeException
2992
-     */
2993
-    public function process_reg_step()
2994
-    {
2995
-        EE_System::do_not_cache();
2996
-        $this->_set_reg_event();
2997
-        /** @var CurrentPage $current_page */
2998
-        $current_page = $this->loader->getShared(CurrentPage::class);
2999
-        $current_page->setEspressoPage(true);
3000
-        $this->request->setRequestParam('uts', time());
3001
-        // what step are we on?
3002
-        $cart = EE_Registry::instance()->SSN->cart();
3003
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3004
-        // if doing ajax then we need to verify the nonce
3005
-        if ($this->request->isAjax()) {
3006
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3007
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3008
-        }
3009
-        switch ($step) {
3010
-            case 'ticket':
3011
-                // process ticket selection
3012
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3013
-                if ($success) {
3014
-                    EE_Error::add_success(
3015
-                        esc_html__(
3016
-                            'Tickets Selected. Now complete the registration.',
3017
-                            'event_espresso'
3018
-                        )
3019
-                    );
3020
-                } else {
3021
-                    $this->request->setRequestParam('step_error', true);
3022
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3023
-                }
3024
-                if ($this->request->isAjax()) {
3025
-                    $this->new_registration(); // display next step
3026
-                } else {
3027
-                    $query_args = [
3028
-                        'action'                  => 'new_registration',
3029
-                        'processing_registration' => 1,
3030
-                        'event_id'                => $this->_reg_event->ID(),
3031
-                        'uts'                     => time(),
3032
-                    ];
3033
-                    $this->_redirect_after_action(
3034
-                        false,
3035
-                        '',
3036
-                        '',
3037
-                        $query_args,
3038
-                        true
3039
-                    );
3040
-                }
3041
-                break;
3042
-            case 'questions':
3043
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3044
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3045
-                }
3046
-                // process registration
3047
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3048
-                if ($cart instanceof EE_Cart) {
3049
-                    $grand_total = $cart->get_grand_total();
3050
-                    if ($grand_total instanceof EE_Line_Item) {
3051
-                        $grand_total->save_this_and_descendants_to_txn();
3052
-                    }
3053
-                }
3054
-                if (! $transaction instanceof EE_Transaction) {
3055
-                    $query_args = [
3056
-                        'action'                  => 'new_registration',
3057
-                        'processing_registration' => 2,
3058
-                        'event_id'                => $this->_reg_event->ID(),
3059
-                        'uts'                     => time(),
3060
-                    ];
3061
-                    if ($this->request->isAjax()) {
3062
-                        // display registration form again because there are errors (maybe validation?)
3063
-                        $this->new_registration();
3064
-                        return;
3065
-                    }
3066
-                    $this->_redirect_after_action(
3067
-                        false,
3068
-                        '',
3069
-                        '',
3070
-                        $query_args,
3071
-                        true
3072
-                    );
3073
-                    return;
3074
-                }
3075
-                // maybe update status, and make sure to save transaction if not done already
3076
-                if (! $transaction->update_status_based_on_total_paid()) {
3077
-                    $transaction->save();
3078
-                }
3079
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3080
-                $query_args = [
3081
-                    'action'        => 'redirect_to_txn',
3082
-                    'TXN_ID'        => $transaction->ID(),
3083
-                    'EVT_ID'        => $this->_reg_event->ID(),
3084
-                    'event_name'    => urlencode($this->_reg_event->name()),
3085
-                    'redirect_from' => 'new_registration',
3086
-                ];
3087
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3088
-                break;
3089
-        }
3090
-        // what are you looking here for?  Should be nothing to do at this point.
3091
-    }
3092
-
3093
-
3094
-    /**
3095
-     * redirect_to_txn
3096
-     *
3097
-     * @return void
3098
-     * @throws EE_Error
3099
-     * @throws InvalidArgumentException
3100
-     * @throws InvalidDataTypeException
3101
-     * @throws InvalidInterfaceException
3102
-     * @throws ReflectionException
3103
-     */
3104
-    public function redirect_to_txn()
3105
-    {
3106
-        EE_System::do_not_cache();
3107
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3108
-        $query_args = [
3109
-            'action' => 'view_transaction',
3110
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3111
-            'page'   => 'espresso_transactions',
3112
-        ];
3113
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3114
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3115
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3116
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3117
-        }
3118
-        EE_Error::add_success(
3119
-            esc_html__(
3120
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3121
-                'event_espresso'
3122
-            )
3123
-        );
3124
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3125
-    }
3126
-
3127
-
3128
-    /**
3129
-     * generates HTML for the Attendee Contact List
3130
-     *
3131
-     * @return void
3132
-     * @throws DomainException
3133
-     * @throws EE_Error
3134
-     */
3135
-    protected function _attendee_contact_list_table()
3136
-    {
3137
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3138
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3139
-        $this->display_admin_list_table_page_with_no_sidebar();
3140
-    }
3141
-
3142
-
3143
-    /**
3144
-     * get_attendees
3145
-     *
3146
-     * @param      $per_page
3147
-     * @param bool $count whether to return count or data.
3148
-     * @param bool $trash
3149
-     * @return array|int
3150
-     * @throws EE_Error
3151
-     * @throws InvalidArgumentException
3152
-     * @throws InvalidDataTypeException
3153
-     * @throws InvalidInterfaceException
3154
-     */
3155
-    public function get_attendees($per_page, $count = false, $trash = false)
3156
-    {
3157
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3158
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3159
-        $orderby = $this->request->getRequestParam('orderby');
3160
-        switch ($orderby) {
3161
-            case 'ATT_ID':
3162
-            case 'ATT_fname':
3163
-            case 'ATT_email':
3164
-            case 'ATT_city':
3165
-            case 'STA_ID':
3166
-            case 'CNT_ID':
3167
-                break;
3168
-            case 'Registration_Count':
3169
-                $orderby = 'Registration_Count';
3170
-                break;
3171
-            default:
3172
-                $orderby = 'ATT_lname';
3173
-        }
3174
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3175
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3176
-        $per_page     = absint($per_page) ? $per_page : 10;
3177
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3178
-        $_where       = [];
3179
-        $search_term  = $this->request->getRequestParam('s');
3180
-        if ($search_term) {
3181
-            $search_term  = '%' . $search_term . '%';
3182
-            $_where['OR'] = [
3183
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3184
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3185
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3186
-                'ATT_fname'                         => ['LIKE', $search_term],
3187
-                'ATT_lname'                         => ['LIKE', $search_term],
3188
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3189
-                'ATT_email'                         => ['LIKE', $search_term],
3190
-                'ATT_address'                       => ['LIKE', $search_term],
3191
-                'ATT_address2'                      => ['LIKE', $search_term],
3192
-                'ATT_city'                          => ['LIKE', $search_term],
3193
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3194
-                'State.STA_name'                    => ['LIKE', $search_term],
3195
-                'ATT_phone'                         => ['LIKE', $search_term],
3196
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3197
-                'Registration.REG_code'             => ['LIKE', $search_term],
3198
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3199
-            ];
3200
-        }
3201
-        $offset     = ($current_page - 1) * $per_page;
3202
-        $limit      = $count ? null : [$offset, $per_page];
3203
-        $query_args = [
3204
-            $_where,
3205
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3206
-            'limit'         => $limit,
3207
-        ];
3208
-        if (! $count) {
3209
-            $query_args['order_by'] = [$orderby => $sort];
3210
-        }
3211
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3212
-        return $count
3213
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3214
-            : $this->getAttendeeModel()->get_all($query_args);
3215
-    }
3216
-
3217
-
3218
-    /**
3219
-     * This is just taking care of resending the registration confirmation
3220
-     *
3221
-     * @return void
3222
-     * @throws EE_Error
3223
-     * @throws InvalidArgumentException
3224
-     * @throws InvalidDataTypeException
3225
-     * @throws InvalidInterfaceException
3226
-     * @throws ReflectionException
3227
-     */
3228
-    protected function _resend_registration()
3229
-    {
3230
-        $this->_process_resend_registration();
3231
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3232
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3233
-        $query_args  = $redirect_to
3234
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3235
-            : ['action' => 'default'];
3236
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3237
-    }
3238
-
3239
-
3240
-    /**
3241
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3242
-     * to use when selecting registrations
3243
-     *
3244
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3245
-     *                                                     the query parameters from the request
3246
-     * @return void ends the request with a redirect or download
3247
-     */
3248
-    public function _registrations_report_base($method_name_for_getting_query_params)
3249
-    {
3250
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3251
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3252
-            : null;
3253
-
3254
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3255
-            $request_params = $this->request->requestParams();
3256
-            wp_redirect(
3257
-                EE_Admin_Page::add_query_args_and_nonce(
3258
-                    [
3259
-                        'page'        => 'espresso_batch',
3260
-                        'batch'       => 'file',
3261
-                        'EVT_ID'      => $EVT_ID,
3262
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3263
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', DataType::URL)),
3264
-                        'filters'     => urlencode(
3265
-                            serialize(
3266
-                                $this->$method_name_for_getting_query_params(
3267
-                                    (isset($request_params['filters']) ? $request_params['filters'] : [])
3268
-                                )
3269
-                            )
3270
-                        ),
3271
-                        'use_filters' => $this->request->getRequestParam('use_filters', false, DataType::BOOL)
3272
-                    ]
3273
-                )
3274
-            );
3275
-        } else {
3276
-            // Pull the current request params
3277
-            $request_args = $this->request->requestParams();
3278
-            // Set the required request_args to be passed to the export
3279
-            $required_request_args = [
3280
-                'export' => 'report',
3281
-                'action' => 'registrations_report_for_event',
3282
-                'EVT_ID' => $EVT_ID,
3283
-            ];
3284
-            // Merge required request args, overriding any currently set
3285
-            $request_args = array_merge($request_args, $required_request_args);
3286
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3287
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3288
-                $EE_Export = EE_Export::instance($request_args);
3289
-                $EE_Export->export();
3290
-            }
3291
-        }
3292
-    }
3293
-
3294
-
3295
-    /**
3296
-     * Creates a registration report using only query parameters in the request
3297
-     *
3298
-     * @return void
3299
-     */
3300
-    public function _registrations_report()
3301
-    {
3302
-        $this->_registrations_report_base('_get_registration_query_parameters');
3303
-    }
3304
-
3305
-
3306
-    public function _contact_list_export()
3307
-    {
3308
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3309
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3310
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3311
-            $EE_Export->export_attendees();
3312
-        }
3313
-    }
3314
-
3315
-
3316
-    public function _contact_list_report()
3317
-    {
3318
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3319
-            wp_redirect(
3320
-                EE_Admin_Page::add_query_args_and_nonce(
3321
-                    [
3322
-                        'page'        => 'espresso_batch',
3323
-                        'batch'       => 'file',
3324
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3325
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3326
-                    ]
3327
-                )
3328
-            );
3329
-        } else {
3330
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3331
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3332
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3333
-                $EE_Export->report_attendees();
3334
-            }
3335
-        }
3336
-    }
3337
-
3338
-
3339
-
3340
-
3341
-
3342
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3343
-    /**
3344
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3345
-     *
3346
-     * @return void
3347
-     * @throws EE_Error
3348
-     * @throws InvalidArgumentException
3349
-     * @throws InvalidDataTypeException
3350
-     * @throws InvalidInterfaceException
3351
-     * @throws ReflectionException
3352
-     */
3353
-    protected function _duplicate_attendee()
3354
-    {
3355
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3356
-        $action = $this->request->getRequestParam('return', 'default');
3357
-        // verify we have necessary info
3358
-        if (! $REG_ID) {
3359
-            EE_Error::add_error(
3360
-                esc_html__(
3361
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3362
-                    'event_espresso'
3363
-                ),
3364
-                __FILE__,
3365
-                __LINE__,
3366
-                __FUNCTION__
3367
-            );
3368
-            $query_args = ['action' => $action];
3369
-            $this->_redirect_after_action('', '', '', $query_args, true);
3370
-        }
3371
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3372
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3373
-        if (! $registration instanceof EE_Registration) {
3374
-            throw new RuntimeException(
3375
-                sprintf(
3376
-                    esc_html__(
3377
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3378
-                        'event_espresso'
3379
-                    ),
3380
-                    $REG_ID
3381
-                )
3382
-            );
3383
-        }
3384
-        $attendee = $registration->attendee();
3385
-        // remove relation of existing attendee on registration
3386
-        $registration->_remove_relation_to($attendee, 'Attendee');
3387
-        // new attendee
3388
-        $new_attendee = clone $attendee;
3389
-        $new_attendee->set('ATT_ID', 0);
3390
-        $new_attendee->save();
3391
-        // add new attendee to reg
3392
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3393
-        EE_Error::add_success(
3394
-            esc_html__(
3395
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3396
-                'event_espresso'
3397
-            )
3398
-        );
3399
-        // redirect to edit page for attendee
3400
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3401
-        $this->_redirect_after_action('', '', '', $query_args, true);
3402
-    }
3403
-
3404
-
3405
-    /**
3406
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3407
-     *
3408
-     * @param int     $post_id
3409
-     * @param WP_Post $post
3410
-     * @throws DomainException
3411
-     * @throws EE_Error
3412
-     * @throws InvalidArgumentException
3413
-     * @throws InvalidDataTypeException
3414
-     * @throws InvalidInterfaceException
3415
-     * @throws LogicException
3416
-     * @throws InvalidFormSubmissionException
3417
-     * @throws ReflectionException
3418
-     */
3419
-    protected function _insert_update_cpt_item($post_id, $post)
3420
-    {
3421
-        $success  = true;
3422
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3423
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3424
-            : null;
3425
-        // for attendee updates
3426
-        if ($attendee instanceof EE_Attendee) {
3427
-            // note we should only be UPDATING attendees at this point.
3428
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3429
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3430
-            $updated_fields = [
3431
-                'ATT_fname'     => $fname,
3432
-                'ATT_lname'     => $lname,
3433
-                'ATT_full_name' => "{$fname} {$lname}",
3434
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3435
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3436
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3437
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3438
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3439
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3440
-            ];
3441
-            foreach ($updated_fields as $field => $value) {
3442
-                $attendee->set($field, $value);
3443
-            }
3444
-
3445
-            // process contact details metabox form handler (which will also save the attendee)
3446
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3447
-            $success              = $contact_details_form->process($this->request->requestParams());
3448
-
3449
-            $attendee_update_callbacks = apply_filters(
3450
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3451
-                []
3452
-            );
3453
-            foreach ($attendee_update_callbacks as $a_callback) {
3454
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3455
-                    throw new EE_Error(
3456
-                        sprintf(
3457
-                            esc_html__(
3458
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3459
-                                'event_espresso'
3460
-                            ),
3461
-                            $a_callback
3462
-                        )
3463
-                    );
3464
-                }
3465
-            }
3466
-        }
3467
-
3468
-        if ($success === false) {
3469
-            EE_Error::add_error(
3470
-                esc_html__(
3471
-                    'Something went wrong with updating the meta table data for the registration.',
3472
-                    'event_espresso'
3473
-                ),
3474
-                __FILE__,
3475
-                __FUNCTION__,
3476
-                __LINE__
3477
-            );
3478
-        }
3479
-    }
3480
-
3481
-
3482
-    public function trash_cpt_item($post_id)
3483
-    {
3484
-    }
3485
-
3486
-
3487
-    public function delete_cpt_item($post_id)
3488
-    {
3489
-    }
3490
-
3491
-
3492
-    public function restore_cpt_item($post_id)
3493
-    {
3494
-    }
3495
-
3496
-
3497
-    protected function _restore_cpt_item($post_id, $revision_id)
3498
-    {
3499
-    }
3500
-
3501
-
3502
-    /**
3503
-     * @throws EE_Error
3504
-     * @throws ReflectionException
3505
-     * @since 4.10.2.p
3506
-     */
3507
-    public function attendee_editor_metaboxes()
3508
-    {
3509
-        $this->verify_cpt_object();
3510
-        remove_meta_box(
3511
-            'postexcerpt',
3512
-            $this->_cpt_routes[ $this->_req_action ],
3513
-            'normal'
3514
-        );
3515
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3516
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3517
-            add_meta_box(
3518
-                'postexcerpt',
3519
-                esc_html__('Short Biography', 'event_espresso'),
3520
-                'post_excerpt_meta_box',
3521
-                $this->_cpt_routes[ $this->_req_action ],
3522
-                'normal'
3523
-            );
3524
-        }
3525
-        if (post_type_supports('espresso_attendees', 'comments')) {
3526
-            add_meta_box(
3527
-                'commentsdiv',
3528
-                esc_html__('Notes on the Contact', 'event_espresso'),
3529
-                'post_comment_meta_box',
3530
-                $this->_cpt_routes[ $this->_req_action ],
3531
-                'normal',
3532
-                'core'
3533
-            );
3534
-        }
3535
-        add_meta_box(
3536
-            'attendee_contact_info',
3537
-            esc_html__('Contact Info', 'event_espresso'),
3538
-            [$this, 'attendee_contact_info'],
3539
-            $this->_cpt_routes[ $this->_req_action ],
3540
-            'side',
3541
-            'core'
3542
-        );
3543
-        add_meta_box(
3544
-            'attendee_details_address',
3545
-            esc_html__('Address Details', 'event_espresso'),
3546
-            [$this, 'attendee_address_details'],
3547
-            $this->_cpt_routes[ $this->_req_action ],
3548
-            'normal',
3549
-            'core'
3550
-        );
3551
-        add_meta_box(
3552
-            'attendee_registrations',
3553
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3554
-            [$this, 'attendee_registrations_meta_box'],
3555
-            $this->_cpt_routes[ $this->_req_action ],
3556
-            'normal',
3557
-            'high'
3558
-        );
3559
-    }
3560
-
3561
-
3562
-    /**
3563
-     * Metabox for attendee contact info
3564
-     *
3565
-     * @param WP_Post $post wp post object
3566
-     * @return void attendee contact info ( and form )
3567
-     * @throws EE_Error
3568
-     * @throws InvalidArgumentException
3569
-     * @throws InvalidDataTypeException
3570
-     * @throws InvalidInterfaceException
3571
-     * @throws LogicException
3572
-     * @throws DomainException
3573
-     */
3574
-    public function attendee_contact_info($post)
3575
-    {
3576
-        // get attendee object ( should already have it )
3577
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3578
-        $form->enqueueStylesAndScripts();
3579
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3580
-    }
3581
-
3582
-
3583
-    /**
3584
-     * Return form handler for the contact details metabox
3585
-     *
3586
-     * @param EE_Attendee $attendee
3587
-     * @return AttendeeContactDetailsMetaboxFormHandler
3588
-     * @throws DomainException
3589
-     * @throws InvalidArgumentException
3590
-     * @throws InvalidDataTypeException
3591
-     * @throws InvalidInterfaceException
3592
-     */
3593
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3594
-    {
3595
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3596
-    }
3597
-
3598
-
3599
-    /**
3600
-     * Metabox for attendee details
3601
-     *
3602
-     * @param WP_Post $post wp post object
3603
-     * @throws EE_Error
3604
-     * @throws ReflectionException
3605
-     */
3606
-    public function attendee_address_details($post)
3607
-    {
3608
-        // get attendee object (should already have it)
3609
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3610
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3611
-            new EE_Question_Form_Input(
3612
-                EE_Question::new_instance(
3613
-                    [
3614
-                        'QST_ID'           => 0,
3615
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3616
-                        'QST_system'       => 'admin-state',
3617
-                    ]
3618
-                ),
3619
-                EE_Answer::new_instance(
3620
-                    [
3621
-                        'ANS_ID'    => 0,
3622
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3623
-                    ]
3624
-                ),
3625
-                [
3626
-                    'input_id'       => 'STA_ID',
3627
-                    'input_name'     => 'STA_ID',
3628
-                    'input_prefix'   => '',
3629
-                    'append_qstn_id' => false,
3630
-                ]
3631
-            )
3632
-        );
3633
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3634
-            new EE_Question_Form_Input(
3635
-                EE_Question::new_instance(
3636
-                    [
3637
-                        'QST_ID'           => 0,
3638
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3639
-                        'QST_system'       => 'admin-country',
3640
-                    ]
3641
-                ),
3642
-                EE_Answer::new_instance(
3643
-                    [
3644
-                        'ANS_ID'    => 0,
3645
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3646
-                    ]
3647
-                ),
3648
-                [
3649
-                    'input_id'       => 'CNT_ISO',
3650
-                    'input_name'     => 'CNT_ISO',
3651
-                    'input_prefix'   => '',
3652
-                    'append_qstn_id' => false,
3653
-                ]
3654
-            )
3655
-        );
3656
-        $template                             =
3657
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3658
-        EEH_Template::display_template($template, $this->_template_args);
3659
-    }
3660
-
3661
-
3662
-    /**
3663
-     * _attendee_details
3664
-     *
3665
-     * @param $post
3666
-     * @return void
3667
-     * @throws DomainException
3668
-     * @throws EE_Error
3669
-     * @throws InvalidArgumentException
3670
-     * @throws InvalidDataTypeException
3671
-     * @throws InvalidInterfaceException
3672
-     * @throws ReflectionException
3673
-     */
3674
-    public function attendee_registrations_meta_box($post)
3675
-    {
3676
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3677
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3678
-        $template                              =
3679
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3680
-        EEH_Template::display_template($template, $this->_template_args);
3681
-    }
3682
-
3683
-
3684
-    /**
3685
-     * add in the form fields for the attendee edit
3686
-     *
3687
-     * @param WP_Post $post wp post object
3688
-     * @return void echos html for new form.
3689
-     * @throws DomainException
3690
-     */
3691
-    public function after_title_form_fields($post)
3692
-    {
3693
-        if ($post->post_type === 'espresso_attendees') {
3694
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3695
-            $template_args['attendee'] = $this->_cpt_model_obj;
3696
-            EEH_Template::display_template($template, $template_args);
3697
-        }
3698
-    }
3699
-
3700
-
3701
-    /**
3702
-     * _trash_or_restore_attendee
3703
-     *
3704
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3705
-     * @return void
3706
-     * @throws EE_Error
3707
-     * @throws InvalidArgumentException
3708
-     * @throws InvalidDataTypeException
3709
-     * @throws InvalidInterfaceException
3710
-     */
3711
-    protected function _trash_or_restore_attendees($trash = true)
3712
-    {
3713
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3714
-        $status = $trash ? 'trash' : 'publish';
3715
-        // Checkboxes
3716
-        if ($this->request->requestParamIsSet('checkbox')) {
3717
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3718
-            // if array has more than one element than success message should be plural
3719
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3720
-            // cycle thru checkboxes
3721
-            foreach ($ATT_IDs as $ATT_ID) {
3722
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3723
-                if (! $updated) {
3724
-                    $success = 0;
3725
-                }
3726
-            }
3727
-        } else {
3728
-            // grab single id and delete
3729
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3730
-            // update attendee
3731
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3732
-        }
3733
-        $what        = $success > 1
3734
-            ? esc_html__('Contacts', 'event_espresso')
3735
-            : esc_html__('Contact', 'event_espresso');
3736
-        $action_desc = $trash
3737
-            ? esc_html__('moved to the trash', 'event_espresso')
3738
-            : esc_html__('restored', 'event_espresso');
3739
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3740
-    }
2893
+		}
2894
+		$template_args = [
2895
+			'title'                    => '',
2896
+			'content'                  => '',
2897
+			'step_button_text'         => '',
2898
+			'show_notification_toggle' => false,
2899
+		];
2900
+		// to indicate we're processing a new registration
2901
+		$hidden_fields = [
2902
+			'processing_registration' => [
2903
+				'type'  => 'hidden',
2904
+				'value' => 0,
2905
+			],
2906
+			'event_id'                => [
2907
+				'type'  => 'hidden',
2908
+				'value' => $this->_reg_event->ID(),
2909
+			],
2910
+		];
2911
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2912
+		$cart = EE_Registry::instance()->SSN->cart();
2913
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2914
+		switch ($step) {
2915
+			case 'ticket':
2916
+				$hidden_fields['processing_registration']['value'] = 1;
2917
+				$template_args['title']                            = esc_html__(
2918
+					'Step One: Select the Ticket for this registration',
2919
+					'event_espresso'
2920
+				);
2921
+				$template_args['content']                          =
2922
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2923
+				$template_args['content']                          .= '</div>';
2924
+				$template_args['step_button_text']                 = esc_html__(
2925
+					'Add Tickets and Continue to Registrant Details',
2926
+					'event_espresso'
2927
+				);
2928
+				$template_args['show_notification_toggle']         = false;
2929
+				break;
2930
+			case 'questions':
2931
+				$hidden_fields['processing_registration']['value'] = 2;
2932
+				$template_args['title']                            = esc_html__(
2933
+					'Step Two: Add Registrant Details for this Registration',
2934
+					'event_espresso'
2935
+				);
2936
+				// in theory, we should be able to run EED_SPCO at this point
2937
+				// because the cart should have been set up properly by the first process_reg_step run.
2938
+				$template_args['content']                  =
2939
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2940
+				$template_args['step_button_text']         = esc_html__(
2941
+					'Save Registration and Continue to Details',
2942
+					'event_espresso'
2943
+				);
2944
+				$template_args['show_notification_toggle'] = true;
2945
+				break;
2946
+		}
2947
+		// we come back to the process_registration_step route.
2948
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2949
+		return EEH_Template::display_template(
2950
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2951
+			$template_args,
2952
+			true
2953
+		);
2954
+	}
2955
+
2956
+
2957
+	/**
2958
+	 * set_reg_event
2959
+	 *
2960
+	 * @return bool
2961
+	 * @throws EE_Error
2962
+	 * @throws InvalidArgumentException
2963
+	 * @throws InvalidDataTypeException
2964
+	 * @throws InvalidInterfaceException
2965
+	 */
2966
+	private function _set_reg_event()
2967
+	{
2968
+		if (is_object($this->_reg_event)) {
2969
+			return true;
2970
+		}
2971
+
2972
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2973
+		if (! $EVT_ID) {
2974
+			return false;
2975
+		}
2976
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2977
+		return true;
2978
+	}
2979
+
2980
+
2981
+	/**
2982
+	 * process_reg_step
2983
+	 *
2984
+	 * @return void
2985
+	 * @throws DomainException
2986
+	 * @throws EE_Error
2987
+	 * @throws InvalidArgumentException
2988
+	 * @throws InvalidDataTypeException
2989
+	 * @throws InvalidInterfaceException
2990
+	 * @throws ReflectionException
2991
+	 * @throws RuntimeException
2992
+	 */
2993
+	public function process_reg_step()
2994
+	{
2995
+		EE_System::do_not_cache();
2996
+		$this->_set_reg_event();
2997
+		/** @var CurrentPage $current_page */
2998
+		$current_page = $this->loader->getShared(CurrentPage::class);
2999
+		$current_page->setEspressoPage(true);
3000
+		$this->request->setRequestParam('uts', time());
3001
+		// what step are we on?
3002
+		$cart = EE_Registry::instance()->SSN->cart();
3003
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3004
+		// if doing ajax then we need to verify the nonce
3005
+		if ($this->request->isAjax()) {
3006
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3007
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3008
+		}
3009
+		switch ($step) {
3010
+			case 'ticket':
3011
+				// process ticket selection
3012
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3013
+				if ($success) {
3014
+					EE_Error::add_success(
3015
+						esc_html__(
3016
+							'Tickets Selected. Now complete the registration.',
3017
+							'event_espresso'
3018
+						)
3019
+					);
3020
+				} else {
3021
+					$this->request->setRequestParam('step_error', true);
3022
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3023
+				}
3024
+				if ($this->request->isAjax()) {
3025
+					$this->new_registration(); // display next step
3026
+				} else {
3027
+					$query_args = [
3028
+						'action'                  => 'new_registration',
3029
+						'processing_registration' => 1,
3030
+						'event_id'                => $this->_reg_event->ID(),
3031
+						'uts'                     => time(),
3032
+					];
3033
+					$this->_redirect_after_action(
3034
+						false,
3035
+						'',
3036
+						'',
3037
+						$query_args,
3038
+						true
3039
+					);
3040
+				}
3041
+				break;
3042
+			case 'questions':
3043
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3044
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3045
+				}
3046
+				// process registration
3047
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3048
+				if ($cart instanceof EE_Cart) {
3049
+					$grand_total = $cart->get_grand_total();
3050
+					if ($grand_total instanceof EE_Line_Item) {
3051
+						$grand_total->save_this_and_descendants_to_txn();
3052
+					}
3053
+				}
3054
+				if (! $transaction instanceof EE_Transaction) {
3055
+					$query_args = [
3056
+						'action'                  => 'new_registration',
3057
+						'processing_registration' => 2,
3058
+						'event_id'                => $this->_reg_event->ID(),
3059
+						'uts'                     => time(),
3060
+					];
3061
+					if ($this->request->isAjax()) {
3062
+						// display registration form again because there are errors (maybe validation?)
3063
+						$this->new_registration();
3064
+						return;
3065
+					}
3066
+					$this->_redirect_after_action(
3067
+						false,
3068
+						'',
3069
+						'',
3070
+						$query_args,
3071
+						true
3072
+					);
3073
+					return;
3074
+				}
3075
+				// maybe update status, and make sure to save transaction if not done already
3076
+				if (! $transaction->update_status_based_on_total_paid()) {
3077
+					$transaction->save();
3078
+				}
3079
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3080
+				$query_args = [
3081
+					'action'        => 'redirect_to_txn',
3082
+					'TXN_ID'        => $transaction->ID(),
3083
+					'EVT_ID'        => $this->_reg_event->ID(),
3084
+					'event_name'    => urlencode($this->_reg_event->name()),
3085
+					'redirect_from' => 'new_registration',
3086
+				];
3087
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3088
+				break;
3089
+		}
3090
+		// what are you looking here for?  Should be nothing to do at this point.
3091
+	}
3092
+
3093
+
3094
+	/**
3095
+	 * redirect_to_txn
3096
+	 *
3097
+	 * @return void
3098
+	 * @throws EE_Error
3099
+	 * @throws InvalidArgumentException
3100
+	 * @throws InvalidDataTypeException
3101
+	 * @throws InvalidInterfaceException
3102
+	 * @throws ReflectionException
3103
+	 */
3104
+	public function redirect_to_txn()
3105
+	{
3106
+		EE_System::do_not_cache();
3107
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3108
+		$query_args = [
3109
+			'action' => 'view_transaction',
3110
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3111
+			'page'   => 'espresso_transactions',
3112
+		];
3113
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3114
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3115
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3116
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3117
+		}
3118
+		EE_Error::add_success(
3119
+			esc_html__(
3120
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3121
+				'event_espresso'
3122
+			)
3123
+		);
3124
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3125
+	}
3126
+
3127
+
3128
+	/**
3129
+	 * generates HTML for the Attendee Contact List
3130
+	 *
3131
+	 * @return void
3132
+	 * @throws DomainException
3133
+	 * @throws EE_Error
3134
+	 */
3135
+	protected function _attendee_contact_list_table()
3136
+	{
3137
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3138
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3139
+		$this->display_admin_list_table_page_with_no_sidebar();
3140
+	}
3141
+
3142
+
3143
+	/**
3144
+	 * get_attendees
3145
+	 *
3146
+	 * @param      $per_page
3147
+	 * @param bool $count whether to return count or data.
3148
+	 * @param bool $trash
3149
+	 * @return array|int
3150
+	 * @throws EE_Error
3151
+	 * @throws InvalidArgumentException
3152
+	 * @throws InvalidDataTypeException
3153
+	 * @throws InvalidInterfaceException
3154
+	 */
3155
+	public function get_attendees($per_page, $count = false, $trash = false)
3156
+	{
3157
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3158
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3159
+		$orderby = $this->request->getRequestParam('orderby');
3160
+		switch ($orderby) {
3161
+			case 'ATT_ID':
3162
+			case 'ATT_fname':
3163
+			case 'ATT_email':
3164
+			case 'ATT_city':
3165
+			case 'STA_ID':
3166
+			case 'CNT_ID':
3167
+				break;
3168
+			case 'Registration_Count':
3169
+				$orderby = 'Registration_Count';
3170
+				break;
3171
+			default:
3172
+				$orderby = 'ATT_lname';
3173
+		}
3174
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3175
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3176
+		$per_page     = absint($per_page) ? $per_page : 10;
3177
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3178
+		$_where       = [];
3179
+		$search_term  = $this->request->getRequestParam('s');
3180
+		if ($search_term) {
3181
+			$search_term  = '%' . $search_term . '%';
3182
+			$_where['OR'] = [
3183
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3184
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3185
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3186
+				'ATT_fname'                         => ['LIKE', $search_term],
3187
+				'ATT_lname'                         => ['LIKE', $search_term],
3188
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3189
+				'ATT_email'                         => ['LIKE', $search_term],
3190
+				'ATT_address'                       => ['LIKE', $search_term],
3191
+				'ATT_address2'                      => ['LIKE', $search_term],
3192
+				'ATT_city'                          => ['LIKE', $search_term],
3193
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3194
+				'State.STA_name'                    => ['LIKE', $search_term],
3195
+				'ATT_phone'                         => ['LIKE', $search_term],
3196
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3197
+				'Registration.REG_code'             => ['LIKE', $search_term],
3198
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3199
+			];
3200
+		}
3201
+		$offset     = ($current_page - 1) * $per_page;
3202
+		$limit      = $count ? null : [$offset, $per_page];
3203
+		$query_args = [
3204
+			$_where,
3205
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3206
+			'limit'         => $limit,
3207
+		];
3208
+		if (! $count) {
3209
+			$query_args['order_by'] = [$orderby => $sort];
3210
+		}
3211
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3212
+		return $count
3213
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3214
+			: $this->getAttendeeModel()->get_all($query_args);
3215
+	}
3216
+
3217
+
3218
+	/**
3219
+	 * This is just taking care of resending the registration confirmation
3220
+	 *
3221
+	 * @return void
3222
+	 * @throws EE_Error
3223
+	 * @throws InvalidArgumentException
3224
+	 * @throws InvalidDataTypeException
3225
+	 * @throws InvalidInterfaceException
3226
+	 * @throws ReflectionException
3227
+	 */
3228
+	protected function _resend_registration()
3229
+	{
3230
+		$this->_process_resend_registration();
3231
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3232
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3233
+		$query_args  = $redirect_to
3234
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3235
+			: ['action' => 'default'];
3236
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3237
+	}
3238
+
3239
+
3240
+	/**
3241
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3242
+	 * to use when selecting registrations
3243
+	 *
3244
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3245
+	 *                                                     the query parameters from the request
3246
+	 * @return void ends the request with a redirect or download
3247
+	 */
3248
+	public function _registrations_report_base($method_name_for_getting_query_params)
3249
+	{
3250
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3251
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3252
+			: null;
3253
+
3254
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3255
+			$request_params = $this->request->requestParams();
3256
+			wp_redirect(
3257
+				EE_Admin_Page::add_query_args_and_nonce(
3258
+					[
3259
+						'page'        => 'espresso_batch',
3260
+						'batch'       => 'file',
3261
+						'EVT_ID'      => $EVT_ID,
3262
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3263
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', DataType::URL)),
3264
+						'filters'     => urlencode(
3265
+							serialize(
3266
+								$this->$method_name_for_getting_query_params(
3267
+									(isset($request_params['filters']) ? $request_params['filters'] : [])
3268
+								)
3269
+							)
3270
+						),
3271
+						'use_filters' => $this->request->getRequestParam('use_filters', false, DataType::BOOL)
3272
+					]
3273
+				)
3274
+			);
3275
+		} else {
3276
+			// Pull the current request params
3277
+			$request_args = $this->request->requestParams();
3278
+			// Set the required request_args to be passed to the export
3279
+			$required_request_args = [
3280
+				'export' => 'report',
3281
+				'action' => 'registrations_report_for_event',
3282
+				'EVT_ID' => $EVT_ID,
3283
+			];
3284
+			// Merge required request args, overriding any currently set
3285
+			$request_args = array_merge($request_args, $required_request_args);
3286
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3287
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3288
+				$EE_Export = EE_Export::instance($request_args);
3289
+				$EE_Export->export();
3290
+			}
3291
+		}
3292
+	}
3293
+
3294
+
3295
+	/**
3296
+	 * Creates a registration report using only query parameters in the request
3297
+	 *
3298
+	 * @return void
3299
+	 */
3300
+	public function _registrations_report()
3301
+	{
3302
+		$this->_registrations_report_base('_get_registration_query_parameters');
3303
+	}
3304
+
3305
+
3306
+	public function _contact_list_export()
3307
+	{
3308
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3309
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3310
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3311
+			$EE_Export->export_attendees();
3312
+		}
3313
+	}
3314
+
3315
+
3316
+	public function _contact_list_report()
3317
+	{
3318
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3319
+			wp_redirect(
3320
+				EE_Admin_Page::add_query_args_and_nonce(
3321
+					[
3322
+						'page'        => 'espresso_batch',
3323
+						'batch'       => 'file',
3324
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3325
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3326
+					]
3327
+				)
3328
+			);
3329
+		} else {
3330
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3331
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3332
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3333
+				$EE_Export->report_attendees();
3334
+			}
3335
+		}
3336
+	}
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3343
+	/**
3344
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3345
+	 *
3346
+	 * @return void
3347
+	 * @throws EE_Error
3348
+	 * @throws InvalidArgumentException
3349
+	 * @throws InvalidDataTypeException
3350
+	 * @throws InvalidInterfaceException
3351
+	 * @throws ReflectionException
3352
+	 */
3353
+	protected function _duplicate_attendee()
3354
+	{
3355
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3356
+		$action = $this->request->getRequestParam('return', 'default');
3357
+		// verify we have necessary info
3358
+		if (! $REG_ID) {
3359
+			EE_Error::add_error(
3360
+				esc_html__(
3361
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3362
+					'event_espresso'
3363
+				),
3364
+				__FILE__,
3365
+				__LINE__,
3366
+				__FUNCTION__
3367
+			);
3368
+			$query_args = ['action' => $action];
3369
+			$this->_redirect_after_action('', '', '', $query_args, true);
3370
+		}
3371
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3372
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3373
+		if (! $registration instanceof EE_Registration) {
3374
+			throw new RuntimeException(
3375
+				sprintf(
3376
+					esc_html__(
3377
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3378
+						'event_espresso'
3379
+					),
3380
+					$REG_ID
3381
+				)
3382
+			);
3383
+		}
3384
+		$attendee = $registration->attendee();
3385
+		// remove relation of existing attendee on registration
3386
+		$registration->_remove_relation_to($attendee, 'Attendee');
3387
+		// new attendee
3388
+		$new_attendee = clone $attendee;
3389
+		$new_attendee->set('ATT_ID', 0);
3390
+		$new_attendee->save();
3391
+		// add new attendee to reg
3392
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3393
+		EE_Error::add_success(
3394
+			esc_html__(
3395
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3396
+				'event_espresso'
3397
+			)
3398
+		);
3399
+		// redirect to edit page for attendee
3400
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3401
+		$this->_redirect_after_action('', '', '', $query_args, true);
3402
+	}
3403
+
3404
+
3405
+	/**
3406
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3407
+	 *
3408
+	 * @param int     $post_id
3409
+	 * @param WP_Post $post
3410
+	 * @throws DomainException
3411
+	 * @throws EE_Error
3412
+	 * @throws InvalidArgumentException
3413
+	 * @throws InvalidDataTypeException
3414
+	 * @throws InvalidInterfaceException
3415
+	 * @throws LogicException
3416
+	 * @throws InvalidFormSubmissionException
3417
+	 * @throws ReflectionException
3418
+	 */
3419
+	protected function _insert_update_cpt_item($post_id, $post)
3420
+	{
3421
+		$success  = true;
3422
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3423
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3424
+			: null;
3425
+		// for attendee updates
3426
+		if ($attendee instanceof EE_Attendee) {
3427
+			// note we should only be UPDATING attendees at this point.
3428
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3429
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3430
+			$updated_fields = [
3431
+				'ATT_fname'     => $fname,
3432
+				'ATT_lname'     => $lname,
3433
+				'ATT_full_name' => "{$fname} {$lname}",
3434
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3435
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3436
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3437
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3438
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3439
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3440
+			];
3441
+			foreach ($updated_fields as $field => $value) {
3442
+				$attendee->set($field, $value);
3443
+			}
3444
+
3445
+			// process contact details metabox form handler (which will also save the attendee)
3446
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3447
+			$success              = $contact_details_form->process($this->request->requestParams());
3448
+
3449
+			$attendee_update_callbacks = apply_filters(
3450
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3451
+				[]
3452
+			);
3453
+			foreach ($attendee_update_callbacks as $a_callback) {
3454
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3455
+					throw new EE_Error(
3456
+						sprintf(
3457
+							esc_html__(
3458
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3459
+								'event_espresso'
3460
+							),
3461
+							$a_callback
3462
+						)
3463
+					);
3464
+				}
3465
+			}
3466
+		}
3467
+
3468
+		if ($success === false) {
3469
+			EE_Error::add_error(
3470
+				esc_html__(
3471
+					'Something went wrong with updating the meta table data for the registration.',
3472
+					'event_espresso'
3473
+				),
3474
+				__FILE__,
3475
+				__FUNCTION__,
3476
+				__LINE__
3477
+			);
3478
+		}
3479
+	}
3480
+
3481
+
3482
+	public function trash_cpt_item($post_id)
3483
+	{
3484
+	}
3485
+
3486
+
3487
+	public function delete_cpt_item($post_id)
3488
+	{
3489
+	}
3490
+
3491
+
3492
+	public function restore_cpt_item($post_id)
3493
+	{
3494
+	}
3495
+
3496
+
3497
+	protected function _restore_cpt_item($post_id, $revision_id)
3498
+	{
3499
+	}
3500
+
3501
+
3502
+	/**
3503
+	 * @throws EE_Error
3504
+	 * @throws ReflectionException
3505
+	 * @since 4.10.2.p
3506
+	 */
3507
+	public function attendee_editor_metaboxes()
3508
+	{
3509
+		$this->verify_cpt_object();
3510
+		remove_meta_box(
3511
+			'postexcerpt',
3512
+			$this->_cpt_routes[ $this->_req_action ],
3513
+			'normal'
3514
+		);
3515
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3516
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3517
+			add_meta_box(
3518
+				'postexcerpt',
3519
+				esc_html__('Short Biography', 'event_espresso'),
3520
+				'post_excerpt_meta_box',
3521
+				$this->_cpt_routes[ $this->_req_action ],
3522
+				'normal'
3523
+			);
3524
+		}
3525
+		if (post_type_supports('espresso_attendees', 'comments')) {
3526
+			add_meta_box(
3527
+				'commentsdiv',
3528
+				esc_html__('Notes on the Contact', 'event_espresso'),
3529
+				'post_comment_meta_box',
3530
+				$this->_cpt_routes[ $this->_req_action ],
3531
+				'normal',
3532
+				'core'
3533
+			);
3534
+		}
3535
+		add_meta_box(
3536
+			'attendee_contact_info',
3537
+			esc_html__('Contact Info', 'event_espresso'),
3538
+			[$this, 'attendee_contact_info'],
3539
+			$this->_cpt_routes[ $this->_req_action ],
3540
+			'side',
3541
+			'core'
3542
+		);
3543
+		add_meta_box(
3544
+			'attendee_details_address',
3545
+			esc_html__('Address Details', 'event_espresso'),
3546
+			[$this, 'attendee_address_details'],
3547
+			$this->_cpt_routes[ $this->_req_action ],
3548
+			'normal',
3549
+			'core'
3550
+		);
3551
+		add_meta_box(
3552
+			'attendee_registrations',
3553
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3554
+			[$this, 'attendee_registrations_meta_box'],
3555
+			$this->_cpt_routes[ $this->_req_action ],
3556
+			'normal',
3557
+			'high'
3558
+		);
3559
+	}
3560
+
3561
+
3562
+	/**
3563
+	 * Metabox for attendee contact info
3564
+	 *
3565
+	 * @param WP_Post $post wp post object
3566
+	 * @return void attendee contact info ( and form )
3567
+	 * @throws EE_Error
3568
+	 * @throws InvalidArgumentException
3569
+	 * @throws InvalidDataTypeException
3570
+	 * @throws InvalidInterfaceException
3571
+	 * @throws LogicException
3572
+	 * @throws DomainException
3573
+	 */
3574
+	public function attendee_contact_info($post)
3575
+	{
3576
+		// get attendee object ( should already have it )
3577
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3578
+		$form->enqueueStylesAndScripts();
3579
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3580
+	}
3581
+
3582
+
3583
+	/**
3584
+	 * Return form handler for the contact details metabox
3585
+	 *
3586
+	 * @param EE_Attendee $attendee
3587
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3588
+	 * @throws DomainException
3589
+	 * @throws InvalidArgumentException
3590
+	 * @throws InvalidDataTypeException
3591
+	 * @throws InvalidInterfaceException
3592
+	 */
3593
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3594
+	{
3595
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3596
+	}
3597
+
3598
+
3599
+	/**
3600
+	 * Metabox for attendee details
3601
+	 *
3602
+	 * @param WP_Post $post wp post object
3603
+	 * @throws EE_Error
3604
+	 * @throws ReflectionException
3605
+	 */
3606
+	public function attendee_address_details($post)
3607
+	{
3608
+		// get attendee object (should already have it)
3609
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3610
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3611
+			new EE_Question_Form_Input(
3612
+				EE_Question::new_instance(
3613
+					[
3614
+						'QST_ID'           => 0,
3615
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3616
+						'QST_system'       => 'admin-state',
3617
+					]
3618
+				),
3619
+				EE_Answer::new_instance(
3620
+					[
3621
+						'ANS_ID'    => 0,
3622
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3623
+					]
3624
+				),
3625
+				[
3626
+					'input_id'       => 'STA_ID',
3627
+					'input_name'     => 'STA_ID',
3628
+					'input_prefix'   => '',
3629
+					'append_qstn_id' => false,
3630
+				]
3631
+			)
3632
+		);
3633
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3634
+			new EE_Question_Form_Input(
3635
+				EE_Question::new_instance(
3636
+					[
3637
+						'QST_ID'           => 0,
3638
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3639
+						'QST_system'       => 'admin-country',
3640
+					]
3641
+				),
3642
+				EE_Answer::new_instance(
3643
+					[
3644
+						'ANS_ID'    => 0,
3645
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3646
+					]
3647
+				),
3648
+				[
3649
+					'input_id'       => 'CNT_ISO',
3650
+					'input_name'     => 'CNT_ISO',
3651
+					'input_prefix'   => '',
3652
+					'append_qstn_id' => false,
3653
+				]
3654
+			)
3655
+		);
3656
+		$template                             =
3657
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3658
+		EEH_Template::display_template($template, $this->_template_args);
3659
+	}
3660
+
3661
+
3662
+	/**
3663
+	 * _attendee_details
3664
+	 *
3665
+	 * @param $post
3666
+	 * @return void
3667
+	 * @throws DomainException
3668
+	 * @throws EE_Error
3669
+	 * @throws InvalidArgumentException
3670
+	 * @throws InvalidDataTypeException
3671
+	 * @throws InvalidInterfaceException
3672
+	 * @throws ReflectionException
3673
+	 */
3674
+	public function attendee_registrations_meta_box($post)
3675
+	{
3676
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3677
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3678
+		$template                              =
3679
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3680
+		EEH_Template::display_template($template, $this->_template_args);
3681
+	}
3682
+
3683
+
3684
+	/**
3685
+	 * add in the form fields for the attendee edit
3686
+	 *
3687
+	 * @param WP_Post $post wp post object
3688
+	 * @return void echos html for new form.
3689
+	 * @throws DomainException
3690
+	 */
3691
+	public function after_title_form_fields($post)
3692
+	{
3693
+		if ($post->post_type === 'espresso_attendees') {
3694
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3695
+			$template_args['attendee'] = $this->_cpt_model_obj;
3696
+			EEH_Template::display_template($template, $template_args);
3697
+		}
3698
+	}
3699
+
3700
+
3701
+	/**
3702
+	 * _trash_or_restore_attendee
3703
+	 *
3704
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3705
+	 * @return void
3706
+	 * @throws EE_Error
3707
+	 * @throws InvalidArgumentException
3708
+	 * @throws InvalidDataTypeException
3709
+	 * @throws InvalidInterfaceException
3710
+	 */
3711
+	protected function _trash_or_restore_attendees($trash = true)
3712
+	{
3713
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3714
+		$status = $trash ? 'trash' : 'publish';
3715
+		// Checkboxes
3716
+		if ($this->request->requestParamIsSet('checkbox')) {
3717
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3718
+			// if array has more than one element than success message should be plural
3719
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3720
+			// cycle thru checkboxes
3721
+			foreach ($ATT_IDs as $ATT_ID) {
3722
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3723
+				if (! $updated) {
3724
+					$success = 0;
3725
+				}
3726
+			}
3727
+		} else {
3728
+			// grab single id and delete
3729
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3730
+			// update attendee
3731
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3732
+		}
3733
+		$what        = $success > 1
3734
+			? esc_html__('Contacts', 'event_espresso')
3735
+			: esc_html__('Contact', 'event_espresso');
3736
+		$action_desc = $trash
3737
+			? esc_html__('moved to the trash', 'event_espresso')
3738
+			: esc_html__('restored', 'event_espresso');
3739
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3740
+	}
3741 3741
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function getRegistrationModel()
96 96
     {
97
-        if (! $this->registration_model instanceof EEM_Registration) {
97
+        if ( ! $this->registration_model instanceof EEM_Registration) {
98 98
             $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
99 99
         }
100 100
         return $this->registration_model;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     protected function getAttendeeModel()
112 112
     {
113
-        if (! $this->attendee_model instanceof EEM_Attendee) {
113
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
114 114
             $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
115 115
         }
116 116
         return $this->attendee_model;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function getEventModel()
128 128
     {
129
-        if (! $this->event_model instanceof EEM_Event) {
129
+        if ( ! $this->event_model instanceof EEM_Event) {
130 130
             $this->event_model = $this->getLoader()->getShared('EEM_Event');
131 131
         }
132 132
         return $this->event_model;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     protected function getStatusModel()
144 144
     {
145
-        if (! $this->status_model instanceof EEM_Status) {
145
+        if ( ! $this->status_model instanceof EEM_Status) {
146 146
             $this->status_model = $this->getLoader()->getShared('EEM_Status');
147 147
         }
148 148
         return $this->status_model;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
         // style
754 754
         wp_register_style(
755 755
             'espresso_reg',
756
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
756
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
757 757
             ['ee-admin-css'],
758 758
             EVENT_ESPRESSO_VERSION
759 759
         );
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
         // script
762 762
         wp_register_script(
763 763
             'espresso_reg',
764
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
764
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
765 765
             ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
766 766
             EVENT_ESPRESSO_VERSION,
767 767
             true
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
             'att_publish_text' => sprintf(
786 786
             /* translators: The date and time */
787 787
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
788
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
788
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
789 789
             ),
790 790
         ];
791 791
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
         wp_dequeue_style('espresso_reg');
817 817
         wp_register_style(
818 818
             'espresso_att',
819
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
819
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
820 820
             ['ee-admin-css'],
821 821
             EVENT_ESPRESSO_VERSION
822 822
         );
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
     {
829 829
         wp_register_script(
830 830
             'ee-spco-for-admin',
831
-            REG_ASSETS_URL . 'spco_for_admin.js',
831
+            REG_ASSETS_URL.'spco_for_admin.js',
832 832
             ['underscore', 'jquery'],
833 833
             EVENT_ESPRESSO_VERSION,
834 834
             true
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
             'no_approve_registrations' => 'not_approved_registration',
877 877
             'cancel_registrations'     => 'cancelled_registration',
878 878
         ];
879
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
879
+        $can_send = EE_Registry::instance()->CAP->current_user_can(
880 880
             'ee_send_message',
881 881
             'batch_send_messages'
882 882
         );
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
982 982
                 ],
983 983
             ];
984
-            $this->_views['trash']      = [
984
+            $this->_views['trash'] = [
985 985
                 'slug'        => 'trash',
986 986
                 'label'       => esc_html__('Trash', 'event_espresso'),
987 987
                 'count'       => 0,
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
         }
1082 1082
         $sc_items = [
1083 1083
             'approved_status'   => [
1084
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1084
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1085 1085
                 'desc'  => EEH_Template::pretty_status(
1086 1086
                     EEM_Registration::status_id_approved,
1087 1087
                     false,
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
                 ),
1090 1090
             ],
1091 1091
             'pending_status'    => [
1092
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1092
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1093 1093
                 'desc'  => EEH_Template::pretty_status(
1094 1094
                     EEM_Registration::status_id_pending_payment,
1095 1095
                     false,
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
                 ),
1098 1098
             ],
1099 1099
             'wait_list'         => [
1100
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1100
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1101 1101
                 'desc'  => EEH_Template::pretty_status(
1102 1102
                     EEM_Registration::status_id_wait_list,
1103 1103
                     false,
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
                 ),
1106 1106
             ],
1107 1107
             'incomplete_status' => [
1108
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1108
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
1109 1109
                 'desc'  => EEH_Template::pretty_status(
1110 1110
                     EEM_Registration::status_id_incomplete,
1111 1111
                     false,
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
                 ),
1114 1114
             ],
1115 1115
             'not_approved'      => [
1116
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1116
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1117 1117
                 'desc'  => EEH_Template::pretty_status(
1118 1118
                     EEM_Registration::status_id_not_approved,
1119 1119
                     false,
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
                 ),
1122 1122
             ],
1123 1123
             'declined_status'   => [
1124
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1124
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1125 1125
                 'desc'  => EEH_Template::pretty_status(
1126 1126
                     EEM_Registration::status_id_declined,
1127 1127
                     false,
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
                 ),
1130 1130
             ],
1131 1131
             'cancelled_status'  => [
1132
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1132
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1133 1133
                 'desc'  => EEH_Template::pretty_status(
1134 1134
                     EEM_Registration::status_id_cancelled,
1135 1135
                     false,
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
                 $EVT_ID
1190 1190
             )
1191 1191
         ) {
1192
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1192
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1193 1193
                 'new_registration',
1194 1194
                 'add-registrant',
1195 1195
                 ['event_id' => $EVT_ID],
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
                 ],
1348 1348
                 REG_ADMIN_URL
1349 1349
             );
1350
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1350
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1351 1351
                 [
1352 1352
                     'action' => 'default',
1353 1353
                     'EVT_ID' => $event_id,
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
                 ],
1356 1356
                 admin_url('admin.php')
1357 1357
             );
1358
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1358
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1359 1359
                 [
1360 1360
                     'page'   => 'espresso_events',
1361 1361
                     'action' => 'edit',
@@ -1364,12 +1364,12 @@  discard block
 block discarded – undo
1364 1364
                 admin_url('admin.php')
1365 1365
             );
1366 1366
             // next and previous links
1367
-            $next_reg                                      = $this->_registration->next(
1367
+            $next_reg = $this->_registration->next(
1368 1368
                 null,
1369 1369
                 [],
1370 1370
                 'REG_ID'
1371 1371
             );
1372
-            $this->_template_args['next_registration']     = $next_reg
1372
+            $this->_template_args['next_registration'] = $next_reg
1373 1373
                 ? $this->_next_link(
1374 1374
                     EE_Admin_Page::add_query_args_and_nonce(
1375 1375
                         [
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1382 1382
                 )
1383 1383
                 : '';
1384
-            $previous_reg                                  = $this->_registration->previous(
1384
+            $previous_reg = $this->_registration->previous(
1385 1385
                 null,
1386 1386
                 [],
1387 1387
                 'REG_ID'
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
                 )
1400 1400
                 : '';
1401 1401
             // grab header
1402
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1402
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1403 1403
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1404 1404
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1405 1405
                 $template_path,
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
                                 EEH_HTML::strong(
1554 1554
                                     $this->_registration->pretty_status(),
1555 1555
                                     '',
1556
-                                    'status-' . $this->_registration->status_ID(),
1556
+                                    'status-'.$this->_registration->status_ID(),
1557 1557
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1558 1558
                                 )
1559 1559
                             )
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
                 $this->_registration->ID()
1570 1570
             )
1571 1571
         ) {
1572
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1572
+            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1573 1573
                 $this->_get_reg_statuses(),
1574 1574
                 [
1575 1575
                     'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
                     ),
1587 1587
                 ]
1588 1588
             );
1589
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1589
+            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1590 1590
                 [
1591 1591
                     'html_class'      => 'button-primary',
1592 1592
                     'html_label_text' => '&nbsp;',
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
     protected function _get_reg_statuses()
1612 1612
     {
1613 1613
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1614
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1614
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1615 1615
         // get current reg status
1616 1616
         $current_status = $this->_registration->status_ID();
1617 1617
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
             $current_status !== EEM_Registration::status_id_pending_payment
1620 1620
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1621 1621
         ) {
1622
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1622
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1623 1623
         }
1624 1624
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1625 1625
     }
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
         $success = false;
1711 1711
         // typecast $REG_IDs
1712 1712
         $REG_IDs = (array) $REG_IDs;
1713
-        if (! empty($REG_IDs)) {
1713
+        if ( ! empty($REG_IDs)) {
1714 1714
             $success = true;
1715 1715
             // set default status if none is passed
1716 1716
             $status         = $status ?: EEM_Registration::status_id_pending_payment;
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
             $action,
1871 1871
             $notify
1872 1872
         );
1873
-        $method = $action . '_registration';
1873
+        $method = $action.'_registration';
1874 1874
         if (method_exists($this, $method)) {
1875 1875
             $this->$method($notify);
1876 1876
         }
@@ -2020,7 +2020,7 @@  discard block
 block discarded – undo
2020 2020
         $filters        = new EE_Line_Item_Filter_Collection();
2021 2021
         $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2022 2022
         $filters->add(new EE_Non_Zero_Line_Item_Filter());
2023
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2023
+        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2024 2024
             $filters,
2025 2025
             $transaction->total_line_item()
2026 2026
         );
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
             $filtered_line_item_tree,
2034 2034
             ['EE_Registration' => $this->_registration]
2035 2035
         );
2036
-        $attendee                                = $this->_registration->attendee();
2036
+        $attendee = $this->_registration->attendee();
2037 2037
         if (
2038 2038
             EE_Registry::instance()->CAP->current_user_can(
2039 2039
                 'ee_read_transaction',
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
                 'Payment method response',
2116 2116
                 'event_espresso'
2117 2117
             );
2118
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2118
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2119 2119
         }
2120 2120
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2121 2121
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2145,7 +2145,7 @@  discard block
 block discarded – undo
2145 2145
         $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2146 2146
         $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2147 2147
         $template_path                                                        =
2148
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2148
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2149 2149
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2150 2150
     }
2151 2151
 
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2184 2184
             $this->_template_args['REG_ID']                    = $this->_registration->ID();
2185 2185
             $template_path                                     =
2186
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2186
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2187 2187
             EEH_Template::display_template($template_path, $this->_template_args);
2188 2188
         }
2189 2189
     }
@@ -2199,7 +2199,7 @@  discard block
 block discarded – undo
2199 2199
     public function form_before_question_group($output)
2200 2200
     {
2201 2201
         EE_Error::doing_it_wrong(
2202
-            __CLASS__ . '::' . __FUNCTION__,
2202
+            __CLASS__.'::'.__FUNCTION__,
2203 2203
             esc_html__(
2204 2204
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2205 2205
                 'event_espresso'
@@ -2223,7 +2223,7 @@  discard block
 block discarded – undo
2223 2223
     public function form_after_question_group($output)
2224 2224
     {
2225 2225
         EE_Error::doing_it_wrong(
2226
-            __CLASS__ . '::' . __FUNCTION__,
2226
+            __CLASS__.'::'.__FUNCTION__,
2227 2227
             esc_html__(
2228 2228
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2229 2229
                 'event_espresso'
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
     public function form_form_field_label_wrap($label)
2261 2261
     {
2262 2262
         EE_Error::doing_it_wrong(
2263
-            __CLASS__ . '::' . __FUNCTION__,
2263
+            __CLASS__.'::'.__FUNCTION__,
2264 2264
             esc_html__(
2265 2265
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2266 2266
                 'event_espresso'
@@ -2270,7 +2270,7 @@  discard block
 block discarded – undo
2270 2270
         return '
2271 2271
 			<tr>
2272 2272
 				<th>
2273
-					' . $label . '
2273
+					' . $label.'
2274 2274
 				</th>';
2275 2275
     }
2276 2276
 
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
     public function form_form_field_input__wrap($input)
2286 2286
     {
2287 2287
         EE_Error::doing_it_wrong(
2288
-            __CLASS__ . '::' . __FUNCTION__,
2288
+            __CLASS__.'::'.__FUNCTION__,
2289 2289
             esc_html__(
2290 2290
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2291 2291
                 'event_espresso'
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
         );
2295 2295
         return '
2296 2296
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2297
-					' . $input . '
2297
+					' . $input.'
2298 2298
 				</td>
2299 2299
 			</tr>';
2300 2300
     }
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
      */
2344 2344
     protected function _get_reg_custom_questions_form($REG_ID)
2345 2345
     {
2346
-        if (! $this->_reg_custom_questions_form) {
2347
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2346
+        if ( ! $this->_reg_custom_questions_form) {
2347
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2348 2348
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2349 2349
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2350 2350
             );
@@ -2367,7 +2367,7 @@  discard block
 block discarded – undo
2367 2367
      */
2368 2368
     private function _save_reg_custom_questions_form($REG_ID = 0)
2369 2369
     {
2370
-        if (! $REG_ID) {
2370
+        if ( ! $REG_ID) {
2371 2371
             EE_Error::add_error(
2372 2372
                 esc_html__(
2373 2373
                     'An error occurred. No registration ID was received.',
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
         if ($form->is_valid()) {
2385 2385
             foreach ($form->subforms() as $question_group_form) {
2386 2386
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2387
-                    $where_conditions    = [
2387
+                    $where_conditions = [
2388 2388
                         'QST_ID' => $question_id,
2389 2389
                         'REG_ID' => $REG_ID,
2390 2390
                     ];
@@ -2425,7 +2425,7 @@  discard block
 block discarded – undo
2425 2425
         $REG = $this->getRegistrationModel();
2426 2426
         // get all other registrations on this transaction, and cache
2427 2427
         // the attendees for them so we don't have to run another query using force_join
2428
-        $registrations                           = $REG->get_all(
2428
+        $registrations = $REG->get_all(
2429 2429
             [
2430 2430
                 [
2431 2431
                     'TXN_ID' => $this->_registration->transaction_ID(),
@@ -2459,23 +2459,23 @@  discard block
 block discarded – undo
2459 2459
                 $attendee                                                      = $registration->attendee()
2460 2460
                     ? $registration->attendee()
2461 2461
                     : $this->getAttendeeModel()->create_default_object();
2462
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2467
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2462
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2463
+                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2464
+                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2465
+                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2466
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2467
+                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2468 2468
                     ', ',
2469 2469
                     $attendee->full_address_as_array()
2470 2470
                 );
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2471
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2472 2472
                     [
2473 2473
                         'action' => 'edit_attendee',
2474 2474
                         'post'   => $attendee->ID(),
2475 2475
                     ],
2476 2476
                     REG_ADMIN_URL
2477 2477
                 );
2478
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2478
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] =
2479 2479
                     $registration->event_obj() instanceof EE_Event
2480 2480
                         ? $registration->event_obj()->name()
2481 2481
                         : '';
@@ -2483,7 +2483,7 @@  discard block
 block discarded – undo
2483 2483
             }
2484 2484
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2485 2485
         }
2486
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2486
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2487 2487
         EEH_Template::display_template($template_path, $this->_template_args);
2488 2488
     }
2489 2489
 
@@ -2509,11 +2509,11 @@  discard block
 block discarded – undo
2509 2509
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2510 2510
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2511 2511
         // primary registration object (that way we know if we need to show create button or not)
2512
-        if (! $this->_registration->is_primary_registrant()) {
2512
+        if ( ! $this->_registration->is_primary_registrant()) {
2513 2513
             $primary_registration = $this->_registration->get_primary_registration();
2514 2514
             $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2515 2515
                 : null;
2516
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2516
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2517 2517
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2518 2518
                 // custom attendee object so let's not worry about the primary reg.
2519 2519
                 $primary_registration = null;
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
         $this->_template_args['phone']             = $attendee->phone();
2529 2529
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2530 2530
         // edit link
2531
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2531
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2532 2532
             [
2533 2533
                 'action' => 'edit_attendee',
2534 2534
                 'post'   => $attendee->ID(),
@@ -2537,7 +2537,7 @@  discard block
 block discarded – undo
2537 2537
         );
2538 2538
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2539 2539
         // create link
2540
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2540
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2541 2541
             ? EE_Admin_Page::add_query_args_and_nonce(
2542 2542
                 [
2543 2543
                     'action'  => 'duplicate_attendee',
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2549 2549
         $this->_template_args['att_check']    = $att_check;
2550 2550
         $template_path                        =
2551
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2551
+            REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2552 2552
         EEH_Template::display_template($template_path, $this->_template_args);
2553 2553
     }
2554 2554
 
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
             /** @var EE_Registration $REG */
2593 2593
             $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2594 2594
             $payments = $REG->registration_payments();
2595
-            if (! empty($payments)) {
2595
+            if ( ! empty($payments)) {
2596 2596
                 $name           = $REG->attendee() instanceof EE_Attendee
2597 2597
                     ? $REG->attendee()->full_name()
2598 2598
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2656,17 +2656,17 @@  discard block
 block discarded – undo
2656 2656
         // Checkboxes
2657 2657
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2658 2658
 
2659
-        if (! empty($REG_IDs)) {
2659
+        if ( ! empty($REG_IDs)) {
2660 2660
             // if array has more than one element than success message should be plural
2661 2661
             $success = count($REG_IDs) > 1 ? 2 : 1;
2662 2662
             // cycle thru checkboxes
2663 2663
             foreach ($REG_IDs as $REG_ID) {
2664 2664
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2665
-                if (! $REG instanceof EE_Registration) {
2665
+                if ( ! $REG instanceof EE_Registration) {
2666 2666
                     continue;
2667 2667
                 }
2668 2668
                 $deleted = $this->_delete_registration($REG);
2669
-                if (! $deleted) {
2669
+                if ( ! $deleted) {
2670 2670
                     $success = 0;
2671 2671
                 }
2672 2672
             }
@@ -2703,7 +2703,7 @@  discard block
 block discarded – undo
2703 2703
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2704 2704
         // registrations on the transaction that are NOT trashed.
2705 2705
         $TXN = $REG->get_first_related('Transaction');
2706
-        if (! $TXN instanceof EE_Transaction) {
2706
+        if ( ! $TXN instanceof EE_Transaction) {
2707 2707
             EE_Error::add_error(
2708 2708
                 sprintf(
2709 2709
                     esc_html__(
@@ -2721,11 +2721,11 @@  discard block
 block discarded – undo
2721 2721
         $REGS        = $TXN->get_many_related('Registration');
2722 2722
         $all_trashed = true;
2723 2723
         foreach ($REGS as $registration) {
2724
-            if (! $registration->get('REG_deleted')) {
2724
+            if ( ! $registration->get('REG_deleted')) {
2725 2725
                 $all_trashed = false;
2726 2726
             }
2727 2727
         }
2728
-        if (! $all_trashed) {
2728
+        if ( ! $all_trashed) {
2729 2729
             EE_Error::add_error(
2730 2730
                 esc_html__(
2731 2731
                     'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
@@ -2787,7 +2787,7 @@  discard block
 block discarded – undo
2787 2787
      */
2788 2788
     public function new_registration()
2789 2789
     {
2790
-        if (! $this->_set_reg_event()) {
2790
+        if ( ! $this->_set_reg_event()) {
2791 2791
             throw new EE_Error(
2792 2792
                 esc_html__(
2793 2793
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2819,7 +2819,7 @@  discard block
 block discarded – undo
2819 2819
                 ],
2820 2820
                 EVENTS_ADMIN_URL
2821 2821
             );
2822
-            $edit_event_lnk                     = '<a href="'
2822
+            $edit_event_lnk = '<a href="'
2823 2823
                                                   . $edit_event_url
2824 2824
                                                   . '" title="'
2825 2825
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2837,7 +2837,7 @@  discard block
 block discarded – undo
2837 2837
         }
2838 2838
         // grab header
2839 2839
         $template_path                              =
2840
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2840
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2841 2841
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2842 2842
             $template_path,
2843 2843
             $this->_template_args,
@@ -2878,7 +2878,7 @@  discard block
 block discarded – undo
2878 2878
                 '</b>'
2879 2879
             );
2880 2880
             return '
2881
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2881
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2882 2882
 	<script >
2883 2883
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2884 2884
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2920,7 +2920,7 @@  discard block
 block discarded – undo
2920 2920
                 );
2921 2921
                 $template_args['content']                          =
2922 2922
                     EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2923
-                $template_args['content']                          .= '</div>';
2923
+                $template_args['content'] .= '</div>';
2924 2924
                 $template_args['step_button_text']                 = esc_html__(
2925 2925
                     'Add Tickets and Continue to Registrant Details',
2926 2926
                     'event_espresso'
@@ -2947,7 +2947,7 @@  discard block
 block discarded – undo
2947 2947
         // we come back to the process_registration_step route.
2948 2948
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2949 2949
         return EEH_Template::display_template(
2950
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2950
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2951 2951
             $template_args,
2952 2952
             true
2953 2953
         );
@@ -2970,7 +2970,7 @@  discard block
 block discarded – undo
2970 2970
         }
2971 2971
 
2972 2972
         $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2973
-        if (! $EVT_ID) {
2973
+        if ( ! $EVT_ID) {
2974 2974
             return false;
2975 2975
         }
2976 2976
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3040,7 +3040,7 @@  discard block
 block discarded – undo
3040 3040
                 }
3041 3041
                 break;
3042 3042
             case 'questions':
3043
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3043
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3044 3044
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3045 3045
                 }
3046 3046
                 // process registration
@@ -3051,7 +3051,7 @@  discard block
 block discarded – undo
3051 3051
                         $grand_total->save_this_and_descendants_to_txn();
3052 3052
                     }
3053 3053
                 }
3054
-                if (! $transaction instanceof EE_Transaction) {
3054
+                if ( ! $transaction instanceof EE_Transaction) {
3055 3055
                     $query_args = [
3056 3056
                         'action'                  => 'new_registration',
3057 3057
                         'processing_registration' => 2,
@@ -3073,7 +3073,7 @@  discard block
 block discarded – undo
3073 3073
                     return;
3074 3074
                 }
3075 3075
                 // maybe update status, and make sure to save transaction if not done already
3076
-                if (! $transaction->update_status_based_on_total_paid()) {
3076
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3077 3077
                     $transaction->save();
3078 3078
                 }
3079 3079
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
     public function get_attendees($per_page, $count = false, $trash = false)
3156 3156
     {
3157 3157
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3158
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3158
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3159 3159
         $orderby = $this->request->getRequestParam('orderby');
3160 3160
         switch ($orderby) {
3161 3161
             case 'ATT_ID':
@@ -3178,7 +3178,7 @@  discard block
 block discarded – undo
3178 3178
         $_where       = [];
3179 3179
         $search_term  = $this->request->getRequestParam('s');
3180 3180
         if ($search_term) {
3181
-            $search_term  = '%' . $search_term . '%';
3181
+            $search_term  = '%'.$search_term.'%';
3182 3182
             $_where['OR'] = [
3183 3183
                 'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3184 3184
                 'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
             'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3206 3206
             'limit'         => $limit,
3207 3207
         ];
3208
-        if (! $count) {
3208
+        if ( ! $count) {
3209 3209
             $query_args['order_by'] = [$orderby => $sort];
3210 3210
         }
3211 3211
         $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
@@ -3251,7 +3251,7 @@  discard block
 block discarded – undo
3251 3251
             ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3252 3252
             : null;
3253 3253
 
3254
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3254
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3255 3255
             $request_params = $this->request->requestParams();
3256 3256
             wp_redirect(
3257 3257
                 EE_Admin_Page::add_query_args_and_nonce(
@@ -3283,8 +3283,8 @@  discard block
 block discarded – undo
3283 3283
             ];
3284 3284
             // Merge required request args, overriding any currently set
3285 3285
             $request_args = array_merge($request_args, $required_request_args);
3286
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3287
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3286
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3287
+                require_once(EE_CLASSES.'EE_Export.class.php');
3288 3288
                 $EE_Export = EE_Export::instance($request_args);
3289 3289
                 $EE_Export->export();
3290 3290
             }
@@ -3305,8 +3305,8 @@  discard block
 block discarded – undo
3305 3305
 
3306 3306
     public function _contact_list_export()
3307 3307
     {
3308
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3309
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3308
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3309
+            require_once(EE_CLASSES.'EE_Export.class.php');
3310 3310
             $EE_Export = EE_Export::instance($this->request->requestParams());
3311 3311
             $EE_Export->export_attendees();
3312 3312
         }
@@ -3315,7 +3315,7 @@  discard block
 block discarded – undo
3315 3315
 
3316 3316
     public function _contact_list_report()
3317 3317
     {
3318
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3318
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3319 3319
             wp_redirect(
3320 3320
                 EE_Admin_Page::add_query_args_and_nonce(
3321 3321
                     [
@@ -3327,8 +3327,8 @@  discard block
 block discarded – undo
3327 3327
                 )
3328 3328
             );
3329 3329
         } else {
3330
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3331
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3330
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3331
+                require_once(EE_CLASSES.'EE_Export.class.php');
3332 3332
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3333 3333
                 $EE_Export->report_attendees();
3334 3334
             }
@@ -3355,7 +3355,7 @@  discard block
 block discarded – undo
3355 3355
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3356 3356
         $action = $this->request->getRequestParam('return', 'default');
3357 3357
         // verify we have necessary info
3358
-        if (! $REG_ID) {
3358
+        if ( ! $REG_ID) {
3359 3359
             EE_Error::add_error(
3360 3360
                 esc_html__(
3361 3361
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3370,7 +3370,7 @@  discard block
 block discarded – undo
3370 3370
         }
3371 3371
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3372 3372
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3373
-        if (! $registration instanceof EE_Registration) {
3373
+        if ( ! $registration instanceof EE_Registration) {
3374 3374
             throw new RuntimeException(
3375 3375
                 sprintf(
3376 3376
                     esc_html__(
@@ -3509,16 +3509,16 @@  discard block
 block discarded – undo
3509 3509
         $this->verify_cpt_object();
3510 3510
         remove_meta_box(
3511 3511
             'postexcerpt',
3512
-            $this->_cpt_routes[ $this->_req_action ],
3512
+            $this->_cpt_routes[$this->_req_action],
3513 3513
             'normal'
3514 3514
         );
3515
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3515
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal');
3516 3516
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3517 3517
             add_meta_box(
3518 3518
                 'postexcerpt',
3519 3519
                 esc_html__('Short Biography', 'event_espresso'),
3520 3520
                 'post_excerpt_meta_box',
3521
-                $this->_cpt_routes[ $this->_req_action ],
3521
+                $this->_cpt_routes[$this->_req_action],
3522 3522
                 'normal'
3523 3523
             );
3524 3524
         }
@@ -3527,7 +3527,7 @@  discard block
 block discarded – undo
3527 3527
                 'commentsdiv',
3528 3528
                 esc_html__('Notes on the Contact', 'event_espresso'),
3529 3529
                 'post_comment_meta_box',
3530
-                $this->_cpt_routes[ $this->_req_action ],
3530
+                $this->_cpt_routes[$this->_req_action],
3531 3531
                 'normal',
3532 3532
                 'core'
3533 3533
             );
@@ -3536,7 +3536,7 @@  discard block
 block discarded – undo
3536 3536
             'attendee_contact_info',
3537 3537
             esc_html__('Contact Info', 'event_espresso'),
3538 3538
             [$this, 'attendee_contact_info'],
3539
-            $this->_cpt_routes[ $this->_req_action ],
3539
+            $this->_cpt_routes[$this->_req_action],
3540 3540
             'side',
3541 3541
             'core'
3542 3542
         );
@@ -3544,7 +3544,7 @@  discard block
 block discarded – undo
3544 3544
             'attendee_details_address',
3545 3545
             esc_html__('Address Details', 'event_espresso'),
3546 3546
             [$this, 'attendee_address_details'],
3547
-            $this->_cpt_routes[ $this->_req_action ],
3547
+            $this->_cpt_routes[$this->_req_action],
3548 3548
             'normal',
3549 3549
             'core'
3550 3550
         );
@@ -3552,7 +3552,7 @@  discard block
 block discarded – undo
3552 3552
             'attendee_registrations',
3553 3553
             esc_html__('Registrations for this Contact', 'event_espresso'),
3554 3554
             [$this, 'attendee_registrations_meta_box'],
3555
-            $this->_cpt_routes[ $this->_req_action ],
3555
+            $this->_cpt_routes[$this->_req_action],
3556 3556
             'normal',
3557 3557
             'high'
3558 3558
         );
@@ -3653,8 +3653,8 @@  discard block
 block discarded – undo
3653 3653
                 ]
3654 3654
             )
3655 3655
         );
3656
-        $template                             =
3657
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3656
+        $template =
3657
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3658 3658
         EEH_Template::display_template($template, $this->_template_args);
3659 3659
     }
3660 3660
 
@@ -3676,7 +3676,7 @@  discard block
 block discarded – undo
3676 3676
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3677 3677
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3678 3678
         $template                              =
3679
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3679
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3680 3680
         EEH_Template::display_template($template, $this->_template_args);
3681 3681
     }
3682 3682
 
@@ -3691,7 +3691,7 @@  discard block
 block discarded – undo
3691 3691
     public function after_title_form_fields($post)
3692 3692
     {
3693 3693
         if ($post->post_type === 'espresso_attendees') {
3694
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3694
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3695 3695
             $template_args['attendee'] = $this->_cpt_model_obj;
3696 3696
             EEH_Template::display_template($template, $template_args);
3697 3697
         }
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
             // cycle thru checkboxes
3721 3721
             foreach ($ATT_IDs as $ATT_ID) {
3722 3722
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3723
-                if (! $updated) {
3723
+                if ( ! $updated) {
3724 3724
                     $success = 0;
3725 3725
                 }
3726 3726
             }
Please login to merge, or discard this patch.