Completed
Branch ENHANCE/255/add-wp-version-to-... (cc1324)
by
unknown
17:11 queued 08:42
created
admin_pages/events/Events_Admin_Page.core.php 1 patch
Indentation   +2665 added lines, -2665 removed lines patch added patch discarded remove patch
@@ -12,2669 +12,2669 @@
 block discarded – undo
12 12
 class Events_Admin_Page extends EE_Admin_Page_CPT
13 13
 {
14 14
 
15
-    /**
16
-     * This will hold the event object for event_details screen.
17
-     *
18
-     * @access protected
19
-     * @var EE_Event $_event
20
-     */
21
-    protected $_event;
22
-
23
-
24
-    /**
25
-     * This will hold the category object for category_details screen.
26
-     *
27
-     * @var stdClass $_category
28
-     */
29
-    protected $_category;
30
-
31
-
32
-    /**
33
-     * This will hold the event model instance
34
-     *
35
-     * @var EEM_Event $_event_model
36
-     */
37
-    protected $_event_model;
38
-
39
-
40
-    /**
41
-     * @var EE_Event
42
-     */
43
-    protected $_cpt_model_obj = false;
44
-
45
-
46
-    /**
47
-     * Initialize page props for this admin page group.
48
-     */
49
-    protected function _init_page_props()
50
-    {
51
-        $this->page_slug = EVENTS_PG_SLUG;
52
-        $this->page_label = EVENTS_LABEL;
53
-        $this->_admin_base_url = EVENTS_ADMIN_URL;
54
-        $this->_admin_base_path = EVENTS_ADMIN;
55
-        $this->_cpt_model_names = array(
56
-            'create_new' => 'EEM_Event',
57
-            'edit'       => 'EEM_Event',
58
-        );
59
-        $this->_cpt_edit_routes = array(
60
-            'espresso_events' => 'edit',
61
-        );
62
-        add_action(
63
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
64
-            array($this, 'verify_event_edit'),
65
-            10,
66
-            2
67
-        );
68
-    }
69
-
70
-
71
-    /**
72
-     * Sets the ajax hooks used for this admin page group.
73
-     */
74
-    protected function _ajax_hooks()
75
-    {
76
-        add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting'));
77
-    }
78
-
79
-
80
-    /**
81
-     * Sets the page properties for this admin page group.
82
-     */
83
-    protected function _define_page_props()
84
-    {
85
-        $this->_admin_page_title = EVENTS_LABEL;
86
-        $this->_labels = array(
87
-            'buttons'      => array(
88
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
89
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
90
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
91
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
92
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
93
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
94
-            ),
95
-            'editor_title' => array(
96
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
97
-            ),
98
-            'publishbox'   => array(
99
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
100
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
101
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
102
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
103
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
104
-            ),
105
-        );
106
-    }
107
-
108
-
109
-    /**
110
-     * Sets the page routes property for this admin page group.
111
-     */
112
-    protected function _set_page_routes()
113
-    {
114
-        // load formatter helper
115
-        // load field generator helper
116
-        // is there a evt_id in the request?
117
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
118
-            ? $this->_req_data['EVT_ID']
119
-            : 0;
120
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
121
-        $this->_page_routes = array(
122
-            'default'                       => array(
123
-                'func'       => '_events_overview_list_table',
124
-                'capability' => 'ee_read_events',
125
-            ),
126
-            'create_new'                    => array(
127
-                'func'       => '_create_new_cpt_item',
128
-                'capability' => 'ee_edit_events',
129
-            ),
130
-            'edit'                          => array(
131
-                'func'       => '_edit_cpt_item',
132
-                'capability' => 'ee_edit_event',
133
-                'obj_id'     => $evt_id,
134
-            ),
135
-            'copy_event'                    => array(
136
-                'func'       => '_copy_events',
137
-                'capability' => 'ee_edit_event',
138
-                'obj_id'     => $evt_id,
139
-                'noheader'   => true,
140
-            ),
141
-            'trash_event'                   => array(
142
-                'func'       => '_trash_or_restore_event',
143
-                'args'       => array('event_status' => 'trash'),
144
-                'capability' => 'ee_delete_event',
145
-                'obj_id'     => $evt_id,
146
-                'noheader'   => true,
147
-            ),
148
-            'trash_events'                  => array(
149
-                'func'       => '_trash_or_restore_events',
150
-                'args'       => array('event_status' => 'trash'),
151
-                'capability' => 'ee_delete_events',
152
-                'noheader'   => true,
153
-            ),
154
-            'restore_event'                 => array(
155
-                'func'       => '_trash_or_restore_event',
156
-                'args'       => array('event_status' => 'draft'),
157
-                'capability' => 'ee_delete_event',
158
-                'obj_id'     => $evt_id,
159
-                'noheader'   => true,
160
-            ),
161
-            'restore_events'                => array(
162
-                'func'       => '_trash_or_restore_events',
163
-                'args'       => array('event_status' => 'draft'),
164
-                'capability' => 'ee_delete_events',
165
-                'noheader'   => true,
166
-            ),
167
-            'delete_event'                  => array(
168
-                'func'       => '_delete_event',
169
-                'capability' => 'ee_delete_event',
170
-                'obj_id'     => $evt_id,
171
-                'noheader'   => true,
172
-            ),
173
-            'delete_events'                 => array(
174
-                'func'       => '_delete_events',
175
-                'capability' => 'ee_delete_events',
176
-                'noheader'   => true,
177
-            ),
178
-            'view_report'                   => array(
179
-                'func'      => '_view_report',
180
-                'capablity' => 'ee_edit_events',
181
-            ),
182
-            'default_event_settings'        => array(
183
-                'func'       => '_default_event_settings',
184
-                'capability' => 'manage_options',
185
-            ),
186
-            'update_default_event_settings' => array(
187
-                'func'       => '_update_default_event_settings',
188
-                'capability' => 'manage_options',
189
-                'noheader'   => true,
190
-            ),
191
-            'template_settings'             => array(
192
-                'func'       => '_template_settings',
193
-                'capability' => 'manage_options',
194
-            ),
195
-            // event category tab related
196
-            'add_category'                  => array(
197
-                'func'       => '_category_details',
198
-                'capability' => 'ee_edit_event_category',
199
-                'args'       => array('add'),
200
-            ),
201
-            'edit_category'                 => array(
202
-                'func'       => '_category_details',
203
-                'capability' => 'ee_edit_event_category',
204
-                'args'       => array('edit'),
205
-            ),
206
-            'delete_categories'             => array(
207
-                'func'       => '_delete_categories',
208
-                'capability' => 'ee_delete_event_category',
209
-                'noheader'   => true,
210
-            ),
211
-            'delete_category'               => array(
212
-                'func'       => '_delete_categories',
213
-                'capability' => 'ee_delete_event_category',
214
-                'noheader'   => true,
215
-            ),
216
-            'insert_category'               => array(
217
-                'func'       => '_insert_or_update_category',
218
-                'args'       => array('new_category' => true),
219
-                'capability' => 'ee_edit_event_category',
220
-                'noheader'   => true,
221
-            ),
222
-            'update_category'               => array(
223
-                'func'       => '_insert_or_update_category',
224
-                'args'       => array('new_category' => false),
225
-                'capability' => 'ee_edit_event_category',
226
-                'noheader'   => true,
227
-            ),
228
-            'category_list'                 => array(
229
-                'func'       => '_category_list_table',
230
-                'capability' => 'ee_manage_event_categories',
231
-            ),
232
-        );
233
-    }
234
-
235
-
236
-    /**
237
-     * Set the _page_config property for this admin page group.
238
-     */
239
-    protected function _set_page_config()
240
-    {
241
-        $this->_page_config = array(
242
-            'default'                => array(
243
-                'nav'           => array(
244
-                    'label' => esc_html__('Overview', 'event_espresso'),
245
-                    'order' => 10,
246
-                ),
247
-                'list_table'    => 'Events_Admin_List_Table',
248
-                'help_tabs'     => array(
249
-                    'events_overview_help_tab'                       => array(
250
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
251
-                        'filename' => 'events_overview',
252
-                    ),
253
-                    'events_overview_table_column_headings_help_tab' => array(
254
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
255
-                        'filename' => 'events_overview_table_column_headings',
256
-                    ),
257
-                    'events_overview_filters_help_tab'               => array(
258
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
259
-                        'filename' => 'events_overview_filters',
260
-                    ),
261
-                    'events_overview_view_help_tab'                  => array(
262
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
263
-                        'filename' => 'events_overview_views',
264
-                    ),
265
-                    'events_overview_other_help_tab'                 => array(
266
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
267
-                        'filename' => 'events_overview_other',
268
-                    ),
269
-                ),
270
-                'help_tour'     => array(
271
-                    'Event_Overview_Help_Tour',
272
-                    // 'New_Features_Test_Help_Tour' for testing multiple help tour
273
-                ),
274
-                'qtips'         => array(
275
-                    'EE_Event_List_Table_Tips',
276
-                ),
277
-                'require_nonce' => false,
278
-            ),
279
-            'create_new'             => array(
280
-                'nav'           => array(
281
-                    'label'      => esc_html__('Add Event', 'event_espresso'),
282
-                    'order'      => 5,
283
-                    'persistent' => false,
284
-                ),
285
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
286
-                'help_tabs'     => array(
287
-                    'event_editor_help_tab'                            => array(
288
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
289
-                        'filename' => 'event_editor',
290
-                    ),
291
-                    'event_editor_title_richtexteditor_help_tab'       => array(
292
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
293
-                        'filename' => 'event_editor_title_richtexteditor',
294
-                    ),
295
-                    'event_editor_venue_details_help_tab'              => array(
296
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
297
-                        'filename' => 'event_editor_venue_details',
298
-                    ),
299
-                    'event_editor_event_datetimes_help_tab'            => array(
300
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
301
-                        'filename' => 'event_editor_event_datetimes',
302
-                    ),
303
-                    'event_editor_event_tickets_help_tab'              => array(
304
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
305
-                        'filename' => 'event_editor_event_tickets',
306
-                    ),
307
-                    'event_editor_event_registration_options_help_tab' => array(
308
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
309
-                        'filename' => 'event_editor_event_registration_options',
310
-                    ),
311
-                    'event_editor_tags_categories_help_tab'            => array(
312
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
313
-                        'filename' => 'event_editor_tags_categories',
314
-                    ),
315
-                    'event_editor_questions_registrants_help_tab'      => array(
316
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
317
-                        'filename' => 'event_editor_questions_registrants',
318
-                    ),
319
-                    'event_editor_save_new_event_help_tab'             => array(
320
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
321
-                        'filename' => 'event_editor_save_new_event',
322
-                    ),
323
-                    'event_editor_other_help_tab'                      => array(
324
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
325
-                        'filename' => 'event_editor_other',
326
-                    ),
327
-                ),
328
-                'help_tour'     => array(
329
-                    'Event_Editor_Help_Tour',
330
-                ),
331
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
332
-                'require_nonce' => false,
333
-            ),
334
-            'edit'                   => array(
335
-                'nav'           => array(
336
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
337
-                    'order'      => 5,
338
-                    'persistent' => false,
339
-                    'url'        => isset($this->_req_data['post'])
340
-                        ? EE_Admin_Page::add_query_args_and_nonce(
341
-                            array('post' => $this->_req_data['post'], 'action' => 'edit'),
342
-                            $this->_current_page_view_url
343
-                        )
344
-                        : $this->_admin_base_url,
345
-                ),
346
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
347
-                'help_tabs'     => array(
348
-                    'event_editor_help_tab'                            => array(
349
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
350
-                        'filename' => 'event_editor',
351
-                    ),
352
-                    'event_editor_title_richtexteditor_help_tab'       => array(
353
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
354
-                        'filename' => 'event_editor_title_richtexteditor',
355
-                    ),
356
-                    'event_editor_venue_details_help_tab'              => array(
357
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
358
-                        'filename' => 'event_editor_venue_details',
359
-                    ),
360
-                    'event_editor_event_datetimes_help_tab'            => array(
361
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
362
-                        'filename' => 'event_editor_event_datetimes',
363
-                    ),
364
-                    'event_editor_event_tickets_help_tab'              => array(
365
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
366
-                        'filename' => 'event_editor_event_tickets',
367
-                    ),
368
-                    'event_editor_event_registration_options_help_tab' => array(
369
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
370
-                        'filename' => 'event_editor_event_registration_options',
371
-                    ),
372
-                    'event_editor_tags_categories_help_tab'            => array(
373
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
374
-                        'filename' => 'event_editor_tags_categories',
375
-                    ),
376
-                    'event_editor_questions_registrants_help_tab'      => array(
377
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
378
-                        'filename' => 'event_editor_questions_registrants',
379
-                    ),
380
-                    'event_editor_save_new_event_help_tab'             => array(
381
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
382
-                        'filename' => 'event_editor_save_new_event',
383
-                    ),
384
-                    'event_editor_other_help_tab'                      => array(
385
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
386
-                        'filename' => 'event_editor_other',
387
-                    ),
388
-                ),
389
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
390
-                'require_nonce' => false,
391
-            ),
392
-            'default_event_settings' => array(
393
-                'nav'           => array(
394
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
395
-                    'order' => 40,
396
-                ),
397
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
398
-                'labels'        => array(
399
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
400
-                ),
401
-                'help_tabs'     => array(
402
-                    'default_settings_help_tab'        => array(
403
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
404
-                        'filename' => 'events_default_settings',
405
-                    ),
406
-                    'default_settings_status_help_tab' => array(
407
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
408
-                        'filename' => 'events_default_settings_status',
409
-                    ),
410
-                    'default_maximum_tickets_help_tab' => array(
411
-                        'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
412
-                        'filename' => 'events_default_settings_max_tickets',
413
-                    ),
414
-                ),
415
-                'help_tour'     => array('Event_Default_Settings_Help_Tour'),
416
-                'require_nonce' => false,
417
-            ),
418
-            // template settings
419
-            'template_settings'      => array(
420
-                'nav'           => array(
421
-                    'label' => esc_html__('Templates', 'event_espresso'),
422
-                    'order' => 30,
423
-                ),
424
-                'metaboxes'     => $this->_default_espresso_metaboxes,
425
-                'help_tabs'     => array(
426
-                    'general_settings_templates_help_tab' => array(
427
-                        'title'    => esc_html__('Templates', 'event_espresso'),
428
-                        'filename' => 'general_settings_templates',
429
-                    ),
430
-                ),
431
-                'help_tour'     => array('Templates_Help_Tour'),
432
-                'require_nonce' => false,
433
-            ),
434
-            // event category stuff
435
-            'add_category'           => array(
436
-                'nav'           => array(
437
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
438
-                    'order'      => 15,
439
-                    'persistent' => false,
440
-                ),
441
-                'help_tabs'     => array(
442
-                    'add_category_help_tab' => array(
443
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
444
-                        'filename' => 'events_add_category',
445
-                    ),
446
-                ),
447
-                'help_tour'     => array('Event_Add_Category_Help_Tour'),
448
-                'metaboxes'     => array('_publish_post_box'),
449
-                'require_nonce' => false,
450
-            ),
451
-            'edit_category'          => array(
452
-                'nav'           => array(
453
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
454
-                    'order'      => 15,
455
-                    'persistent' => false,
456
-                    'url'        => isset($this->_req_data['EVT_CAT_ID'])
457
-                        ? add_query_arg(
458
-                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
459
-                            $this->_current_page_view_url
460
-                        )
461
-                        : $this->_admin_base_url,
462
-                ),
463
-                'help_tabs'     => array(
464
-                    'edit_category_help_tab' => array(
465
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
466
-                        'filename' => 'events_edit_category',
467
-                    ),
468
-                ),
469
-                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
470
-                'metaboxes'     => array('_publish_post_box'),
471
-                'require_nonce' => false,
472
-            ),
473
-            'category_list'          => array(
474
-                'nav'           => array(
475
-                    'label' => esc_html__('Categories', 'event_espresso'),
476
-                    'order' => 20,
477
-                ),
478
-                'list_table'    => 'Event_Categories_Admin_List_Table',
479
-                'help_tabs'     => array(
480
-                    'events_categories_help_tab'                       => array(
481
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
482
-                        'filename' => 'events_categories',
483
-                    ),
484
-                    'events_categories_table_column_headings_help_tab' => array(
485
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
486
-                        'filename' => 'events_categories_table_column_headings',
487
-                    ),
488
-                    'events_categories_view_help_tab'                  => array(
489
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
490
-                        'filename' => 'events_categories_views',
491
-                    ),
492
-                    'events_categories_other_help_tab'                 => array(
493
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
494
-                        'filename' => 'events_categories_other',
495
-                    ),
496
-                ),
497
-                'help_tour'     => array(
498
-                    'Event_Categories_Help_Tour',
499
-                ),
500
-                'metaboxes'     => $this->_default_espresso_metaboxes,
501
-                'require_nonce' => false,
502
-            ),
503
-        );
504
-    }
505
-
506
-
507
-    /**
508
-     * Used to register any global screen options if necessary for every route in this admin page group.
509
-     */
510
-    protected function _add_screen_options()
511
-    {
512
-    }
513
-
514
-
515
-    /**
516
-     * Implementing the screen options for the 'default' route.
517
-     */
518
-    protected function _add_screen_options_default()
519
-    {
520
-        $this->_per_page_screen_option();
521
-    }
522
-
523
-
524
-    /**
525
-     * Implementing screen options for the category list route.
526
-     */
527
-    protected function _add_screen_options_category_list()
528
-    {
529
-        $page_title = $this->_admin_page_title;
530
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
531
-        $this->_per_page_screen_option();
532
-        $this->_admin_page_title = $page_title;
533
-    }
534
-
535
-
536
-    /**
537
-     * Used to register any global feature pointers for the admin page group.
538
-     */
539
-    protected function _add_feature_pointers()
540
-    {
541
-    }
542
-
543
-
544
-    /**
545
-     * Registers and enqueues any global scripts and styles for the entire admin page group.
546
-     */
547
-    public function load_scripts_styles()
548
-    {
549
-        wp_register_style(
550
-            'events-admin-css',
551
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
552
-            array(),
553
-            EVENT_ESPRESSO_VERSION
554
-        );
555
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
556
-        wp_enqueue_style('events-admin-css');
557
-        wp_enqueue_style('ee-cat-admin');
558
-        // todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
559
-        // registers for all views
560
-        // scripts
561
-        wp_register_script(
562
-            'event_editor_js',
563
-            EVENTS_ASSETS_URL . 'event_editor.js',
564
-            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
565
-            EVENT_ESPRESSO_VERSION,
566
-            true
567
-        );
568
-    }
569
-
570
-
571
-    /**
572
-     * Enqueuing scripts and styles specific to this view
573
-     */
574
-    public function load_scripts_styles_create_new()
575
-    {
576
-        $this->load_scripts_styles_edit();
577
-    }
578
-
579
-
580
-    /**
581
-     * Enqueuing scripts and styles specific to this view
582
-     */
583
-    public function load_scripts_styles_edit()
584
-    {
585
-        // styles
586
-        wp_enqueue_style('espresso-ui-theme');
587
-        wp_register_style(
588
-            'event-editor-css',
589
-            EVENTS_ASSETS_URL . 'event-editor.css',
590
-            array('ee-admin-css'),
591
-            EVENT_ESPRESSO_VERSION
592
-        );
593
-        wp_enqueue_style('event-editor-css');
594
-        // scripts
595
-        wp_register_script(
596
-            'event-datetime-metabox',
597
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
598
-            array('event_editor_js', 'ee-datepicker'),
599
-            EVENT_ESPRESSO_VERSION
600
-        );
601
-        wp_enqueue_script('event-datetime-metabox');
602
-    }
603
-
604
-
605
-    /**
606
-     * Populating the _views property for the category list table view.
607
-     */
608
-    protected function _set_list_table_views_category_list()
609
-    {
610
-        $this->_views = array(
611
-            'all' => array(
612
-                'slug'        => 'all',
613
-                'label'       => esc_html__('All', 'event_espresso'),
614
-                'count'       => 0,
615
-                'bulk_action' => array(
616
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
617
-                ),
618
-            ),
619
-        );
620
-    }
621
-
622
-
623
-    /**
624
-     * For adding anything that fires on the admin_init hook for any route within this admin page group.
625
-     */
626
-    public function admin_init()
627
-    {
628
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
629
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
630
-            'event_espresso'
631
-        );
632
-    }
633
-
634
-
635
-    /**
636
-     * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
637
-     * group.
638
-     */
639
-    public function admin_notices()
640
-    {
641
-    }
642
-
643
-
644
-    /**
645
-     * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
646
-     * this admin page group.
647
-     */
648
-    public function admin_footer_scripts()
649
-    {
650
-    }
651
-
652
-
653
-    /**
654
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
655
-     * warning (via EE_Error::add_error());
656
-     *
657
-     * @param  EE_Event $event Event object
658
-     * @param string    $req_type
659
-     * @return void
660
-     * @throws EE_Error
661
-     * @access public
662
-     */
663
-    public function verify_event_edit($event = null, $req_type = '')
664
-    {
665
-        // don't need to do this when processing
666
-        if (! empty($req_type)) {
667
-            return;
668
-        }
669
-        // no event?
670
-        if (empty($event)) {
671
-            // set event
672
-            $event = $this->_cpt_model_obj;
673
-        }
674
-        // STILL no event?
675
-        if (! $event instanceof EE_Event) {
676
-            return;
677
-        }
678
-        $orig_status = $event->status();
679
-        // first check if event is active.
680
-        if ($orig_status === EEM_Event::cancelled
681
-            || $orig_status === EEM_Event::postponed
682
-            || $event->is_expired()
683
-            || $event->is_inactive()
684
-        ) {
685
-            return;
686
-        }
687
-        // made it here so it IS active... next check that any of the tickets are sold.
688
-        if ($event->is_sold_out(true)) {
689
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
690
-                EE_Error::add_attention(
691
-                    sprintf(
692
-                        esc_html__(
693
-                            'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
694
-                            'event_espresso'
695
-                        ),
696
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
697
-                    )
698
-                );
699
-            }
700
-            return;
701
-        } elseif ($orig_status === EEM_Event::sold_out) {
702
-            EE_Error::add_attention(
703
-                sprintf(
704
-                    esc_html__(
705
-                        'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
706
-                        'event_espresso'
707
-                    ),
708
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
709
-                )
710
-            );
711
-        }
712
-        // now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
713
-        if (! $event->tickets_on_sale()) {
714
-            return;
715
-        }
716
-        // made it here so show warning
717
-        $this->_edit_event_warning();
718
-    }
719
-
720
-
721
-    /**
722
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
723
-     * When needed, hook this into a EE_Error::add_error() notice.
724
-     *
725
-     * @access protected
726
-     * @return void
727
-     */
728
-    protected function _edit_event_warning()
729
-    {
730
-        // we don't want to add warnings during these requests
731
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
732
-            return;
733
-        }
734
-        EE_Error::add_attention(
735
-            sprintf(
736
-                esc_html__(
737
-                    'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
738
-                    'event_espresso'
739
-                ),
740
-                '<a class="espresso-help-tab-lnk">',
741
-                '</a>'
742
-            )
743
-        );
744
-    }
745
-
746
-
747
-    /**
748
-     * When a user is creating a new event, notify them if they haven't set their timezone.
749
-     * Otherwise, do the normal logic
750
-     *
751
-     * @return string
752
-     * @throws \EE_Error
753
-     */
754
-    protected function _create_new_cpt_item()
755
-    {
756
-        $has_timezone_string = get_option('timezone_string');
757
-        // only nag them about setting their timezone if it's their first event, and they haven't already done it
758
-        if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
759
-            EE_Error::add_attention(
760
-                sprintf(
761
-                    __(
762
-                        'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s',
763
-                        'event_espresso'
764
-                    ),
765
-                    '<br>',
766
-                    '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
767
-                    . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
768
-                    . '</select>',
769
-                    '<button class="button button-secondary timezone-submit">',
770
-                    '</button><span class="spinner"></span>'
771
-                ),
772
-                __FILE__,
773
-                __FUNCTION__,
774
-                __LINE__
775
-            );
776
-        }
777
-        return parent::_create_new_cpt_item();
778
-    }
779
-
780
-
781
-    /**
782
-     * Sets the _views property for the default route in this admin page group.
783
-     */
784
-    protected function _set_list_table_views_default()
785
-    {
786
-        $this->_views = array(
787
-            'all'   => array(
788
-                'slug'        => 'all',
789
-                'label'       => esc_html__('View All Events', 'event_espresso'),
790
-                'count'       => 0,
791
-                'bulk_action' => array(
792
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
793
-                ),
794
-            ),
795
-            'draft' => array(
796
-                'slug'        => 'draft',
797
-                'label'       => esc_html__('Draft', 'event_espresso'),
798
-                'count'       => 0,
799
-                'bulk_action' => array(
800
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
801
-                ),
802
-            ),
803
-        );
804
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
805
-            $this->_views['trash'] = array(
806
-                'slug'        => 'trash',
807
-                'label'       => esc_html__('Trash', 'event_espresso'),
808
-                'count'       => 0,
809
-                'bulk_action' => array(
810
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
811
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
812
-                ),
813
-            );
814
-        }
815
-    }
816
-
817
-
818
-    /**
819
-     * Provides the legend item array for the default list table view.
820
-     *
821
-     * @return array
822
-     */
823
-    protected function _event_legend_items()
824
-    {
825
-        $items = array(
826
-            'view_details'   => array(
827
-                'class' => 'dashicons dashicons-search',
828
-                'desc'  => esc_html__('View Event', 'event_espresso'),
829
-            ),
830
-            'edit_event'     => array(
831
-                'class' => 'ee-icon ee-icon-calendar-edit',
832
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
833
-            ),
834
-            'view_attendees' => array(
835
-                'class' => 'dashicons dashicons-groups',
836
-                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
837
-            ),
838
-        );
839
-        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
840
-        $statuses = array(
841
-            'sold_out_status'  => array(
842
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
843
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
844
-            ),
845
-            'active_status'    => array(
846
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
847
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
848
-            ),
849
-            'upcoming_status'  => array(
850
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
851
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
852
-            ),
853
-            'postponed_status' => array(
854
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
855
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
856
-            ),
857
-            'cancelled_status' => array(
858
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
859
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
860
-            ),
861
-            'expired_status'   => array(
862
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
863
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
864
-            ),
865
-            'inactive_status'  => array(
866
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
867
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
868
-            ),
869
-        );
870
-        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
871
-        return array_merge($items, $statuses);
872
-    }
873
-
874
-
875
-    /**
876
-     * @return EEM_Event
877
-     */
878
-    private function _event_model()
879
-    {
880
-        if (! $this->_event_model instanceof EEM_Event) {
881
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
882
-        }
883
-        return $this->_event_model;
884
-    }
885
-
886
-
887
-    /**
888
-     * Adds extra buttons to the WP CPT permalink field row.
889
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
890
-     *
891
-     * @param  string $return    the current html
892
-     * @param  int    $id        the post id for the page
893
-     * @param  string $new_title What the title is
894
-     * @param  string $new_slug  what the slug is
895
-     * @return string            The new html string for the permalink area
896
-     */
897
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
898
-    {
899
-        // make sure this is only when editing
900
-        if (! empty($id)) {
901
-            $post = get_post($id);
902
-            $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
903
-                       . esc_html__('Shortcode', 'event_espresso')
904
-                       . '</a> ';
905
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
906
-                       . $post->ID
907
-                       . ']">';
908
-        }
909
-        return $return;
910
-    }
911
-
912
-
913
-    /**
914
-     * _events_overview_list_table
915
-     * This contains the logic for showing the events_overview list
916
-     *
917
-     * @access protected
918
-     * @return void
919
-     * @throws \EE_Error
920
-     */
921
-    protected function _events_overview_list_table()
922
-    {
923
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
924
-        $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
925
-            ? (array) $this->_template_args['after_list_table']
926
-            : array();
927
-        $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
928
-                . EEH_Template::get_button_or_link(
929
-                    get_post_type_archive_link('espresso_events'),
930
-                    esc_html__("View Event Archive Page", "event_espresso"),
931
-                    'button'
932
-                );
933
-        $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
934
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
935
-            'create_new',
936
-            'add',
937
-            array(),
938
-            'add-new-h2'
939
-        );
940
-        $this->display_admin_list_table_page_with_no_sidebar();
941
-    }
942
-
943
-
944
-    /**
945
-     * this allows for extra misc actions in the default WP publish box
946
-     *
947
-     * @return void
948
-     */
949
-    public function extra_misc_actions_publish_box()
950
-    {
951
-        $this->_generate_publish_box_extra_content();
952
-    }
953
-
954
-
955
-    /**
956
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
957
-     * saved.
958
-     * Typically you would use this to save any additional data.
959
-     * Keep in mind also that "save_post" runs on EVERY post update to the database.
960
-     * ALSO very important.  When a post transitions from scheduled to published,
961
-     * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from
962
-     * other meta saves. So MAKE sure that you handle this accordingly.
963
-     *
964
-     * @access protected
965
-     * @abstract
966
-     * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
967
-     * @param  object $post    The post object of the cpt that was saved.
968
-     * @return void
969
-     * @throws \EE_Error
970
-     */
971
-    protected function _insert_update_cpt_item($post_id, $post)
972
-    {
973
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
974
-            // get out we're not processing an event save.
975
-            return;
976
-        }
977
-        $event_values = array(
978
-            'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
979
-            'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
980
-            'EVT_additional_limit'            => min(
981
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
982
-                ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
983
-            ),
984
-            'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
985
-                ? $this->_req_data['EVT_default_registration_status']
986
-                : EE_Registry::instance()->CFG->registration->default_STS_ID,
987
-            'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
988
-            'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
989
-            'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
990
-                ? $this->_req_data['timezone_string'] : null,
991
-            'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
992
-                ? $this->_req_data['externalURL'] : null,
993
-            'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
994
-                ? $this->_req_data['event_phone'] : null,
995
-        );
996
-        // update event
997
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
998
-        // get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
999
-        $get_one_where = array(
1000
-            $this->_event_model()->primary_key_name() => $post_id,
1001
-            'OR'                                      => array(
1002
-                'status'   => $post->post_status,
1003
-                // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1004
-                // but the returned object here has a status of "publish", so use the original post status as well
1005
-                'status*1' => $this->_req_data['original_post_status'],
1006
-            ),
1007
-        );
1008
-        $event = $this->_event_model()->get_one(array($get_one_where));
1009
-        // the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
1010
-        $event_update_callbacks = apply_filters(
1011
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1012
-            array(
1013
-                array($this, '_default_venue_update'),
1014
-                array($this, '_default_tickets_update'),
1015
-            )
1016
-        );
1017
-        $att_success = true;
1018
-        foreach ($event_update_callbacks as $e_callback) {
1019
-            $_success = is_callable($e_callback)
1020
-                ? call_user_func($e_callback, $event, $this->_req_data)
1021
-                : false;
1022
-            // if ANY of these updates fail then we want the appropriate global error message
1023
-            $att_success = ! $att_success ? $att_success : $_success;
1024
-        }
1025
-        // any errors?
1026
-        if ($success && false === $att_success) {
1027
-            EE_Error::add_error(
1028
-                esc_html__(
1029
-                    'Event Details saved successfully but something went wrong with saving attachments.',
1030
-                    'event_espresso'
1031
-                ),
1032
-                __FILE__,
1033
-                __FUNCTION__,
1034
-                __LINE__
1035
-            );
1036
-        } elseif ($success === false) {
1037
-            EE_Error::add_error(
1038
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
1039
-                __FILE__,
1040
-                __FUNCTION__,
1041
-                __LINE__
1042
-            );
1043
-        }
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     * @see parent::restore_item()
1049
-     * @param int $post_id
1050
-     * @param int $revision_id
1051
-     */
1052
-    protected function _restore_cpt_item($post_id, $revision_id)
1053
-    {
1054
-        // copy existing event meta to new post
1055
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1056
-        if ($post_evt instanceof EE_Event) {
1057
-            // meta revision restore
1058
-            $post_evt->restore_revision($revision_id);
1059
-            // related objs restore
1060
-            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1061
-        }
1062
-    }
1063
-
1064
-
1065
-    /**
1066
-     * Attach the venue to the Event
1067
-     *
1068
-     * @param  \EE_Event $evtobj Event Object to add the venue to
1069
-     * @param  array     $data   The request data from the form
1070
-     * @return bool           Success or fail.
1071
-     */
1072
-    protected function _default_venue_update(\EE_Event $evtobj, $data)
1073
-    {
1074
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1075
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1076
-        $rows_affected = null;
1077
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1078
-        // very important.  If we don't have a venue name...
1079
-        // then we'll get out because not necessary to create empty venue
1080
-        if (empty($data['venue_title'])) {
1081
-            return false;
1082
-        }
1083
-        $venue_array = array(
1084
-            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1085
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1086
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1087
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1088
-            'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1089
-                : null,
1090
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1091
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1092
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1093
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1094
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1095
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1096
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1097
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1098
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1099
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1100
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1101
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1102
-            'status'              => 'publish',
1103
-        );
1104
-        // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1105
-        if (! empty($venue_id)) {
1106
-            $update_where = array($venue_model->primary_key_name() => $venue_id);
1107
-            $rows_affected = $venue_model->update($venue_array, array($update_where));
1108
-            // we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1109
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1110
-            return $rows_affected > 0 ? true : false;
1111
-        } else {
1112
-            // we insert the venue
1113
-            $venue_id = $venue_model->insert($venue_array);
1114
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1115
-            return ! empty($venue_id) ? true : false;
1116
-        }
1117
-        // when we have the ancestor come in it's already been handled by the revision save.
1118
-    }
1119
-
1120
-
1121
-    /**
1122
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1123
-     *
1124
-     * @param  EE_Event $evtobj The Event object we're attaching data to
1125
-     * @param  array    $data   The request data from the form
1126
-     * @return array
1127
-     */
1128
-    protected function _default_tickets_update(EE_Event $evtobj, $data)
1129
-    {
1130
-        $success = true;
1131
-        $saved_dtt = null;
1132
-        $saved_tickets = array();
1133
-        $incoming_date_formats = array('Y-m-d', 'h:i a');
1134
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1135
-            // trim all values to ensure any excess whitespace is removed.
1136
-            $dtt = array_map('trim', $dtt);
1137
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1138
-                : $dtt['DTT_EVT_start'];
1139
-            $datetime_values = array(
1140
-                'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1141
-                'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1142
-                'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1143
-                'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1144
-                'DTT_order'     => $row,
1145
-            );
1146
-            // if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1147
-            if (! empty($dtt['DTT_ID'])) {
1148
-                $DTM = EE_Registry::instance()
1149
-                                  ->load_model('Datetime', array($evtobj->get_timezone()))
1150
-                                  ->get_one_by_ID($dtt['DTT_ID']);
1151
-                $DTM->set_date_format($incoming_date_formats[0]);
1152
-                $DTM->set_time_format($incoming_date_formats[1]);
1153
-                foreach ($datetime_values as $field => $value) {
1154
-                    $DTM->set($field, $value);
1155
-                }
1156
-                // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1157
-                $saved_dtts[ $DTM->ID() ] = $DTM;
1158
-            } else {
1159
-                $DTM = EE_Registry::instance()->load_class(
1160
-                    'Datetime',
1161
-                    array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1162
-                    false,
1163
-                    false
1164
-                );
1165
-                foreach ($datetime_values as $field => $value) {
1166
-                    $DTM->set($field, $value);
1167
-                }
1168
-            }
1169
-            $DTM->save();
1170
-            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1171
-            // load DTT helper
1172
-            // before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1173
-            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1174
-                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1175
-                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1176
-                $DTT->save();
1177
-            }
1178
-            // now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1179
-            $saved_dtt = $DTT;
1180
-            $success = ! $success ? $success : $DTT;
1181
-            // if ANY of these updates fail then we want the appropriate global error message.
1182
-            // //todo this is actually sucky we need a better error message but this is what it is for now.
1183
-        }
1184
-        // no dtts get deleted so we don't do any of that logic here.
1185
-        // update tickets next
1186
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1187
-        foreach ($data['edit_tickets'] as $row => $tkt) {
1188
-            $incoming_date_formats = array('Y-m-d', 'h:i a');
1189
-            $update_prices = false;
1190
-            $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1191
-                ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1192
-            // trim inputs to ensure any excess whitespace is removed.
1193
-            $tkt = array_map('trim', $tkt);
1194
-            if (empty($tkt['TKT_start_date'])) {
1195
-                // let's use now in the set timezone.
1196
-                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1197
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1198
-            }
1199
-            if (empty($tkt['TKT_end_date'])) {
1200
-                // use the start date of the first datetime
1201
-                $dtt = $evtobj->first_datetime();
1202
-                $tkt['TKT_end_date'] = $dtt->start_date_and_time(
1203
-                    $incoming_date_formats[0],
1204
-                    $incoming_date_formats[1]
1205
-                );
1206
-            }
1207
-            $TKT_values = array(
1208
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1209
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1210
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1211
-                'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1212
-                'TKT_start_date'  => $tkt['TKT_start_date'],
1213
-                'TKT_end_date'    => $tkt['TKT_end_date'],
1214
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1215
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1216
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1217
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1218
-                'TKT_row'         => $row,
1219
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1220
-                'TKT_price'       => $ticket_price,
1221
-            );
1222
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1223
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1224
-                $TKT_values['TKT_ID'] = 0;
1225
-                $TKT_values['TKT_is_default'] = 0;
1226
-                $TKT_values['TKT_price'] = $ticket_price;
1227
-                $update_prices = true;
1228
-            }
1229
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
1230
-            // we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1231
-            // keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1232
-            if (! empty($tkt['TKT_ID'])) {
1233
-                $TKT = EE_Registry::instance()
1234
-                                  ->load_model('Ticket', array($evtobj->get_timezone()))
1235
-                                  ->get_one_by_ID($tkt['TKT_ID']);
1236
-                if ($TKT instanceof EE_Ticket) {
1237
-                    $ticket_sold = $TKT->count_related(
1238
-                        'Registration',
1239
-                        array(
1240
-                            array(
1241
-                                'STS_ID' => array(
1242
-                                    'NOT IN',
1243
-                                    array(EEM_Registration::status_id_incomplete),
1244
-                                ),
1245
-                            ),
1246
-                        )
1247
-                    ) > 0 ? true : false;
1248
-                    // let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1249
-                    $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1250
-                                      && ! $TKT->get('TKT_deleted');
1251
-                    $TKT->set_date_format($incoming_date_formats[0]);
1252
-                    $TKT->set_time_format($incoming_date_formats[1]);
1253
-                    // set new values
1254
-                    foreach ($TKT_values as $field => $value) {
1255
-                        if ($field == 'TKT_qty') {
1256
-                            $TKT->set_qty($value);
1257
-                        } else {
1258
-                            $TKT->set($field, $value);
1259
-                        }
1260
-                    }
1261
-                    // if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1262
-                    if ($create_new_TKT) {
1263
-                        // archive the old ticket first
1264
-                        $TKT->set('TKT_deleted', 1);
1265
-                        $TKT->save();
1266
-                        // make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1267
-                        $saved_tickets[ $TKT->ID() ] = $TKT;
1268
-                        // create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1269
-                        $TKT = clone $TKT;
1270
-                        $TKT->set('TKT_ID', 0);
1271
-                        $TKT->set('TKT_deleted', 0);
1272
-                        $TKT->set('TKT_price', $ticket_price);
1273
-                        $TKT->set('TKT_sold', 0);
1274
-                        // now we need to make sure that $new prices are created as well and attached to new ticket.
1275
-                        $update_prices = true;
1276
-                    }
1277
-                    // make sure price is set if it hasn't been already
1278
-                    $TKT->set('TKT_price', $ticket_price);
1279
-                }
1280
-            } else {
1281
-                // no TKT_id so a new TKT
1282
-                $TKT_values['TKT_price'] = $ticket_price;
1283
-                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1284
-                if ($TKT instanceof EE_Ticket) {
1285
-                    // need to reset values to properly account for the date formats
1286
-                    $TKT->set_date_format($incoming_date_formats[0]);
1287
-                    $TKT->set_time_format($incoming_date_formats[1]);
1288
-                    $TKT->set_timezone($evtobj->get_timezone());
1289
-                    // set new values
1290
-                    foreach ($TKT_values as $field => $value) {
1291
-                        if ($field == 'TKT_qty') {
1292
-                            $TKT->set_qty($value);
1293
-                        } else {
1294
-                            $TKT->set($field, $value);
1295
-                        }
1296
-                    }
1297
-                    $update_prices = true;
1298
-                }
1299
-            }
1300
-            // cap ticket qty by datetime reg limits
1301
-            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1302
-            // update ticket.
1303
-            $TKT->save();
1304
-            // before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1305
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1306
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1307
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1308
-                $TKT->save();
1309
-            }
1310
-            // initially let's add the ticket to the dtt
1311
-            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1312
-            $saved_tickets[ $TKT->ID() ] = $TKT;
1313
-            // add prices to ticket
1314
-            $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1315
-        }
1316
-        // however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1317
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1318
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1319
-        foreach ($tickets_removed as $id) {
1320
-            $id = absint($id);
1321
-            // get the ticket for this id
1322
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1323
-            // need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1324
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
1325
-            foreach ($dtts as $dtt) {
1326
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1327
-            }
1328
-            // need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1329
-            $tkt_to_remove->delete_related_permanently('Price');
1330
-            // finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1331
-            $tkt_to_remove->delete_permanently();
1332
-        }
1333
-        return array($saved_dtt, $saved_tickets);
1334
-    }
1335
-
1336
-
1337
-    /**
1338
-     * This attaches a list of given prices to a ticket.
1339
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1340
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1341
-     * price info and prices are automatically "archived" via the ticket.
1342
-     *
1343
-     * @access  private
1344
-     * @param array     $prices     Array of prices from the form.
1345
-     * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1346
-     * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1347
-     * @return  void
1348
-     */
1349
-    private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1350
-    {
1351
-        foreach ($prices as $row => $prc) {
1352
-            $PRC_values = array(
1353
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1354
-                'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1355
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1356
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1357
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1358
-                'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1359
-                'PRC_order'      => $row,
1360
-            );
1361
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
1362
-                $PRC_values['PRC_ID'] = 0;
1363
-                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1364
-            } else {
1365
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1366
-                // update this price with new values
1367
-                foreach ($PRC_values as $field => $newprc) {
1368
-                    $PRC->set($field, $newprc);
1369
-                }
1370
-                $PRC->save();
1371
-            }
1372
-            $ticket->_add_relation_to($PRC, 'Price');
1373
-        }
1374
-    }
1375
-
1376
-
1377
-    /**
1378
-     * Add in our autosave ajax handlers
1379
-     *
1380
-     */
1381
-    protected function _ee_autosave_create_new()
1382
-    {
1383
-    }
1384
-
1385
-
1386
-    /**
1387
-     * More autosave handlers.
1388
-     */
1389
-    protected function _ee_autosave_edit()
1390
-    {
1391
-        return; // TEMPORARILY EXITING CAUSE THIS IS A TODO
1392
-    }
1393
-
1394
-
1395
-    /**
1396
-     *    _generate_publish_box_extra_content
1397
-     */
1398
-    private function _generate_publish_box_extra_content()
1399
-    {
1400
-        // load formatter helper
1401
-        // args for getting related registrations
1402
-        $approved_query_args = array(
1403
-            array(
1404
-                'REG_deleted' => 0,
1405
-                'STS_ID'      => EEM_Registration::status_id_approved,
1406
-            ),
1407
-        );
1408
-        $not_approved_query_args = array(
1409
-            array(
1410
-                'REG_deleted' => 0,
1411
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1412
-            ),
1413
-        );
1414
-        $pending_payment_query_args = array(
1415
-            array(
1416
-                'REG_deleted' => 0,
1417
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1418
-            ),
1419
-        );
1420
-        // publish box
1421
-        $publish_box_extra_args = array(
1422
-            'view_approved_reg_url'        => add_query_arg(
1423
-                array(
1424
-                    'action'      => 'default',
1425
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1426
-                    '_reg_status' => EEM_Registration::status_id_approved,
1427
-                ),
1428
-                REG_ADMIN_URL
1429
-            ),
1430
-            'view_not_approved_reg_url'    => add_query_arg(
1431
-                array(
1432
-                    'action'      => 'default',
1433
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1434
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1435
-                ),
1436
-                REG_ADMIN_URL
1437
-            ),
1438
-            'view_pending_payment_reg_url' => add_query_arg(
1439
-                array(
1440
-                    'action'      => 'default',
1441
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1442
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1443
-                ),
1444
-                REG_ADMIN_URL
1445
-            ),
1446
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1447
-                'Registration',
1448
-                $approved_query_args
1449
-            ),
1450
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1451
-                'Registration',
1452
-                $not_approved_query_args
1453
-            ),
1454
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1455
-                'Registration',
1456
-                $pending_payment_query_args
1457
-            ),
1458
-            'misc_pub_section_class'       => apply_filters(
1459
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1460
-                'misc-pub-section'
1461
-            ),
1462
-        );
1463
-        ob_start();
1464
-        do_action(
1465
-            'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1466
-            $this->_cpt_model_obj
1467
-        );
1468
-        $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1469
-        // load template
1470
-        EEH_Template::display_template(
1471
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1472
-            $publish_box_extra_args
1473
-        );
1474
-    }
1475
-
1476
-
1477
-    /**
1478
-     * @return EE_Event
1479
-     */
1480
-    public function get_event_object()
1481
-    {
1482
-        return $this->_cpt_model_obj;
1483
-    }
1484
-
1485
-
1486
-
1487
-
1488
-    /** METABOXES * */
1489
-    /**
1490
-     * _register_event_editor_meta_boxes
1491
-     * add all metaboxes related to the event_editor
1492
-     *
1493
-     * @return void
1494
-     */
1495
-    protected function _register_event_editor_meta_boxes()
1496
-    {
1497
-        $this->verify_cpt_object();
1498
-        add_meta_box(
1499
-            'espresso_event_editor_tickets',
1500
-            esc_html__('Event Datetime & Ticket', 'event_espresso'),
1501
-            array($this, 'ticket_metabox'),
1502
-            $this->page_slug,
1503
-            'normal',
1504
-            'high'
1505
-        );
1506
-        add_meta_box(
1507
-            'espresso_event_editor_event_options',
1508
-            esc_html__('Event Registration Options', 'event_espresso'),
1509
-            array($this, 'registration_options_meta_box'),
1510
-            $this->page_slug,
1511
-            'side',
1512
-            'default'
1513
-        );
1514
-        // NOTE: if you're looking for other metaboxes in here,
1515
-        // where a metabox has a related management page in the admin
1516
-        // you will find it setup in the related management page's "_Hooks" file.
1517
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1518
-    }
1519
-
1520
-
1521
-    /**
1522
-     * @throws DomainException
1523
-     * @throws EE_Error
1524
-     */
1525
-    public function ticket_metabox()
1526
-    {
1527
-        $existing_datetime_ids = $existing_ticket_ids = array();
1528
-        // defaults for template args
1529
-        $template_args = array(
1530
-            'existing_datetime_ids'    => '',
1531
-            'event_datetime_help_link' => '',
1532
-            'ticket_options_help_link' => '',
1533
-            'time'                     => null,
1534
-            'ticket_rows'              => '',
1535
-            'existing_ticket_ids'      => '',
1536
-            'total_ticket_rows'        => 1,
1537
-            'ticket_js_structure'      => '',
1538
-            'trash_icon'               => 'ee-lock-icon',
1539
-            'disabled'                 => '',
1540
-        );
1541
-        $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1542
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1543
-        /**
1544
-         * 1. Start with retrieving Datetimes
1545
-         * 2. Fore each datetime get related tickets
1546
-         * 3. For each ticket get related prices
1547
-         */
1548
-        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1549
-        /** @type EE_Datetime $first_datetime */
1550
-        $first_datetime = reset($times);
1551
-        // do we get related tickets?
1552
-        if ($first_datetime instanceof EE_Datetime
1553
-            && $first_datetime->ID() !== 0
1554
-        ) {
1555
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1556
-            $template_args['time'] = $first_datetime;
1557
-            $related_tickets = $first_datetime->tickets(
1558
-                array(
1559
-                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1560
-                    'default_where_conditions' => 'none',
1561
-                )
1562
-            );
1563
-            if (! empty($related_tickets)) {
1564
-                $template_args['total_ticket_rows'] = count($related_tickets);
1565
-                $row = 0;
1566
-                foreach ($related_tickets as $ticket) {
1567
-                    $existing_ticket_ids[] = $ticket->get('TKT_ID');
1568
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1569
-                    $row++;
1570
-                }
1571
-            } else {
1572
-                $template_args['total_ticket_rows'] = 1;
1573
-                /** @type EE_Ticket $ticket */
1574
-                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1575
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1576
-            }
1577
-        } else {
1578
-            $template_args['time'] = $times[0];
1579
-            /** @type EE_Ticket $ticket */
1580
-            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1581
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1582
-            // NOTE: we're just sending the first default row
1583
-            // (decaf can't manage default tickets so this should be sufficient);
1584
-        }
1585
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1586
-            'event_editor_event_datetimes_help_tab'
1587
-        );
1588
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1589
-        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1590
-        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1591
-        $template_args['ticket_js_structure'] = $this->_get_ticket_row(
1592
-            EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1593
-            true
1594
-        );
1595
-        $template = apply_filters(
1596
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1597
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1598
-        );
1599
-        EEH_Template::display_template($template, $template_args);
1600
-    }
1601
-
1602
-
1603
-    /**
1604
-     * Setup an individual ticket form for the decaf event editor page
1605
-     *
1606
-     * @access private
1607
-     * @param  EE_Ticket $ticket   the ticket object
1608
-     * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1609
-     * @param int        $row
1610
-     * @return string generated html for the ticket row.
1611
-     */
1612
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1613
-    {
1614
-        $template_args = array(
1615
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1616
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1617
-                : '',
1618
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1619
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1620
-            'TKT_name'            => $ticket->get('TKT_name'),
1621
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1622
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1623
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1624
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1625
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1626
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1627
-            'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1628
-                                     && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1629
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1630
-            'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1631
-                : ' disabled=disabled',
1632
-        );
1633
-        $price = $ticket->ID() !== 0
1634
-            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1635
-            : EE_Registry::instance()->load_model('Price')->create_default_object();
1636
-        $price_args = array(
1637
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1638
-            'PRC_amount'            => $price->get('PRC_amount'),
1639
-            'PRT_ID'                => $price->get('PRT_ID'),
1640
-            'PRC_ID'                => $price->get('PRC_ID'),
1641
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1642
-        );
1643
-        // make sure we have default start and end dates if skeleton
1644
-        // handle rows that should NOT be empty
1645
-        if (empty($template_args['TKT_start_date'])) {
1646
-            // if empty then the start date will be now.
1647
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1648
-        }
1649
-        if (empty($template_args['TKT_end_date'])) {
1650
-            // get the earliest datetime (if present);
1651
-            $earliest_dtt = $this->_cpt_model_obj->ID() > 0
1652
-                ? $this->_cpt_model_obj->get_first_related(
1653
-                    'Datetime',
1654
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1655
-                )
1656
-                : null;
1657
-            if (! empty($earliest_dtt)) {
1658
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1659
-            } else {
1660
-                $template_args['TKT_end_date'] = date(
1661
-                    'Y-m-d h:i a',
1662
-                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1663
-                );
1664
-            }
1665
-        }
1666
-        $template_args = array_merge($template_args, $price_args);
1667
-        $template = apply_filters(
1668
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1669
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1670
-            $ticket
1671
-        );
1672
-        return EEH_Template::display_template($template, $template_args, true);
1673
-    }
1674
-
1675
-
1676
-    /**
1677
-     * @throws DomainException
1678
-     */
1679
-    public function registration_options_meta_box()
1680
-    {
1681
-        $yes_no_values = array(
1682
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1683
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1684
-        );
1685
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1686
-            array(
1687
-                EEM_Registration::status_id_cancelled,
1688
-                EEM_Registration::status_id_declined,
1689
-                EEM_Registration::status_id_incomplete,
1690
-            ),
1691
-            true
1692
-        );
1693
-        // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1694
-        $template_args['_event'] = $this->_cpt_model_obj;
1695
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1696
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1697
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1698
-            'default_reg_status',
1699
-            $default_reg_status_values,
1700
-            $this->_cpt_model_obj->default_registration_status()
1701
-        );
1702
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
1703
-            'display_desc',
1704
-            $yes_no_values,
1705
-            $this->_cpt_model_obj->display_description()
1706
-        );
1707
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1708
-            'display_ticket_selector',
1709
-            $yes_no_values,
1710
-            $this->_cpt_model_obj->display_ticket_selector(),
1711
-            '',
1712
-            '',
1713
-            false
1714
-        );
1715
-        $template_args['additional_registration_options'] = apply_filters(
1716
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1717
-            '',
1718
-            $template_args,
1719
-            $yes_no_values,
1720
-            $default_reg_status_values
1721
-        );
1722
-        EEH_Template::display_template(
1723
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1724
-            $template_args
1725
-        );
1726
-    }
1727
-
1728
-
1729
-    /**
1730
-     * _get_events()
1731
-     * This method simply returns all the events (for the given _view and paging)
1732
-     *
1733
-     * @access public
1734
-     * @param int  $per_page     count of items per page (20 default);
1735
-     * @param int  $current_page what is the current page being viewed.
1736
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1737
-     *                           If FALSE then we return an array of event objects
1738
-     *                           that match the given _view and paging parameters.
1739
-     * @return array an array of event objects.
1740
-     */
1741
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1742
-    {
1743
-        $EEME = $this->_event_model();
1744
-        $offset = ($current_page - 1) * $per_page;
1745
-        $limit = $count ? null : $offset . ',' . $per_page;
1746
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1747
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1748
-        if (isset($this->_req_data['month_range'])) {
1749
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1750
-            // simulate the FIRST day of the month, that fixes issues for months like February
1751
-            // where PHP doesn't know what to assume for date.
1752
-            // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1753
-            $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1754
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1755
-        }
1756
-        $where = array();
1757
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1758
-        // determine what post_status our condition will have for the query.
1759
-        switch ($status) {
1760
-            case 'month':
1761
-            case 'today':
1762
-            case null:
1763
-            case 'all':
1764
-                break;
1765
-            case 'draft':
1766
-                $where['status'] = array('IN', array('draft', 'auto-draft'));
1767
-                break;
1768
-            default:
1769
-                $where['status'] = $status;
1770
-        }
1771
-        // categories?
1772
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1773
-            ? $this->_req_data['EVT_CAT'] : null;
1774
-        if (! empty($category)) {
1775
-            $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1776
-            $where['Term_Taxonomy.term_id'] = $category;
1777
-        }
1778
-        // date where conditions
1779
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1780
-        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1781
-            $DateTime = new DateTime(
1782
-                $year_r . '-' . $month_r . '-01 00:00:00',
1783
-                new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1784
-            );
1785
-            $start = $DateTime->format(implode(' ', $start_formats));
1786
-            $end = $DateTime->setDate(
1787
-                $year_r,
1788
-                $month_r,
1789
-                $DateTime
1790
-                    ->format('t')
1791
-            )->setTime(23, 59, 59)
1792
-                            ->format(implode(' ', $start_formats));
1793
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1794
-        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1795
-            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1796
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1797
-            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1798
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1799
-        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1800
-            $now = date('Y-m-01');
1801
-            $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1802
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1803
-            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1804
-                            ->setTime(23, 59, 59)
1805
-                            ->format(implode(' ', $start_formats));
1806
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1807
-        }
1808
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1809
-            $where['EVT_wp_user'] = get_current_user_id();
1810
-        } else {
1811
-            if (! isset($where['status'])) {
1812
-                if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1813
-                    $where['OR'] = array(
1814
-                        'status*restrict_private' => array('!=', 'private'),
1815
-                        'AND'                     => array(
1816
-                            'status*inclusive' => array('=', 'private'),
1817
-                            'EVT_wp_user'      => get_current_user_id(),
1818
-                        ),
1819
-                    );
1820
-                }
1821
-            }
1822
-        }
1823
-        if (isset($this->_req_data['EVT_wp_user'])) {
1824
-            if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1825
-                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1826
-            ) {
1827
-                $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1828
-            }
1829
-        }
1830
-        // search query handling
1831
-        if (isset($this->_req_data['s'])) {
1832
-            $search_string = '%' . $this->_req_data['s'] . '%';
1833
-            $where['OR'] = array(
1834
-                'EVT_name'       => array('LIKE', $search_string),
1835
-                'EVT_desc'       => array('LIKE', $search_string),
1836
-                'EVT_short_desc' => array('LIKE', $search_string),
1837
-            );
1838
-        }
1839
-        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1840
-        $query_params = apply_filters(
1841
-            'FHEE__Events_Admin_Page__get_events__query_params',
1842
-            array(
1843
-                $where,
1844
-                'limit'    => $limit,
1845
-                'order_by' => $orderby,
1846
-                'order'    => $order,
1847
-                'group_by' => 'EVT_ID',
1848
-            ),
1849
-            $this->_req_data
1850
-        );
1851
-        // let's first check if we have special requests coming in.
1852
-        if (isset($this->_req_data['active_status'])) {
1853
-            switch ($this->_req_data['active_status']) {
1854
-                case 'upcoming':
1855
-                    return $EEME->get_upcoming_events($query_params, $count);
1856
-                    break;
1857
-                case 'expired':
1858
-                    return $EEME->get_expired_events($query_params, $count);
1859
-                    break;
1860
-                case 'active':
1861
-                    return $EEME->get_active_events($query_params, $count);
1862
-                    break;
1863
-                case 'inactive':
1864
-                    return $EEME->get_inactive_events($query_params, $count);
1865
-                    break;
1866
-            }
1867
-        }
1868
-        $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1869
-        return $events;
1870
-    }
1871
-
1872
-
1873
-    /**
1874
-     * handling for WordPress CPT actions (trash, restore, delete)
1875
-     *
1876
-     * @param string $post_id
1877
-     */
1878
-    public function trash_cpt_item($post_id)
1879
-    {
1880
-        $this->_req_data['EVT_ID'] = $post_id;
1881
-        $this->_trash_or_restore_event('trash', false);
1882
-    }
1883
-
1884
-
1885
-    /**
1886
-     * @param string $post_id
1887
-     */
1888
-    public function restore_cpt_item($post_id)
1889
-    {
1890
-        $this->_req_data['EVT_ID'] = $post_id;
1891
-        $this->_trash_or_restore_event('draft', false);
1892
-    }
1893
-
1894
-
1895
-    /**
1896
-     * @param string $post_id
1897
-     */
1898
-    public function delete_cpt_item($post_id)
1899
-    {
1900
-        $this->_req_data['EVT_ID'] = $post_id;
1901
-        $this->_delete_event(false);
1902
-    }
1903
-
1904
-
1905
-    /**
1906
-     * _trash_or_restore_event
1907
-     *
1908
-     * @access protected
1909
-     * @param  string $event_status
1910
-     * @param bool    $redirect_after
1911
-     */
1912
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1913
-    {
1914
-        // determine the event id and set to array.
1915
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1916
-        // loop thru events
1917
-        if ($EVT_ID) {
1918
-            // clean status
1919
-            $event_status = sanitize_key($event_status);
1920
-            // grab status
1921
-            if (! empty($event_status)) {
1922
-                $success = $this->_change_event_status($EVT_ID, $event_status);
1923
-            } else {
1924
-                $success = false;
1925
-                $msg = esc_html__(
1926
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1927
-                    'event_espresso'
1928
-                );
1929
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1930
-            }
1931
-        } else {
1932
-            $success = false;
1933
-            $msg = esc_html__(
1934
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1935
-                'event_espresso'
1936
-            );
1937
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1938
-        }
1939
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1940
-        if ($redirect_after) {
1941
-            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1942
-        }
1943
-    }
1944
-
1945
-
1946
-    /**
1947
-     * _trash_or_restore_events
1948
-     *
1949
-     * @access protected
1950
-     * @param  string $event_status
1951
-     * @return void
1952
-     */
1953
-    protected function _trash_or_restore_events($event_status = 'trash')
1954
-    {
1955
-        // clean status
1956
-        $event_status = sanitize_key($event_status);
1957
-        // grab status
1958
-        if (! empty($event_status)) {
1959
-            $success = true;
1960
-            // determine the event id and set to array.
1961
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1962
-            // loop thru events
1963
-            foreach ($EVT_IDs as $EVT_ID) {
1964
-                if ($EVT_ID = absint($EVT_ID)) {
1965
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
1966
-                    $success = $results !== false ? $success : false;
1967
-                } else {
1968
-                    $msg = sprintf(
1969
-                        esc_html__(
1970
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1971
-                            'event_espresso'
1972
-                        ),
1973
-                        $EVT_ID
1974
-                    );
1975
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1976
-                    $success = false;
1977
-                }
1978
-            }
1979
-        } else {
1980
-            $success = false;
1981
-            $msg = esc_html__(
1982
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1983
-                'event_espresso'
1984
-            );
1985
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1986
-        }
1987
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1988
-        $success = $success ? 2 : false;
1989
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1990
-        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1991
-    }
1992
-
1993
-
1994
-    /**
1995
-     * _trash_or_restore_events
1996
-     *
1997
-     * @access  private
1998
-     * @param  int    $EVT_ID
1999
-     * @param  string $event_status
2000
-     * @return bool
2001
-     */
2002
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
2003
-    {
2004
-        // grab event id
2005
-        if (! $EVT_ID) {
2006
-            $msg = esc_html__(
2007
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2008
-                'event_espresso'
2009
-            );
2010
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2011
-            return false;
2012
-        }
2013
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2014
-        // clean status
2015
-        $event_status = sanitize_key($event_status);
2016
-        // grab status
2017
-        if (empty($event_status)) {
2018
-            $msg = esc_html__(
2019
-                'An error occurred. No Event Status or an invalid Event Status was received.',
2020
-                'event_espresso'
2021
-            );
2022
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2023
-            return false;
2024
-        }
2025
-        // was event trashed or restored ?
2026
-        switch ($event_status) {
2027
-            case 'draft':
2028
-                $action = 'restored from the trash';
2029
-                $hook = 'AHEE_event_restored_from_trash';
2030
-                break;
2031
-            case 'trash':
2032
-                $action = 'moved to the trash';
2033
-                $hook = 'AHEE_event_moved_to_trash';
2034
-                break;
2035
-            default:
2036
-                $action = 'updated';
2037
-                $hook = false;
2038
-        }
2039
-        // use class to change status
2040
-        $this->_cpt_model_obj->set_status($event_status);
2041
-        $success = $this->_cpt_model_obj->save();
2042
-        if ($success === false) {
2043
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2044
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2045
-            return false;
2046
-        }
2047
-        if ($hook) {
2048
-            do_action($hook);
2049
-        }
2050
-        return true;
2051
-    }
2052
-
2053
-
2054
-    /**
2055
-     * _delete_event
2056
-     *
2057
-     * @access protected
2058
-     * @param bool $redirect_after
2059
-     */
2060
-    protected function _delete_event($redirect_after = true)
2061
-    {
2062
-        // determine the event id and set to array.
2063
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2064
-        $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2065
-        // loop thru events
2066
-        if ($EVT_ID) {
2067
-            $success = $this->_permanently_delete_event($EVT_ID);
2068
-            // get list of events with no prices
2069
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2070
-            // remove this event from the list of events with no prices
2071
-            if (isset($espresso_no_ticket_prices[ $EVT_ID ])) {
2072
-                unset($espresso_no_ticket_prices[ $EVT_ID ]);
2073
-            }
2074
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2075
-        } else {
2076
-            $success = false;
2077
-            $msg = esc_html__(
2078
-                'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2079
-                'event_espresso'
2080
-            );
2081
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2082
-        }
2083
-        if ($redirect_after) {
2084
-            $this->_redirect_after_action(
2085
-                $success,
2086
-                'Event',
2087
-                'deleted',
2088
-                array('action' => 'default', 'status' => 'trash')
2089
-            );
2090
-        }
2091
-    }
2092
-
2093
-
2094
-    /**
2095
-     * _delete_events
2096
-     *
2097
-     * @access protected
2098
-     * @return void
2099
-     */
2100
-    protected function _delete_events()
2101
-    {
2102
-        $success = true;
2103
-        // get list of events with no prices
2104
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2105
-        // determine the event id and set to array.
2106
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2107
-        // loop thru events
2108
-        foreach ($EVT_IDs as $EVT_ID) {
2109
-            $EVT_ID = absint($EVT_ID);
2110
-            if ($EVT_ID) {
2111
-                $results = $this->_permanently_delete_event($EVT_ID);
2112
-                $success = $results !== false ? $success : false;
2113
-                // remove this event from the list of events with no prices
2114
-                unset($espresso_no_ticket_prices[ $EVT_ID ]);
2115
-            } else {
2116
-                $success = false;
2117
-                $msg = esc_html__(
2118
-                    'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2119
-                    'event_espresso'
2120
-                );
2121
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2122
-            }
2123
-        }
2124
-        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2125
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2126
-        $success = $success ? 2 : false;
2127
-        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2128
-    }
2129
-
2130
-
2131
-    /**
2132
-     * _permanently_delete_event
2133
-     *
2134
-     * @access  private
2135
-     * @param  int $EVT_ID
2136
-     * @return bool
2137
-     */
2138
-    private function _permanently_delete_event($EVT_ID = 0)
2139
-    {
2140
-        // grab event id
2141
-        if (! $EVT_ID) {
2142
-            $msg = esc_html__(
2143
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2144
-                'event_espresso'
2145
-            );
2146
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2147
-            return false;
2148
-        }
2149
-        if (! $this->_cpt_model_obj instanceof EE_Event
2150
-            || $this->_cpt_model_obj->ID() !== $EVT_ID
2151
-        ) {
2152
-            $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2153
-        }
2154
-        if (! $this->_cpt_model_obj instanceof EE_Event) {
2155
-            return false;
2156
-        }
2157
-        // need to delete related tickets and prices first.
2158
-        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2159
-        foreach ($datetimes as $datetime) {
2160
-            $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2161
-            $tickets = $datetime->get_many_related('Ticket');
2162
-            foreach ($tickets as $ticket) {
2163
-                $ticket->_remove_relation_to($datetime, 'Datetime');
2164
-                $ticket->delete_related_permanently('Price');
2165
-                $ticket->delete_permanently();
2166
-            }
2167
-            $datetime->delete();
2168
-        }
2169
-        // what about related venues or terms?
2170
-        $venues = $this->_cpt_model_obj->get_many_related('Venue');
2171
-        foreach ($venues as $venue) {
2172
-            $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2173
-        }
2174
-        // any attached question groups?
2175
-        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2176
-        if (! empty($question_groups)) {
2177
-            foreach ($question_groups as $question_group) {
2178
-                $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2179
-            }
2180
-        }
2181
-        // Message Template Groups
2182
-        $this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2183
-        /** @type EE_Term_Taxonomy[] $term_taxonomies */
2184
-        $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2185
-        foreach ($term_taxonomies as $term_taxonomy) {
2186
-            $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2187
-        }
2188
-        $success = $this->_cpt_model_obj->delete_permanently();
2189
-        // did it all go as planned ?
2190
-        if ($success) {
2191
-            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2192
-            EE_Error::add_success($msg);
2193
-        } else {
2194
-            $msg = sprintf(
2195
-                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2196
-                $EVT_ID
2197
-            );
2198
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2199
-            return false;
2200
-        }
2201
-        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2202
-        return true;
2203
-    }
2204
-
2205
-
2206
-    /**
2207
-     * get total number of events
2208
-     *
2209
-     * @access public
2210
-     * @return int
2211
-     */
2212
-    public function total_events()
2213
-    {
2214
-        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2215
-        return $count;
2216
-    }
2217
-
2218
-
2219
-    /**
2220
-     * get total number of draft events
2221
-     *
2222
-     * @access public
2223
-     * @return int
2224
-     */
2225
-    public function total_events_draft()
2226
-    {
2227
-        $where = array(
2228
-            'status' => array('IN', array('draft', 'auto-draft')),
2229
-        );
2230
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2231
-        return $count;
2232
-    }
2233
-
2234
-
2235
-    /**
2236
-     * get total number of trashed events
2237
-     *
2238
-     * @access public
2239
-     * @return int
2240
-     */
2241
-    public function total_trashed_events()
2242
-    {
2243
-        $where = array(
2244
-            'status' => 'trash',
2245
-        );
2246
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2247
-        return $count;
2248
-    }
2249
-
2250
-
2251
-    /**
2252
-     *    _default_event_settings
2253
-     *    This generates the Default Settings Tab
2254
-     *
2255
-     * @return void
2256
-     * @throws EE_Error
2257
-     */
2258
-    protected function _default_event_settings()
2259
-    {
2260
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2261
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2262
-        $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2263
-        $this->display_admin_page_with_sidebar();
2264
-    }
2265
-
2266
-
2267
-    /**
2268
-     * Return the form for event settings.
2269
-     *
2270
-     * @return EE_Form_Section_Proper
2271
-     * @throws EE_Error
2272
-     */
2273
-    protected function _default_event_settings_form()
2274
-    {
2275
-        $registration_config = EE_Registry::instance()->CFG->registration;
2276
-        $registration_stati_for_selection = EEM_Registration::reg_status_array(
2277
-            // exclude
2278
-            array(
2279
-                EEM_Registration::status_id_cancelled,
2280
-                EEM_Registration::status_id_declined,
2281
-                EEM_Registration::status_id_incomplete,
2282
-                EEM_Registration::status_id_wait_list,
2283
-            ),
2284
-            true
2285
-        );
2286
-        return new EE_Form_Section_Proper(
2287
-            array(
2288
-                'name'            => 'update_default_event_settings',
2289
-                'html_id'         => 'update_default_event_settings',
2290
-                'html_class'      => 'form-table',
2291
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2292
-                'subsections'     => apply_filters(
2293
-                    'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2294
-                    array(
2295
-                        'default_reg_status'  => new EE_Select_Input(
2296
-                            $registration_stati_for_selection,
2297
-                            array(
2298
-                                'default'         => isset($registration_config->default_STS_ID)
2299
-                                                     && array_key_exists(
2300
-                                                         $registration_config->default_STS_ID,
2301
-                                                         $registration_stati_for_selection
2302
-                                                     )
2303
-                                    ? sanitize_text_field($registration_config->default_STS_ID)
2304
-                                    : EEM_Registration::status_id_pending_payment,
2305
-                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2306
-                                                     . EEH_Template::get_help_tab_link(
2307
-                                                         'default_settings_status_help_tab'
2308
-                                                     ),
2309
-                                'html_help_text'  => esc_html__(
2310
-                                    'This setting allows you to preselect what the default registration status setting is when creating an event.  Note that changing this setting does NOT retroactively apply it to existing events.',
2311
-                                    'event_espresso'
2312
-                                ),
2313
-                            )
2314
-                        ),
2315
-                        'default_max_tickets' => new EE_Integer_Input(
2316
-                            array(
2317
-                                'default'         => isset($registration_config->default_maximum_number_of_tickets)
2318
-                                    ? $registration_config->default_maximum_number_of_tickets
2319
-                                    : EEM_Event::get_default_additional_limit(),
2320
-                                'html_label_text' => esc_html__(
2321
-                                    'Default Maximum Tickets Allowed Per Order:',
2322
-                                    'event_espresso'
2323
-                                )
2324
-                                                     . EEH_Template::get_help_tab_link(
2325
-                                                         'default_maximum_tickets_help_tab"'
2326
-                                                     ),
2327
-                                'html_help_text'  => esc_html__(
2328
-                                    'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2329
-                                    'event_espresso'
2330
-                                ),
2331
-                            )
2332
-                        ),
2333
-                    )
2334
-                ),
2335
-            )
2336
-        );
2337
-    }
2338
-
2339
-
2340
-    /**
2341
-     * _update_default_event_settings
2342
-     *
2343
-     * @access protected
2344
-     * @return void
2345
-     * @throws EE_Error
2346
-     */
2347
-    protected function _update_default_event_settings()
2348
-    {
2349
-        $registration_config = EE_Registry::instance()->CFG->registration;
2350
-        $form = $this->_default_event_settings_form();
2351
-        if ($form->was_submitted()) {
2352
-            $form->receive_form_submission();
2353
-            if ($form->is_valid()) {
2354
-                $valid_data = $form->valid_data();
2355
-                if (isset($valid_data['default_reg_status'])) {
2356
-                    $registration_config->default_STS_ID = $valid_data['default_reg_status'];
2357
-                }
2358
-                if (isset($valid_data['default_max_tickets'])) {
2359
-                    $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2360
-                }
2361
-                // update because data was valid!
2362
-                EE_Registry::instance()->CFG->update_espresso_config();
2363
-                EE_Error::overwrite_success();
2364
-                EE_Error::add_success(
2365
-                    __('Default Event Settings were updated', 'event_espresso')
2366
-                );
2367
-            }
2368
-        }
2369
-        $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2370
-    }
2371
-
2372
-
2373
-    /*************        Templates        *************/
2374
-    protected function _template_settings()
2375
-    {
2376
-        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2377
-        $this->_template_args['preview_img'] = '<img src="'
2378
-                                               . EVENTS_ASSETS_URL
2379
-                                               . '/images/'
2380
-                                               . 'caffeinated_template_features.jpg" alt="'
2381
-                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2382
-                                               . '" />';
2383
-        $this->_template_args['preview_text'] = '<strong>'
2384
-                                                . esc_html__(
2385
-                                                    'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2386
-                                                    'event_espresso'
2387
-                                                ) . '</strong>';
2388
-        $this->display_admin_caf_preview_page('template_settings_tab');
2389
-    }
2390
-
2391
-
2392
-    /** Event Category Stuff **/
2393
-    /**
2394
-     * set the _category property with the category object for the loaded page.
2395
-     *
2396
-     * @access private
2397
-     * @return void
2398
-     */
2399
-    private function _set_category_object()
2400
-    {
2401
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2402
-            return;
2403
-        } //already have the category object so get out.
2404
-        // set default category object
2405
-        $this->_set_empty_category_object();
2406
-        // only set if we've got an id
2407
-        if (! isset($this->_req_data['EVT_CAT_ID'])) {
2408
-            return;
2409
-        }
2410
-        $category_id = absint($this->_req_data['EVT_CAT_ID']);
2411
-        $term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2412
-        if (! empty($term)) {
2413
-            $this->_category->category_name = $term->name;
2414
-            $this->_category->category_identifier = $term->slug;
2415
-            $this->_category->category_desc = $term->description;
2416
-            $this->_category->id = $term->term_id;
2417
-            $this->_category->parent = $term->parent;
2418
-        }
2419
-    }
2420
-
2421
-
2422
-    /**
2423
-     * Clears out category properties.
2424
-     */
2425
-    private function _set_empty_category_object()
2426
-    {
2427
-        $this->_category = new stdClass();
2428
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2429
-        $this->_category->id = $this->_category->parent = 0;
2430
-    }
2431
-
2432
-
2433
-    /**
2434
-     * @throws EE_Error
2435
-     */
2436
-    protected function _category_list_table()
2437
-    {
2438
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2439
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2440
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2441
-            'add_category',
2442
-            'add_category',
2443
-            array(),
2444
-            'add-new-h2'
2445
-        );
2446
-        $this->display_admin_list_table_page_with_sidebar();
2447
-    }
2448
-
2449
-
2450
-    /**
2451
-     * Output category details view.
2452
-     */
2453
-    protected function _category_details($view)
2454
-    {
2455
-        // load formatter helper
2456
-        // load field generator helper
2457
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
2458
-        $this->_set_add_edit_form_tags($route);
2459
-        $this->_set_category_object();
2460
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
2461
-        $delete_action = 'delete_category';
2462
-        // custom redirect
2463
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2464
-            array('action' => 'category_list'),
2465
-            $this->_admin_base_url
2466
-        );
2467
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2468
-        // take care of contents
2469
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2470
-        $this->display_admin_page_with_sidebar();
2471
-    }
2472
-
2473
-
2474
-    /**
2475
-     * Output category details content.
2476
-     */
2477
-    protected function _category_details_content()
2478
-    {
2479
-        $editor_args['category_desc'] = array(
2480
-            'type'          => 'wp_editor',
2481
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2482
-            'class'         => 'my_editor_custom',
2483
-            'wpeditor_args' => array('media_buttons' => false),
2484
-        );
2485
-        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2486
-        $all_terms = get_terms(
2487
-            array(EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY),
2488
-            array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2489
-        );
2490
-        // setup category select for term parents.
2491
-        $category_select_values[] = array(
2492
-            'text' => esc_html__('No Parent', 'event_espresso'),
2493
-            'id'   => 0,
2494
-        );
2495
-        foreach ($all_terms as $term) {
2496
-            $category_select_values[] = array(
2497
-                'text' => $term->name,
2498
-                'id'   => $term->term_id,
2499
-            );
2500
-        }
2501
-        $category_select = EEH_Form_Fields::select_input(
2502
-            'category_parent',
2503
-            $category_select_values,
2504
-            $this->_category->parent
2505
-        );
2506
-        $template_args = array(
2507
-            'category'                 => $this->_category,
2508
-            'category_select'          => $category_select,
2509
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2510
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2511
-            'disable'                  => '',
2512
-            'disabled_message'         => false,
2513
-        );
2514
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2515
-        return EEH_Template::display_template($template, $template_args, true);
2516
-    }
2517
-
2518
-
2519
-    /**
2520
-     * Handles deleting categories.
2521
-     */
2522
-    protected function _delete_categories()
2523
-    {
2524
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2525
-            : (array) $this->_req_data['category_id'];
2526
-        foreach ($cat_ids as $cat_id) {
2527
-            $this->_delete_category($cat_id);
2528
-        }
2529
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
2530
-        $query_args = array(
2531
-            'action' => 'category_list',
2532
-        );
2533
-        $this->_redirect_after_action(0, '', '', $query_args);
2534
-    }
2535
-
2536
-
2537
-    /**
2538
-     * Handles deleting specific category.
2539
-     *
2540
-     * @param int $cat_id
2541
-     */
2542
-    protected function _delete_category($cat_id)
2543
-    {
2544
-        $cat_id = absint($cat_id);
2545
-        wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2546
-    }
2547
-
2548
-
2549
-    /**
2550
-     * Handles triggering the update or insertion of a new category.
2551
-     *
2552
-     * @param bool $new_category true means we're triggering the insert of a new category.
2553
-     */
2554
-    protected function _insert_or_update_category($new_category)
2555
-    {
2556
-        $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2557
-        $success = 0; // we already have a success message so lets not send another.
2558
-        if ($cat_id) {
2559
-            $query_args = array(
2560
-                'action'     => 'edit_category',
2561
-                'EVT_CAT_ID' => $cat_id,
2562
-            );
2563
-        } else {
2564
-            $query_args = array('action' => 'add_category');
2565
-        }
2566
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2567
-    }
2568
-
2569
-
2570
-    /**
2571
-     * Inserts or updates category
2572
-     *
2573
-     * @param bool $update (true indicates we're updating a category).
2574
-     * @return bool|mixed|string
2575
-     */
2576
-    private function _insert_category($update = false)
2577
-    {
2578
-        $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2579
-        $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2580
-        $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2581
-        $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2582
-        if (empty($category_name)) {
2583
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
2584
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2585
-            return false;
2586
-        }
2587
-        $term_args = array(
2588
-            'name'        => $category_name,
2589
-            'description' => $category_desc,
2590
-            'parent'      => $category_parent,
2591
-        );
2592
-        // was the category_identifier input disabled?
2593
-        if (isset($this->_req_data['category_identifier'])) {
2594
-            $term_args['slug'] = $this->_req_data['category_identifier'];
2595
-        }
2596
-        $insert_ids = $update
2597
-            ? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2598
-            : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2599
-        if (! is_array($insert_ids)) {
2600
-            $msg = esc_html__(
2601
-                'An error occurred and the category has not been saved to the database.',
2602
-                'event_espresso'
2603
-            );
2604
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2605
-        } else {
2606
-            $cat_id = $insert_ids['term_id'];
2607
-            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2608
-            EE_Error::add_success($msg);
2609
-        }
2610
-        return $cat_id;
2611
-    }
2612
-
2613
-
2614
-    /**
2615
-     * Gets categories or count of categories matching the arguments in the request.
2616
-     *
2617
-     * @param int  $per_page
2618
-     * @param int  $current_page
2619
-     * @param bool $count
2620
-     * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int
2621
-     */
2622
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2623
-    {
2624
-        // testing term stuff
2625
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2626
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2627
-        $limit = ($current_page - 1) * $per_page;
2628
-        $where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2629
-        if (isset($this->_req_data['s'])) {
2630
-            $sstr = '%' . $this->_req_data['s'] . '%';
2631
-            $where['OR'] = array(
2632
-                'Term.name'   => array('LIKE', $sstr),
2633
-                'description' => array('LIKE', $sstr),
2634
-            );
2635
-        }
2636
-        $query_params = array(
2637
-            $where,
2638
-            'order_by'   => array($orderby => $order),
2639
-            'limit'      => $limit . ',' . $per_page,
2640
-            'force_join' => array('Term'),
2641
-        );
2642
-        $categories = $count
2643
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2644
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2645
-        return $categories;
2646
-    }
2647
-
2648
-    /* end category stuff */
2649
-    /**************/
2650
-
2651
-
2652
-    /**
2653
-     * Callback for the `ee_save_timezone_setting` ajax action.
2654
-     *
2655
-     * @throws EE_Error
2656
-     */
2657
-    public function save_timezonestring_setting()
2658
-    {
2659
-        $timezone_string = isset($this->_req_data['timezone_selected'])
2660
-            ? $this->_req_data['timezone_selected']
2661
-            : '';
2662
-        if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2663
-            EE_Error::add_error(
2664
-                esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2665
-                __FILE__,
2666
-                __FUNCTION__,
2667
-                __LINE__
2668
-            );
2669
-            $this->_template_args['error'] = true;
2670
-            $this->_return_json();
2671
-        }
2672
-
2673
-        update_option('timezone_string', $timezone_string);
2674
-        EE_Error::add_success(
2675
-            esc_html__('Your timezone string was updated.', 'event_espresso')
2676
-        );
2677
-        $this->_template_args['success'] = true;
2678
-        $this->_return_json(true, array('action' => 'create_new'));
2679
-    }
15
+	/**
16
+	 * This will hold the event object for event_details screen.
17
+	 *
18
+	 * @access protected
19
+	 * @var EE_Event $_event
20
+	 */
21
+	protected $_event;
22
+
23
+
24
+	/**
25
+	 * This will hold the category object for category_details screen.
26
+	 *
27
+	 * @var stdClass $_category
28
+	 */
29
+	protected $_category;
30
+
31
+
32
+	/**
33
+	 * This will hold the event model instance
34
+	 *
35
+	 * @var EEM_Event $_event_model
36
+	 */
37
+	protected $_event_model;
38
+
39
+
40
+	/**
41
+	 * @var EE_Event
42
+	 */
43
+	protected $_cpt_model_obj = false;
44
+
45
+
46
+	/**
47
+	 * Initialize page props for this admin page group.
48
+	 */
49
+	protected function _init_page_props()
50
+	{
51
+		$this->page_slug = EVENTS_PG_SLUG;
52
+		$this->page_label = EVENTS_LABEL;
53
+		$this->_admin_base_url = EVENTS_ADMIN_URL;
54
+		$this->_admin_base_path = EVENTS_ADMIN;
55
+		$this->_cpt_model_names = array(
56
+			'create_new' => 'EEM_Event',
57
+			'edit'       => 'EEM_Event',
58
+		);
59
+		$this->_cpt_edit_routes = array(
60
+			'espresso_events' => 'edit',
61
+		);
62
+		add_action(
63
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
64
+			array($this, 'verify_event_edit'),
65
+			10,
66
+			2
67
+		);
68
+	}
69
+
70
+
71
+	/**
72
+	 * Sets the ajax hooks used for this admin page group.
73
+	 */
74
+	protected function _ajax_hooks()
75
+	{
76
+		add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting'));
77
+	}
78
+
79
+
80
+	/**
81
+	 * Sets the page properties for this admin page group.
82
+	 */
83
+	protected function _define_page_props()
84
+	{
85
+		$this->_admin_page_title = EVENTS_LABEL;
86
+		$this->_labels = array(
87
+			'buttons'      => array(
88
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
89
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
90
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
91
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
92
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
93
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
94
+			),
95
+			'editor_title' => array(
96
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
97
+			),
98
+			'publishbox'   => array(
99
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
100
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
101
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
102
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
103
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
104
+			),
105
+		);
106
+	}
107
+
108
+
109
+	/**
110
+	 * Sets the page routes property for this admin page group.
111
+	 */
112
+	protected function _set_page_routes()
113
+	{
114
+		// load formatter helper
115
+		// load field generator helper
116
+		// is there a evt_id in the request?
117
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
118
+			? $this->_req_data['EVT_ID']
119
+			: 0;
120
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
121
+		$this->_page_routes = array(
122
+			'default'                       => array(
123
+				'func'       => '_events_overview_list_table',
124
+				'capability' => 'ee_read_events',
125
+			),
126
+			'create_new'                    => array(
127
+				'func'       => '_create_new_cpt_item',
128
+				'capability' => 'ee_edit_events',
129
+			),
130
+			'edit'                          => array(
131
+				'func'       => '_edit_cpt_item',
132
+				'capability' => 'ee_edit_event',
133
+				'obj_id'     => $evt_id,
134
+			),
135
+			'copy_event'                    => array(
136
+				'func'       => '_copy_events',
137
+				'capability' => 'ee_edit_event',
138
+				'obj_id'     => $evt_id,
139
+				'noheader'   => true,
140
+			),
141
+			'trash_event'                   => array(
142
+				'func'       => '_trash_or_restore_event',
143
+				'args'       => array('event_status' => 'trash'),
144
+				'capability' => 'ee_delete_event',
145
+				'obj_id'     => $evt_id,
146
+				'noheader'   => true,
147
+			),
148
+			'trash_events'                  => array(
149
+				'func'       => '_trash_or_restore_events',
150
+				'args'       => array('event_status' => 'trash'),
151
+				'capability' => 'ee_delete_events',
152
+				'noheader'   => true,
153
+			),
154
+			'restore_event'                 => array(
155
+				'func'       => '_trash_or_restore_event',
156
+				'args'       => array('event_status' => 'draft'),
157
+				'capability' => 'ee_delete_event',
158
+				'obj_id'     => $evt_id,
159
+				'noheader'   => true,
160
+			),
161
+			'restore_events'                => array(
162
+				'func'       => '_trash_or_restore_events',
163
+				'args'       => array('event_status' => 'draft'),
164
+				'capability' => 'ee_delete_events',
165
+				'noheader'   => true,
166
+			),
167
+			'delete_event'                  => array(
168
+				'func'       => '_delete_event',
169
+				'capability' => 'ee_delete_event',
170
+				'obj_id'     => $evt_id,
171
+				'noheader'   => true,
172
+			),
173
+			'delete_events'                 => array(
174
+				'func'       => '_delete_events',
175
+				'capability' => 'ee_delete_events',
176
+				'noheader'   => true,
177
+			),
178
+			'view_report'                   => array(
179
+				'func'      => '_view_report',
180
+				'capablity' => 'ee_edit_events',
181
+			),
182
+			'default_event_settings'        => array(
183
+				'func'       => '_default_event_settings',
184
+				'capability' => 'manage_options',
185
+			),
186
+			'update_default_event_settings' => array(
187
+				'func'       => '_update_default_event_settings',
188
+				'capability' => 'manage_options',
189
+				'noheader'   => true,
190
+			),
191
+			'template_settings'             => array(
192
+				'func'       => '_template_settings',
193
+				'capability' => 'manage_options',
194
+			),
195
+			// event category tab related
196
+			'add_category'                  => array(
197
+				'func'       => '_category_details',
198
+				'capability' => 'ee_edit_event_category',
199
+				'args'       => array('add'),
200
+			),
201
+			'edit_category'                 => array(
202
+				'func'       => '_category_details',
203
+				'capability' => 'ee_edit_event_category',
204
+				'args'       => array('edit'),
205
+			),
206
+			'delete_categories'             => array(
207
+				'func'       => '_delete_categories',
208
+				'capability' => 'ee_delete_event_category',
209
+				'noheader'   => true,
210
+			),
211
+			'delete_category'               => array(
212
+				'func'       => '_delete_categories',
213
+				'capability' => 'ee_delete_event_category',
214
+				'noheader'   => true,
215
+			),
216
+			'insert_category'               => array(
217
+				'func'       => '_insert_or_update_category',
218
+				'args'       => array('new_category' => true),
219
+				'capability' => 'ee_edit_event_category',
220
+				'noheader'   => true,
221
+			),
222
+			'update_category'               => array(
223
+				'func'       => '_insert_or_update_category',
224
+				'args'       => array('new_category' => false),
225
+				'capability' => 'ee_edit_event_category',
226
+				'noheader'   => true,
227
+			),
228
+			'category_list'                 => array(
229
+				'func'       => '_category_list_table',
230
+				'capability' => 'ee_manage_event_categories',
231
+			),
232
+		);
233
+	}
234
+
235
+
236
+	/**
237
+	 * Set the _page_config property for this admin page group.
238
+	 */
239
+	protected function _set_page_config()
240
+	{
241
+		$this->_page_config = array(
242
+			'default'                => array(
243
+				'nav'           => array(
244
+					'label' => esc_html__('Overview', 'event_espresso'),
245
+					'order' => 10,
246
+				),
247
+				'list_table'    => 'Events_Admin_List_Table',
248
+				'help_tabs'     => array(
249
+					'events_overview_help_tab'                       => array(
250
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
251
+						'filename' => 'events_overview',
252
+					),
253
+					'events_overview_table_column_headings_help_tab' => array(
254
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
255
+						'filename' => 'events_overview_table_column_headings',
256
+					),
257
+					'events_overview_filters_help_tab'               => array(
258
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
259
+						'filename' => 'events_overview_filters',
260
+					),
261
+					'events_overview_view_help_tab'                  => array(
262
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
263
+						'filename' => 'events_overview_views',
264
+					),
265
+					'events_overview_other_help_tab'                 => array(
266
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
267
+						'filename' => 'events_overview_other',
268
+					),
269
+				),
270
+				'help_tour'     => array(
271
+					'Event_Overview_Help_Tour',
272
+					// 'New_Features_Test_Help_Tour' for testing multiple help tour
273
+				),
274
+				'qtips'         => array(
275
+					'EE_Event_List_Table_Tips',
276
+				),
277
+				'require_nonce' => false,
278
+			),
279
+			'create_new'             => array(
280
+				'nav'           => array(
281
+					'label'      => esc_html__('Add Event', 'event_espresso'),
282
+					'order'      => 5,
283
+					'persistent' => false,
284
+				),
285
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
286
+				'help_tabs'     => array(
287
+					'event_editor_help_tab'                            => array(
288
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
289
+						'filename' => 'event_editor',
290
+					),
291
+					'event_editor_title_richtexteditor_help_tab'       => array(
292
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
293
+						'filename' => 'event_editor_title_richtexteditor',
294
+					),
295
+					'event_editor_venue_details_help_tab'              => array(
296
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
297
+						'filename' => 'event_editor_venue_details',
298
+					),
299
+					'event_editor_event_datetimes_help_tab'            => array(
300
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
301
+						'filename' => 'event_editor_event_datetimes',
302
+					),
303
+					'event_editor_event_tickets_help_tab'              => array(
304
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
305
+						'filename' => 'event_editor_event_tickets',
306
+					),
307
+					'event_editor_event_registration_options_help_tab' => array(
308
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
309
+						'filename' => 'event_editor_event_registration_options',
310
+					),
311
+					'event_editor_tags_categories_help_tab'            => array(
312
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
313
+						'filename' => 'event_editor_tags_categories',
314
+					),
315
+					'event_editor_questions_registrants_help_tab'      => array(
316
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
317
+						'filename' => 'event_editor_questions_registrants',
318
+					),
319
+					'event_editor_save_new_event_help_tab'             => array(
320
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
321
+						'filename' => 'event_editor_save_new_event',
322
+					),
323
+					'event_editor_other_help_tab'                      => array(
324
+						'title'    => esc_html__('Event Other', 'event_espresso'),
325
+						'filename' => 'event_editor_other',
326
+					),
327
+				),
328
+				'help_tour'     => array(
329
+					'Event_Editor_Help_Tour',
330
+				),
331
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
332
+				'require_nonce' => false,
333
+			),
334
+			'edit'                   => array(
335
+				'nav'           => array(
336
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
337
+					'order'      => 5,
338
+					'persistent' => false,
339
+					'url'        => isset($this->_req_data['post'])
340
+						? EE_Admin_Page::add_query_args_and_nonce(
341
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
342
+							$this->_current_page_view_url
343
+						)
344
+						: $this->_admin_base_url,
345
+				),
346
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
347
+				'help_tabs'     => array(
348
+					'event_editor_help_tab'                            => array(
349
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
350
+						'filename' => 'event_editor',
351
+					),
352
+					'event_editor_title_richtexteditor_help_tab'       => array(
353
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
354
+						'filename' => 'event_editor_title_richtexteditor',
355
+					),
356
+					'event_editor_venue_details_help_tab'              => array(
357
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
358
+						'filename' => 'event_editor_venue_details',
359
+					),
360
+					'event_editor_event_datetimes_help_tab'            => array(
361
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
362
+						'filename' => 'event_editor_event_datetimes',
363
+					),
364
+					'event_editor_event_tickets_help_tab'              => array(
365
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
366
+						'filename' => 'event_editor_event_tickets',
367
+					),
368
+					'event_editor_event_registration_options_help_tab' => array(
369
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
370
+						'filename' => 'event_editor_event_registration_options',
371
+					),
372
+					'event_editor_tags_categories_help_tab'            => array(
373
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
374
+						'filename' => 'event_editor_tags_categories',
375
+					),
376
+					'event_editor_questions_registrants_help_tab'      => array(
377
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
378
+						'filename' => 'event_editor_questions_registrants',
379
+					),
380
+					'event_editor_save_new_event_help_tab'             => array(
381
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
382
+						'filename' => 'event_editor_save_new_event',
383
+					),
384
+					'event_editor_other_help_tab'                      => array(
385
+						'title'    => esc_html__('Event Other', 'event_espresso'),
386
+						'filename' => 'event_editor_other',
387
+					),
388
+				),
389
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
390
+				'require_nonce' => false,
391
+			),
392
+			'default_event_settings' => array(
393
+				'nav'           => array(
394
+					'label' => esc_html__('Default Settings', 'event_espresso'),
395
+					'order' => 40,
396
+				),
397
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
398
+				'labels'        => array(
399
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
400
+				),
401
+				'help_tabs'     => array(
402
+					'default_settings_help_tab'        => array(
403
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
404
+						'filename' => 'events_default_settings',
405
+					),
406
+					'default_settings_status_help_tab' => array(
407
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
408
+						'filename' => 'events_default_settings_status',
409
+					),
410
+					'default_maximum_tickets_help_tab' => array(
411
+						'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
412
+						'filename' => 'events_default_settings_max_tickets',
413
+					),
414
+				),
415
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
416
+				'require_nonce' => false,
417
+			),
418
+			// template settings
419
+			'template_settings'      => array(
420
+				'nav'           => array(
421
+					'label' => esc_html__('Templates', 'event_espresso'),
422
+					'order' => 30,
423
+				),
424
+				'metaboxes'     => $this->_default_espresso_metaboxes,
425
+				'help_tabs'     => array(
426
+					'general_settings_templates_help_tab' => array(
427
+						'title'    => esc_html__('Templates', 'event_espresso'),
428
+						'filename' => 'general_settings_templates',
429
+					),
430
+				),
431
+				'help_tour'     => array('Templates_Help_Tour'),
432
+				'require_nonce' => false,
433
+			),
434
+			// event category stuff
435
+			'add_category'           => array(
436
+				'nav'           => array(
437
+					'label'      => esc_html__('Add Category', 'event_espresso'),
438
+					'order'      => 15,
439
+					'persistent' => false,
440
+				),
441
+				'help_tabs'     => array(
442
+					'add_category_help_tab' => array(
443
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
444
+						'filename' => 'events_add_category',
445
+					),
446
+				),
447
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
448
+				'metaboxes'     => array('_publish_post_box'),
449
+				'require_nonce' => false,
450
+			),
451
+			'edit_category'          => array(
452
+				'nav'           => array(
453
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
454
+					'order'      => 15,
455
+					'persistent' => false,
456
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
457
+						? add_query_arg(
458
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
459
+							$this->_current_page_view_url
460
+						)
461
+						: $this->_admin_base_url,
462
+				),
463
+				'help_tabs'     => array(
464
+					'edit_category_help_tab' => array(
465
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
466
+						'filename' => 'events_edit_category',
467
+					),
468
+				),
469
+				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
470
+				'metaboxes'     => array('_publish_post_box'),
471
+				'require_nonce' => false,
472
+			),
473
+			'category_list'          => array(
474
+				'nav'           => array(
475
+					'label' => esc_html__('Categories', 'event_espresso'),
476
+					'order' => 20,
477
+				),
478
+				'list_table'    => 'Event_Categories_Admin_List_Table',
479
+				'help_tabs'     => array(
480
+					'events_categories_help_tab'                       => array(
481
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
482
+						'filename' => 'events_categories',
483
+					),
484
+					'events_categories_table_column_headings_help_tab' => array(
485
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
486
+						'filename' => 'events_categories_table_column_headings',
487
+					),
488
+					'events_categories_view_help_tab'                  => array(
489
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
490
+						'filename' => 'events_categories_views',
491
+					),
492
+					'events_categories_other_help_tab'                 => array(
493
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
494
+						'filename' => 'events_categories_other',
495
+					),
496
+				),
497
+				'help_tour'     => array(
498
+					'Event_Categories_Help_Tour',
499
+				),
500
+				'metaboxes'     => $this->_default_espresso_metaboxes,
501
+				'require_nonce' => false,
502
+			),
503
+		);
504
+	}
505
+
506
+
507
+	/**
508
+	 * Used to register any global screen options if necessary for every route in this admin page group.
509
+	 */
510
+	protected function _add_screen_options()
511
+	{
512
+	}
513
+
514
+
515
+	/**
516
+	 * Implementing the screen options for the 'default' route.
517
+	 */
518
+	protected function _add_screen_options_default()
519
+	{
520
+		$this->_per_page_screen_option();
521
+	}
522
+
523
+
524
+	/**
525
+	 * Implementing screen options for the category list route.
526
+	 */
527
+	protected function _add_screen_options_category_list()
528
+	{
529
+		$page_title = $this->_admin_page_title;
530
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
531
+		$this->_per_page_screen_option();
532
+		$this->_admin_page_title = $page_title;
533
+	}
534
+
535
+
536
+	/**
537
+	 * Used to register any global feature pointers for the admin page group.
538
+	 */
539
+	protected function _add_feature_pointers()
540
+	{
541
+	}
542
+
543
+
544
+	/**
545
+	 * Registers and enqueues any global scripts and styles for the entire admin page group.
546
+	 */
547
+	public function load_scripts_styles()
548
+	{
549
+		wp_register_style(
550
+			'events-admin-css',
551
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
552
+			array(),
553
+			EVENT_ESPRESSO_VERSION
554
+		);
555
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
556
+		wp_enqueue_style('events-admin-css');
557
+		wp_enqueue_style('ee-cat-admin');
558
+		// todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
559
+		// registers for all views
560
+		// scripts
561
+		wp_register_script(
562
+			'event_editor_js',
563
+			EVENTS_ASSETS_URL . 'event_editor.js',
564
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
565
+			EVENT_ESPRESSO_VERSION,
566
+			true
567
+		);
568
+	}
569
+
570
+
571
+	/**
572
+	 * Enqueuing scripts and styles specific to this view
573
+	 */
574
+	public function load_scripts_styles_create_new()
575
+	{
576
+		$this->load_scripts_styles_edit();
577
+	}
578
+
579
+
580
+	/**
581
+	 * Enqueuing scripts and styles specific to this view
582
+	 */
583
+	public function load_scripts_styles_edit()
584
+	{
585
+		// styles
586
+		wp_enqueue_style('espresso-ui-theme');
587
+		wp_register_style(
588
+			'event-editor-css',
589
+			EVENTS_ASSETS_URL . 'event-editor.css',
590
+			array('ee-admin-css'),
591
+			EVENT_ESPRESSO_VERSION
592
+		);
593
+		wp_enqueue_style('event-editor-css');
594
+		// scripts
595
+		wp_register_script(
596
+			'event-datetime-metabox',
597
+			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
598
+			array('event_editor_js', 'ee-datepicker'),
599
+			EVENT_ESPRESSO_VERSION
600
+		);
601
+		wp_enqueue_script('event-datetime-metabox');
602
+	}
603
+
604
+
605
+	/**
606
+	 * Populating the _views property for the category list table view.
607
+	 */
608
+	protected function _set_list_table_views_category_list()
609
+	{
610
+		$this->_views = array(
611
+			'all' => array(
612
+				'slug'        => 'all',
613
+				'label'       => esc_html__('All', 'event_espresso'),
614
+				'count'       => 0,
615
+				'bulk_action' => array(
616
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
617
+				),
618
+			),
619
+		);
620
+	}
621
+
622
+
623
+	/**
624
+	 * For adding anything that fires on the admin_init hook for any route within this admin page group.
625
+	 */
626
+	public function admin_init()
627
+	{
628
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
629
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
630
+			'event_espresso'
631
+		);
632
+	}
633
+
634
+
635
+	/**
636
+	 * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
637
+	 * group.
638
+	 */
639
+	public function admin_notices()
640
+	{
641
+	}
642
+
643
+
644
+	/**
645
+	 * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
646
+	 * this admin page group.
647
+	 */
648
+	public function admin_footer_scripts()
649
+	{
650
+	}
651
+
652
+
653
+	/**
654
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
655
+	 * warning (via EE_Error::add_error());
656
+	 *
657
+	 * @param  EE_Event $event Event object
658
+	 * @param string    $req_type
659
+	 * @return void
660
+	 * @throws EE_Error
661
+	 * @access public
662
+	 */
663
+	public function verify_event_edit($event = null, $req_type = '')
664
+	{
665
+		// don't need to do this when processing
666
+		if (! empty($req_type)) {
667
+			return;
668
+		}
669
+		// no event?
670
+		if (empty($event)) {
671
+			// set event
672
+			$event = $this->_cpt_model_obj;
673
+		}
674
+		// STILL no event?
675
+		if (! $event instanceof EE_Event) {
676
+			return;
677
+		}
678
+		$orig_status = $event->status();
679
+		// first check if event is active.
680
+		if ($orig_status === EEM_Event::cancelled
681
+			|| $orig_status === EEM_Event::postponed
682
+			|| $event->is_expired()
683
+			|| $event->is_inactive()
684
+		) {
685
+			return;
686
+		}
687
+		// made it here so it IS active... next check that any of the tickets are sold.
688
+		if ($event->is_sold_out(true)) {
689
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
690
+				EE_Error::add_attention(
691
+					sprintf(
692
+						esc_html__(
693
+							'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
694
+							'event_espresso'
695
+						),
696
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
697
+					)
698
+				);
699
+			}
700
+			return;
701
+		} elseif ($orig_status === EEM_Event::sold_out) {
702
+			EE_Error::add_attention(
703
+				sprintf(
704
+					esc_html__(
705
+						'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
706
+						'event_espresso'
707
+					),
708
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
709
+				)
710
+			);
711
+		}
712
+		// now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
713
+		if (! $event->tickets_on_sale()) {
714
+			return;
715
+		}
716
+		// made it here so show warning
717
+		$this->_edit_event_warning();
718
+	}
719
+
720
+
721
+	/**
722
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
723
+	 * When needed, hook this into a EE_Error::add_error() notice.
724
+	 *
725
+	 * @access protected
726
+	 * @return void
727
+	 */
728
+	protected function _edit_event_warning()
729
+	{
730
+		// we don't want to add warnings during these requests
731
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
732
+			return;
733
+		}
734
+		EE_Error::add_attention(
735
+			sprintf(
736
+				esc_html__(
737
+					'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
738
+					'event_espresso'
739
+				),
740
+				'<a class="espresso-help-tab-lnk">',
741
+				'</a>'
742
+			)
743
+		);
744
+	}
745
+
746
+
747
+	/**
748
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
749
+	 * Otherwise, do the normal logic
750
+	 *
751
+	 * @return string
752
+	 * @throws \EE_Error
753
+	 */
754
+	protected function _create_new_cpt_item()
755
+	{
756
+		$has_timezone_string = get_option('timezone_string');
757
+		// only nag them about setting their timezone if it's their first event, and they haven't already done it
758
+		if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
759
+			EE_Error::add_attention(
760
+				sprintf(
761
+					__(
762
+						'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s',
763
+						'event_espresso'
764
+					),
765
+					'<br>',
766
+					'<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
767
+					. EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
768
+					. '</select>',
769
+					'<button class="button button-secondary timezone-submit">',
770
+					'</button><span class="spinner"></span>'
771
+				),
772
+				__FILE__,
773
+				__FUNCTION__,
774
+				__LINE__
775
+			);
776
+		}
777
+		return parent::_create_new_cpt_item();
778
+	}
779
+
780
+
781
+	/**
782
+	 * Sets the _views property for the default route in this admin page group.
783
+	 */
784
+	protected function _set_list_table_views_default()
785
+	{
786
+		$this->_views = array(
787
+			'all'   => array(
788
+				'slug'        => 'all',
789
+				'label'       => esc_html__('View All Events', 'event_espresso'),
790
+				'count'       => 0,
791
+				'bulk_action' => array(
792
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
793
+				),
794
+			),
795
+			'draft' => array(
796
+				'slug'        => 'draft',
797
+				'label'       => esc_html__('Draft', 'event_espresso'),
798
+				'count'       => 0,
799
+				'bulk_action' => array(
800
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
801
+				),
802
+			),
803
+		);
804
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
805
+			$this->_views['trash'] = array(
806
+				'slug'        => 'trash',
807
+				'label'       => esc_html__('Trash', 'event_espresso'),
808
+				'count'       => 0,
809
+				'bulk_action' => array(
810
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
811
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
812
+				),
813
+			);
814
+		}
815
+	}
816
+
817
+
818
+	/**
819
+	 * Provides the legend item array for the default list table view.
820
+	 *
821
+	 * @return array
822
+	 */
823
+	protected function _event_legend_items()
824
+	{
825
+		$items = array(
826
+			'view_details'   => array(
827
+				'class' => 'dashicons dashicons-search',
828
+				'desc'  => esc_html__('View Event', 'event_espresso'),
829
+			),
830
+			'edit_event'     => array(
831
+				'class' => 'ee-icon ee-icon-calendar-edit',
832
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
833
+			),
834
+			'view_attendees' => array(
835
+				'class' => 'dashicons dashicons-groups',
836
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
837
+			),
838
+		);
839
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
840
+		$statuses = array(
841
+			'sold_out_status'  => array(
842
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
843
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
844
+			),
845
+			'active_status'    => array(
846
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
847
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
848
+			),
849
+			'upcoming_status'  => array(
850
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
851
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
852
+			),
853
+			'postponed_status' => array(
854
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
855
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
856
+			),
857
+			'cancelled_status' => array(
858
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
859
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
860
+			),
861
+			'expired_status'   => array(
862
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
863
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
864
+			),
865
+			'inactive_status'  => array(
866
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
867
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
868
+			),
869
+		);
870
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
871
+		return array_merge($items, $statuses);
872
+	}
873
+
874
+
875
+	/**
876
+	 * @return EEM_Event
877
+	 */
878
+	private function _event_model()
879
+	{
880
+		if (! $this->_event_model instanceof EEM_Event) {
881
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
882
+		}
883
+		return $this->_event_model;
884
+	}
885
+
886
+
887
+	/**
888
+	 * Adds extra buttons to the WP CPT permalink field row.
889
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
890
+	 *
891
+	 * @param  string $return    the current html
892
+	 * @param  int    $id        the post id for the page
893
+	 * @param  string $new_title What the title is
894
+	 * @param  string $new_slug  what the slug is
895
+	 * @return string            The new html string for the permalink area
896
+	 */
897
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
898
+	{
899
+		// make sure this is only when editing
900
+		if (! empty($id)) {
901
+			$post = get_post($id);
902
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
903
+					   . esc_html__('Shortcode', 'event_espresso')
904
+					   . '</a> ';
905
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
906
+					   . $post->ID
907
+					   . ']">';
908
+		}
909
+		return $return;
910
+	}
911
+
912
+
913
+	/**
914
+	 * _events_overview_list_table
915
+	 * This contains the logic for showing the events_overview list
916
+	 *
917
+	 * @access protected
918
+	 * @return void
919
+	 * @throws \EE_Error
920
+	 */
921
+	protected function _events_overview_list_table()
922
+	{
923
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
924
+		$this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
925
+			? (array) $this->_template_args['after_list_table']
926
+			: array();
927
+		$this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
928
+				. EEH_Template::get_button_or_link(
929
+					get_post_type_archive_link('espresso_events'),
930
+					esc_html__("View Event Archive Page", "event_espresso"),
931
+					'button'
932
+				);
933
+		$this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
934
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
935
+			'create_new',
936
+			'add',
937
+			array(),
938
+			'add-new-h2'
939
+		);
940
+		$this->display_admin_list_table_page_with_no_sidebar();
941
+	}
942
+
943
+
944
+	/**
945
+	 * this allows for extra misc actions in the default WP publish box
946
+	 *
947
+	 * @return void
948
+	 */
949
+	public function extra_misc_actions_publish_box()
950
+	{
951
+		$this->_generate_publish_box_extra_content();
952
+	}
953
+
954
+
955
+	/**
956
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
957
+	 * saved.
958
+	 * Typically you would use this to save any additional data.
959
+	 * Keep in mind also that "save_post" runs on EVERY post update to the database.
960
+	 * ALSO very important.  When a post transitions from scheduled to published,
961
+	 * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from
962
+	 * other meta saves. So MAKE sure that you handle this accordingly.
963
+	 *
964
+	 * @access protected
965
+	 * @abstract
966
+	 * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
967
+	 * @param  object $post    The post object of the cpt that was saved.
968
+	 * @return void
969
+	 * @throws \EE_Error
970
+	 */
971
+	protected function _insert_update_cpt_item($post_id, $post)
972
+	{
973
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
974
+			// get out we're not processing an event save.
975
+			return;
976
+		}
977
+		$event_values = array(
978
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
979
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
980
+			'EVT_additional_limit'            => min(
981
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
982
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
983
+			),
984
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
985
+				? $this->_req_data['EVT_default_registration_status']
986
+				: EE_Registry::instance()->CFG->registration->default_STS_ID,
987
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
988
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
989
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
990
+				? $this->_req_data['timezone_string'] : null,
991
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
992
+				? $this->_req_data['externalURL'] : null,
993
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
994
+				? $this->_req_data['event_phone'] : null,
995
+		);
996
+		// update event
997
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
998
+		// get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
999
+		$get_one_where = array(
1000
+			$this->_event_model()->primary_key_name() => $post_id,
1001
+			'OR'                                      => array(
1002
+				'status'   => $post->post_status,
1003
+				// if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1004
+				// but the returned object here has a status of "publish", so use the original post status as well
1005
+				'status*1' => $this->_req_data['original_post_status'],
1006
+			),
1007
+		);
1008
+		$event = $this->_event_model()->get_one(array($get_one_where));
1009
+		// the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
1010
+		$event_update_callbacks = apply_filters(
1011
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1012
+			array(
1013
+				array($this, '_default_venue_update'),
1014
+				array($this, '_default_tickets_update'),
1015
+			)
1016
+		);
1017
+		$att_success = true;
1018
+		foreach ($event_update_callbacks as $e_callback) {
1019
+			$_success = is_callable($e_callback)
1020
+				? call_user_func($e_callback, $event, $this->_req_data)
1021
+				: false;
1022
+			// if ANY of these updates fail then we want the appropriate global error message
1023
+			$att_success = ! $att_success ? $att_success : $_success;
1024
+		}
1025
+		// any errors?
1026
+		if ($success && false === $att_success) {
1027
+			EE_Error::add_error(
1028
+				esc_html__(
1029
+					'Event Details saved successfully but something went wrong with saving attachments.',
1030
+					'event_espresso'
1031
+				),
1032
+				__FILE__,
1033
+				__FUNCTION__,
1034
+				__LINE__
1035
+			);
1036
+		} elseif ($success === false) {
1037
+			EE_Error::add_error(
1038
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
1039
+				__FILE__,
1040
+				__FUNCTION__,
1041
+				__LINE__
1042
+			);
1043
+		}
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 * @see parent::restore_item()
1049
+	 * @param int $post_id
1050
+	 * @param int $revision_id
1051
+	 */
1052
+	protected function _restore_cpt_item($post_id, $revision_id)
1053
+	{
1054
+		// copy existing event meta to new post
1055
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1056
+		if ($post_evt instanceof EE_Event) {
1057
+			// meta revision restore
1058
+			$post_evt->restore_revision($revision_id);
1059
+			// related objs restore
1060
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1061
+		}
1062
+	}
1063
+
1064
+
1065
+	/**
1066
+	 * Attach the venue to the Event
1067
+	 *
1068
+	 * @param  \EE_Event $evtobj Event Object to add the venue to
1069
+	 * @param  array     $data   The request data from the form
1070
+	 * @return bool           Success or fail.
1071
+	 */
1072
+	protected function _default_venue_update(\EE_Event $evtobj, $data)
1073
+	{
1074
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1075
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1076
+		$rows_affected = null;
1077
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1078
+		// very important.  If we don't have a venue name...
1079
+		// then we'll get out because not necessary to create empty venue
1080
+		if (empty($data['venue_title'])) {
1081
+			return false;
1082
+		}
1083
+		$venue_array = array(
1084
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1085
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1086
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1087
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1088
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1089
+				: null,
1090
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1091
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1092
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1093
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1094
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1095
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1096
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1097
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1098
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1099
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1100
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1101
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1102
+			'status'              => 'publish',
1103
+		);
1104
+		// if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1105
+		if (! empty($venue_id)) {
1106
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1107
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1108
+			// we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1109
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1110
+			return $rows_affected > 0 ? true : false;
1111
+		} else {
1112
+			// we insert the venue
1113
+			$venue_id = $venue_model->insert($venue_array);
1114
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1115
+			return ! empty($venue_id) ? true : false;
1116
+		}
1117
+		// when we have the ancestor come in it's already been handled by the revision save.
1118
+	}
1119
+
1120
+
1121
+	/**
1122
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1123
+	 *
1124
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
1125
+	 * @param  array    $data   The request data from the form
1126
+	 * @return array
1127
+	 */
1128
+	protected function _default_tickets_update(EE_Event $evtobj, $data)
1129
+	{
1130
+		$success = true;
1131
+		$saved_dtt = null;
1132
+		$saved_tickets = array();
1133
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1134
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1135
+			// trim all values to ensure any excess whitespace is removed.
1136
+			$dtt = array_map('trim', $dtt);
1137
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1138
+				: $dtt['DTT_EVT_start'];
1139
+			$datetime_values = array(
1140
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1141
+				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1142
+				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1143
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1144
+				'DTT_order'     => $row,
1145
+			);
1146
+			// if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1147
+			if (! empty($dtt['DTT_ID'])) {
1148
+				$DTM = EE_Registry::instance()
1149
+								  ->load_model('Datetime', array($evtobj->get_timezone()))
1150
+								  ->get_one_by_ID($dtt['DTT_ID']);
1151
+				$DTM->set_date_format($incoming_date_formats[0]);
1152
+				$DTM->set_time_format($incoming_date_formats[1]);
1153
+				foreach ($datetime_values as $field => $value) {
1154
+					$DTM->set($field, $value);
1155
+				}
1156
+				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1157
+				$saved_dtts[ $DTM->ID() ] = $DTM;
1158
+			} else {
1159
+				$DTM = EE_Registry::instance()->load_class(
1160
+					'Datetime',
1161
+					array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1162
+					false,
1163
+					false
1164
+				);
1165
+				foreach ($datetime_values as $field => $value) {
1166
+					$DTM->set($field, $value);
1167
+				}
1168
+			}
1169
+			$DTM->save();
1170
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1171
+			// load DTT helper
1172
+			// before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1173
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1174
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1175
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1176
+				$DTT->save();
1177
+			}
1178
+			// now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1179
+			$saved_dtt = $DTT;
1180
+			$success = ! $success ? $success : $DTT;
1181
+			// if ANY of these updates fail then we want the appropriate global error message.
1182
+			// //todo this is actually sucky we need a better error message but this is what it is for now.
1183
+		}
1184
+		// no dtts get deleted so we don't do any of that logic here.
1185
+		// update tickets next
1186
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1187
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1188
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1189
+			$update_prices = false;
1190
+			$ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1191
+				? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1192
+			// trim inputs to ensure any excess whitespace is removed.
1193
+			$tkt = array_map('trim', $tkt);
1194
+			if (empty($tkt['TKT_start_date'])) {
1195
+				// let's use now in the set timezone.
1196
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1197
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1198
+			}
1199
+			if (empty($tkt['TKT_end_date'])) {
1200
+				// use the start date of the first datetime
1201
+				$dtt = $evtobj->first_datetime();
1202
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
1203
+					$incoming_date_formats[0],
1204
+					$incoming_date_formats[1]
1205
+				);
1206
+			}
1207
+			$TKT_values = array(
1208
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1209
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1210
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1211
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1212
+				'TKT_start_date'  => $tkt['TKT_start_date'],
1213
+				'TKT_end_date'    => $tkt['TKT_end_date'],
1214
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1215
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1216
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1217
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1218
+				'TKT_row'         => $row,
1219
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1220
+				'TKT_price'       => $ticket_price,
1221
+			);
1222
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1223
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1224
+				$TKT_values['TKT_ID'] = 0;
1225
+				$TKT_values['TKT_is_default'] = 0;
1226
+				$TKT_values['TKT_price'] = $ticket_price;
1227
+				$update_prices = true;
1228
+			}
1229
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
1230
+			// we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1231
+			// keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1232
+			if (! empty($tkt['TKT_ID'])) {
1233
+				$TKT = EE_Registry::instance()
1234
+								  ->load_model('Ticket', array($evtobj->get_timezone()))
1235
+								  ->get_one_by_ID($tkt['TKT_ID']);
1236
+				if ($TKT instanceof EE_Ticket) {
1237
+					$ticket_sold = $TKT->count_related(
1238
+						'Registration',
1239
+						array(
1240
+							array(
1241
+								'STS_ID' => array(
1242
+									'NOT IN',
1243
+									array(EEM_Registration::status_id_incomplete),
1244
+								),
1245
+							),
1246
+						)
1247
+					) > 0 ? true : false;
1248
+					// let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1249
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1250
+									  && ! $TKT->get('TKT_deleted');
1251
+					$TKT->set_date_format($incoming_date_formats[0]);
1252
+					$TKT->set_time_format($incoming_date_formats[1]);
1253
+					// set new values
1254
+					foreach ($TKT_values as $field => $value) {
1255
+						if ($field == 'TKT_qty') {
1256
+							$TKT->set_qty($value);
1257
+						} else {
1258
+							$TKT->set($field, $value);
1259
+						}
1260
+					}
1261
+					// if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1262
+					if ($create_new_TKT) {
1263
+						// archive the old ticket first
1264
+						$TKT->set('TKT_deleted', 1);
1265
+						$TKT->save();
1266
+						// make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1267
+						$saved_tickets[ $TKT->ID() ] = $TKT;
1268
+						// create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1269
+						$TKT = clone $TKT;
1270
+						$TKT->set('TKT_ID', 0);
1271
+						$TKT->set('TKT_deleted', 0);
1272
+						$TKT->set('TKT_price', $ticket_price);
1273
+						$TKT->set('TKT_sold', 0);
1274
+						// now we need to make sure that $new prices are created as well and attached to new ticket.
1275
+						$update_prices = true;
1276
+					}
1277
+					// make sure price is set if it hasn't been already
1278
+					$TKT->set('TKT_price', $ticket_price);
1279
+				}
1280
+			} else {
1281
+				// no TKT_id so a new TKT
1282
+				$TKT_values['TKT_price'] = $ticket_price;
1283
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1284
+				if ($TKT instanceof EE_Ticket) {
1285
+					// need to reset values to properly account for the date formats
1286
+					$TKT->set_date_format($incoming_date_formats[0]);
1287
+					$TKT->set_time_format($incoming_date_formats[1]);
1288
+					$TKT->set_timezone($evtobj->get_timezone());
1289
+					// set new values
1290
+					foreach ($TKT_values as $field => $value) {
1291
+						if ($field == 'TKT_qty') {
1292
+							$TKT->set_qty($value);
1293
+						} else {
1294
+							$TKT->set($field, $value);
1295
+						}
1296
+					}
1297
+					$update_prices = true;
1298
+				}
1299
+			}
1300
+			// cap ticket qty by datetime reg limits
1301
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1302
+			// update ticket.
1303
+			$TKT->save();
1304
+			// before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1305
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1306
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1307
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1308
+				$TKT->save();
1309
+			}
1310
+			// initially let's add the ticket to the dtt
1311
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1312
+			$saved_tickets[ $TKT->ID() ] = $TKT;
1313
+			// add prices to ticket
1314
+			$this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1315
+		}
1316
+		// however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1317
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1318
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1319
+		foreach ($tickets_removed as $id) {
1320
+			$id = absint($id);
1321
+			// get the ticket for this id
1322
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1323
+			// need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1324
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1325
+			foreach ($dtts as $dtt) {
1326
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1327
+			}
1328
+			// need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1329
+			$tkt_to_remove->delete_related_permanently('Price');
1330
+			// finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1331
+			$tkt_to_remove->delete_permanently();
1332
+		}
1333
+		return array($saved_dtt, $saved_tickets);
1334
+	}
1335
+
1336
+
1337
+	/**
1338
+	 * This attaches a list of given prices to a ticket.
1339
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1340
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1341
+	 * price info and prices are automatically "archived" via the ticket.
1342
+	 *
1343
+	 * @access  private
1344
+	 * @param array     $prices     Array of prices from the form.
1345
+	 * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1346
+	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1347
+	 * @return  void
1348
+	 */
1349
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1350
+	{
1351
+		foreach ($prices as $row => $prc) {
1352
+			$PRC_values = array(
1353
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1354
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1355
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1356
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1357
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1358
+				'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1359
+				'PRC_order'      => $row,
1360
+			);
1361
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1362
+				$PRC_values['PRC_ID'] = 0;
1363
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1364
+			} else {
1365
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1366
+				// update this price with new values
1367
+				foreach ($PRC_values as $field => $newprc) {
1368
+					$PRC->set($field, $newprc);
1369
+				}
1370
+				$PRC->save();
1371
+			}
1372
+			$ticket->_add_relation_to($PRC, 'Price');
1373
+		}
1374
+	}
1375
+
1376
+
1377
+	/**
1378
+	 * Add in our autosave ajax handlers
1379
+	 *
1380
+	 */
1381
+	protected function _ee_autosave_create_new()
1382
+	{
1383
+	}
1384
+
1385
+
1386
+	/**
1387
+	 * More autosave handlers.
1388
+	 */
1389
+	protected function _ee_autosave_edit()
1390
+	{
1391
+		return; // TEMPORARILY EXITING CAUSE THIS IS A TODO
1392
+	}
1393
+
1394
+
1395
+	/**
1396
+	 *    _generate_publish_box_extra_content
1397
+	 */
1398
+	private function _generate_publish_box_extra_content()
1399
+	{
1400
+		// load formatter helper
1401
+		// args for getting related registrations
1402
+		$approved_query_args = array(
1403
+			array(
1404
+				'REG_deleted' => 0,
1405
+				'STS_ID'      => EEM_Registration::status_id_approved,
1406
+			),
1407
+		);
1408
+		$not_approved_query_args = array(
1409
+			array(
1410
+				'REG_deleted' => 0,
1411
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1412
+			),
1413
+		);
1414
+		$pending_payment_query_args = array(
1415
+			array(
1416
+				'REG_deleted' => 0,
1417
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1418
+			),
1419
+		);
1420
+		// publish box
1421
+		$publish_box_extra_args = array(
1422
+			'view_approved_reg_url'        => add_query_arg(
1423
+				array(
1424
+					'action'      => 'default',
1425
+					'event_id'    => $this->_cpt_model_obj->ID(),
1426
+					'_reg_status' => EEM_Registration::status_id_approved,
1427
+				),
1428
+				REG_ADMIN_URL
1429
+			),
1430
+			'view_not_approved_reg_url'    => add_query_arg(
1431
+				array(
1432
+					'action'      => 'default',
1433
+					'event_id'    => $this->_cpt_model_obj->ID(),
1434
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1435
+				),
1436
+				REG_ADMIN_URL
1437
+			),
1438
+			'view_pending_payment_reg_url' => add_query_arg(
1439
+				array(
1440
+					'action'      => 'default',
1441
+					'event_id'    => $this->_cpt_model_obj->ID(),
1442
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1443
+				),
1444
+				REG_ADMIN_URL
1445
+			),
1446
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1447
+				'Registration',
1448
+				$approved_query_args
1449
+			),
1450
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1451
+				'Registration',
1452
+				$not_approved_query_args
1453
+			),
1454
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1455
+				'Registration',
1456
+				$pending_payment_query_args
1457
+			),
1458
+			'misc_pub_section_class'       => apply_filters(
1459
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1460
+				'misc-pub-section'
1461
+			),
1462
+		);
1463
+		ob_start();
1464
+		do_action(
1465
+			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1466
+			$this->_cpt_model_obj
1467
+		);
1468
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1469
+		// load template
1470
+		EEH_Template::display_template(
1471
+			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1472
+			$publish_box_extra_args
1473
+		);
1474
+	}
1475
+
1476
+
1477
+	/**
1478
+	 * @return EE_Event
1479
+	 */
1480
+	public function get_event_object()
1481
+	{
1482
+		return $this->_cpt_model_obj;
1483
+	}
1484
+
1485
+
1486
+
1487
+
1488
+	/** METABOXES * */
1489
+	/**
1490
+	 * _register_event_editor_meta_boxes
1491
+	 * add all metaboxes related to the event_editor
1492
+	 *
1493
+	 * @return void
1494
+	 */
1495
+	protected function _register_event_editor_meta_boxes()
1496
+	{
1497
+		$this->verify_cpt_object();
1498
+		add_meta_box(
1499
+			'espresso_event_editor_tickets',
1500
+			esc_html__('Event Datetime & Ticket', 'event_espresso'),
1501
+			array($this, 'ticket_metabox'),
1502
+			$this->page_slug,
1503
+			'normal',
1504
+			'high'
1505
+		);
1506
+		add_meta_box(
1507
+			'espresso_event_editor_event_options',
1508
+			esc_html__('Event Registration Options', 'event_espresso'),
1509
+			array($this, 'registration_options_meta_box'),
1510
+			$this->page_slug,
1511
+			'side',
1512
+			'default'
1513
+		);
1514
+		// NOTE: if you're looking for other metaboxes in here,
1515
+		// where a metabox has a related management page in the admin
1516
+		// you will find it setup in the related management page's "_Hooks" file.
1517
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1518
+	}
1519
+
1520
+
1521
+	/**
1522
+	 * @throws DomainException
1523
+	 * @throws EE_Error
1524
+	 */
1525
+	public function ticket_metabox()
1526
+	{
1527
+		$existing_datetime_ids = $existing_ticket_ids = array();
1528
+		// defaults for template args
1529
+		$template_args = array(
1530
+			'existing_datetime_ids'    => '',
1531
+			'event_datetime_help_link' => '',
1532
+			'ticket_options_help_link' => '',
1533
+			'time'                     => null,
1534
+			'ticket_rows'              => '',
1535
+			'existing_ticket_ids'      => '',
1536
+			'total_ticket_rows'        => 1,
1537
+			'ticket_js_structure'      => '',
1538
+			'trash_icon'               => 'ee-lock-icon',
1539
+			'disabled'                 => '',
1540
+		);
1541
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1542
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1543
+		/**
1544
+		 * 1. Start with retrieving Datetimes
1545
+		 * 2. Fore each datetime get related tickets
1546
+		 * 3. For each ticket get related prices
1547
+		 */
1548
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1549
+		/** @type EE_Datetime $first_datetime */
1550
+		$first_datetime = reset($times);
1551
+		// do we get related tickets?
1552
+		if ($first_datetime instanceof EE_Datetime
1553
+			&& $first_datetime->ID() !== 0
1554
+		) {
1555
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1556
+			$template_args['time'] = $first_datetime;
1557
+			$related_tickets = $first_datetime->tickets(
1558
+				array(
1559
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1560
+					'default_where_conditions' => 'none',
1561
+				)
1562
+			);
1563
+			if (! empty($related_tickets)) {
1564
+				$template_args['total_ticket_rows'] = count($related_tickets);
1565
+				$row = 0;
1566
+				foreach ($related_tickets as $ticket) {
1567
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1568
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1569
+					$row++;
1570
+				}
1571
+			} else {
1572
+				$template_args['total_ticket_rows'] = 1;
1573
+				/** @type EE_Ticket $ticket */
1574
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1575
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1576
+			}
1577
+		} else {
1578
+			$template_args['time'] = $times[0];
1579
+			/** @type EE_Ticket $ticket */
1580
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1581
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1582
+			// NOTE: we're just sending the first default row
1583
+			// (decaf can't manage default tickets so this should be sufficient);
1584
+		}
1585
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1586
+			'event_editor_event_datetimes_help_tab'
1587
+		);
1588
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1589
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1590
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1591
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1592
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1593
+			true
1594
+		);
1595
+		$template = apply_filters(
1596
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1597
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1598
+		);
1599
+		EEH_Template::display_template($template, $template_args);
1600
+	}
1601
+
1602
+
1603
+	/**
1604
+	 * Setup an individual ticket form for the decaf event editor page
1605
+	 *
1606
+	 * @access private
1607
+	 * @param  EE_Ticket $ticket   the ticket object
1608
+	 * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1609
+	 * @param int        $row
1610
+	 * @return string generated html for the ticket row.
1611
+	 */
1612
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1613
+	{
1614
+		$template_args = array(
1615
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1616
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1617
+				: '',
1618
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1619
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1620
+			'TKT_name'            => $ticket->get('TKT_name'),
1621
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1622
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1623
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1624
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1625
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1626
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1627
+			'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1628
+									 && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1629
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1630
+			'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1631
+				: ' disabled=disabled',
1632
+		);
1633
+		$price = $ticket->ID() !== 0
1634
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1635
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1636
+		$price_args = array(
1637
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1638
+			'PRC_amount'            => $price->get('PRC_amount'),
1639
+			'PRT_ID'                => $price->get('PRT_ID'),
1640
+			'PRC_ID'                => $price->get('PRC_ID'),
1641
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1642
+		);
1643
+		// make sure we have default start and end dates if skeleton
1644
+		// handle rows that should NOT be empty
1645
+		if (empty($template_args['TKT_start_date'])) {
1646
+			// if empty then the start date will be now.
1647
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1648
+		}
1649
+		if (empty($template_args['TKT_end_date'])) {
1650
+			// get the earliest datetime (if present);
1651
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1652
+				? $this->_cpt_model_obj->get_first_related(
1653
+					'Datetime',
1654
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1655
+				)
1656
+				: null;
1657
+			if (! empty($earliest_dtt)) {
1658
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1659
+			} else {
1660
+				$template_args['TKT_end_date'] = date(
1661
+					'Y-m-d h:i a',
1662
+					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1663
+				);
1664
+			}
1665
+		}
1666
+		$template_args = array_merge($template_args, $price_args);
1667
+		$template = apply_filters(
1668
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1669
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1670
+			$ticket
1671
+		);
1672
+		return EEH_Template::display_template($template, $template_args, true);
1673
+	}
1674
+
1675
+
1676
+	/**
1677
+	 * @throws DomainException
1678
+	 */
1679
+	public function registration_options_meta_box()
1680
+	{
1681
+		$yes_no_values = array(
1682
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1683
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1684
+		);
1685
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1686
+			array(
1687
+				EEM_Registration::status_id_cancelled,
1688
+				EEM_Registration::status_id_declined,
1689
+				EEM_Registration::status_id_incomplete,
1690
+			),
1691
+			true
1692
+		);
1693
+		// $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1694
+		$template_args['_event'] = $this->_cpt_model_obj;
1695
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1696
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1697
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1698
+			'default_reg_status',
1699
+			$default_reg_status_values,
1700
+			$this->_cpt_model_obj->default_registration_status()
1701
+		);
1702
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
1703
+			'display_desc',
1704
+			$yes_no_values,
1705
+			$this->_cpt_model_obj->display_description()
1706
+		);
1707
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1708
+			'display_ticket_selector',
1709
+			$yes_no_values,
1710
+			$this->_cpt_model_obj->display_ticket_selector(),
1711
+			'',
1712
+			'',
1713
+			false
1714
+		);
1715
+		$template_args['additional_registration_options'] = apply_filters(
1716
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1717
+			'',
1718
+			$template_args,
1719
+			$yes_no_values,
1720
+			$default_reg_status_values
1721
+		);
1722
+		EEH_Template::display_template(
1723
+			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1724
+			$template_args
1725
+		);
1726
+	}
1727
+
1728
+
1729
+	/**
1730
+	 * _get_events()
1731
+	 * This method simply returns all the events (for the given _view and paging)
1732
+	 *
1733
+	 * @access public
1734
+	 * @param int  $per_page     count of items per page (20 default);
1735
+	 * @param int  $current_page what is the current page being viewed.
1736
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1737
+	 *                           If FALSE then we return an array of event objects
1738
+	 *                           that match the given _view and paging parameters.
1739
+	 * @return array an array of event objects.
1740
+	 */
1741
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1742
+	{
1743
+		$EEME = $this->_event_model();
1744
+		$offset = ($current_page - 1) * $per_page;
1745
+		$limit = $count ? null : $offset . ',' . $per_page;
1746
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1747
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1748
+		if (isset($this->_req_data['month_range'])) {
1749
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1750
+			// simulate the FIRST day of the month, that fixes issues for months like February
1751
+			// where PHP doesn't know what to assume for date.
1752
+			// @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1753
+			$month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1754
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1755
+		}
1756
+		$where = array();
1757
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1758
+		// determine what post_status our condition will have for the query.
1759
+		switch ($status) {
1760
+			case 'month':
1761
+			case 'today':
1762
+			case null:
1763
+			case 'all':
1764
+				break;
1765
+			case 'draft':
1766
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1767
+				break;
1768
+			default:
1769
+				$where['status'] = $status;
1770
+		}
1771
+		// categories?
1772
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1773
+			? $this->_req_data['EVT_CAT'] : null;
1774
+		if (! empty($category)) {
1775
+			$where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1776
+			$where['Term_Taxonomy.term_id'] = $category;
1777
+		}
1778
+		// date where conditions
1779
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1780
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1781
+			$DateTime = new DateTime(
1782
+				$year_r . '-' . $month_r . '-01 00:00:00',
1783
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1784
+			);
1785
+			$start = $DateTime->format(implode(' ', $start_formats));
1786
+			$end = $DateTime->setDate(
1787
+				$year_r,
1788
+				$month_r,
1789
+				$DateTime
1790
+					->format('t')
1791
+			)->setTime(23, 59, 59)
1792
+							->format(implode(' ', $start_formats));
1793
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1794
+		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1795
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1796
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1797
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1798
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1799
+		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1800
+			$now = date('Y-m-01');
1801
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1802
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1803
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1804
+							->setTime(23, 59, 59)
1805
+							->format(implode(' ', $start_formats));
1806
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1807
+		}
1808
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1809
+			$where['EVT_wp_user'] = get_current_user_id();
1810
+		} else {
1811
+			if (! isset($where['status'])) {
1812
+				if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1813
+					$where['OR'] = array(
1814
+						'status*restrict_private' => array('!=', 'private'),
1815
+						'AND'                     => array(
1816
+							'status*inclusive' => array('=', 'private'),
1817
+							'EVT_wp_user'      => get_current_user_id(),
1818
+						),
1819
+					);
1820
+				}
1821
+			}
1822
+		}
1823
+		if (isset($this->_req_data['EVT_wp_user'])) {
1824
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1825
+				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1826
+			) {
1827
+				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1828
+			}
1829
+		}
1830
+		// search query handling
1831
+		if (isset($this->_req_data['s'])) {
1832
+			$search_string = '%' . $this->_req_data['s'] . '%';
1833
+			$where['OR'] = array(
1834
+				'EVT_name'       => array('LIKE', $search_string),
1835
+				'EVT_desc'       => array('LIKE', $search_string),
1836
+				'EVT_short_desc' => array('LIKE', $search_string),
1837
+			);
1838
+		}
1839
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1840
+		$query_params = apply_filters(
1841
+			'FHEE__Events_Admin_Page__get_events__query_params',
1842
+			array(
1843
+				$where,
1844
+				'limit'    => $limit,
1845
+				'order_by' => $orderby,
1846
+				'order'    => $order,
1847
+				'group_by' => 'EVT_ID',
1848
+			),
1849
+			$this->_req_data
1850
+		);
1851
+		// let's first check if we have special requests coming in.
1852
+		if (isset($this->_req_data['active_status'])) {
1853
+			switch ($this->_req_data['active_status']) {
1854
+				case 'upcoming':
1855
+					return $EEME->get_upcoming_events($query_params, $count);
1856
+					break;
1857
+				case 'expired':
1858
+					return $EEME->get_expired_events($query_params, $count);
1859
+					break;
1860
+				case 'active':
1861
+					return $EEME->get_active_events($query_params, $count);
1862
+					break;
1863
+				case 'inactive':
1864
+					return $EEME->get_inactive_events($query_params, $count);
1865
+					break;
1866
+			}
1867
+		}
1868
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1869
+		return $events;
1870
+	}
1871
+
1872
+
1873
+	/**
1874
+	 * handling for WordPress CPT actions (trash, restore, delete)
1875
+	 *
1876
+	 * @param string $post_id
1877
+	 */
1878
+	public function trash_cpt_item($post_id)
1879
+	{
1880
+		$this->_req_data['EVT_ID'] = $post_id;
1881
+		$this->_trash_or_restore_event('trash', false);
1882
+	}
1883
+
1884
+
1885
+	/**
1886
+	 * @param string $post_id
1887
+	 */
1888
+	public function restore_cpt_item($post_id)
1889
+	{
1890
+		$this->_req_data['EVT_ID'] = $post_id;
1891
+		$this->_trash_or_restore_event('draft', false);
1892
+	}
1893
+
1894
+
1895
+	/**
1896
+	 * @param string $post_id
1897
+	 */
1898
+	public function delete_cpt_item($post_id)
1899
+	{
1900
+		$this->_req_data['EVT_ID'] = $post_id;
1901
+		$this->_delete_event(false);
1902
+	}
1903
+
1904
+
1905
+	/**
1906
+	 * _trash_or_restore_event
1907
+	 *
1908
+	 * @access protected
1909
+	 * @param  string $event_status
1910
+	 * @param bool    $redirect_after
1911
+	 */
1912
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1913
+	{
1914
+		// determine the event id and set to array.
1915
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1916
+		// loop thru events
1917
+		if ($EVT_ID) {
1918
+			// clean status
1919
+			$event_status = sanitize_key($event_status);
1920
+			// grab status
1921
+			if (! empty($event_status)) {
1922
+				$success = $this->_change_event_status($EVT_ID, $event_status);
1923
+			} else {
1924
+				$success = false;
1925
+				$msg = esc_html__(
1926
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1927
+					'event_espresso'
1928
+				);
1929
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1930
+			}
1931
+		} else {
1932
+			$success = false;
1933
+			$msg = esc_html__(
1934
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1935
+				'event_espresso'
1936
+			);
1937
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1938
+		}
1939
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1940
+		if ($redirect_after) {
1941
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1942
+		}
1943
+	}
1944
+
1945
+
1946
+	/**
1947
+	 * _trash_or_restore_events
1948
+	 *
1949
+	 * @access protected
1950
+	 * @param  string $event_status
1951
+	 * @return void
1952
+	 */
1953
+	protected function _trash_or_restore_events($event_status = 'trash')
1954
+	{
1955
+		// clean status
1956
+		$event_status = sanitize_key($event_status);
1957
+		// grab status
1958
+		if (! empty($event_status)) {
1959
+			$success = true;
1960
+			// determine the event id and set to array.
1961
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1962
+			// loop thru events
1963
+			foreach ($EVT_IDs as $EVT_ID) {
1964
+				if ($EVT_ID = absint($EVT_ID)) {
1965
+					$results = $this->_change_event_status($EVT_ID, $event_status);
1966
+					$success = $results !== false ? $success : false;
1967
+				} else {
1968
+					$msg = sprintf(
1969
+						esc_html__(
1970
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1971
+							'event_espresso'
1972
+						),
1973
+						$EVT_ID
1974
+					);
1975
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1976
+					$success = false;
1977
+				}
1978
+			}
1979
+		} else {
1980
+			$success = false;
1981
+			$msg = esc_html__(
1982
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1983
+				'event_espresso'
1984
+			);
1985
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1986
+		}
1987
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1988
+		$success = $success ? 2 : false;
1989
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1990
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1991
+	}
1992
+
1993
+
1994
+	/**
1995
+	 * _trash_or_restore_events
1996
+	 *
1997
+	 * @access  private
1998
+	 * @param  int    $EVT_ID
1999
+	 * @param  string $event_status
2000
+	 * @return bool
2001
+	 */
2002
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
2003
+	{
2004
+		// grab event id
2005
+		if (! $EVT_ID) {
2006
+			$msg = esc_html__(
2007
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2008
+				'event_espresso'
2009
+			);
2010
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2011
+			return false;
2012
+		}
2013
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2014
+		// clean status
2015
+		$event_status = sanitize_key($event_status);
2016
+		// grab status
2017
+		if (empty($event_status)) {
2018
+			$msg = esc_html__(
2019
+				'An error occurred. No Event Status or an invalid Event Status was received.',
2020
+				'event_espresso'
2021
+			);
2022
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2023
+			return false;
2024
+		}
2025
+		// was event trashed or restored ?
2026
+		switch ($event_status) {
2027
+			case 'draft':
2028
+				$action = 'restored from the trash';
2029
+				$hook = 'AHEE_event_restored_from_trash';
2030
+				break;
2031
+			case 'trash':
2032
+				$action = 'moved to the trash';
2033
+				$hook = 'AHEE_event_moved_to_trash';
2034
+				break;
2035
+			default:
2036
+				$action = 'updated';
2037
+				$hook = false;
2038
+		}
2039
+		// use class to change status
2040
+		$this->_cpt_model_obj->set_status($event_status);
2041
+		$success = $this->_cpt_model_obj->save();
2042
+		if ($success === false) {
2043
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2044
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2045
+			return false;
2046
+		}
2047
+		if ($hook) {
2048
+			do_action($hook);
2049
+		}
2050
+		return true;
2051
+	}
2052
+
2053
+
2054
+	/**
2055
+	 * _delete_event
2056
+	 *
2057
+	 * @access protected
2058
+	 * @param bool $redirect_after
2059
+	 */
2060
+	protected function _delete_event($redirect_after = true)
2061
+	{
2062
+		// determine the event id and set to array.
2063
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2064
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2065
+		// loop thru events
2066
+		if ($EVT_ID) {
2067
+			$success = $this->_permanently_delete_event($EVT_ID);
2068
+			// get list of events with no prices
2069
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2070
+			// remove this event from the list of events with no prices
2071
+			if (isset($espresso_no_ticket_prices[ $EVT_ID ])) {
2072
+				unset($espresso_no_ticket_prices[ $EVT_ID ]);
2073
+			}
2074
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2075
+		} else {
2076
+			$success = false;
2077
+			$msg = esc_html__(
2078
+				'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2079
+				'event_espresso'
2080
+			);
2081
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2082
+		}
2083
+		if ($redirect_after) {
2084
+			$this->_redirect_after_action(
2085
+				$success,
2086
+				'Event',
2087
+				'deleted',
2088
+				array('action' => 'default', 'status' => 'trash')
2089
+			);
2090
+		}
2091
+	}
2092
+
2093
+
2094
+	/**
2095
+	 * _delete_events
2096
+	 *
2097
+	 * @access protected
2098
+	 * @return void
2099
+	 */
2100
+	protected function _delete_events()
2101
+	{
2102
+		$success = true;
2103
+		// get list of events with no prices
2104
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2105
+		// determine the event id and set to array.
2106
+		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2107
+		// loop thru events
2108
+		foreach ($EVT_IDs as $EVT_ID) {
2109
+			$EVT_ID = absint($EVT_ID);
2110
+			if ($EVT_ID) {
2111
+				$results = $this->_permanently_delete_event($EVT_ID);
2112
+				$success = $results !== false ? $success : false;
2113
+				// remove this event from the list of events with no prices
2114
+				unset($espresso_no_ticket_prices[ $EVT_ID ]);
2115
+			} else {
2116
+				$success = false;
2117
+				$msg = esc_html__(
2118
+					'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2119
+					'event_espresso'
2120
+				);
2121
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2122
+			}
2123
+		}
2124
+		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2125
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2126
+		$success = $success ? 2 : false;
2127
+		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2128
+	}
2129
+
2130
+
2131
+	/**
2132
+	 * _permanently_delete_event
2133
+	 *
2134
+	 * @access  private
2135
+	 * @param  int $EVT_ID
2136
+	 * @return bool
2137
+	 */
2138
+	private function _permanently_delete_event($EVT_ID = 0)
2139
+	{
2140
+		// grab event id
2141
+		if (! $EVT_ID) {
2142
+			$msg = esc_html__(
2143
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2144
+				'event_espresso'
2145
+			);
2146
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2147
+			return false;
2148
+		}
2149
+		if (! $this->_cpt_model_obj instanceof EE_Event
2150
+			|| $this->_cpt_model_obj->ID() !== $EVT_ID
2151
+		) {
2152
+			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2153
+		}
2154
+		if (! $this->_cpt_model_obj instanceof EE_Event) {
2155
+			return false;
2156
+		}
2157
+		// need to delete related tickets and prices first.
2158
+		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2159
+		foreach ($datetimes as $datetime) {
2160
+			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2161
+			$tickets = $datetime->get_many_related('Ticket');
2162
+			foreach ($tickets as $ticket) {
2163
+				$ticket->_remove_relation_to($datetime, 'Datetime');
2164
+				$ticket->delete_related_permanently('Price');
2165
+				$ticket->delete_permanently();
2166
+			}
2167
+			$datetime->delete();
2168
+		}
2169
+		// what about related venues or terms?
2170
+		$venues = $this->_cpt_model_obj->get_many_related('Venue');
2171
+		foreach ($venues as $venue) {
2172
+			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2173
+		}
2174
+		// any attached question groups?
2175
+		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2176
+		if (! empty($question_groups)) {
2177
+			foreach ($question_groups as $question_group) {
2178
+				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2179
+			}
2180
+		}
2181
+		// Message Template Groups
2182
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2183
+		/** @type EE_Term_Taxonomy[] $term_taxonomies */
2184
+		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2185
+		foreach ($term_taxonomies as $term_taxonomy) {
2186
+			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2187
+		}
2188
+		$success = $this->_cpt_model_obj->delete_permanently();
2189
+		// did it all go as planned ?
2190
+		if ($success) {
2191
+			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2192
+			EE_Error::add_success($msg);
2193
+		} else {
2194
+			$msg = sprintf(
2195
+				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2196
+				$EVT_ID
2197
+			);
2198
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2199
+			return false;
2200
+		}
2201
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2202
+		return true;
2203
+	}
2204
+
2205
+
2206
+	/**
2207
+	 * get total number of events
2208
+	 *
2209
+	 * @access public
2210
+	 * @return int
2211
+	 */
2212
+	public function total_events()
2213
+	{
2214
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2215
+		return $count;
2216
+	}
2217
+
2218
+
2219
+	/**
2220
+	 * get total number of draft events
2221
+	 *
2222
+	 * @access public
2223
+	 * @return int
2224
+	 */
2225
+	public function total_events_draft()
2226
+	{
2227
+		$where = array(
2228
+			'status' => array('IN', array('draft', 'auto-draft')),
2229
+		);
2230
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2231
+		return $count;
2232
+	}
2233
+
2234
+
2235
+	/**
2236
+	 * get total number of trashed events
2237
+	 *
2238
+	 * @access public
2239
+	 * @return int
2240
+	 */
2241
+	public function total_trashed_events()
2242
+	{
2243
+		$where = array(
2244
+			'status' => 'trash',
2245
+		);
2246
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2247
+		return $count;
2248
+	}
2249
+
2250
+
2251
+	/**
2252
+	 *    _default_event_settings
2253
+	 *    This generates the Default Settings Tab
2254
+	 *
2255
+	 * @return void
2256
+	 * @throws EE_Error
2257
+	 */
2258
+	protected function _default_event_settings()
2259
+	{
2260
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2261
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2262
+		$this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2263
+		$this->display_admin_page_with_sidebar();
2264
+	}
2265
+
2266
+
2267
+	/**
2268
+	 * Return the form for event settings.
2269
+	 *
2270
+	 * @return EE_Form_Section_Proper
2271
+	 * @throws EE_Error
2272
+	 */
2273
+	protected function _default_event_settings_form()
2274
+	{
2275
+		$registration_config = EE_Registry::instance()->CFG->registration;
2276
+		$registration_stati_for_selection = EEM_Registration::reg_status_array(
2277
+			// exclude
2278
+			array(
2279
+				EEM_Registration::status_id_cancelled,
2280
+				EEM_Registration::status_id_declined,
2281
+				EEM_Registration::status_id_incomplete,
2282
+				EEM_Registration::status_id_wait_list,
2283
+			),
2284
+			true
2285
+		);
2286
+		return new EE_Form_Section_Proper(
2287
+			array(
2288
+				'name'            => 'update_default_event_settings',
2289
+				'html_id'         => 'update_default_event_settings',
2290
+				'html_class'      => 'form-table',
2291
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2292
+				'subsections'     => apply_filters(
2293
+					'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2294
+					array(
2295
+						'default_reg_status'  => new EE_Select_Input(
2296
+							$registration_stati_for_selection,
2297
+							array(
2298
+								'default'         => isset($registration_config->default_STS_ID)
2299
+													 && array_key_exists(
2300
+														 $registration_config->default_STS_ID,
2301
+														 $registration_stati_for_selection
2302
+													 )
2303
+									? sanitize_text_field($registration_config->default_STS_ID)
2304
+									: EEM_Registration::status_id_pending_payment,
2305
+								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2306
+													 . EEH_Template::get_help_tab_link(
2307
+														 'default_settings_status_help_tab'
2308
+													 ),
2309
+								'html_help_text'  => esc_html__(
2310
+									'This setting allows you to preselect what the default registration status setting is when creating an event.  Note that changing this setting does NOT retroactively apply it to existing events.',
2311
+									'event_espresso'
2312
+								),
2313
+							)
2314
+						),
2315
+						'default_max_tickets' => new EE_Integer_Input(
2316
+							array(
2317
+								'default'         => isset($registration_config->default_maximum_number_of_tickets)
2318
+									? $registration_config->default_maximum_number_of_tickets
2319
+									: EEM_Event::get_default_additional_limit(),
2320
+								'html_label_text' => esc_html__(
2321
+									'Default Maximum Tickets Allowed Per Order:',
2322
+									'event_espresso'
2323
+								)
2324
+													 . EEH_Template::get_help_tab_link(
2325
+														 'default_maximum_tickets_help_tab"'
2326
+													 ),
2327
+								'html_help_text'  => esc_html__(
2328
+									'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2329
+									'event_espresso'
2330
+								),
2331
+							)
2332
+						),
2333
+					)
2334
+				),
2335
+			)
2336
+		);
2337
+	}
2338
+
2339
+
2340
+	/**
2341
+	 * _update_default_event_settings
2342
+	 *
2343
+	 * @access protected
2344
+	 * @return void
2345
+	 * @throws EE_Error
2346
+	 */
2347
+	protected function _update_default_event_settings()
2348
+	{
2349
+		$registration_config = EE_Registry::instance()->CFG->registration;
2350
+		$form = $this->_default_event_settings_form();
2351
+		if ($form->was_submitted()) {
2352
+			$form->receive_form_submission();
2353
+			if ($form->is_valid()) {
2354
+				$valid_data = $form->valid_data();
2355
+				if (isset($valid_data['default_reg_status'])) {
2356
+					$registration_config->default_STS_ID = $valid_data['default_reg_status'];
2357
+				}
2358
+				if (isset($valid_data['default_max_tickets'])) {
2359
+					$registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2360
+				}
2361
+				// update because data was valid!
2362
+				EE_Registry::instance()->CFG->update_espresso_config();
2363
+				EE_Error::overwrite_success();
2364
+				EE_Error::add_success(
2365
+					__('Default Event Settings were updated', 'event_espresso')
2366
+				);
2367
+			}
2368
+		}
2369
+		$this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2370
+	}
2371
+
2372
+
2373
+	/*************        Templates        *************/
2374
+	protected function _template_settings()
2375
+	{
2376
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2377
+		$this->_template_args['preview_img'] = '<img src="'
2378
+											   . EVENTS_ASSETS_URL
2379
+											   . '/images/'
2380
+											   . 'caffeinated_template_features.jpg" alt="'
2381
+											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2382
+											   . '" />';
2383
+		$this->_template_args['preview_text'] = '<strong>'
2384
+												. esc_html__(
2385
+													'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2386
+													'event_espresso'
2387
+												) . '</strong>';
2388
+		$this->display_admin_caf_preview_page('template_settings_tab');
2389
+	}
2390
+
2391
+
2392
+	/** Event Category Stuff **/
2393
+	/**
2394
+	 * set the _category property with the category object for the loaded page.
2395
+	 *
2396
+	 * @access private
2397
+	 * @return void
2398
+	 */
2399
+	private function _set_category_object()
2400
+	{
2401
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2402
+			return;
2403
+		} //already have the category object so get out.
2404
+		// set default category object
2405
+		$this->_set_empty_category_object();
2406
+		// only set if we've got an id
2407
+		if (! isset($this->_req_data['EVT_CAT_ID'])) {
2408
+			return;
2409
+		}
2410
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2411
+		$term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2412
+		if (! empty($term)) {
2413
+			$this->_category->category_name = $term->name;
2414
+			$this->_category->category_identifier = $term->slug;
2415
+			$this->_category->category_desc = $term->description;
2416
+			$this->_category->id = $term->term_id;
2417
+			$this->_category->parent = $term->parent;
2418
+		}
2419
+	}
2420
+
2421
+
2422
+	/**
2423
+	 * Clears out category properties.
2424
+	 */
2425
+	private function _set_empty_category_object()
2426
+	{
2427
+		$this->_category = new stdClass();
2428
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2429
+		$this->_category->id = $this->_category->parent = 0;
2430
+	}
2431
+
2432
+
2433
+	/**
2434
+	 * @throws EE_Error
2435
+	 */
2436
+	protected function _category_list_table()
2437
+	{
2438
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2439
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2440
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2441
+			'add_category',
2442
+			'add_category',
2443
+			array(),
2444
+			'add-new-h2'
2445
+		);
2446
+		$this->display_admin_list_table_page_with_sidebar();
2447
+	}
2448
+
2449
+
2450
+	/**
2451
+	 * Output category details view.
2452
+	 */
2453
+	protected function _category_details($view)
2454
+	{
2455
+		// load formatter helper
2456
+		// load field generator helper
2457
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2458
+		$this->_set_add_edit_form_tags($route);
2459
+		$this->_set_category_object();
2460
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2461
+		$delete_action = 'delete_category';
2462
+		// custom redirect
2463
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2464
+			array('action' => 'category_list'),
2465
+			$this->_admin_base_url
2466
+		);
2467
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2468
+		// take care of contents
2469
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2470
+		$this->display_admin_page_with_sidebar();
2471
+	}
2472
+
2473
+
2474
+	/**
2475
+	 * Output category details content.
2476
+	 */
2477
+	protected function _category_details_content()
2478
+	{
2479
+		$editor_args['category_desc'] = array(
2480
+			'type'          => 'wp_editor',
2481
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2482
+			'class'         => 'my_editor_custom',
2483
+			'wpeditor_args' => array('media_buttons' => false),
2484
+		);
2485
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2486
+		$all_terms = get_terms(
2487
+			array(EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY),
2488
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2489
+		);
2490
+		// setup category select for term parents.
2491
+		$category_select_values[] = array(
2492
+			'text' => esc_html__('No Parent', 'event_espresso'),
2493
+			'id'   => 0,
2494
+		);
2495
+		foreach ($all_terms as $term) {
2496
+			$category_select_values[] = array(
2497
+				'text' => $term->name,
2498
+				'id'   => $term->term_id,
2499
+			);
2500
+		}
2501
+		$category_select = EEH_Form_Fields::select_input(
2502
+			'category_parent',
2503
+			$category_select_values,
2504
+			$this->_category->parent
2505
+		);
2506
+		$template_args = array(
2507
+			'category'                 => $this->_category,
2508
+			'category_select'          => $category_select,
2509
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2510
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2511
+			'disable'                  => '',
2512
+			'disabled_message'         => false,
2513
+		);
2514
+		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2515
+		return EEH_Template::display_template($template, $template_args, true);
2516
+	}
2517
+
2518
+
2519
+	/**
2520
+	 * Handles deleting categories.
2521
+	 */
2522
+	protected function _delete_categories()
2523
+	{
2524
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2525
+			: (array) $this->_req_data['category_id'];
2526
+		foreach ($cat_ids as $cat_id) {
2527
+			$this->_delete_category($cat_id);
2528
+		}
2529
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
2530
+		$query_args = array(
2531
+			'action' => 'category_list',
2532
+		);
2533
+		$this->_redirect_after_action(0, '', '', $query_args);
2534
+	}
2535
+
2536
+
2537
+	/**
2538
+	 * Handles deleting specific category.
2539
+	 *
2540
+	 * @param int $cat_id
2541
+	 */
2542
+	protected function _delete_category($cat_id)
2543
+	{
2544
+		$cat_id = absint($cat_id);
2545
+		wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2546
+	}
2547
+
2548
+
2549
+	/**
2550
+	 * Handles triggering the update or insertion of a new category.
2551
+	 *
2552
+	 * @param bool $new_category true means we're triggering the insert of a new category.
2553
+	 */
2554
+	protected function _insert_or_update_category($new_category)
2555
+	{
2556
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2557
+		$success = 0; // we already have a success message so lets not send another.
2558
+		if ($cat_id) {
2559
+			$query_args = array(
2560
+				'action'     => 'edit_category',
2561
+				'EVT_CAT_ID' => $cat_id,
2562
+			);
2563
+		} else {
2564
+			$query_args = array('action' => 'add_category');
2565
+		}
2566
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2567
+	}
2568
+
2569
+
2570
+	/**
2571
+	 * Inserts or updates category
2572
+	 *
2573
+	 * @param bool $update (true indicates we're updating a category).
2574
+	 * @return bool|mixed|string
2575
+	 */
2576
+	private function _insert_category($update = false)
2577
+	{
2578
+		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2579
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2580
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2581
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2582
+		if (empty($category_name)) {
2583
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2584
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2585
+			return false;
2586
+		}
2587
+		$term_args = array(
2588
+			'name'        => $category_name,
2589
+			'description' => $category_desc,
2590
+			'parent'      => $category_parent,
2591
+		);
2592
+		// was the category_identifier input disabled?
2593
+		if (isset($this->_req_data['category_identifier'])) {
2594
+			$term_args['slug'] = $this->_req_data['category_identifier'];
2595
+		}
2596
+		$insert_ids = $update
2597
+			? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2598
+			: wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2599
+		if (! is_array($insert_ids)) {
2600
+			$msg = esc_html__(
2601
+				'An error occurred and the category has not been saved to the database.',
2602
+				'event_espresso'
2603
+			);
2604
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2605
+		} else {
2606
+			$cat_id = $insert_ids['term_id'];
2607
+			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2608
+			EE_Error::add_success($msg);
2609
+		}
2610
+		return $cat_id;
2611
+	}
2612
+
2613
+
2614
+	/**
2615
+	 * Gets categories or count of categories matching the arguments in the request.
2616
+	 *
2617
+	 * @param int  $per_page
2618
+	 * @param int  $current_page
2619
+	 * @param bool $count
2620
+	 * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int
2621
+	 */
2622
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2623
+	{
2624
+		// testing term stuff
2625
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2626
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2627
+		$limit = ($current_page - 1) * $per_page;
2628
+		$where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2629
+		if (isset($this->_req_data['s'])) {
2630
+			$sstr = '%' . $this->_req_data['s'] . '%';
2631
+			$where['OR'] = array(
2632
+				'Term.name'   => array('LIKE', $sstr),
2633
+				'description' => array('LIKE', $sstr),
2634
+			);
2635
+		}
2636
+		$query_params = array(
2637
+			$where,
2638
+			'order_by'   => array($orderby => $order),
2639
+			'limit'      => $limit . ',' . $per_page,
2640
+			'force_join' => array('Term'),
2641
+		);
2642
+		$categories = $count
2643
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2644
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2645
+		return $categories;
2646
+	}
2647
+
2648
+	/* end category stuff */
2649
+	/**************/
2650
+
2651
+
2652
+	/**
2653
+	 * Callback for the `ee_save_timezone_setting` ajax action.
2654
+	 *
2655
+	 * @throws EE_Error
2656
+	 */
2657
+	public function save_timezonestring_setting()
2658
+	{
2659
+		$timezone_string = isset($this->_req_data['timezone_selected'])
2660
+			? $this->_req_data['timezone_selected']
2661
+			: '';
2662
+		if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2663
+			EE_Error::add_error(
2664
+				esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2665
+				__FILE__,
2666
+				__FUNCTION__,
2667
+				__LINE__
2668
+			);
2669
+			$this->_template_args['error'] = true;
2670
+			$this->_return_json();
2671
+		}
2672
+
2673
+		update_option('timezone_string', $timezone_string);
2674
+		EE_Error::add_success(
2675
+			esc_html__('Your timezone string was updated.', 'event_espresso')
2676
+		);
2677
+		$this->_template_args['success'] = true;
2678
+		$this->_return_json(true, array('action' => 'create_new'));
2679
+	}
2680 2680
 }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page_Init.core.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -17,39 +17,39 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    public function __construct()
21
-    {
22
-        // define some event categories related constants
23
-        define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
20
+	public function __construct()
21
+	{
22
+		// define some event categories related constants
23
+		define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
+		define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
+		define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
+		define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
27 27
 
28
-        parent::__construct();
29
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
30
-    }
28
+		parent::__construct();
29
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
30
+	}
31 31
 
32
-    protected function _set_init_properties()
33
-    {
34
-        $this->label = __('Event Venues', 'event_espresso');
35
-        $this->menu_label = __('Venues', 'event_espresso');
36
-        $this->menu_slug = EE_VENUES_PG_SLUG;
37
-    }
32
+	protected function _set_init_properties()
33
+	{
34
+		$this->label = __('Event Venues', 'event_espresso');
35
+		$this->menu_label = __('Venues', 'event_espresso');
36
+		$this->menu_slug = EE_VENUES_PG_SLUG;
37
+	}
38 38
 
39 39
 
40
-    protected function _set_menu_map()
41
-    {
42
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
43
-            array(
44
-                'menu_group'      => 'management',
45
-                'menu_order'      => 40,
46
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
-                'parent_slug'     => 'espresso_events',
48
-                'menu_slug'       => EE_VENUES_PG_SLUG,
49
-                'menu_label'      => __('Venues', 'event_espresso'),
50
-                'capability'      => 'ee_read_venues',
51
-                'admin_init_page' => $this,
52
-            )
53
-        );
54
-    }
40
+	protected function _set_menu_map()
41
+	{
42
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
43
+			array(
44
+				'menu_group'      => 'management',
45
+				'menu_order'      => 40,
46
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
+				'parent_slug'     => 'espresso_events',
48
+				'menu_slug'       => EE_VENUES_PG_SLUG,
49
+				'menu_label'      => __('Venues', 'event_espresso'),
50
+				'capability'      => 'ee_read_venues',
51
+				'admin_init_page' => $this,
52
+			)
53
+		);
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
     {
22 22
         // define some event categories related constants
23 23
         define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
24
+        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page='.EE_VENUES_PG_SLUG));
25
+        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL.'venues/assets/');
26
+        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES.'venues/templates/');
27 27
 
28 28
         parent::__construct();
29
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
29
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
30 30
     }
31 31
 
32 32
     protected function _set_init_properties()
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page_Init.core.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,52 +12,52 @@
 block discarded – undo
12 12
  */
13 13
 class Messages_Admin_Page_Init extends EE_Admin_Page_Init
14 14
 {
15
-    /**
16
-     *constructor
17
-     *
18
-     * @Constructor
19
-     * @access public
20
-     * @return void
21
-     */
22
-    public function __construct()
23
-    {
15
+	/**
16
+	 *constructor
17
+	 *
18
+	 * @Constructor
19
+	 * @access public
20
+	 * @return void
21
+	 */
22
+	public function __construct()
23
+	{
24 24
 
25
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
25
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26 26
 
27
-        if (! defined('EE_MSG_PG_SLUG')) {
28
-            define('EE_MSG_PG_SLUG', 'espresso_messages');
29
-            define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
36
-        }
27
+		if (! defined('EE_MSG_PG_SLUG')) {
28
+			define('EE_MSG_PG_SLUG', 'espresso_messages');
29
+			define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
+			define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
+			define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
+			define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
+			define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
+			define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
+			define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
36
+		}
37 37
 
38
-        parent::__construct();
39
-    }
38
+		parent::__construct();
39
+	}
40 40
 
41 41
 
42
-    protected function _set_init_properties()
43
-    {
44
-        $this->label = __('Messages System', 'event_espresso');
45
-    }
42
+	protected function _set_init_properties()
43
+	{
44
+		$this->label = __('Messages System', 'event_espresso');
45
+	}
46 46
 
47 47
 
48
-    protected function _set_menu_map()
49
-    {
50
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
51
-            array(
52
-                'menu_group'      => 'management',
53
-                'menu_order'      => 10,
54
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
55
-                'parent_slug'     => 'espresso_events',
56
-                'menu_slug'       => EE_MSG_PG_SLUG,
57
-                'menu_label'      => __('Messages', 'event_espresso'),
58
-                'capability'      => 'ee_read_global_messages',
59
-                'admin_init_page' => $this,
60
-            )
61
-        );
62
-    }
48
+	protected function _set_menu_map()
49
+	{
50
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
51
+			array(
52
+				'menu_group'      => 'management',
53
+				'menu_order'      => 10,
54
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
55
+				'parent_slug'     => 'espresso_events',
56
+				'menu_slug'       => EE_MSG_PG_SLUG,
57
+				'menu_label'      => __('Messages', 'event_espresso'),
58
+				'capability'      => 'ee_read_global_messages',
59
+				'admin_init_page' => $this,
60
+			)
61
+		);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26 26
 
27
-        if (! defined('EE_MSG_PG_SLUG')) {
27
+        if ( ! defined('EE_MSG_PG_SLUG')) {
28 28
             define('EE_MSG_PG_SLUG', 'espresso_messages');
29 29
             define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
30
+            define('EE_MSG_ADMIN', EE_ADMIN_PAGES.'messages/');
31
+            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page='.EE_MSG_PG_SLUG));
32
+            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN.'assets/');
33
+            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL.'messages/assets/');
34
+            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN.'templates/');
35
+            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'messages/templates/');
36 36
         }
37 37
 
38 38
         parent::__construct();
Please login to merge, or discard this patch.
admin_pages/registration_form/Registration_Form_Admin_Page_Init.core.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
18 18
 class Registration_Form_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20 20
 
21
-    public function __construct()
22
-    {
23
-        // define some constants
24
-        define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25
-        define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26
-        define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
34
-        parent::__construct();
35
-    }
21
+	public function __construct()
22
+	{
23
+		// define some constants
24
+		define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25
+		define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26
+		define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
+		define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
+		define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
+		define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
+		define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
+		define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
+		define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
+		define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
34
+		parent::__construct();
35
+	}
36 36
 
37
-    protected function _set_init_properties()
38
-    {
39
-        $this->label = __('Registration Form Overview', 'event_espresso');
40
-    }
37
+	protected function _set_init_properties()
38
+	{
39
+		$this->label = __('Registration Form Overview', 'event_espresso');
40
+	}
41 41
 
42 42
 
43
-    protected function _set_menu_map()
44
-    {
45
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
46
-            array(
47
-                'menu_group'      => 'management',
48
-                'menu_order'      => 30,
49
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
50
-                'parent_slug'     => 'espresso_events',
51
-                'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
52
-                'menu_label'      => __('Registration Form', 'event_espresso'),
53
-                'capability'      => 'ee_read_questions',
54
-                'admin_init_page' => $this,
55
-            )
56
-        );
57
-    }
43
+	protected function _set_menu_map()
44
+	{
45
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
46
+			array(
47
+				'menu_group'      => 'management',
48
+				'menu_order'      => 30,
49
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
50
+				'parent_slug'     => 'espresso_events',
51
+				'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
52
+				'menu_label'      => __('Registration Form', 'event_espresso'),
53
+				'capability'      => 'ee_read_questions',
54
+				'admin_init_page' => $this,
55
+			)
56
+		);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@
 block discarded – undo
24 24
         define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25 25
         define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26 26
         define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
27
+        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES.'registration_form/');
28
+        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
29
+        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
30
+        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN.'assets/');
31
+        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL.'registration_form/assets/');
32
+        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN.'templates/');
33
+        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registration_form/templates/');
34 34
         parent::__construct();
35 35
     }
36 36
 
Please login to merge, or discard this patch.
admin_pages/about/About_Admin_Page_Init.core.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,37 +14,37 @@
 block discarded – undo
14 14
 class About_Admin_Page_Init extends EE_Admin_Page_Init
15 15
 {
16 16
 
17
-    public function __construct()
18
-    {
19
-        // define some events related constants
20
-        define('EE_ABOUT_PG_SLUG', 'espresso_about');
21
-        define('EE_ABOUT_LABEL', __('About', 'event_espresso'));
22
-        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
-        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
-        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
-        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
26
-        parent::__construct();
27
-    }
17
+	public function __construct()
18
+	{
19
+		// define some events related constants
20
+		define('EE_ABOUT_PG_SLUG', 'espresso_about');
21
+		define('EE_ABOUT_LABEL', __('About', 'event_espresso'));
22
+		define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
+		define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
+		define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
+		define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
26
+		parent::__construct();
27
+	}
28 28
 
29
-    protected function _set_init_properties()
30
-    {
31
-        $this->label = __('About Event Espresso', 'event_espresso');
32
-    }
29
+	protected function _set_init_properties()
30
+	{
31
+		$this->label = __('About Event Espresso', 'event_espresso');
32
+	}
33 33
 
34
-    protected function _set_menu_map()
35
-    {
36
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
37
-            array(
38
-                'menu_group'              => 'extras',
39
-                'menu_order'              => 40,
40
-                'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
41
-                'parent_slug'             => 'espresso_events',
42
-                'menu_slug'               => 'espresso_about',
43
-                'menu_label'              => EE_ABOUT_LABEL,
44
-                'capability'              => 'manage_options',
45
-                'maintenance_mode_parent' => 'espresso_maintenance_settings',
46
-                'admin_init_page'         => $this,
47
-            )
48
-        );
49
-    }
34
+	protected function _set_menu_map()
35
+	{
36
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
37
+			array(
38
+				'menu_group'              => 'extras',
39
+				'menu_order'              => 40,
40
+				'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
41
+				'parent_slug'             => 'espresso_events',
42
+				'menu_slug'               => 'espresso_about',
43
+				'menu_label'              => EE_ABOUT_LABEL,
44
+				'capability'              => 'manage_options',
45
+				'maintenance_mode_parent' => 'espresso_maintenance_settings',
46
+				'admin_init_page'         => $this,
47
+			)
48
+		);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
         // define some events related constants
20 20
         define('EE_ABOUT_PG_SLUG', 'espresso_about');
21 21
         define('EE_ABOUT_LABEL', __('About', 'event_espresso'));
22
-        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
-        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
-        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
-        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
22
+        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES.'about/');
23
+        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page='.EE_ABOUT_PG_SLUG));
24
+        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN.'templates/');
25
+        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL.'about/assets/');
26 26
         parent::__construct();
27 27
     }
28 28
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3828 added lines, -3828 removed lines patch added patch discarded remove patch
@@ -19,2399 +19,2399 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    private static $_reg_status;
38
-
39
-    /**
40
-     * Form for displaying the custom questions for this registration.
41
-     * This gets used a few times throughout the request so its best to cache it
42
-     *
43
-     * @var EE_Registration_Custom_Questions_Form
44
-     */
45
-    protected $_reg_custom_questions_form = null;
46
-
47
-
48
-    /**
49
-     *        constructor
50
-     *
51
-     * @Constructor
52
-     * @access public
53
-     * @param bool $routing
54
-     * @return Registrations_Admin_Page
55
-     */
56
-    public function __construct($routing = true)
57
-    {
58
-        parent::__construct($routing);
59
-        add_action('wp_loaded', array($this, 'wp_loaded'));
60
-    }
61
-
62
-
63
-    public function wp_loaded()
64
-    {
65
-        // when adding a new registration...
66
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
-            EE_System::do_not_cache();
68
-            if (! isset($this->_req_data['processing_registration'])
69
-                || absint($this->_req_data['processing_registration']) !== 1
70
-            ) {
71
-                // and it's NOT the attendee information reg step
72
-                // force cookie expiration by setting time to last week
73
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
-                // and update the global
75
-                $_COOKIE['ee_registration_added'] = 0;
76
-            }
77
-        }
78
-    }
79
-
80
-
81
-    protected function _init_page_props()
82
-    {
83
-        $this->page_slug = REG_PG_SLUG;
84
-        $this->_admin_base_url = REG_ADMIN_URL;
85
-        $this->_admin_base_path = REG_ADMIN;
86
-        $this->page_label = esc_html__('Registrations', 'event_espresso');
87
-        $this->_cpt_routes = array(
88
-            'add_new_attendee' => 'espresso_attendees',
89
-            'edit_attendee'    => 'espresso_attendees',
90
-            'insert_attendee'  => 'espresso_attendees',
91
-            'update_attendee'  => 'espresso_attendees',
92
-        );
93
-        $this->_cpt_model_names = array(
94
-            'add_new_attendee' => 'EEM_Attendee',
95
-            'edit_attendee'    => 'EEM_Attendee',
96
-        );
97
-        $this->_cpt_edit_routes = array(
98
-            'espresso_attendees' => 'edit_attendee',
99
-        );
100
-        $this->_pagenow_map = array(
101
-            'add_new_attendee' => 'post-new.php',
102
-            'edit_attendee'    => 'post.php',
103
-            'trash'            => 'post.php',
104
-        );
105
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
-        // add filters so that the comment urls don't take users to a confusing 404 page
107
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
-    }
109
-
110
-
111
-    public function clear_comment_link($link, $comment, $args)
112
-    {
113
-        // gotta make sure this only happens on this route
114
-        $post_type = get_post_type($comment->comment_post_ID);
115
-        if ($post_type === 'espresso_attendees') {
116
-            return '#commentsdiv';
117
-        }
118
-        return $link;
119
-    }
120
-
121
-
122
-    protected function _ajax_hooks()
123
-    {
124
-        // todo: all hooks for registrations ajax goes in here
125
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
-    }
127
-
128
-
129
-    protected function _define_page_props()
130
-    {
131
-        $this->_admin_page_title = $this->page_label;
132
-        $this->_labels = array(
133
-            'buttons'                      => array(
134
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
-                'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
-                'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
-            ),
143
-            'publishbox'                   => array(
144
-                'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
-                'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
-            ),
147
-            'hide_add_button_on_cpt_route' => array(
148
-                'edit_attendee' => true,
149
-            ),
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     *        grab url requests and route them
156
-     *
157
-     * @access private
158
-     * @return void
159
-     */
160
-    public function _set_page_routes()
161
-    {
162
-        $this->_get_registration_status_array();
163
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
-            ? $this->_req_data['_REG_ID'] : 0;
165
-        $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
-            ? $this->_req_data['reg_status_change_form']['REG_ID']
167
-            : $reg_id;
168
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
-            ? $this->_req_data['ATT_ID'] : 0;
170
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
-            ? $this->_req_data['post']
172
-            : $att_id;
173
-        $this->_page_routes = array(
174
-            'default'                             => array(
175
-                'func'       => '_registrations_overview_list_table',
176
-                'capability' => 'ee_read_registrations',
177
-            ),
178
-            'view_registration'                   => array(
179
-                'func'       => '_registration_details',
180
-                'capability' => 'ee_read_registration',
181
-                'obj_id'     => $reg_id,
182
-            ),
183
-            'edit_registration'                   => array(
184
-                'func'               => '_update_attendee_registration_form',
185
-                'noheader'           => true,
186
-                'headers_sent_route' => 'view_registration',
187
-                'capability'         => 'ee_edit_registration',
188
-                'obj_id'             => $reg_id,
189
-                '_REG_ID'            => $reg_id,
190
-            ),
191
-            'trash_registrations'                 => array(
192
-                'func'       => '_trash_or_restore_registrations',
193
-                'args'       => array('trash' => true),
194
-                'noheader'   => true,
195
-                'capability' => 'ee_delete_registrations',
196
-            ),
197
-            'restore_registrations'               => array(
198
-                'func'       => '_trash_or_restore_registrations',
199
-                'args'       => array('trash' => false),
200
-                'noheader'   => true,
201
-                'capability' => 'ee_delete_registrations',
202
-            ),
203
-            'delete_registrations'                => array(
204
-                'func'       => '_delete_registrations',
205
-                'noheader'   => true,
206
-                'capability' => 'ee_delete_registrations',
207
-            ),
208
-            'new_registration'                    => array(
209
-                'func'       => 'new_registration',
210
-                'capability' => 'ee_edit_registrations',
211
-            ),
212
-            'process_reg_step'                    => array(
213
-                'func'       => 'process_reg_step',
214
-                'noheader'   => true,
215
-                'capability' => 'ee_edit_registrations',
216
-            ),
217
-            'redirect_to_txn'                     => array(
218
-                'func'       => 'redirect_to_txn',
219
-                'noheader'   => true,
220
-                'capability' => 'ee_edit_registrations',
221
-            ),
222
-            'change_reg_status'                   => array(
223
-                'func'       => '_change_reg_status',
224
-                'noheader'   => true,
225
-                'capability' => 'ee_edit_registration',
226
-                'obj_id'     => $reg_id,
227
-            ),
228
-            'approve_registration'                => array(
229
-                'func'       => 'approve_registration',
230
-                'noheader'   => true,
231
-                'capability' => 'ee_edit_registration',
232
-                'obj_id'     => $reg_id,
233
-            ),
234
-            'approve_and_notify_registration'     => array(
235
-                'func'       => 'approve_registration',
236
-                'noheader'   => true,
237
-                'args'       => array(true),
238
-                'capability' => 'ee_edit_registration',
239
-                'obj_id'     => $reg_id,
240
-            ),
241
-            'approve_registrations'               => array(
242
-                'func'       => 'bulk_action_on_registrations',
243
-                'noheader'   => true,
244
-                'capability' => 'ee_edit_registrations',
245
-                'args'       => array('approve'),
246
-            ),
247
-            'approve_and_notify_registrations'    => array(
248
-                'func'       => 'bulk_action_on_registrations',
249
-                'noheader'   => true,
250
-                'capability' => 'ee_edit_registrations',
251
-                'args'       => array('approve', true),
252
-            ),
253
-            'decline_registration'                => array(
254
-                'func'       => 'decline_registration',
255
-                'noheader'   => true,
256
-                'capability' => 'ee_edit_registration',
257
-                'obj_id'     => $reg_id,
258
-            ),
259
-            'decline_and_notify_registration'     => array(
260
-                'func'       => 'decline_registration',
261
-                'noheader'   => true,
262
-                'args'       => array(true),
263
-                'capability' => 'ee_edit_registration',
264
-                'obj_id'     => $reg_id,
265
-            ),
266
-            'decline_registrations'               => array(
267
-                'func'       => 'bulk_action_on_registrations',
268
-                'noheader'   => true,
269
-                'capability' => 'ee_edit_registrations',
270
-                'args'       => array('decline'),
271
-            ),
272
-            'decline_and_notify_registrations'    => array(
273
-                'func'       => 'bulk_action_on_registrations',
274
-                'noheader'   => true,
275
-                'capability' => 'ee_edit_registrations',
276
-                'args'       => array('decline', true),
277
-            ),
278
-            'pending_registration'                => array(
279
-                'func'       => 'pending_registration',
280
-                'noheader'   => true,
281
-                'capability' => 'ee_edit_registration',
282
-                'obj_id'     => $reg_id,
283
-            ),
284
-            'pending_and_notify_registration'     => array(
285
-                'func'       => 'pending_registration',
286
-                'noheader'   => true,
287
-                'args'       => array(true),
288
-                'capability' => 'ee_edit_registration',
289
-                'obj_id'     => $reg_id,
290
-            ),
291
-            'pending_registrations'               => array(
292
-                'func'       => 'bulk_action_on_registrations',
293
-                'noheader'   => true,
294
-                'capability' => 'ee_edit_registrations',
295
-                'args'       => array('pending'),
296
-            ),
297
-            'pending_and_notify_registrations'    => array(
298
-                'func'       => 'bulk_action_on_registrations',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-                'args'       => array('pending', true),
302
-            ),
303
-            'no_approve_registration'             => array(
304
-                'func'       => 'not_approve_registration',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registration',
307
-                'obj_id'     => $reg_id,
308
-            ),
309
-            'no_approve_and_notify_registration'  => array(
310
-                'func'       => 'not_approve_registration',
311
-                'noheader'   => true,
312
-                'args'       => array(true),
313
-                'capability' => 'ee_edit_registration',
314
-                'obj_id'     => $reg_id,
315
-            ),
316
-            'no_approve_registrations'            => array(
317
-                'func'       => 'bulk_action_on_registrations',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_registrations',
320
-                'args'       => array('not_approve'),
321
-            ),
322
-            'no_approve_and_notify_registrations' => array(
323
-                'func'       => 'bulk_action_on_registrations',
324
-                'noheader'   => true,
325
-                'capability' => 'ee_edit_registrations',
326
-                'args'       => array('not_approve', true),
327
-            ),
328
-            'cancel_registration'                 => array(
329
-                'func'       => 'cancel_registration',
330
-                'noheader'   => true,
331
-                'capability' => 'ee_edit_registration',
332
-                'obj_id'     => $reg_id,
333
-            ),
334
-            'cancel_and_notify_registration'      => array(
335
-                'func'       => 'cancel_registration',
336
-                'noheader'   => true,
337
-                'args'       => array(true),
338
-                'capability' => 'ee_edit_registration',
339
-                'obj_id'     => $reg_id,
340
-            ),
341
-            'cancel_registrations'                => array(
342
-                'func'       => 'bulk_action_on_registrations',
343
-                'noheader'   => true,
344
-                'capability' => 'ee_edit_registrations',
345
-                'args'       => array('cancel'),
346
-            ),
347
-            'cancel_and_notify_registrations'     => array(
348
-                'func'       => 'bulk_action_on_registrations',
349
-                'noheader'   => true,
350
-                'capability' => 'ee_edit_registrations',
351
-                'args'       => array('cancel', true),
352
-            ),
353
-            'wait_list_registration'              => array(
354
-                'func'       => 'wait_list_registration',
355
-                'noheader'   => true,
356
-                'capability' => 'ee_edit_registration',
357
-                'obj_id'     => $reg_id,
358
-            ),
359
-            'wait_list_and_notify_registration'   => array(
360
-                'func'       => 'wait_list_registration',
361
-                'noheader'   => true,
362
-                'args'       => array(true),
363
-                'capability' => 'ee_edit_registration',
364
-                'obj_id'     => $reg_id,
365
-            ),
366
-            'contact_list'                        => array(
367
-                'func'       => '_attendee_contact_list_table',
368
-                'capability' => 'ee_read_contacts',
369
-            ),
370
-            'add_new_attendee'                    => array(
371
-                'func' => '_create_new_cpt_item',
372
-                'args' => array(
373
-                    'new_attendee' => true,
374
-                    'capability'   => 'ee_edit_contacts',
375
-                ),
376
-            ),
377
-            'edit_attendee'                       => array(
378
-                'func'       => '_edit_cpt_item',
379
-                'capability' => 'ee_edit_contacts',
380
-                'obj_id'     => $att_id,
381
-            ),
382
-            'duplicate_attendee'                  => array(
383
-                'func'       => '_duplicate_attendee',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_contacts',
386
-                'obj_id'     => $att_id,
387
-            ),
388
-            'insert_attendee'                     => array(
389
-                'func'       => '_insert_or_update_attendee',
390
-                'args'       => array(
391
-                    'new_attendee' => true,
392
-                ),
393
-                'noheader'   => true,
394
-                'capability' => 'ee_edit_contacts',
395
-            ),
396
-            'update_attendee'                     => array(
397
-                'func'       => '_insert_or_update_attendee',
398
-                'args'       => array(
399
-                    'new_attendee' => false,
400
-                ),
401
-                'noheader'   => true,
402
-                'capability' => 'ee_edit_contacts',
403
-                'obj_id'     => $att_id,
404
-            ),
405
-            'trash_attendees'                     => array(
406
-                'func'       => '_trash_or_restore_attendees',
407
-                'args'       => array(
408
-                    'trash' => 'true',
409
-                ),
410
-                'noheader'   => true,
411
-                'capability' => 'ee_delete_contacts',
412
-            ),
413
-            'trash_attendee'                      => array(
414
-                'func'       => '_trash_or_restore_attendees',
415
-                'args'       => array(
416
-                    'trash' => true,
417
-                ),
418
-                'noheader'   => true,
419
-                'capability' => 'ee_delete_contacts',
420
-                'obj_id'     => $att_id,
421
-            ),
422
-            'restore_attendees'                   => array(
423
-                'func'       => '_trash_or_restore_attendees',
424
-                'args'       => array(
425
-                    'trash' => false,
426
-                ),
427
-                'noheader'   => true,
428
-                'capability' => 'ee_delete_contacts',
429
-                'obj_id'     => $att_id,
430
-            ),
431
-            'resend_registration'                 => array(
432
-                'func'       => '_resend_registration',
433
-                'noheader'   => true,
434
-                'capability' => 'ee_send_message',
435
-            ),
436
-            'registrations_report'                => array(
437
-                'func'       => '_registrations_report',
438
-                'noheader'   => true,
439
-                'capability' => 'ee_read_registrations',
440
-            ),
441
-            'contact_list_export'                 => array(
442
-                'func'       => '_contact_list_export',
443
-                'noheader'   => true,
444
-                'capability' => 'export',
445
-            ),
446
-            'contact_list_report'                 => array(
447
-                'func'       => '_contact_list_report',
448
-                'noheader'   => true,
449
-                'capability' => 'ee_read_contacts',
450
-            ),
451
-        );
452
-    }
453
-
454
-
455
-    protected function _set_page_config()
456
-    {
457
-        $this->_page_config = array(
458
-            'default'           => array(
459
-                'nav'           => array(
460
-                    'label' => esc_html__('Overview', 'event_espresso'),
461
-                    'order' => 5,
462
-                ),
463
-                'help_tabs'     => array(
464
-                    'registrations_overview_help_tab'                       => array(
465
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
-                        'filename' => 'registrations_overview',
467
-                    ),
468
-                    'registrations_overview_table_column_headings_help_tab' => array(
469
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
-                        'filename' => 'registrations_overview_table_column_headings',
471
-                    ),
472
-                    'registrations_overview_filters_help_tab'               => array(
473
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
-                        'filename' => 'registrations_overview_filters',
475
-                    ),
476
-                    'registrations_overview_views_help_tab'                 => array(
477
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
478
-                        'filename' => 'registrations_overview_views',
479
-                    ),
480
-                    'registrations_regoverview_other_help_tab'              => array(
481
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
-                        'filename' => 'registrations_overview_other',
483
-                    ),
484
-                ),
485
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
486
-                'qtips'         => array('Registration_List_Table_Tips'),
487
-                'list_table'    => 'EE_Registrations_List_Table',
488
-                'require_nonce' => false,
489
-            ),
490
-            'view_registration' => array(
491
-                'nav'           => array(
492
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
493
-                    'order'      => 15,
494
-                    'url'        => isset($this->_req_data['_REG_ID'])
495
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
-                        : $this->_admin_base_url,
497
-                    'persistent' => false,
498
-                ),
499
-                'help_tabs'     => array(
500
-                    'registrations_details_help_tab'                    => array(
501
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
502
-                        'filename' => 'registrations_details',
503
-                    ),
504
-                    'registrations_details_table_help_tab'              => array(
505
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
-                        'filename' => 'registrations_details_table',
507
-                    ),
508
-                    'registrations_details_form_answers_help_tab'       => array(
509
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
-                        'filename' => 'registrations_details_form_answers',
511
-                    ),
512
-                    'registrations_details_registrant_details_help_tab' => array(
513
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
514
-                        'filename' => 'registrations_details_registrant_details',
515
-                    ),
516
-                ),
517
-                'help_tour'     => array('Registration_Details_Help_Tour'),
518
-                'metaboxes'     => array_merge(
519
-                    $this->_default_espresso_metaboxes,
520
-                    array('_registration_details_metaboxes')
521
-                ),
522
-                'require_nonce' => false,
523
-            ),
524
-            'new_registration'  => array(
525
-                'nav'           => array(
526
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
-                    'url'        => '#',
528
-                    'order'      => 15,
529
-                    'persistent' => false,
530
-                ),
531
-                'metaboxes'     => $this->_default_espresso_metaboxes,
532
-                'labels'        => array(
533
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
-                ),
535
-                'require_nonce' => false,
536
-            ),
537
-            'add_new_attendee'  => array(
538
-                'nav'           => array(
539
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
540
-                    'order'      => 15,
541
-                    'persistent' => false,
542
-                ),
543
-                'metaboxes'     => array_merge(
544
-                    $this->_default_espresso_metaboxes,
545
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
546
-                ),
547
-                'require_nonce' => false,
548
-            ),
549
-            'edit_attendee'     => array(
550
-                'nav'           => array(
551
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
-                    'order'      => 15,
553
-                    'persistent' => false,
554
-                    'url'        => isset($this->_req_data['ATT_ID'])
555
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
-                        : $this->_admin_base_url,
557
-                ),
558
-                'metaboxes'     => array('attendee_editor_metaboxes'),
559
-                'require_nonce' => false,
560
-            ),
561
-            'contact_list'      => array(
562
-                'nav'           => array(
563
-                    'label' => esc_html__('Contact List', 'event_espresso'),
564
-                    'order' => 20,
565
-                ),
566
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
567
-                'help_tabs'     => array(
568
-                    'registrations_contact_list_help_tab'                       => array(
569
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
-                        'filename' => 'registrations_contact_list',
571
-                    ),
572
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
573
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
-                        'filename' => 'registrations_contact_list_table_column_headings',
575
-                    ),
576
-                    'registrations_contact_list_views_help_tab'                 => array(
577
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
-                        'filename' => 'registrations_contact_list_views',
579
-                    ),
580
-                    'registrations_contact_list_other_help_tab'                 => array(
581
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
-                        'filename' => 'registrations_contact_list_other',
583
-                    ),
584
-                ),
585
-                'help_tour'     => array('Contact_List_Help_Tour'),
586
-                'metaboxes'     => array(),
587
-                'require_nonce' => false,
588
-            ),
589
-            // override default cpt routes
590
-            'create_new'        => '',
591
-            'edit'              => '',
592
-        );
593
-    }
594
-
595
-
596
-    /**
597
-     * The below methods aren't used by this class currently
598
-     */
599
-    protected function _add_screen_options()
600
-    {
601
-    }
602
-
603
-
604
-    protected function _add_feature_pointers()
605
-    {
606
-    }
607
-
608
-
609
-    public function admin_init()
610
-    {
611
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
-            'click "Update Registration Questions" to save your changes',
613
-            'event_espresso'
614
-        );
615
-    }
616
-
617
-
618
-    public function admin_notices()
619
-    {
620
-    }
621
-
622
-
623
-    public function admin_footer_scripts()
624
-    {
625
-    }
626
-
627
-
628
-    /**
629
-     *        get list of registration statuses
630
-     *
631
-     * @access private
632
-     * @return void
633
-     * @throws EE_Error
634
-     */
635
-    private function _get_registration_status_array()
636
-    {
637
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
-    }
639
-
640
-
641
-    protected function _add_screen_options_default()
642
-    {
643
-        $this->_per_page_screen_option();
644
-    }
645
-
646
-
647
-    protected function _add_screen_options_contact_list()
648
-    {
649
-        $page_title = $this->_admin_page_title;
650
-        $this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
-        $this->_per_page_screen_option();
652
-        $this->_admin_page_title = $page_title;
653
-    }
654
-
655
-
656
-    public function load_scripts_styles()
657
-    {
658
-        // style
659
-        wp_register_style(
660
-            'espresso_reg',
661
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
-            array('ee-admin-css'),
663
-            EVENT_ESPRESSO_VERSION
664
-        );
665
-        wp_enqueue_style('espresso_reg');
666
-        // script
667
-        wp_register_script(
668
-            'espresso_reg',
669
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
-            EVENT_ESPRESSO_VERSION,
672
-            true
673
-        );
674
-        wp_enqueue_script('espresso_reg');
675
-    }
676
-
677
-
678
-    public function load_scripts_styles_edit_attendee()
679
-    {
680
-        // stuff to only show up on our attendee edit details page.
681
-        $attendee_details_translations = array(
682
-            'att_publish_text' => sprintf(
683
-                /* translators: The date and time */
684
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
685
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
686
-            ),
687
-        );
688
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
689
-        wp_enqueue_script('jquery-validate');
690
-    }
691
-
692
-
693
-    public function load_scripts_styles_view_registration()
694
-    {
695
-        // styles
696
-        wp_enqueue_style('espresso-ui-theme');
697
-        // scripts
698
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
699
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
700
-    }
701
-
702
-
703
-    public function load_scripts_styles_contact_list()
704
-    {
705
-        wp_dequeue_style('espresso_reg');
706
-        wp_register_style(
707
-            'espresso_att',
708
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
709
-            array('ee-admin-css'),
710
-            EVENT_ESPRESSO_VERSION
711
-        );
712
-        wp_enqueue_style('espresso_att');
713
-    }
714
-
715
-
716
-    public function load_scripts_styles_new_registration()
717
-    {
718
-        wp_register_script(
719
-            'ee-spco-for-admin',
720
-            REG_ASSETS_URL . 'spco_for_admin.js',
721
-            array('underscore', 'jquery'),
722
-            EVENT_ESPRESSO_VERSION,
723
-            true
724
-        );
725
-        wp_enqueue_script('ee-spco-for-admin');
726
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
727
-        EE_Form_Section_Proper::wp_enqueue_scripts();
728
-        EED_Ticket_Selector::load_tckt_slctr_assets();
729
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
730
-    }
731
-
732
-
733
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
734
-    {
735
-        add_filter('FHEE_load_EE_messages', '__return_true');
736
-    }
737
-
738
-
739
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
740
-    {
741
-        add_filter('FHEE_load_EE_messages', '__return_true');
742
-    }
743
-
744
-
745
-    protected function _set_list_table_views_default()
746
-    {
747
-        // for notification related bulk actions we need to make sure only active messengers have an option.
748
-        EED_Messages::set_autoloaders();
749
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
750
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
751
-        $active_mts = $message_resource_manager->list_of_active_message_types();
752
-        // key= bulk_action_slug, value= message type.
753
-        $match_array = array(
754
-            'approve_registrations'    => 'registration',
755
-            'decline_registrations'    => 'declined_registration',
756
-            'pending_registrations'    => 'pending_approval',
757
-            'no_approve_registrations' => 'not_approved_registration',
758
-            'cancel_registrations'     => 'cancelled_registration',
759
-        );
760
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
761
-            'ee_send_message',
762
-            'batch_send_messages'
763
-        );
764
-        /** setup reg status bulk actions **/
765
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
766
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
767
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
768
-                'Approve and Notify Registrations',
769
-                'event_espresso'
770
-            );
771
-        }
772
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
773
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
774
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
775
-                'Decline and Notify Registrations',
776
-                'event_espresso'
777
-            );
778
-        }
779
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
780
-            'Set Registrations to Pending Payment',
781
-            'event_espresso'
782
-        );
783
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
784
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
785
-                'Set Registrations to Pending Payment and Notify',
786
-                'event_espresso'
787
-            );
788
-        }
789
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
790
-            'Set Registrations to Not Approved',
791
-            'event_espresso'
792
-        );
793
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
794
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
795
-                'Set Registrations to Not Approved and Notify',
796
-                'event_espresso'
797
-            );
798
-        }
799
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
800
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
801
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
802
-                'Cancel Registrations and Notify',
803
-                'event_espresso'
804
-            );
805
-        }
806
-        $def_reg_status_actions = apply_filters(
807
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
808
-            $def_reg_status_actions,
809
-            $active_mts,
810
-            $can_send
811
-        );
812
-
813
-        $this->_views = array(
814
-            'all'   => array(
815
-                'slug'        => 'all',
816
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
817
-                'count'       => 0,
818
-                'bulk_action' => array_merge(
819
-                    $def_reg_status_actions,
820
-                    array(
821
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
822
-                    )
823
-                ),
824
-            ),
825
-            'month' => array(
826
-                'slug'        => 'month',
827
-                'label'       => esc_html__('This Month', 'event_espresso'),
828
-                'count'       => 0,
829
-                'bulk_action' => array_merge(
830
-                    $def_reg_status_actions,
831
-                    array(
832
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
833
-                    )
834
-                ),
835
-            ),
836
-            'today' => array(
837
-                'slug'        => 'today',
838
-                'label'       => sprintf(
839
-                    esc_html__('Today - %s', 'event_espresso'),
840
-                    date('M d, Y', current_time('timestamp'))
841
-                ),
842
-                'count'       => 0,
843
-                'bulk_action' => array_merge(
844
-                    $def_reg_status_actions,
845
-                    array(
846
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
847
-                    )
848
-                ),
849
-            ),
850
-        );
851
-        if (EE_Registry::instance()->CAP->current_user_can(
852
-            'ee_delete_registrations',
853
-            'espresso_registrations_delete_registration'
854
-        )) {
855
-            $this->_views['incomplete'] = array(
856
-                'slug'        => 'incomplete',
857
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
858
-                'count'       => 0,
859
-                'bulk_action' => array(
860
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
861
-                ),
862
-            );
863
-            $this->_views['trash'] = array(
864
-                'slug'        => 'trash',
865
-                'label'       => esc_html__('Trash', 'event_espresso'),
866
-                'count'       => 0,
867
-                'bulk_action' => array(
868
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
869
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
870
-                ),
871
-            );
872
-        }
873
-    }
874
-
875
-
876
-    protected function _set_list_table_views_contact_list()
877
-    {
878
-        $this->_views = array(
879
-            'in_use' => array(
880
-                'slug'        => 'in_use',
881
-                'label'       => esc_html__('In Use', 'event_espresso'),
882
-                'count'       => 0,
883
-                'bulk_action' => array(
884
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
885
-                ),
886
-            ),
887
-        );
888
-        if (EE_Registry::instance()->CAP->current_user_can(
889
-            'ee_delete_contacts',
890
-            'espresso_registrations_trash_attendees'
891
-        )
892
-        ) {
893
-            $this->_views['trash'] = array(
894
-                'slug'        => 'trash',
895
-                'label'       => esc_html__('Trash', 'event_espresso'),
896
-                'count'       => 0,
897
-                'bulk_action' => array(
898
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
899
-                ),
900
-            );
901
-        }
902
-    }
903
-
904
-
905
-    protected function _registration_legend_items()
906
-    {
907
-        $fc_items = array(
908
-            'star-icon'        => array(
909
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
910
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
911
-            ),
912
-            'view_details'     => array(
913
-                'class' => 'dashicons dashicons-clipboard',
914
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
915
-            ),
916
-            'edit_attendee'    => array(
917
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
918
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
919
-            ),
920
-            'view_transaction' => array(
921
-                'class' => 'dashicons dashicons-cart',
922
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
923
-            ),
924
-            'view_invoice'     => array(
925
-                'class' => 'dashicons dashicons-media-spreadsheet',
926
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
927
-            ),
928
-        );
929
-        if (EE_Registry::instance()->CAP->current_user_can(
930
-            'ee_send_message',
931
-            'espresso_registrations_resend_registration'
932
-        )) {
933
-            $fc_items['resend_registration'] = array(
934
-                'class' => 'dashicons dashicons-email-alt',
935
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
936
-            );
937
-        } else {
938
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
939
-        }
940
-        if (EE_Registry::instance()->CAP->current_user_can(
941
-            'ee_read_global_messages',
942
-            'view_filtered_messages'
943
-        )) {
944
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
945
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
946
-                $fc_items['view_related_messages'] = array(
947
-                    'class' => $related_for_icon['css_class'],
948
-                    'desc'  => $related_for_icon['label'],
949
-                );
950
-            }
951
-        }
952
-        $sc_items = array(
953
-            'approved_status'   => array(
954
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
955
-                'desc'  => EEH_Template::pretty_status(
956
-                    EEM_Registration::status_id_approved,
957
-                    false,
958
-                    'sentence'
959
-                ),
960
-            ),
961
-            'pending_status'    => array(
962
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
963
-                'desc'  => EEH_Template::pretty_status(
964
-                    EEM_Registration::status_id_pending_payment,
965
-                    false,
966
-                    'sentence'
967
-                ),
968
-            ),
969
-            'wait_list'         => array(
970
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
971
-                'desc'  => EEH_Template::pretty_status(
972
-                    EEM_Registration::status_id_wait_list,
973
-                    false,
974
-                    'sentence'
975
-                ),
976
-            ),
977
-            'incomplete_status' => array(
978
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
979
-                'desc'  => EEH_Template::pretty_status(
980
-                    EEM_Registration::status_id_incomplete,
981
-                    false,
982
-                    'sentence'
983
-                ),
984
-            ),
985
-            'not_approved'      => array(
986
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
987
-                'desc'  => EEH_Template::pretty_status(
988
-                    EEM_Registration::status_id_not_approved,
989
-                    false,
990
-                    'sentence'
991
-                ),
992
-            ),
993
-            'declined_status'   => array(
994
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
995
-                'desc'  => EEH_Template::pretty_status(
996
-                    EEM_Registration::status_id_declined,
997
-                    false,
998
-                    'sentence'
999
-                ),
1000
-            ),
1001
-            'cancelled_status'  => array(
1002
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1003
-                'desc'  => EEH_Template::pretty_status(
1004
-                    EEM_Registration::status_id_cancelled,
1005
-                    false,
1006
-                    'sentence'
1007
-                ),
1008
-            ),
1009
-        );
1010
-        return array_merge($fc_items, $sc_items);
1011
-    }
1012
-
1013
-
1014
-
1015
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1016
-    /**
1017
-     * @throws \EE_Error
1018
-     */
1019
-    protected function _registrations_overview_list_table()
1020
-    {
1021
-        $this->_template_args['admin_page_header'] = '';
1022
-        $EVT_ID = ! empty($this->_req_data['event_id'])
1023
-            ? absint($this->_req_data['event_id'])
1024
-            : 0;
1025
-        $ATT_ID = ! empty($this->_req_data['ATT_ID'])
1026
-            ? absint($this->_req_data['ATT_ID'])
1027
-            : 0;
1028
-        if ($ATT_ID) {
1029
-            $attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1030
-            if ($attendee instanceof EE_Attendee) {
1031
-                $this->_template_args['admin_page_header'] = sprintf(
1032
-                    esc_html__(
1033
-                        '%1$s Viewing registrations for %2$s%3$s',
1034
-                        'event_espresso'
1035
-                    ),
1036
-                    '<h3 style="line-height:1.5em;">',
1037
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1038
-                        array(
1039
-                            'action' => 'edit_attendee',
1040
-                            'post'   => $ATT_ID,
1041
-                        ),
1042
-                        REG_ADMIN_URL
1043
-                    ) . '">' . $attendee->full_name() . '</a>',
1044
-                    '</h3>'
1045
-                );
1046
-            }
1047
-        }
1048
-        if ($EVT_ID) {
1049
-            if (EE_Registry::instance()->CAP->current_user_can(
1050
-                'ee_edit_registrations',
1051
-                'espresso_registrations_new_registration',
1052
-                $EVT_ID
1053
-            )) {
1054
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1055
-                    'new_registration',
1056
-                    'add-registrant',
1057
-                    array('event_id' => $EVT_ID),
1058
-                    'add-new-h2'
1059
-                );
1060
-            }
1061
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1062
-            if ($event instanceof EE_Event) {
1063
-                $this->_template_args['admin_page_header'] = sprintf(
1064
-                    esc_html__(
1065
-                        '%s Viewing registrations for the event: %s%s',
1066
-                        'event_espresso'
1067
-                    ),
1068
-                    '<h3 style="line-height:1.5em;">',
1069
-                    '<br /><a href="'
1070
-                    . EE_Admin_Page::add_query_args_and_nonce(
1071
-                        array(
1072
-                            'action' => 'edit',
1073
-                            'post'   => $event->ID(),
1074
-                        ),
1075
-                        EVENTS_ADMIN_URL
1076
-                    )
1077
-                    . '">&nbsp;'
1078
-                    . $event->get('EVT_name')
1079
-                    . '&nbsp;</a>&nbsp;',
1080
-                    '</h3>'
1081
-                );
1082
-            }
1083
-            $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1084
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1085
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1086
-                $this->_template_args['admin_page_header'] = substr(
1087
-                    $this->_template_args['admin_page_header'],
1088
-                    0,
1089
-                    -5
1090
-                );
1091
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1092
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1093
-                $this->_template_args['admin_page_header'] .= $datetime->name();
1094
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1095
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
1096
-            }
1097
-        }
1098
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1099
-        $this->display_admin_list_table_page_with_no_sidebar();
1100
-    }
1101
-
1102
-
1103
-    /**
1104
-     * This sets the _registration property for the registration details screen
1105
-     *
1106
-     * @access private
1107
-     * @return bool
1108
-     * @throws EE_Error
1109
-     * @throws InvalidArgumentException
1110
-     * @throws InvalidDataTypeException
1111
-     * @throws InvalidInterfaceException
1112
-     */
1113
-    private function _set_registration_object()
1114
-    {
1115
-        // get out if we've already set the object
1116
-        if ($this->_registration instanceof EE_Registration) {
1117
-            return true;
1118
-        }
1119
-        $REG = EEM_Registration::instance();
1120
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1121
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1122
-            return true;
1123
-        } else {
1124
-            $error_msg = sprintf(
1125
-                esc_html__(
1126
-                    'An error occurred and the details for Registration ID #%s could not be retrieved.',
1127
-                    'event_espresso'
1128
-                ),
1129
-                $REG_ID
1130
-            );
1131
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1132
-            $this->_registration = null;
1133
-            return false;
1134
-        }
1135
-    }
1136
-
1137
-
1138
-    /**
1139
-     * Used to retrieve registrations for the list table.
1140
-     *
1141
-     * @param int  $per_page
1142
-     * @param bool $count
1143
-     * @param bool $this_month
1144
-     * @param bool $today
1145
-     * @return EE_Registration[]|int
1146
-     * @throws EE_Error
1147
-     * @throws InvalidArgumentException
1148
-     * @throws InvalidDataTypeException
1149
-     * @throws InvalidInterfaceException
1150
-     */
1151
-    public function get_registrations(
1152
-        $per_page = 10,
1153
-        $count = false,
1154
-        $this_month = false,
1155
-        $today = false
1156
-    ) {
1157
-        if ($this_month) {
1158
-            $this->_req_data['status'] = 'month';
1159
-        }
1160
-        if ($today) {
1161
-            $this->_req_data['status'] = 'today';
1162
-        }
1163
-        $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1164
-        /**
1165
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1166
-         *
1167
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1168
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1169
-         *                             or if you have the development copy of EE you can view this at the path:
1170
-         *                             /docs/G--Model-System/model-query-params.md
1171
-         */
1172
-        $query_params['group_by'] = '';
1173
-
1174
-        return $count
1175
-            ? EEM_Registration::instance()->count($query_params)
1176
-            /** @type EE_Registration[] */
1177
-            : EEM_Registration::instance()->get_all($query_params);
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1183
-     * Note: this listens to values on the request for some of the query parameters.
1184
-     *
1185
-     * @param array $request
1186
-     * @param int   $per_page
1187
-     * @param bool  $count
1188
-     * @return array
1189
-     * @throws EE_Error
1190
-     */
1191
-    protected function _get_registration_query_parameters(
1192
-        $request = array(),
1193
-        $per_page = 10,
1194
-        $count = false
1195
-    ) {
1196
-
1197
-        $query_params = array(
1198
-            0                          => $this->_get_where_conditions_for_registrations_query(
1199
-                $request
1200
-            ),
1201
-            'caps'                     => EEM_Registration::caps_read_admin,
1202
-            'default_where_conditions' => 'this_model_only',
1203
-        );
1204
-        if (! $count) {
1205
-            $query_params = array_merge(
1206
-                $query_params,
1207
-                $this->_get_orderby_for_registrations_query(),
1208
-                $this->_get_limit($per_page)
1209
-            );
1210
-        }
1211
-
1212
-        return $query_params;
1213
-    }
1214
-
1215
-
1216
-    /**
1217
-     * This will add ATT_ID to the provided $where array for EE model query parameters.
1218
-     *
1219
-     * @param array $request usually the same as $this->_req_data but not necessarily
1220
-     * @return array
1221
-     */
1222
-    protected function addAttendeeIdToWhereConditions(array $request)
1223
-    {
1224
-        $where = array();
1225
-        if (! empty($request['ATT_ID'])) {
1226
-            $where['ATT_ID'] = absint($request['ATT_ID']);
1227
-        }
1228
-        return $where;
1229
-    }
1230
-
1231
-
1232
-    /**
1233
-     * This will add EVT_ID to the provided $where array for EE model query parameters.
1234
-     *
1235
-     * @param array $request usually the same as $this->_req_data but not necessarily
1236
-     * @return array
1237
-     */
1238
-    protected function _add_event_id_to_where_conditions(array $request)
1239
-    {
1240
-        $where = array();
1241
-        if (! empty($request['event_id'])) {
1242
-            $where['EVT_ID'] = absint($request['event_id']);
1243
-        }
1244
-        return $where;
1245
-    }
1246
-
1247
-
1248
-    /**
1249
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
1250
-     *
1251
-     * @param array $request usually the same as $this->_req_data but not necessarily
1252
-     * @return array
1253
-     */
1254
-    protected function _add_category_id_to_where_conditions(array $request)
1255
-    {
1256
-        $where = array();
1257
-        if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1258
-            $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1259
-        }
1260
-        return $where;
1261
-    }
1262
-
1263
-
1264
-    /**
1265
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1266
-     *
1267
-     * @param array $request usually the same as $this->_req_data but not necessarily
1268
-     * @return array
1269
-     */
1270
-    protected function _add_datetime_id_to_where_conditions(array $request)
1271
-    {
1272
-        $where = array();
1273
-        if (! empty($request['datetime_id'])) {
1274
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1275
-        }
1276
-        if (! empty($request['DTT_ID'])) {
1277
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1278
-        }
1279
-        return $where;
1280
-    }
1281
-
1282
-
1283
-    /**
1284
-     * Adds the correct registration status to the where conditions for the registrations query.
1285
-     *
1286
-     * @param array $request usually the same as $this->_req_data but not necessarily
1287
-     * @return array
1288
-     */
1289
-    protected function _add_registration_status_to_where_conditions(array $request)
1290
-    {
1291
-        $where = array();
1292
-        $view = EEH_Array::is_set($request, 'status', '');
1293
-        $registration_status = ! empty($request['_reg_status'])
1294
-            ? sanitize_text_field($request['_reg_status'])
1295
-            : '';
1296
-
1297
-        /*
22
+	/**
23
+	 * @var EE_Registration
24
+	 */
25
+	private $_registration;
26
+
27
+	/**
28
+	 * @var EE_Event
29
+	 */
30
+	private $_reg_event;
31
+
32
+	/**
33
+	 * @var EE_Session
34
+	 */
35
+	private $_session;
36
+
37
+	private static $_reg_status;
38
+
39
+	/**
40
+	 * Form for displaying the custom questions for this registration.
41
+	 * This gets used a few times throughout the request so its best to cache it
42
+	 *
43
+	 * @var EE_Registration_Custom_Questions_Form
44
+	 */
45
+	protected $_reg_custom_questions_form = null;
46
+
47
+
48
+	/**
49
+	 *        constructor
50
+	 *
51
+	 * @Constructor
52
+	 * @access public
53
+	 * @param bool $routing
54
+	 * @return Registrations_Admin_Page
55
+	 */
56
+	public function __construct($routing = true)
57
+	{
58
+		parent::__construct($routing);
59
+		add_action('wp_loaded', array($this, 'wp_loaded'));
60
+	}
61
+
62
+
63
+	public function wp_loaded()
64
+	{
65
+		// when adding a new registration...
66
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
+			EE_System::do_not_cache();
68
+			if (! isset($this->_req_data['processing_registration'])
69
+				|| absint($this->_req_data['processing_registration']) !== 1
70
+			) {
71
+				// and it's NOT the attendee information reg step
72
+				// force cookie expiration by setting time to last week
73
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
+				// and update the global
75
+				$_COOKIE['ee_registration_added'] = 0;
76
+			}
77
+		}
78
+	}
79
+
80
+
81
+	protected function _init_page_props()
82
+	{
83
+		$this->page_slug = REG_PG_SLUG;
84
+		$this->_admin_base_url = REG_ADMIN_URL;
85
+		$this->_admin_base_path = REG_ADMIN;
86
+		$this->page_label = esc_html__('Registrations', 'event_espresso');
87
+		$this->_cpt_routes = array(
88
+			'add_new_attendee' => 'espresso_attendees',
89
+			'edit_attendee'    => 'espresso_attendees',
90
+			'insert_attendee'  => 'espresso_attendees',
91
+			'update_attendee'  => 'espresso_attendees',
92
+		);
93
+		$this->_cpt_model_names = array(
94
+			'add_new_attendee' => 'EEM_Attendee',
95
+			'edit_attendee'    => 'EEM_Attendee',
96
+		);
97
+		$this->_cpt_edit_routes = array(
98
+			'espresso_attendees' => 'edit_attendee',
99
+		);
100
+		$this->_pagenow_map = array(
101
+			'add_new_attendee' => 'post-new.php',
102
+			'edit_attendee'    => 'post.php',
103
+			'trash'            => 'post.php',
104
+		);
105
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
+		// add filters so that the comment urls don't take users to a confusing 404 page
107
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
+	}
109
+
110
+
111
+	public function clear_comment_link($link, $comment, $args)
112
+	{
113
+		// gotta make sure this only happens on this route
114
+		$post_type = get_post_type($comment->comment_post_ID);
115
+		if ($post_type === 'espresso_attendees') {
116
+			return '#commentsdiv';
117
+		}
118
+		return $link;
119
+	}
120
+
121
+
122
+	protected function _ajax_hooks()
123
+	{
124
+		// todo: all hooks for registrations ajax goes in here
125
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
+	}
127
+
128
+
129
+	protected function _define_page_props()
130
+	{
131
+		$this->_admin_page_title = $this->page_label;
132
+		$this->_labels = array(
133
+			'buttons'                      => array(
134
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
+				'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
+				'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
+			),
143
+			'publishbox'                   => array(
144
+				'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
+				'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
+			),
147
+			'hide_add_button_on_cpt_route' => array(
148
+				'edit_attendee' => true,
149
+			),
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 *        grab url requests and route them
156
+	 *
157
+	 * @access private
158
+	 * @return void
159
+	 */
160
+	public function _set_page_routes()
161
+	{
162
+		$this->_get_registration_status_array();
163
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
+			? $this->_req_data['_REG_ID'] : 0;
165
+		$reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
+			? $this->_req_data['reg_status_change_form']['REG_ID']
167
+			: $reg_id;
168
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
+			? $this->_req_data['ATT_ID'] : 0;
170
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
+			? $this->_req_data['post']
172
+			: $att_id;
173
+		$this->_page_routes = array(
174
+			'default'                             => array(
175
+				'func'       => '_registrations_overview_list_table',
176
+				'capability' => 'ee_read_registrations',
177
+			),
178
+			'view_registration'                   => array(
179
+				'func'       => '_registration_details',
180
+				'capability' => 'ee_read_registration',
181
+				'obj_id'     => $reg_id,
182
+			),
183
+			'edit_registration'                   => array(
184
+				'func'               => '_update_attendee_registration_form',
185
+				'noheader'           => true,
186
+				'headers_sent_route' => 'view_registration',
187
+				'capability'         => 'ee_edit_registration',
188
+				'obj_id'             => $reg_id,
189
+				'_REG_ID'            => $reg_id,
190
+			),
191
+			'trash_registrations'                 => array(
192
+				'func'       => '_trash_or_restore_registrations',
193
+				'args'       => array('trash' => true),
194
+				'noheader'   => true,
195
+				'capability' => 'ee_delete_registrations',
196
+			),
197
+			'restore_registrations'               => array(
198
+				'func'       => '_trash_or_restore_registrations',
199
+				'args'       => array('trash' => false),
200
+				'noheader'   => true,
201
+				'capability' => 'ee_delete_registrations',
202
+			),
203
+			'delete_registrations'                => array(
204
+				'func'       => '_delete_registrations',
205
+				'noheader'   => true,
206
+				'capability' => 'ee_delete_registrations',
207
+			),
208
+			'new_registration'                    => array(
209
+				'func'       => 'new_registration',
210
+				'capability' => 'ee_edit_registrations',
211
+			),
212
+			'process_reg_step'                    => array(
213
+				'func'       => 'process_reg_step',
214
+				'noheader'   => true,
215
+				'capability' => 'ee_edit_registrations',
216
+			),
217
+			'redirect_to_txn'                     => array(
218
+				'func'       => 'redirect_to_txn',
219
+				'noheader'   => true,
220
+				'capability' => 'ee_edit_registrations',
221
+			),
222
+			'change_reg_status'                   => array(
223
+				'func'       => '_change_reg_status',
224
+				'noheader'   => true,
225
+				'capability' => 'ee_edit_registration',
226
+				'obj_id'     => $reg_id,
227
+			),
228
+			'approve_registration'                => array(
229
+				'func'       => 'approve_registration',
230
+				'noheader'   => true,
231
+				'capability' => 'ee_edit_registration',
232
+				'obj_id'     => $reg_id,
233
+			),
234
+			'approve_and_notify_registration'     => array(
235
+				'func'       => 'approve_registration',
236
+				'noheader'   => true,
237
+				'args'       => array(true),
238
+				'capability' => 'ee_edit_registration',
239
+				'obj_id'     => $reg_id,
240
+			),
241
+			'approve_registrations'               => array(
242
+				'func'       => 'bulk_action_on_registrations',
243
+				'noheader'   => true,
244
+				'capability' => 'ee_edit_registrations',
245
+				'args'       => array('approve'),
246
+			),
247
+			'approve_and_notify_registrations'    => array(
248
+				'func'       => 'bulk_action_on_registrations',
249
+				'noheader'   => true,
250
+				'capability' => 'ee_edit_registrations',
251
+				'args'       => array('approve', true),
252
+			),
253
+			'decline_registration'                => array(
254
+				'func'       => 'decline_registration',
255
+				'noheader'   => true,
256
+				'capability' => 'ee_edit_registration',
257
+				'obj_id'     => $reg_id,
258
+			),
259
+			'decline_and_notify_registration'     => array(
260
+				'func'       => 'decline_registration',
261
+				'noheader'   => true,
262
+				'args'       => array(true),
263
+				'capability' => 'ee_edit_registration',
264
+				'obj_id'     => $reg_id,
265
+			),
266
+			'decline_registrations'               => array(
267
+				'func'       => 'bulk_action_on_registrations',
268
+				'noheader'   => true,
269
+				'capability' => 'ee_edit_registrations',
270
+				'args'       => array('decline'),
271
+			),
272
+			'decline_and_notify_registrations'    => array(
273
+				'func'       => 'bulk_action_on_registrations',
274
+				'noheader'   => true,
275
+				'capability' => 'ee_edit_registrations',
276
+				'args'       => array('decline', true),
277
+			),
278
+			'pending_registration'                => array(
279
+				'func'       => 'pending_registration',
280
+				'noheader'   => true,
281
+				'capability' => 'ee_edit_registration',
282
+				'obj_id'     => $reg_id,
283
+			),
284
+			'pending_and_notify_registration'     => array(
285
+				'func'       => 'pending_registration',
286
+				'noheader'   => true,
287
+				'args'       => array(true),
288
+				'capability' => 'ee_edit_registration',
289
+				'obj_id'     => $reg_id,
290
+			),
291
+			'pending_registrations'               => array(
292
+				'func'       => 'bulk_action_on_registrations',
293
+				'noheader'   => true,
294
+				'capability' => 'ee_edit_registrations',
295
+				'args'       => array('pending'),
296
+			),
297
+			'pending_and_notify_registrations'    => array(
298
+				'func'       => 'bulk_action_on_registrations',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+				'args'       => array('pending', true),
302
+			),
303
+			'no_approve_registration'             => array(
304
+				'func'       => 'not_approve_registration',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registration',
307
+				'obj_id'     => $reg_id,
308
+			),
309
+			'no_approve_and_notify_registration'  => array(
310
+				'func'       => 'not_approve_registration',
311
+				'noheader'   => true,
312
+				'args'       => array(true),
313
+				'capability' => 'ee_edit_registration',
314
+				'obj_id'     => $reg_id,
315
+			),
316
+			'no_approve_registrations'            => array(
317
+				'func'       => 'bulk_action_on_registrations',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_registrations',
320
+				'args'       => array('not_approve'),
321
+			),
322
+			'no_approve_and_notify_registrations' => array(
323
+				'func'       => 'bulk_action_on_registrations',
324
+				'noheader'   => true,
325
+				'capability' => 'ee_edit_registrations',
326
+				'args'       => array('not_approve', true),
327
+			),
328
+			'cancel_registration'                 => array(
329
+				'func'       => 'cancel_registration',
330
+				'noheader'   => true,
331
+				'capability' => 'ee_edit_registration',
332
+				'obj_id'     => $reg_id,
333
+			),
334
+			'cancel_and_notify_registration'      => array(
335
+				'func'       => 'cancel_registration',
336
+				'noheader'   => true,
337
+				'args'       => array(true),
338
+				'capability' => 'ee_edit_registration',
339
+				'obj_id'     => $reg_id,
340
+			),
341
+			'cancel_registrations'                => array(
342
+				'func'       => 'bulk_action_on_registrations',
343
+				'noheader'   => true,
344
+				'capability' => 'ee_edit_registrations',
345
+				'args'       => array('cancel'),
346
+			),
347
+			'cancel_and_notify_registrations'     => array(
348
+				'func'       => 'bulk_action_on_registrations',
349
+				'noheader'   => true,
350
+				'capability' => 'ee_edit_registrations',
351
+				'args'       => array('cancel', true),
352
+			),
353
+			'wait_list_registration'              => array(
354
+				'func'       => 'wait_list_registration',
355
+				'noheader'   => true,
356
+				'capability' => 'ee_edit_registration',
357
+				'obj_id'     => $reg_id,
358
+			),
359
+			'wait_list_and_notify_registration'   => array(
360
+				'func'       => 'wait_list_registration',
361
+				'noheader'   => true,
362
+				'args'       => array(true),
363
+				'capability' => 'ee_edit_registration',
364
+				'obj_id'     => $reg_id,
365
+			),
366
+			'contact_list'                        => array(
367
+				'func'       => '_attendee_contact_list_table',
368
+				'capability' => 'ee_read_contacts',
369
+			),
370
+			'add_new_attendee'                    => array(
371
+				'func' => '_create_new_cpt_item',
372
+				'args' => array(
373
+					'new_attendee' => true,
374
+					'capability'   => 'ee_edit_contacts',
375
+				),
376
+			),
377
+			'edit_attendee'                       => array(
378
+				'func'       => '_edit_cpt_item',
379
+				'capability' => 'ee_edit_contacts',
380
+				'obj_id'     => $att_id,
381
+			),
382
+			'duplicate_attendee'                  => array(
383
+				'func'       => '_duplicate_attendee',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_contacts',
386
+				'obj_id'     => $att_id,
387
+			),
388
+			'insert_attendee'                     => array(
389
+				'func'       => '_insert_or_update_attendee',
390
+				'args'       => array(
391
+					'new_attendee' => true,
392
+				),
393
+				'noheader'   => true,
394
+				'capability' => 'ee_edit_contacts',
395
+			),
396
+			'update_attendee'                     => array(
397
+				'func'       => '_insert_or_update_attendee',
398
+				'args'       => array(
399
+					'new_attendee' => false,
400
+				),
401
+				'noheader'   => true,
402
+				'capability' => 'ee_edit_contacts',
403
+				'obj_id'     => $att_id,
404
+			),
405
+			'trash_attendees'                     => array(
406
+				'func'       => '_trash_or_restore_attendees',
407
+				'args'       => array(
408
+					'trash' => 'true',
409
+				),
410
+				'noheader'   => true,
411
+				'capability' => 'ee_delete_contacts',
412
+			),
413
+			'trash_attendee'                      => array(
414
+				'func'       => '_trash_or_restore_attendees',
415
+				'args'       => array(
416
+					'trash' => true,
417
+				),
418
+				'noheader'   => true,
419
+				'capability' => 'ee_delete_contacts',
420
+				'obj_id'     => $att_id,
421
+			),
422
+			'restore_attendees'                   => array(
423
+				'func'       => '_trash_or_restore_attendees',
424
+				'args'       => array(
425
+					'trash' => false,
426
+				),
427
+				'noheader'   => true,
428
+				'capability' => 'ee_delete_contacts',
429
+				'obj_id'     => $att_id,
430
+			),
431
+			'resend_registration'                 => array(
432
+				'func'       => '_resend_registration',
433
+				'noheader'   => true,
434
+				'capability' => 'ee_send_message',
435
+			),
436
+			'registrations_report'                => array(
437
+				'func'       => '_registrations_report',
438
+				'noheader'   => true,
439
+				'capability' => 'ee_read_registrations',
440
+			),
441
+			'contact_list_export'                 => array(
442
+				'func'       => '_contact_list_export',
443
+				'noheader'   => true,
444
+				'capability' => 'export',
445
+			),
446
+			'contact_list_report'                 => array(
447
+				'func'       => '_contact_list_report',
448
+				'noheader'   => true,
449
+				'capability' => 'ee_read_contacts',
450
+			),
451
+		);
452
+	}
453
+
454
+
455
+	protected function _set_page_config()
456
+	{
457
+		$this->_page_config = array(
458
+			'default'           => array(
459
+				'nav'           => array(
460
+					'label' => esc_html__('Overview', 'event_espresso'),
461
+					'order' => 5,
462
+				),
463
+				'help_tabs'     => array(
464
+					'registrations_overview_help_tab'                       => array(
465
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
+						'filename' => 'registrations_overview',
467
+					),
468
+					'registrations_overview_table_column_headings_help_tab' => array(
469
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
+						'filename' => 'registrations_overview_table_column_headings',
471
+					),
472
+					'registrations_overview_filters_help_tab'               => array(
473
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
+						'filename' => 'registrations_overview_filters',
475
+					),
476
+					'registrations_overview_views_help_tab'                 => array(
477
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
478
+						'filename' => 'registrations_overview_views',
479
+					),
480
+					'registrations_regoverview_other_help_tab'              => array(
481
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
+						'filename' => 'registrations_overview_other',
483
+					),
484
+				),
485
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
486
+				'qtips'         => array('Registration_List_Table_Tips'),
487
+				'list_table'    => 'EE_Registrations_List_Table',
488
+				'require_nonce' => false,
489
+			),
490
+			'view_registration' => array(
491
+				'nav'           => array(
492
+					'label'      => esc_html__('REG Details', 'event_espresso'),
493
+					'order'      => 15,
494
+					'url'        => isset($this->_req_data['_REG_ID'])
495
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
+						: $this->_admin_base_url,
497
+					'persistent' => false,
498
+				),
499
+				'help_tabs'     => array(
500
+					'registrations_details_help_tab'                    => array(
501
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
502
+						'filename' => 'registrations_details',
503
+					),
504
+					'registrations_details_table_help_tab'              => array(
505
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
+						'filename' => 'registrations_details_table',
507
+					),
508
+					'registrations_details_form_answers_help_tab'       => array(
509
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
+						'filename' => 'registrations_details_form_answers',
511
+					),
512
+					'registrations_details_registrant_details_help_tab' => array(
513
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
514
+						'filename' => 'registrations_details_registrant_details',
515
+					),
516
+				),
517
+				'help_tour'     => array('Registration_Details_Help_Tour'),
518
+				'metaboxes'     => array_merge(
519
+					$this->_default_espresso_metaboxes,
520
+					array('_registration_details_metaboxes')
521
+				),
522
+				'require_nonce' => false,
523
+			),
524
+			'new_registration'  => array(
525
+				'nav'           => array(
526
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
+					'url'        => '#',
528
+					'order'      => 15,
529
+					'persistent' => false,
530
+				),
531
+				'metaboxes'     => $this->_default_espresso_metaboxes,
532
+				'labels'        => array(
533
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
+				),
535
+				'require_nonce' => false,
536
+			),
537
+			'add_new_attendee'  => array(
538
+				'nav'           => array(
539
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
540
+					'order'      => 15,
541
+					'persistent' => false,
542
+				),
543
+				'metaboxes'     => array_merge(
544
+					$this->_default_espresso_metaboxes,
545
+					array('_publish_post_box', 'attendee_editor_metaboxes')
546
+				),
547
+				'require_nonce' => false,
548
+			),
549
+			'edit_attendee'     => array(
550
+				'nav'           => array(
551
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
+					'order'      => 15,
553
+					'persistent' => false,
554
+					'url'        => isset($this->_req_data['ATT_ID'])
555
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
+						: $this->_admin_base_url,
557
+				),
558
+				'metaboxes'     => array('attendee_editor_metaboxes'),
559
+				'require_nonce' => false,
560
+			),
561
+			'contact_list'      => array(
562
+				'nav'           => array(
563
+					'label' => esc_html__('Contact List', 'event_espresso'),
564
+					'order' => 20,
565
+				),
566
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
567
+				'help_tabs'     => array(
568
+					'registrations_contact_list_help_tab'                       => array(
569
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
+						'filename' => 'registrations_contact_list',
571
+					),
572
+					'registrations_contact-list_table_column_headings_help_tab' => array(
573
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
+						'filename' => 'registrations_contact_list_table_column_headings',
575
+					),
576
+					'registrations_contact_list_views_help_tab'                 => array(
577
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
+						'filename' => 'registrations_contact_list_views',
579
+					),
580
+					'registrations_contact_list_other_help_tab'                 => array(
581
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
+						'filename' => 'registrations_contact_list_other',
583
+					),
584
+				),
585
+				'help_tour'     => array('Contact_List_Help_Tour'),
586
+				'metaboxes'     => array(),
587
+				'require_nonce' => false,
588
+			),
589
+			// override default cpt routes
590
+			'create_new'        => '',
591
+			'edit'              => '',
592
+		);
593
+	}
594
+
595
+
596
+	/**
597
+	 * The below methods aren't used by this class currently
598
+	 */
599
+	protected function _add_screen_options()
600
+	{
601
+	}
602
+
603
+
604
+	protected function _add_feature_pointers()
605
+	{
606
+	}
607
+
608
+
609
+	public function admin_init()
610
+	{
611
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
+			'click "Update Registration Questions" to save your changes',
613
+			'event_espresso'
614
+		);
615
+	}
616
+
617
+
618
+	public function admin_notices()
619
+	{
620
+	}
621
+
622
+
623
+	public function admin_footer_scripts()
624
+	{
625
+	}
626
+
627
+
628
+	/**
629
+	 *        get list of registration statuses
630
+	 *
631
+	 * @access private
632
+	 * @return void
633
+	 * @throws EE_Error
634
+	 */
635
+	private function _get_registration_status_array()
636
+	{
637
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
+	}
639
+
640
+
641
+	protected function _add_screen_options_default()
642
+	{
643
+		$this->_per_page_screen_option();
644
+	}
645
+
646
+
647
+	protected function _add_screen_options_contact_list()
648
+	{
649
+		$page_title = $this->_admin_page_title;
650
+		$this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
+		$this->_per_page_screen_option();
652
+		$this->_admin_page_title = $page_title;
653
+	}
654
+
655
+
656
+	public function load_scripts_styles()
657
+	{
658
+		// style
659
+		wp_register_style(
660
+			'espresso_reg',
661
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
+			array('ee-admin-css'),
663
+			EVENT_ESPRESSO_VERSION
664
+		);
665
+		wp_enqueue_style('espresso_reg');
666
+		// script
667
+		wp_register_script(
668
+			'espresso_reg',
669
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
+			EVENT_ESPRESSO_VERSION,
672
+			true
673
+		);
674
+		wp_enqueue_script('espresso_reg');
675
+	}
676
+
677
+
678
+	public function load_scripts_styles_edit_attendee()
679
+	{
680
+		// stuff to only show up on our attendee edit details page.
681
+		$attendee_details_translations = array(
682
+			'att_publish_text' => sprintf(
683
+				/* translators: The date and time */
684
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
685
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
686
+			),
687
+		);
688
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
689
+		wp_enqueue_script('jquery-validate');
690
+	}
691
+
692
+
693
+	public function load_scripts_styles_view_registration()
694
+	{
695
+		// styles
696
+		wp_enqueue_style('espresso-ui-theme');
697
+		// scripts
698
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
699
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
700
+	}
701
+
702
+
703
+	public function load_scripts_styles_contact_list()
704
+	{
705
+		wp_dequeue_style('espresso_reg');
706
+		wp_register_style(
707
+			'espresso_att',
708
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
709
+			array('ee-admin-css'),
710
+			EVENT_ESPRESSO_VERSION
711
+		);
712
+		wp_enqueue_style('espresso_att');
713
+	}
714
+
715
+
716
+	public function load_scripts_styles_new_registration()
717
+	{
718
+		wp_register_script(
719
+			'ee-spco-for-admin',
720
+			REG_ASSETS_URL . 'spco_for_admin.js',
721
+			array('underscore', 'jquery'),
722
+			EVENT_ESPRESSO_VERSION,
723
+			true
724
+		);
725
+		wp_enqueue_script('ee-spco-for-admin');
726
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
727
+		EE_Form_Section_Proper::wp_enqueue_scripts();
728
+		EED_Ticket_Selector::load_tckt_slctr_assets();
729
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
730
+	}
731
+
732
+
733
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
734
+	{
735
+		add_filter('FHEE_load_EE_messages', '__return_true');
736
+	}
737
+
738
+
739
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
740
+	{
741
+		add_filter('FHEE_load_EE_messages', '__return_true');
742
+	}
743
+
744
+
745
+	protected function _set_list_table_views_default()
746
+	{
747
+		// for notification related bulk actions we need to make sure only active messengers have an option.
748
+		EED_Messages::set_autoloaders();
749
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
750
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
751
+		$active_mts = $message_resource_manager->list_of_active_message_types();
752
+		// key= bulk_action_slug, value= message type.
753
+		$match_array = array(
754
+			'approve_registrations'    => 'registration',
755
+			'decline_registrations'    => 'declined_registration',
756
+			'pending_registrations'    => 'pending_approval',
757
+			'no_approve_registrations' => 'not_approved_registration',
758
+			'cancel_registrations'     => 'cancelled_registration',
759
+		);
760
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
761
+			'ee_send_message',
762
+			'batch_send_messages'
763
+		);
764
+		/** setup reg status bulk actions **/
765
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
766
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
767
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
768
+				'Approve and Notify Registrations',
769
+				'event_espresso'
770
+			);
771
+		}
772
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
773
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
774
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
775
+				'Decline and Notify Registrations',
776
+				'event_espresso'
777
+			);
778
+		}
779
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
780
+			'Set Registrations to Pending Payment',
781
+			'event_espresso'
782
+		);
783
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
784
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
785
+				'Set Registrations to Pending Payment and Notify',
786
+				'event_espresso'
787
+			);
788
+		}
789
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
790
+			'Set Registrations to Not Approved',
791
+			'event_espresso'
792
+		);
793
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
794
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
795
+				'Set Registrations to Not Approved and Notify',
796
+				'event_espresso'
797
+			);
798
+		}
799
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
800
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
801
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
802
+				'Cancel Registrations and Notify',
803
+				'event_espresso'
804
+			);
805
+		}
806
+		$def_reg_status_actions = apply_filters(
807
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
808
+			$def_reg_status_actions,
809
+			$active_mts,
810
+			$can_send
811
+		);
812
+
813
+		$this->_views = array(
814
+			'all'   => array(
815
+				'slug'        => 'all',
816
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
817
+				'count'       => 0,
818
+				'bulk_action' => array_merge(
819
+					$def_reg_status_actions,
820
+					array(
821
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
822
+					)
823
+				),
824
+			),
825
+			'month' => array(
826
+				'slug'        => 'month',
827
+				'label'       => esc_html__('This Month', 'event_espresso'),
828
+				'count'       => 0,
829
+				'bulk_action' => array_merge(
830
+					$def_reg_status_actions,
831
+					array(
832
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
833
+					)
834
+				),
835
+			),
836
+			'today' => array(
837
+				'slug'        => 'today',
838
+				'label'       => sprintf(
839
+					esc_html__('Today - %s', 'event_espresso'),
840
+					date('M d, Y', current_time('timestamp'))
841
+				),
842
+				'count'       => 0,
843
+				'bulk_action' => array_merge(
844
+					$def_reg_status_actions,
845
+					array(
846
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
847
+					)
848
+				),
849
+			),
850
+		);
851
+		if (EE_Registry::instance()->CAP->current_user_can(
852
+			'ee_delete_registrations',
853
+			'espresso_registrations_delete_registration'
854
+		)) {
855
+			$this->_views['incomplete'] = array(
856
+				'slug'        => 'incomplete',
857
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
858
+				'count'       => 0,
859
+				'bulk_action' => array(
860
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
861
+				),
862
+			);
863
+			$this->_views['trash'] = array(
864
+				'slug'        => 'trash',
865
+				'label'       => esc_html__('Trash', 'event_espresso'),
866
+				'count'       => 0,
867
+				'bulk_action' => array(
868
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
869
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
870
+				),
871
+			);
872
+		}
873
+	}
874
+
875
+
876
+	protected function _set_list_table_views_contact_list()
877
+	{
878
+		$this->_views = array(
879
+			'in_use' => array(
880
+				'slug'        => 'in_use',
881
+				'label'       => esc_html__('In Use', 'event_espresso'),
882
+				'count'       => 0,
883
+				'bulk_action' => array(
884
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
885
+				),
886
+			),
887
+		);
888
+		if (EE_Registry::instance()->CAP->current_user_can(
889
+			'ee_delete_contacts',
890
+			'espresso_registrations_trash_attendees'
891
+		)
892
+		) {
893
+			$this->_views['trash'] = array(
894
+				'slug'        => 'trash',
895
+				'label'       => esc_html__('Trash', 'event_espresso'),
896
+				'count'       => 0,
897
+				'bulk_action' => array(
898
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
899
+				),
900
+			);
901
+		}
902
+	}
903
+
904
+
905
+	protected function _registration_legend_items()
906
+	{
907
+		$fc_items = array(
908
+			'star-icon'        => array(
909
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
910
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
911
+			),
912
+			'view_details'     => array(
913
+				'class' => 'dashicons dashicons-clipboard',
914
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
915
+			),
916
+			'edit_attendee'    => array(
917
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
918
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
919
+			),
920
+			'view_transaction' => array(
921
+				'class' => 'dashicons dashicons-cart',
922
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
923
+			),
924
+			'view_invoice'     => array(
925
+				'class' => 'dashicons dashicons-media-spreadsheet',
926
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
927
+			),
928
+		);
929
+		if (EE_Registry::instance()->CAP->current_user_can(
930
+			'ee_send_message',
931
+			'espresso_registrations_resend_registration'
932
+		)) {
933
+			$fc_items['resend_registration'] = array(
934
+				'class' => 'dashicons dashicons-email-alt',
935
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
936
+			);
937
+		} else {
938
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
939
+		}
940
+		if (EE_Registry::instance()->CAP->current_user_can(
941
+			'ee_read_global_messages',
942
+			'view_filtered_messages'
943
+		)) {
944
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
945
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
946
+				$fc_items['view_related_messages'] = array(
947
+					'class' => $related_for_icon['css_class'],
948
+					'desc'  => $related_for_icon['label'],
949
+				);
950
+			}
951
+		}
952
+		$sc_items = array(
953
+			'approved_status'   => array(
954
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
955
+				'desc'  => EEH_Template::pretty_status(
956
+					EEM_Registration::status_id_approved,
957
+					false,
958
+					'sentence'
959
+				),
960
+			),
961
+			'pending_status'    => array(
962
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
963
+				'desc'  => EEH_Template::pretty_status(
964
+					EEM_Registration::status_id_pending_payment,
965
+					false,
966
+					'sentence'
967
+				),
968
+			),
969
+			'wait_list'         => array(
970
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
971
+				'desc'  => EEH_Template::pretty_status(
972
+					EEM_Registration::status_id_wait_list,
973
+					false,
974
+					'sentence'
975
+				),
976
+			),
977
+			'incomplete_status' => array(
978
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
979
+				'desc'  => EEH_Template::pretty_status(
980
+					EEM_Registration::status_id_incomplete,
981
+					false,
982
+					'sentence'
983
+				),
984
+			),
985
+			'not_approved'      => array(
986
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
987
+				'desc'  => EEH_Template::pretty_status(
988
+					EEM_Registration::status_id_not_approved,
989
+					false,
990
+					'sentence'
991
+				),
992
+			),
993
+			'declined_status'   => array(
994
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
995
+				'desc'  => EEH_Template::pretty_status(
996
+					EEM_Registration::status_id_declined,
997
+					false,
998
+					'sentence'
999
+				),
1000
+			),
1001
+			'cancelled_status'  => array(
1002
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1003
+				'desc'  => EEH_Template::pretty_status(
1004
+					EEM_Registration::status_id_cancelled,
1005
+					false,
1006
+					'sentence'
1007
+				),
1008
+			),
1009
+		);
1010
+		return array_merge($fc_items, $sc_items);
1011
+	}
1012
+
1013
+
1014
+
1015
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1016
+	/**
1017
+	 * @throws \EE_Error
1018
+	 */
1019
+	protected function _registrations_overview_list_table()
1020
+	{
1021
+		$this->_template_args['admin_page_header'] = '';
1022
+		$EVT_ID = ! empty($this->_req_data['event_id'])
1023
+			? absint($this->_req_data['event_id'])
1024
+			: 0;
1025
+		$ATT_ID = ! empty($this->_req_data['ATT_ID'])
1026
+			? absint($this->_req_data['ATT_ID'])
1027
+			: 0;
1028
+		if ($ATT_ID) {
1029
+			$attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1030
+			if ($attendee instanceof EE_Attendee) {
1031
+				$this->_template_args['admin_page_header'] = sprintf(
1032
+					esc_html__(
1033
+						'%1$s Viewing registrations for %2$s%3$s',
1034
+						'event_espresso'
1035
+					),
1036
+					'<h3 style="line-height:1.5em;">',
1037
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1038
+						array(
1039
+							'action' => 'edit_attendee',
1040
+							'post'   => $ATT_ID,
1041
+						),
1042
+						REG_ADMIN_URL
1043
+					) . '">' . $attendee->full_name() . '</a>',
1044
+					'</h3>'
1045
+				);
1046
+			}
1047
+		}
1048
+		if ($EVT_ID) {
1049
+			if (EE_Registry::instance()->CAP->current_user_can(
1050
+				'ee_edit_registrations',
1051
+				'espresso_registrations_new_registration',
1052
+				$EVT_ID
1053
+			)) {
1054
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1055
+					'new_registration',
1056
+					'add-registrant',
1057
+					array('event_id' => $EVT_ID),
1058
+					'add-new-h2'
1059
+				);
1060
+			}
1061
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1062
+			if ($event instanceof EE_Event) {
1063
+				$this->_template_args['admin_page_header'] = sprintf(
1064
+					esc_html__(
1065
+						'%s Viewing registrations for the event: %s%s',
1066
+						'event_espresso'
1067
+					),
1068
+					'<h3 style="line-height:1.5em;">',
1069
+					'<br /><a href="'
1070
+					. EE_Admin_Page::add_query_args_and_nonce(
1071
+						array(
1072
+							'action' => 'edit',
1073
+							'post'   => $event->ID(),
1074
+						),
1075
+						EVENTS_ADMIN_URL
1076
+					)
1077
+					. '">&nbsp;'
1078
+					. $event->get('EVT_name')
1079
+					. '&nbsp;</a>&nbsp;',
1080
+					'</h3>'
1081
+				);
1082
+			}
1083
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1084
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1085
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1086
+				$this->_template_args['admin_page_header'] = substr(
1087
+					$this->_template_args['admin_page_header'],
1088
+					0,
1089
+					-5
1090
+				);
1091
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1092
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1093
+				$this->_template_args['admin_page_header'] .= $datetime->name();
1094
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1095
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
1096
+			}
1097
+		}
1098
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1099
+		$this->display_admin_list_table_page_with_no_sidebar();
1100
+	}
1101
+
1102
+
1103
+	/**
1104
+	 * This sets the _registration property for the registration details screen
1105
+	 *
1106
+	 * @access private
1107
+	 * @return bool
1108
+	 * @throws EE_Error
1109
+	 * @throws InvalidArgumentException
1110
+	 * @throws InvalidDataTypeException
1111
+	 * @throws InvalidInterfaceException
1112
+	 */
1113
+	private function _set_registration_object()
1114
+	{
1115
+		// get out if we've already set the object
1116
+		if ($this->_registration instanceof EE_Registration) {
1117
+			return true;
1118
+		}
1119
+		$REG = EEM_Registration::instance();
1120
+		$REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1121
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1122
+			return true;
1123
+		} else {
1124
+			$error_msg = sprintf(
1125
+				esc_html__(
1126
+					'An error occurred and the details for Registration ID #%s could not be retrieved.',
1127
+					'event_espresso'
1128
+				),
1129
+				$REG_ID
1130
+			);
1131
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1132
+			$this->_registration = null;
1133
+			return false;
1134
+		}
1135
+	}
1136
+
1137
+
1138
+	/**
1139
+	 * Used to retrieve registrations for the list table.
1140
+	 *
1141
+	 * @param int  $per_page
1142
+	 * @param bool $count
1143
+	 * @param bool $this_month
1144
+	 * @param bool $today
1145
+	 * @return EE_Registration[]|int
1146
+	 * @throws EE_Error
1147
+	 * @throws InvalidArgumentException
1148
+	 * @throws InvalidDataTypeException
1149
+	 * @throws InvalidInterfaceException
1150
+	 */
1151
+	public function get_registrations(
1152
+		$per_page = 10,
1153
+		$count = false,
1154
+		$this_month = false,
1155
+		$today = false
1156
+	) {
1157
+		if ($this_month) {
1158
+			$this->_req_data['status'] = 'month';
1159
+		}
1160
+		if ($today) {
1161
+			$this->_req_data['status'] = 'today';
1162
+		}
1163
+		$query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1164
+		/**
1165
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1166
+		 *
1167
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1168
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1169
+		 *                             or if you have the development copy of EE you can view this at the path:
1170
+		 *                             /docs/G--Model-System/model-query-params.md
1171
+		 */
1172
+		$query_params['group_by'] = '';
1173
+
1174
+		return $count
1175
+			? EEM_Registration::instance()->count($query_params)
1176
+			/** @type EE_Registration[] */
1177
+			: EEM_Registration::instance()->get_all($query_params);
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1183
+	 * Note: this listens to values on the request for some of the query parameters.
1184
+	 *
1185
+	 * @param array $request
1186
+	 * @param int   $per_page
1187
+	 * @param bool  $count
1188
+	 * @return array
1189
+	 * @throws EE_Error
1190
+	 */
1191
+	protected function _get_registration_query_parameters(
1192
+		$request = array(),
1193
+		$per_page = 10,
1194
+		$count = false
1195
+	) {
1196
+
1197
+		$query_params = array(
1198
+			0                          => $this->_get_where_conditions_for_registrations_query(
1199
+				$request
1200
+			),
1201
+			'caps'                     => EEM_Registration::caps_read_admin,
1202
+			'default_where_conditions' => 'this_model_only',
1203
+		);
1204
+		if (! $count) {
1205
+			$query_params = array_merge(
1206
+				$query_params,
1207
+				$this->_get_orderby_for_registrations_query(),
1208
+				$this->_get_limit($per_page)
1209
+			);
1210
+		}
1211
+
1212
+		return $query_params;
1213
+	}
1214
+
1215
+
1216
+	/**
1217
+	 * This will add ATT_ID to the provided $where array for EE model query parameters.
1218
+	 *
1219
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1220
+	 * @return array
1221
+	 */
1222
+	protected function addAttendeeIdToWhereConditions(array $request)
1223
+	{
1224
+		$where = array();
1225
+		if (! empty($request['ATT_ID'])) {
1226
+			$where['ATT_ID'] = absint($request['ATT_ID']);
1227
+		}
1228
+		return $where;
1229
+	}
1230
+
1231
+
1232
+	/**
1233
+	 * This will add EVT_ID to the provided $where array for EE model query parameters.
1234
+	 *
1235
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1236
+	 * @return array
1237
+	 */
1238
+	protected function _add_event_id_to_where_conditions(array $request)
1239
+	{
1240
+		$where = array();
1241
+		if (! empty($request['event_id'])) {
1242
+			$where['EVT_ID'] = absint($request['event_id']);
1243
+		}
1244
+		return $where;
1245
+	}
1246
+
1247
+
1248
+	/**
1249
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
1250
+	 *
1251
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1252
+	 * @return array
1253
+	 */
1254
+	protected function _add_category_id_to_where_conditions(array $request)
1255
+	{
1256
+		$where = array();
1257
+		if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1258
+			$where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1259
+		}
1260
+		return $where;
1261
+	}
1262
+
1263
+
1264
+	/**
1265
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1266
+	 *
1267
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1268
+	 * @return array
1269
+	 */
1270
+	protected function _add_datetime_id_to_where_conditions(array $request)
1271
+	{
1272
+		$where = array();
1273
+		if (! empty($request['datetime_id'])) {
1274
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1275
+		}
1276
+		if (! empty($request['DTT_ID'])) {
1277
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1278
+		}
1279
+		return $where;
1280
+	}
1281
+
1282
+
1283
+	/**
1284
+	 * Adds the correct registration status to the where conditions for the registrations query.
1285
+	 *
1286
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1287
+	 * @return array
1288
+	 */
1289
+	protected function _add_registration_status_to_where_conditions(array $request)
1290
+	{
1291
+		$where = array();
1292
+		$view = EEH_Array::is_set($request, 'status', '');
1293
+		$registration_status = ! empty($request['_reg_status'])
1294
+			? sanitize_text_field($request['_reg_status'])
1295
+			: '';
1296
+
1297
+		/*
1298 1298
          * If filtering by registration status, then we show registrations matching that status.
1299 1299
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1300 1300
          * UNLESS viewing trashed registrations.
1301 1301
          */
1302
-        if (! empty($registration_status)) {
1303
-            $where['STS_ID'] = $registration_status;
1304
-        } else {
1305
-            // make sure we exclude incomplete registrations, but only if not trashed.
1306
-            if ($view === 'trash') {
1307
-                $where['REG_deleted'] = true;
1308
-            } elseif ($view === 'incomplete') {
1309
-                $where['STS_ID'] = EEM_Registration::status_id_incomplete;
1310
-            } else {
1311
-                $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1312
-            }
1313
-        }
1314
-        return $where;
1315
-    }
1316
-
1317
-
1318
-    /**
1319
-     * Adds any provided date restraints to the where conditions for the registrations query.
1320
-     *
1321
-     * @param array $request usually the same as $this->_req_data but not necessarily
1322
-     * @return array
1323
-     * @throws EE_Error
1324
-     * @throws InvalidArgumentException
1325
-     * @throws InvalidDataTypeException
1326
-     * @throws InvalidInterfaceException
1327
-     */
1328
-    protected function _add_date_to_where_conditions(array $request)
1329
-    {
1330
-        $where = array();
1331
-        $view = EEH_Array::is_set($request, 'status', '');
1332
-        $month_range = ! empty($request['month_range'])
1333
-            ? sanitize_text_field($request['month_range'])
1334
-            : '';
1335
-        $retrieve_for_today = $view === 'today';
1336
-        $retrieve_for_this_month = $view === 'month';
1337
-
1338
-        if ($retrieve_for_today) {
1339
-            $now = date('Y-m-d', current_time('timestamp'));
1340
-            $where['REG_date'] = array(
1341
-                'BETWEEN',
1342
-                array(
1343
-                    EEM_Registration::instance()->convert_datetime_for_query(
1344
-                        'REG_date',
1345
-                        $now . ' 00:00:00',
1346
-                        'Y-m-d H:i:s'
1347
-                    ),
1348
-                    EEM_Registration::instance()->convert_datetime_for_query(
1349
-                        'REG_date',
1350
-                        $now . ' 23:59:59',
1351
-                        'Y-m-d H:i:s'
1352
-                    ),
1353
-                ),
1354
-            );
1355
-        } elseif ($retrieve_for_this_month) {
1356
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
1357
-            $days_this_month = date('t', current_time('timestamp'));
1358
-            $where['REG_date'] = array(
1359
-                'BETWEEN',
1360
-                array(
1361
-                    EEM_Registration::instance()->convert_datetime_for_query(
1362
-                        'REG_date',
1363
-                        $current_year_and_month . '-01 00:00:00',
1364
-                        'Y-m-d H:i:s'
1365
-                    ),
1366
-                    EEM_Registration::instance()->convert_datetime_for_query(
1367
-                        'REG_date',
1368
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1369
-                        'Y-m-d H:i:s'
1370
-                    ),
1371
-                ),
1372
-            );
1373
-        } elseif ($month_range) {
1374
-            $pieces = explode(' ', $month_range, 3);
1375
-            $month_requested = ! empty($pieces[0])
1376
-                ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1377
-                : '';
1378
-            $year_requested = ! empty($pieces[1])
1379
-                ? $pieces[1]
1380
-                : '';
1381
-            // if there is not a month or year then we can't go further
1382
-            if ($month_requested && $year_requested) {
1383
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1384
-                $where['REG_date'] = array(
1385
-                    'BETWEEN',
1386
-                    array(
1387
-                        EEM_Registration::instance()->convert_datetime_for_query(
1388
-                            'REG_date',
1389
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1390
-                            'Y-m-d H:i:s'
1391
-                        ),
1392
-                        EEM_Registration::instance()->convert_datetime_for_query(
1393
-                            'REG_date',
1394
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1395
-                            'Y-m-d H:i:s'
1396
-                        ),
1397
-                    ),
1398
-                );
1399
-            }
1400
-        }
1401
-        return $where;
1402
-    }
1403
-
1404
-
1405
-    /**
1406
-     * Adds any provided search restraints to the where conditions for the registrations query
1407
-     *
1408
-     * @param array $request usually the same as $this->_req_data but not necessarily
1409
-     * @return array
1410
-     */
1411
-    protected function _add_search_to_where_conditions(array $request)
1412
-    {
1413
-        $where = array();
1414
-        if (! empty($request['s'])) {
1415
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1416
-            $where['OR*search_conditions'] = array(
1417
-                'Event.EVT_name'                          => array('LIKE', $search_string),
1418
-                'Event.EVT_desc'                          => array('LIKE', $search_string),
1419
-                'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1420
-                'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1421
-                'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1422
-                'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1423
-                'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1424
-                'Attendee.ATT_email'                      => array('LIKE', $search_string),
1425
-                'Attendee.ATT_address'                    => array('LIKE', $search_string),
1426
-                'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1427
-                'Attendee.ATT_city'                       => array('LIKE', $search_string),
1428
-                'REG_final_price'                         => array('LIKE', $search_string),
1429
-                'REG_code'                                => array('LIKE', $search_string),
1430
-                'REG_count'                               => array('LIKE', $search_string),
1431
-                'REG_group_size'                          => array('LIKE', $search_string),
1432
-                'Ticket.TKT_name'                         => array('LIKE', $search_string),
1433
-                'Ticket.TKT_description'                  => array('LIKE', $search_string),
1434
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1435
-            );
1436
-        }
1437
-        return $where;
1438
-    }
1439
-
1440
-
1441
-    /**
1442
-     * Sets up the where conditions for the registrations query.
1443
-     *
1444
-     * @param array $request
1445
-     * @return array
1446
-     * @throws EE_Error
1447
-     */
1448
-    protected function _get_where_conditions_for_registrations_query($request)
1449
-    {
1450
-        return apply_filters(
1451
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1452
-            array_merge(
1453
-                $this->addAttendeeIdToWhereConditions($request),
1454
-                $this->_add_event_id_to_where_conditions($request),
1455
-                $this->_add_category_id_to_where_conditions($request),
1456
-                $this->_add_datetime_id_to_where_conditions($request),
1457
-                $this->_add_registration_status_to_where_conditions($request),
1458
-                $this->_add_date_to_where_conditions($request),
1459
-                $this->_add_search_to_where_conditions($request)
1460
-            ),
1461
-            $request
1462
-        );
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * Sets up the orderby for the registrations query.
1468
-     *
1469
-     * @return array
1470
-     */
1471
-    protected function _get_orderby_for_registrations_query()
1472
-    {
1473
-        $orderby_field = ! empty($this->_req_data['orderby'])
1474
-            ? sanitize_text_field($this->_req_data['orderby'])
1475
-            : '_REG_date';
1476
-        switch ($orderby_field) {
1477
-            case '_REG_ID':
1478
-                $orderby = array('REG_ID');
1479
-                break;
1480
-            case '_Reg_status':
1481
-                $orderby = array('STS_ID');
1482
-                break;
1483
-            case 'ATT_fname':
1484
-                $orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1485
-                break;
1486
-            case 'ATT_lname':
1487
-                $orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1488
-                break;
1489
-            case 'event_name':
1490
-                $orderby = array('Event.EVT_name');
1491
-                break;
1492
-            case 'DTT_EVT_start':
1493
-                $orderby = array('Event.Datetime.DTT_EVT_start');
1494
-                break;
1495
-            case '_REG_date':
1496
-                $orderby = array('REG_date');
1497
-                break;
1498
-            default:
1499
-                $orderby = array($orderby_field);
1500
-                break;
1501
-        }
1502
-
1503
-        // order
1504
-        $order = ! empty($this->_req_data['order'])
1505
-            ? sanitize_text_field($this->_req_data['order'])
1506
-            : 'DESC';
1507
-        $orderby = array_combine(
1508
-            $orderby,
1509
-            array_fill(0, count($orderby), $order)
1510
-        );
1511
-        // because there are many registrations with the same date, define
1512
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
1513
-        if (empty($orderby['REG_ID'])) {
1514
-            $orderby['REG_ID'] = $order;
1515
-        }
1516
-
1517
-        $orderby = apply_filters(
1518
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1519
-            $orderby,
1520
-            $this->_req_data
1521
-        );
1522
-
1523
-        return array('order_by' => $orderby);
1524
-    }
1525
-
1526
-
1527
-    /**
1528
-     * Sets up the limit for the registrations query.
1529
-     *
1530
-     * @param $per_page
1531
-     * @return array
1532
-     */
1533
-    protected function _get_limit($per_page)
1534
-    {
1535
-        $current_page = ! empty($this->_req_data['paged'])
1536
-            ? absint($this->_req_data['paged'])
1537
-            : 1;
1538
-        $per_page = ! empty($this->_req_data['perpage'])
1539
-            ? $this->_req_data['perpage']
1540
-            : $per_page;
1541
-
1542
-        // -1 means return all results so get out if that's set.
1543
-        if ((int) $per_page === -1) {
1544
-            return array();
1545
-        }
1546
-        $per_page = absint($per_page);
1547
-        $offset = ($current_page - 1) * $per_page;
1548
-        return array('limit' => array($offset, $per_page));
1549
-    }
1550
-
1551
-
1552
-    public function get_registration_status_array()
1553
-    {
1554
-        return self::$_reg_status;
1555
-    }
1556
-
1557
-
1558
-
1559
-
1560
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1561
-    /**
1562
-     *        generates HTML for the View Registration Details Admin page
1563
-     *
1564
-     * @access protected
1565
-     * @return void
1566
-     * @throws DomainException
1567
-     * @throws EE_Error
1568
-     * @throws InvalidArgumentException
1569
-     * @throws InvalidDataTypeException
1570
-     * @throws InvalidInterfaceException
1571
-     * @throws EntityNotFoundException
1572
-     */
1573
-    protected function _registration_details()
1574
-    {
1575
-        $this->_template_args = array();
1576
-        $this->_set_registration_object();
1577
-        if (is_object($this->_registration)) {
1578
-            $transaction = $this->_registration->transaction()
1579
-                ? $this->_registration->transaction()
1580
-                : EE_Transaction::new_instance();
1581
-            $this->_session = $transaction->session_data();
1582
-            $event_id = $this->_registration->event_ID();
1583
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1584
-            $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1585
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1586
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1587
-            $this->_template_args['grand_total'] = $transaction->total();
1588
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1589
-            // link back to overview
1590
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1591
-            $this->_template_args['registration'] = $this->_registration;
1592
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1593
-                array(
1594
-                    'action'   => 'default',
1595
-                    'event_id' => $event_id,
1596
-                ),
1597
-                REG_ADMIN_URL
1598
-            );
1599
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1600
-                array(
1601
-                    'action' => 'default',
1602
-                    'EVT_ID' => $event_id,
1603
-                    'page'   => 'espresso_transactions',
1604
-                ),
1605
-                admin_url('admin.php')
1606
-            );
1607
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1608
-                array(
1609
-                    'page'   => 'espresso_events',
1610
-                    'action' => 'edit',
1611
-                    'post'   => $event_id,
1612
-                ),
1613
-                admin_url('admin.php')
1614
-            );
1615
-            // next and previous links
1616
-            $next_reg = $this->_registration->next(
1617
-                null,
1618
-                array(),
1619
-                'REG_ID'
1620
-            );
1621
-            $this->_template_args['next_registration'] = $next_reg
1622
-                ? $this->_next_link(
1623
-                    EE_Admin_Page::add_query_args_and_nonce(
1624
-                        array(
1625
-                            'action'  => 'view_registration',
1626
-                            '_REG_ID' => $next_reg['REG_ID'],
1627
-                        ),
1628
-                        REG_ADMIN_URL
1629
-                    ),
1630
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1631
-                )
1632
-                : '';
1633
-            $previous_reg = $this->_registration->previous(
1634
-                null,
1635
-                array(),
1636
-                'REG_ID'
1637
-            );
1638
-            $this->_template_args['previous_registration'] = $previous_reg
1639
-                ? $this->_previous_link(
1640
-                    EE_Admin_Page::add_query_args_and_nonce(
1641
-                        array(
1642
-                            'action'  => 'view_registration',
1643
-                            '_REG_ID' => $previous_reg['REG_ID'],
1644
-                        ),
1645
-                        REG_ADMIN_URL
1646
-                    ),
1647
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1648
-                )
1649
-                : '';
1650
-            // grab header
1651
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1652
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1653
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1654
-                $template_path,
1655
-                $this->_template_args,
1656
-                true
1657
-            );
1658
-        } else {
1659
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1660
-        }
1661
-        // the details template wrapper
1662
-        $this->display_admin_page_with_sidebar();
1663
-    }
1664
-
1665
-
1666
-    protected function _registration_details_metaboxes()
1667
-    {
1668
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1669
-        $this->_set_registration_object();
1670
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1671
-        add_meta_box(
1672
-            'edit-reg-status-mbox',
1673
-            esc_html__('Registration Status', 'event_espresso'),
1674
-            array($this, 'set_reg_status_buttons_metabox'),
1675
-            $this->wp_page_slug,
1676
-            'normal',
1677
-            'high'
1678
-        );
1679
-        add_meta_box(
1680
-            'edit-reg-details-mbox',
1681
-            esc_html__('Registration Details', 'event_espresso'),
1682
-            array($this, '_reg_details_meta_box'),
1683
-            $this->wp_page_slug,
1684
-            'normal',
1685
-            'high'
1686
-        );
1687
-        if ($attendee instanceof EE_Attendee
1688
-            && EE_Registry::instance()->CAP->current_user_can(
1689
-                'ee_read_registration',
1690
-                'edit-reg-questions-mbox',
1691
-                $this->_registration->ID()
1692
-            )
1693
-        ) {
1694
-            add_meta_box(
1695
-                'edit-reg-questions-mbox',
1696
-                esc_html__('Registration Form Answers', 'event_espresso'),
1697
-                array($this, '_reg_questions_meta_box'),
1698
-                $this->wp_page_slug,
1699
-                'normal',
1700
-                'high'
1701
-            );
1702
-        }
1703
-        add_meta_box(
1704
-            'edit-reg-registrant-mbox',
1705
-            esc_html__('Contact Details', 'event_espresso'),
1706
-            array($this, '_reg_registrant_side_meta_box'),
1707
-            $this->wp_page_slug,
1708
-            'side',
1709
-            'high'
1710
-        );
1711
-        if ($this->_registration->group_size() > 1) {
1712
-            add_meta_box(
1713
-                'edit-reg-attendees-mbox',
1714
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1715
-                array($this, '_reg_attendees_meta_box'),
1716
-                $this->wp_page_slug,
1717
-                'normal',
1718
-                'high'
1719
-            );
1720
-        }
1721
-    }
1722
-
1723
-
1724
-    /**
1725
-     * set_reg_status_buttons_metabox
1726
-     *
1727
-     * @access protected
1728
-     * @return string
1729
-     * @throws \EE_Error
1730
-     */
1731
-    public function set_reg_status_buttons_metabox()
1732
-    {
1733
-        $this->_set_registration_object();
1734
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1735
-        echo $change_reg_status_form->form_open(
1736
-            self::add_query_args_and_nonce(
1737
-                array(
1738
-                    'action' => 'change_reg_status',
1739
-                ),
1740
-                REG_ADMIN_URL
1741
-            )
1742
-        );
1743
-        echo $change_reg_status_form->get_html();
1744
-        echo $change_reg_status_form->form_close();
1745
-    }
1746
-
1747
-
1748
-    /**
1749
-     * @return EE_Form_Section_Proper
1750
-     * @throws EE_Error
1751
-     * @throws InvalidArgumentException
1752
-     * @throws InvalidDataTypeException
1753
-     * @throws InvalidInterfaceException
1754
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1755
-     */
1756
-    protected function _generate_reg_status_change_form()
1757
-    {
1758
-        $reg_status_change_form_array = array(
1759
-            'name'            => 'reg_status_change_form',
1760
-            'html_id'         => 'reg-status-change-form',
1761
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1762
-            'subsections'     => array(
1763
-                'return'             => new EE_Hidden_Input(
1764
-                    array(
1765
-                        'name'    => 'return',
1766
-                        'default' => 'view_registration',
1767
-                    )
1768
-                ),
1769
-                'REG_ID'             => new EE_Hidden_Input(
1770
-                    array(
1771
-                        'name'    => 'REG_ID',
1772
-                        'default' => $this->_registration->ID(),
1773
-                    )
1774
-                ),
1775
-                'current_status'     => new EE_Form_Section_HTML(
1776
-                    EEH_HTML::table(
1777
-                        EEH_HTML::tr(
1778
-                            EEH_HTML::th(
1779
-                                EEH_HTML::label(
1780
-                                    EEH_HTML::strong(
1781
-                                        esc_html__('Current Registration Status', 'event_espresso')
1782
-                                    )
1783
-                                )
1784
-                            )
1785
-                            . EEH_HTML::td(
1786
-                                EEH_HTML::strong(
1787
-                                    $this->_registration->pretty_status(),
1788
-                                    '',
1789
-                                    'status-' . $this->_registration->status_ID(),
1790
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1791
-                                )
1792
-                            )
1793
-                        )
1794
-                    )
1795
-                )
1796
-            )
1797
-        );
1798
-        if (EE_Registry::instance()->CAP->current_user_can(
1799
-            'ee_edit_registration',
1800
-            'toggle_registration_status',
1801
-            $this->_registration->ID()
1802
-        )) {
1803
-            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1804
-                $this->_get_reg_statuses(),
1805
-                array(
1806
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1807
-                    'default'         => $this->_registration->status_ID(),
1808
-                )
1809
-            );
1810
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1811
-                array(
1812
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1813
-                    'default'         => false,
1814
-                    'html_help_text'  => esc_html__(
1815
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1816
-                        'event_espresso'
1817
-                    )
1818
-                )
1819
-            );
1820
-            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1821
-                array(
1822
-                    'html_class'      => 'button-primary',
1823
-                    'html_label_text' => '&nbsp;',
1824
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1825
-                )
1826
-            );
1827
-        }
1828
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1829
-    }
1830
-
1831
-
1832
-    /**
1833
-     * Returns an array of all the buttons for the various statuses and switch status actions
1834
-     *
1835
-     * @return array
1836
-     * @throws EE_Error
1837
-     * @throws InvalidArgumentException
1838
-     * @throws InvalidDataTypeException
1839
-     * @throws InvalidInterfaceException
1840
-     * @throws EntityNotFoundException
1841
-     */
1842
-    protected function _get_reg_statuses()
1843
-    {
1844
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1845
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1846
-        // get current reg status
1847
-        $current_status = $this->_registration->status_ID();
1848
-        // is registration for free event? This will determine whether to display the pending payment option
1849
-        if ($current_status !== EEM_Registration::status_id_pending_payment
1850
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1851
-        ) {
1852
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1853
-        }
1854
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1855
-    }
1856
-
1857
-
1858
-    /**
1859
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1860
-     *
1861
-     * @param bool $status REG status given for changing registrations to.
1862
-     * @param bool $notify Whether to send messages notifications or not.
1863
-     * @return array (array with reg_id(s) updated and whether update was successful.
1864
-     * @throws EE_Error
1865
-     * @throws InvalidArgumentException
1866
-     * @throws InvalidDataTypeException
1867
-     * @throws InvalidInterfaceException
1868
-     * @throws ReflectionException
1869
-     * @throws RuntimeException
1870
-     * @throws EntityNotFoundException
1871
-     */
1872
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1873
-    {
1874
-        if (isset($this->_req_data['reg_status_change_form'])) {
1875
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1876
-                ? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1877
-                : array();
1878
-        } else {
1879
-            $REG_IDs = isset($this->_req_data['_REG_ID'])
1880
-                ? (array) $this->_req_data['_REG_ID']
1881
-                : array();
1882
-        }
1883
-        // sanitize $REG_IDs
1884
-        $REG_IDs = array_map('absint', $REG_IDs);
1885
-        // and remove empty entries
1886
-        $REG_IDs = array_filter($REG_IDs);
1887
-
1888
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1889
-
1890
-        /**
1891
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1892
-         * Currently this value is used downstream by the _process_resend_registration method.
1893
-         *
1894
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1895
-         * @param bool                     $status           The status registrations were changed to.
1896
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1897
-         * @param Registrations_Admin_Page $admin_page_object
1898
-         */
1899
-        $this->_req_data['_REG_ID'] = apply_filters(
1900
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1901
-            $result['REG_ID'],
1902
-            $status,
1903
-            $result['success'],
1904
-            $this
1905
-        );
1906
-
1907
-        // notify?
1908
-        if ($notify
1909
-            && $result['success']
1910
-            && ! empty($this->_req_data['_REG_ID'])
1911
-            && EE_Registry::instance()->CAP->current_user_can(
1912
-                'ee_send_message',
1913
-                'espresso_registrations_resend_registration'
1914
-            )
1915
-        ) {
1916
-            $this->_process_resend_registration();
1917
-        }
1918
-        return $result;
1919
-    }
1920
-
1921
-
1922
-    /**
1923
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1924
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1925
-     *
1926
-     * @param array  $REG_IDs
1927
-     * @param string $status
1928
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1929
-     *                        slug sent with setting the registration status.
1930
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1931
-     * @throws EE_Error
1932
-     * @throws InvalidArgumentException
1933
-     * @throws InvalidDataTypeException
1934
-     * @throws InvalidInterfaceException
1935
-     * @throws ReflectionException
1936
-     * @throws RuntimeException
1937
-     * @throws EntityNotFoundException
1938
-     */
1939
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1940
-    {
1941
-        $success = false;
1942
-        // typecast $REG_IDs
1943
-        $REG_IDs = (array) $REG_IDs;
1944
-        if (! empty($REG_IDs)) {
1945
-            $success = true;
1946
-            // set default status if none is passed
1947
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1948
-            $status_context = $notify
1949
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1950
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1951
-            // loop through REG_ID's and change status
1952
-            foreach ($REG_IDs as $REG_ID) {
1953
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1954
-                if ($registration instanceof EE_Registration) {
1955
-                    $registration->set_status(
1956
-                        $status,
1957
-                        false,
1958
-                        new Context(
1959
-                            $status_context,
1960
-                            esc_html__(
1961
-                                'Manually triggered status change on a Registration Admin Page route.',
1962
-                                'event_espresso'
1963
-                            )
1964
-                        )
1965
-                    );
1966
-                    $result = $registration->save();
1967
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1968
-                    $success = $result !== false ? $success : false;
1969
-                }
1970
-            }
1971
-        }
1972
-
1973
-        // return $success and processed registrations
1974
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1975
-    }
1976
-
1977
-
1978
-    /**
1979
-     * Common logic for setting up success message and redirecting to appropriate route
1980
-     *
1981
-     * @param  string $STS_ID status id for the registration changed to
1982
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1983
-     * @return void
1984
-     * @throws EE_Error
1985
-     */
1986
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1987
-    {
1988
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1989
-            : array('success' => false);
1990
-        $success = isset($result['success']) && $result['success'];
1991
-        // setup success message
1992
-        if ($success) {
1993
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1994
-                $msg = sprintf(
1995
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1996
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1997
-                );
1998
-            } else {
1999
-                $msg = sprintf(
2000
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
2001
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
2002
-                );
2003
-            }
2004
-            EE_Error::add_success($msg);
2005
-        } else {
2006
-            EE_Error::add_error(
2007
-                esc_html__(
2008
-                    'Something went wrong, and the status was not changed',
2009
-                    'event_espresso'
2010
-                ),
2011
-                __FILE__,
2012
-                __LINE__,
2013
-                __FUNCTION__
2014
-            );
2015
-        }
2016
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2017
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2018
-        } else {
2019
-            $route = array('action' => 'default');
2020
-        }
2021
-        $route = $this->mergeExistingRequestParamsWithRedirectArgs($route);
2022
-        $this->_redirect_after_action($success, '', '', $route, true);
2023
-    }
2024
-
2025
-
2026
-    /**
2027
-     * incoming reg status change from reg details page.
2028
-     *
2029
-     * @return void
2030
-     */
2031
-    protected function _change_reg_status()
2032
-    {
2033
-        $this->_req_data['return'] = 'view_registration';
2034
-        // set notify based on whether the send notifications toggle is set or not
2035
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2036
-        // $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2037
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2038
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2039
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2040
-            case EEM_Registration::status_id_approved:
2041
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2042
-                $this->approve_registration($notify);
2043
-                break;
2044
-            case EEM_Registration::status_id_pending_payment:
2045
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2046
-                $this->pending_registration($notify);
2047
-                break;
2048
-            case EEM_Registration::status_id_not_approved:
2049
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2050
-                $this->not_approve_registration($notify);
2051
-                break;
2052
-            case EEM_Registration::status_id_declined:
2053
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2054
-                $this->decline_registration($notify);
2055
-                break;
2056
-            case EEM_Registration::status_id_cancelled:
2057
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2058
-                $this->cancel_registration($notify);
2059
-                break;
2060
-            case EEM_Registration::status_id_wait_list:
2061
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2062
-                $this->wait_list_registration($notify);
2063
-                break;
2064
-            case EEM_Registration::status_id_incomplete:
2065
-            default:
2066
-                $result['success'] = false;
2067
-                unset($this->_req_data['return']);
2068
-                $this->_reg_status_change_return('', false);
2069
-                break;
2070
-        }
2071
-    }
2072
-
2073
-
2074
-    /**
2075
-     * Callback for bulk action routes.
2076
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2077
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
2078
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2079
-     * when an action is happening on just a single registration).
2080
-     *
2081
-     * @param      $action
2082
-     * @param bool $notify
2083
-     */
2084
-    protected function bulk_action_on_registrations($action, $notify = false)
2085
-    {
2086
-        do_action(
2087
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2088
-            $this,
2089
-            $action,
2090
-            $notify
2091
-        );
2092
-        $method = $action . '_registration';
2093
-        if (method_exists($this, $method)) {
2094
-            $this->$method($notify);
2095
-        }
2096
-    }
2097
-
2098
-
2099
-    /**
2100
-     * approve_registration
2101
-     *
2102
-     * @access protected
2103
-     * @param bool $notify whether or not to notify the registrant about their approval.
2104
-     * @return void
2105
-     */
2106
-    protected function approve_registration($notify = false)
2107
-    {
2108
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2109
-    }
2110
-
2111
-
2112
-    /**
2113
-     *        decline_registration
2114
-     *
2115
-     * @access protected
2116
-     * @param bool $notify whether or not to notify the registrant about their status change.
2117
-     * @return void
2118
-     */
2119
-    protected function decline_registration($notify = false)
2120
-    {
2121
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2122
-    }
2123
-
2124
-
2125
-    /**
2126
-     *        cancel_registration
2127
-     *
2128
-     * @access protected
2129
-     * @param bool $notify whether or not to notify the registrant about their status change.
2130
-     * @return void
2131
-     */
2132
-    protected function cancel_registration($notify = false)
2133
-    {
2134
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     *        not_approve_registration
2140
-     *
2141
-     * @access protected
2142
-     * @param bool $notify whether or not to notify the registrant about their status change.
2143
-     * @return void
2144
-     */
2145
-    protected function not_approve_registration($notify = false)
2146
-    {
2147
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2148
-    }
2149
-
2150
-
2151
-    /**
2152
-     *        decline_registration
2153
-     *
2154
-     * @access protected
2155
-     * @param bool $notify whether or not to notify the registrant about their status change.
2156
-     * @return void
2157
-     */
2158
-    protected function pending_registration($notify = false)
2159
-    {
2160
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2161
-    }
2162
-
2163
-
2164
-    /**
2165
-     * waitlist_registration
2166
-     *
2167
-     * @access protected
2168
-     * @param bool $notify whether or not to notify the registrant about their status change.
2169
-     * @return void
2170
-     */
2171
-    protected function wait_list_registration($notify = false)
2172
-    {
2173
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2174
-    }
2175
-
2176
-
2177
-    /**
2178
-     *        generates HTML for the Registration main meta box
2179
-     *
2180
-     * @access public
2181
-     * @return void
2182
-     * @throws DomainException
2183
-     * @throws EE_Error
2184
-     * @throws InvalidArgumentException
2185
-     * @throws InvalidDataTypeException
2186
-     * @throws InvalidInterfaceException
2187
-     * @throws ReflectionException
2188
-     * @throws EntityNotFoundException
2189
-     */
2190
-    public function _reg_details_meta_box()
2191
-    {
2192
-        EEH_Autoloader::register_line_item_display_autoloaders();
2193
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2194
-        EE_Registry::instance()->load_helper('Line_Item');
2195
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2196
-            : EE_Transaction::new_instance();
2197
-        $this->_session = $transaction->session_data();
2198
-        $filters = new EE_Line_Item_Filter_Collection();
2199
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2200
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2201
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2202
-            $filters,
2203
-            $transaction->total_line_item()
2204
-        );
2205
-        $filtered_line_item_tree = $line_item_filter_processor->process();
2206
-        $line_item_display = new EE_Line_Item_Display(
2207
-            'reg_admin_table',
2208
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2209
-        );
2210
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2211
-            $filtered_line_item_tree,
2212
-            array('EE_Registration' => $this->_registration)
2213
-        );
2214
-        $attendee = $this->_registration->attendee();
2215
-        if (EE_Registry::instance()->CAP->current_user_can(
2216
-            'ee_read_transaction',
2217
-            'espresso_transactions_view_transaction'
2218
-        )) {
2219
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2220
-                EE_Admin_Page::add_query_args_and_nonce(
2221
-                    array(
2222
-                        'action' => 'view_transaction',
2223
-                        'TXN_ID' => $transaction->ID(),
2224
-                    ),
2225
-                    TXN_ADMIN_URL
2226
-                ),
2227
-                esc_html__(' View Transaction', 'event_espresso'),
2228
-                'button secondary-button right',
2229
-                'dashicons dashicons-cart'
2230
-            );
2231
-        } else {
2232
-            $this->_template_args['view_transaction_button'] = '';
2233
-        }
2234
-        if ($attendee instanceof EE_Attendee
2235
-            && EE_Registry::instance()->CAP->current_user_can(
2236
-                'ee_send_message',
2237
-                'espresso_registrations_resend_registration'
2238
-            )
2239
-        ) {
2240
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2241
-                EE_Admin_Page::add_query_args_and_nonce(
2242
-                    array(
2243
-                        'action'      => 'resend_registration',
2244
-                        '_REG_ID'     => $this->_registration->ID(),
2245
-                        'redirect_to' => 'view_registration',
2246
-                    ),
2247
-                    REG_ADMIN_URL
2248
-                ),
2249
-                esc_html__(' Resend Registration', 'event_espresso'),
2250
-                'button secondary-button right',
2251
-                'dashicons dashicons-email-alt'
2252
-            );
2253
-        } else {
2254
-            $this->_template_args['resend_registration_button'] = '';
2255
-        }
2256
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2257
-        $payment = $transaction->get_first_related('Payment');
2258
-        $payment = ! $payment instanceof EE_Payment
2259
-            ? EE_Payment::new_instance()
2260
-            : $payment;
2261
-        $payment_method = $payment->get_first_related('Payment_Method');
2262
-        $payment_method = ! $payment_method instanceof EE_Payment_Method
2263
-            ? EE_Payment_Method::new_instance()
2264
-            : $payment_method;
2265
-        $reg_details = array(
2266
-            'payment_method'       => $payment_method->name(),
2267
-            'response_msg'         => $payment->gateway_response(),
2268
-            'registration_id'      => $this->_registration->get('REG_code'),
2269
-            'registration_session' => $this->_registration->session_ID(),
2270
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2271
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2272
-        );
2273
-        if (isset($reg_details['registration_id'])) {
2274
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2275
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2276
-                'Registration ID',
2277
-                'event_espresso'
2278
-            );
2279
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2280
-        }
2281
-        if (isset($reg_details['payment_method'])) {
2282
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2283
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2284
-                'Most Recent Payment Method',
2285
-                'event_espresso'
2286
-            );
2287
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2288
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2289
-            $this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2290
-                'Payment method response',
2291
-                'event_espresso'
2292
-            );
2293
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2294
-        }
2295
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2296
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2297
-            'Registration Session',
2298
-            'event_espresso'
2299
-        );
2300
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2301
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2302
-        $this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2303
-            'Registration placed from IP',
2304
-            'event_espresso'
2305
-        );
2306
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2307
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2308
-        $this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2309
-            'Registrant User Agent',
2310
-            'event_espresso'
2311
-        );
2312
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2313
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2314
-            array(
2315
-                'action'   => 'default',
2316
-                'event_id' => $this->_registration->event_ID(),
2317
-            ),
2318
-            REG_ADMIN_URL
2319
-        );
2320
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2321
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2322
-        $template_path =
2323
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2324
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325
-    }
2326
-
2327
-
2328
-    /**
2329
-     * generates HTML for the Registration Questions meta box.
2330
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2331
-     * otherwise uses new forms system
2332
-     *
2333
-     * @access public
2334
-     * @return void
2335
-     * @throws DomainException
2336
-     * @throws EE_Error
2337
-     */
2338
-    public function _reg_questions_meta_box()
2339
-    {
2340
-        // allow someone to override this method entirely
2341
-        if (apply_filters(
2342
-            'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2343
-            true,
2344
-            $this,
2345
-            $this->_registration
2346
-        )) {
2347
-            $form = $this->_get_reg_custom_questions_form(
2348
-                $this->_registration->ID()
2349
-            );
2350
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2351
-                ? $form->get_html_and_js()
2352
-                : '';
2353
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2355
-            $template_path =
2356
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2357
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358
-        }
2359
-    }
2360
-
2361
-
2362
-    /**
2363
-     * form_before_question_group
2364
-     *
2365
-     * @deprecated    as of 4.8.32.rc.000
2366
-     * @access        public
2367
-     * @param        string $output
2368
-     * @return        string
2369
-     */
2370
-    public function form_before_question_group($output)
2371
-    {
2372
-        EE_Error::doing_it_wrong(
2373
-            __CLASS__ . '::' . __FUNCTION__,
2374
-            esc_html__(
2375
-                '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.',
2376
-                'event_espresso'
2377
-            ),
2378
-            '4.8.32.rc.000'
2379
-        );
2380
-        return '
1302
+		if (! empty($registration_status)) {
1303
+			$where['STS_ID'] = $registration_status;
1304
+		} else {
1305
+			// make sure we exclude incomplete registrations, but only if not trashed.
1306
+			if ($view === 'trash') {
1307
+				$where['REG_deleted'] = true;
1308
+			} elseif ($view === 'incomplete') {
1309
+				$where['STS_ID'] = EEM_Registration::status_id_incomplete;
1310
+			} else {
1311
+				$where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1312
+			}
1313
+		}
1314
+		return $where;
1315
+	}
1316
+
1317
+
1318
+	/**
1319
+	 * Adds any provided date restraints to the where conditions for the registrations query.
1320
+	 *
1321
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1322
+	 * @return array
1323
+	 * @throws EE_Error
1324
+	 * @throws InvalidArgumentException
1325
+	 * @throws InvalidDataTypeException
1326
+	 * @throws InvalidInterfaceException
1327
+	 */
1328
+	protected function _add_date_to_where_conditions(array $request)
1329
+	{
1330
+		$where = array();
1331
+		$view = EEH_Array::is_set($request, 'status', '');
1332
+		$month_range = ! empty($request['month_range'])
1333
+			? sanitize_text_field($request['month_range'])
1334
+			: '';
1335
+		$retrieve_for_today = $view === 'today';
1336
+		$retrieve_for_this_month = $view === 'month';
1337
+
1338
+		if ($retrieve_for_today) {
1339
+			$now = date('Y-m-d', current_time('timestamp'));
1340
+			$where['REG_date'] = array(
1341
+				'BETWEEN',
1342
+				array(
1343
+					EEM_Registration::instance()->convert_datetime_for_query(
1344
+						'REG_date',
1345
+						$now . ' 00:00:00',
1346
+						'Y-m-d H:i:s'
1347
+					),
1348
+					EEM_Registration::instance()->convert_datetime_for_query(
1349
+						'REG_date',
1350
+						$now . ' 23:59:59',
1351
+						'Y-m-d H:i:s'
1352
+					),
1353
+				),
1354
+			);
1355
+		} elseif ($retrieve_for_this_month) {
1356
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
1357
+			$days_this_month = date('t', current_time('timestamp'));
1358
+			$where['REG_date'] = array(
1359
+				'BETWEEN',
1360
+				array(
1361
+					EEM_Registration::instance()->convert_datetime_for_query(
1362
+						'REG_date',
1363
+						$current_year_and_month . '-01 00:00:00',
1364
+						'Y-m-d H:i:s'
1365
+					),
1366
+					EEM_Registration::instance()->convert_datetime_for_query(
1367
+						'REG_date',
1368
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1369
+						'Y-m-d H:i:s'
1370
+					),
1371
+				),
1372
+			);
1373
+		} elseif ($month_range) {
1374
+			$pieces = explode(' ', $month_range, 3);
1375
+			$month_requested = ! empty($pieces[0])
1376
+				? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1377
+				: '';
1378
+			$year_requested = ! empty($pieces[1])
1379
+				? $pieces[1]
1380
+				: '';
1381
+			// if there is not a month or year then we can't go further
1382
+			if ($month_requested && $year_requested) {
1383
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1384
+				$where['REG_date'] = array(
1385
+					'BETWEEN',
1386
+					array(
1387
+						EEM_Registration::instance()->convert_datetime_for_query(
1388
+							'REG_date',
1389
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
1390
+							'Y-m-d H:i:s'
1391
+						),
1392
+						EEM_Registration::instance()->convert_datetime_for_query(
1393
+							'REG_date',
1394
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1395
+							'Y-m-d H:i:s'
1396
+						),
1397
+					),
1398
+				);
1399
+			}
1400
+		}
1401
+		return $where;
1402
+	}
1403
+
1404
+
1405
+	/**
1406
+	 * Adds any provided search restraints to the where conditions for the registrations query
1407
+	 *
1408
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1409
+	 * @return array
1410
+	 */
1411
+	protected function _add_search_to_where_conditions(array $request)
1412
+	{
1413
+		$where = array();
1414
+		if (! empty($request['s'])) {
1415
+			$search_string = '%' . sanitize_text_field($request['s']) . '%';
1416
+			$where['OR*search_conditions'] = array(
1417
+				'Event.EVT_name'                          => array('LIKE', $search_string),
1418
+				'Event.EVT_desc'                          => array('LIKE', $search_string),
1419
+				'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1420
+				'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1421
+				'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1422
+				'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1423
+				'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1424
+				'Attendee.ATT_email'                      => array('LIKE', $search_string),
1425
+				'Attendee.ATT_address'                    => array('LIKE', $search_string),
1426
+				'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1427
+				'Attendee.ATT_city'                       => array('LIKE', $search_string),
1428
+				'REG_final_price'                         => array('LIKE', $search_string),
1429
+				'REG_code'                                => array('LIKE', $search_string),
1430
+				'REG_count'                               => array('LIKE', $search_string),
1431
+				'REG_group_size'                          => array('LIKE', $search_string),
1432
+				'Ticket.TKT_name'                         => array('LIKE', $search_string),
1433
+				'Ticket.TKT_description'                  => array('LIKE', $search_string),
1434
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1435
+			);
1436
+		}
1437
+		return $where;
1438
+	}
1439
+
1440
+
1441
+	/**
1442
+	 * Sets up the where conditions for the registrations query.
1443
+	 *
1444
+	 * @param array $request
1445
+	 * @return array
1446
+	 * @throws EE_Error
1447
+	 */
1448
+	protected function _get_where_conditions_for_registrations_query($request)
1449
+	{
1450
+		return apply_filters(
1451
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1452
+			array_merge(
1453
+				$this->addAttendeeIdToWhereConditions($request),
1454
+				$this->_add_event_id_to_where_conditions($request),
1455
+				$this->_add_category_id_to_where_conditions($request),
1456
+				$this->_add_datetime_id_to_where_conditions($request),
1457
+				$this->_add_registration_status_to_where_conditions($request),
1458
+				$this->_add_date_to_where_conditions($request),
1459
+				$this->_add_search_to_where_conditions($request)
1460
+			),
1461
+			$request
1462
+		);
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * Sets up the orderby for the registrations query.
1468
+	 *
1469
+	 * @return array
1470
+	 */
1471
+	protected function _get_orderby_for_registrations_query()
1472
+	{
1473
+		$orderby_field = ! empty($this->_req_data['orderby'])
1474
+			? sanitize_text_field($this->_req_data['orderby'])
1475
+			: '_REG_date';
1476
+		switch ($orderby_field) {
1477
+			case '_REG_ID':
1478
+				$orderby = array('REG_ID');
1479
+				break;
1480
+			case '_Reg_status':
1481
+				$orderby = array('STS_ID');
1482
+				break;
1483
+			case 'ATT_fname':
1484
+				$orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1485
+				break;
1486
+			case 'ATT_lname':
1487
+				$orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1488
+				break;
1489
+			case 'event_name':
1490
+				$orderby = array('Event.EVT_name');
1491
+				break;
1492
+			case 'DTT_EVT_start':
1493
+				$orderby = array('Event.Datetime.DTT_EVT_start');
1494
+				break;
1495
+			case '_REG_date':
1496
+				$orderby = array('REG_date');
1497
+				break;
1498
+			default:
1499
+				$orderby = array($orderby_field);
1500
+				break;
1501
+		}
1502
+
1503
+		// order
1504
+		$order = ! empty($this->_req_data['order'])
1505
+			? sanitize_text_field($this->_req_data['order'])
1506
+			: 'DESC';
1507
+		$orderby = array_combine(
1508
+			$orderby,
1509
+			array_fill(0, count($orderby), $order)
1510
+		);
1511
+		// because there are many registrations with the same date, define
1512
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
1513
+		if (empty($orderby['REG_ID'])) {
1514
+			$orderby['REG_ID'] = $order;
1515
+		}
1516
+
1517
+		$orderby = apply_filters(
1518
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1519
+			$orderby,
1520
+			$this->_req_data
1521
+		);
1522
+
1523
+		return array('order_by' => $orderby);
1524
+	}
1525
+
1526
+
1527
+	/**
1528
+	 * Sets up the limit for the registrations query.
1529
+	 *
1530
+	 * @param $per_page
1531
+	 * @return array
1532
+	 */
1533
+	protected function _get_limit($per_page)
1534
+	{
1535
+		$current_page = ! empty($this->_req_data['paged'])
1536
+			? absint($this->_req_data['paged'])
1537
+			: 1;
1538
+		$per_page = ! empty($this->_req_data['perpage'])
1539
+			? $this->_req_data['perpage']
1540
+			: $per_page;
1541
+
1542
+		// -1 means return all results so get out if that's set.
1543
+		if ((int) $per_page === -1) {
1544
+			return array();
1545
+		}
1546
+		$per_page = absint($per_page);
1547
+		$offset = ($current_page - 1) * $per_page;
1548
+		return array('limit' => array($offset, $per_page));
1549
+	}
1550
+
1551
+
1552
+	public function get_registration_status_array()
1553
+	{
1554
+		return self::$_reg_status;
1555
+	}
1556
+
1557
+
1558
+
1559
+
1560
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1561
+	/**
1562
+	 *        generates HTML for the View Registration Details Admin page
1563
+	 *
1564
+	 * @access protected
1565
+	 * @return void
1566
+	 * @throws DomainException
1567
+	 * @throws EE_Error
1568
+	 * @throws InvalidArgumentException
1569
+	 * @throws InvalidDataTypeException
1570
+	 * @throws InvalidInterfaceException
1571
+	 * @throws EntityNotFoundException
1572
+	 */
1573
+	protected function _registration_details()
1574
+	{
1575
+		$this->_template_args = array();
1576
+		$this->_set_registration_object();
1577
+		if (is_object($this->_registration)) {
1578
+			$transaction = $this->_registration->transaction()
1579
+				? $this->_registration->transaction()
1580
+				: EE_Transaction::new_instance();
1581
+			$this->_session = $transaction->session_data();
1582
+			$event_id = $this->_registration->event_ID();
1583
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1584
+			$this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1585
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1586
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1587
+			$this->_template_args['grand_total'] = $transaction->total();
1588
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1589
+			// link back to overview
1590
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1591
+			$this->_template_args['registration'] = $this->_registration;
1592
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1593
+				array(
1594
+					'action'   => 'default',
1595
+					'event_id' => $event_id,
1596
+				),
1597
+				REG_ADMIN_URL
1598
+			);
1599
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1600
+				array(
1601
+					'action' => 'default',
1602
+					'EVT_ID' => $event_id,
1603
+					'page'   => 'espresso_transactions',
1604
+				),
1605
+				admin_url('admin.php')
1606
+			);
1607
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1608
+				array(
1609
+					'page'   => 'espresso_events',
1610
+					'action' => 'edit',
1611
+					'post'   => $event_id,
1612
+				),
1613
+				admin_url('admin.php')
1614
+			);
1615
+			// next and previous links
1616
+			$next_reg = $this->_registration->next(
1617
+				null,
1618
+				array(),
1619
+				'REG_ID'
1620
+			);
1621
+			$this->_template_args['next_registration'] = $next_reg
1622
+				? $this->_next_link(
1623
+					EE_Admin_Page::add_query_args_and_nonce(
1624
+						array(
1625
+							'action'  => 'view_registration',
1626
+							'_REG_ID' => $next_reg['REG_ID'],
1627
+						),
1628
+						REG_ADMIN_URL
1629
+					),
1630
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1631
+				)
1632
+				: '';
1633
+			$previous_reg = $this->_registration->previous(
1634
+				null,
1635
+				array(),
1636
+				'REG_ID'
1637
+			);
1638
+			$this->_template_args['previous_registration'] = $previous_reg
1639
+				? $this->_previous_link(
1640
+					EE_Admin_Page::add_query_args_and_nonce(
1641
+						array(
1642
+							'action'  => 'view_registration',
1643
+							'_REG_ID' => $previous_reg['REG_ID'],
1644
+						),
1645
+						REG_ADMIN_URL
1646
+					),
1647
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1648
+				)
1649
+				: '';
1650
+			// grab header
1651
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1652
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1653
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1654
+				$template_path,
1655
+				$this->_template_args,
1656
+				true
1657
+			);
1658
+		} else {
1659
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1660
+		}
1661
+		// the details template wrapper
1662
+		$this->display_admin_page_with_sidebar();
1663
+	}
1664
+
1665
+
1666
+	protected function _registration_details_metaboxes()
1667
+	{
1668
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1669
+		$this->_set_registration_object();
1670
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1671
+		add_meta_box(
1672
+			'edit-reg-status-mbox',
1673
+			esc_html__('Registration Status', 'event_espresso'),
1674
+			array($this, 'set_reg_status_buttons_metabox'),
1675
+			$this->wp_page_slug,
1676
+			'normal',
1677
+			'high'
1678
+		);
1679
+		add_meta_box(
1680
+			'edit-reg-details-mbox',
1681
+			esc_html__('Registration Details', 'event_espresso'),
1682
+			array($this, '_reg_details_meta_box'),
1683
+			$this->wp_page_slug,
1684
+			'normal',
1685
+			'high'
1686
+		);
1687
+		if ($attendee instanceof EE_Attendee
1688
+			&& EE_Registry::instance()->CAP->current_user_can(
1689
+				'ee_read_registration',
1690
+				'edit-reg-questions-mbox',
1691
+				$this->_registration->ID()
1692
+			)
1693
+		) {
1694
+			add_meta_box(
1695
+				'edit-reg-questions-mbox',
1696
+				esc_html__('Registration Form Answers', 'event_espresso'),
1697
+				array($this, '_reg_questions_meta_box'),
1698
+				$this->wp_page_slug,
1699
+				'normal',
1700
+				'high'
1701
+			);
1702
+		}
1703
+		add_meta_box(
1704
+			'edit-reg-registrant-mbox',
1705
+			esc_html__('Contact Details', 'event_espresso'),
1706
+			array($this, '_reg_registrant_side_meta_box'),
1707
+			$this->wp_page_slug,
1708
+			'side',
1709
+			'high'
1710
+		);
1711
+		if ($this->_registration->group_size() > 1) {
1712
+			add_meta_box(
1713
+				'edit-reg-attendees-mbox',
1714
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1715
+				array($this, '_reg_attendees_meta_box'),
1716
+				$this->wp_page_slug,
1717
+				'normal',
1718
+				'high'
1719
+			);
1720
+		}
1721
+	}
1722
+
1723
+
1724
+	/**
1725
+	 * set_reg_status_buttons_metabox
1726
+	 *
1727
+	 * @access protected
1728
+	 * @return string
1729
+	 * @throws \EE_Error
1730
+	 */
1731
+	public function set_reg_status_buttons_metabox()
1732
+	{
1733
+		$this->_set_registration_object();
1734
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1735
+		echo $change_reg_status_form->form_open(
1736
+			self::add_query_args_and_nonce(
1737
+				array(
1738
+					'action' => 'change_reg_status',
1739
+				),
1740
+				REG_ADMIN_URL
1741
+			)
1742
+		);
1743
+		echo $change_reg_status_form->get_html();
1744
+		echo $change_reg_status_form->form_close();
1745
+	}
1746
+
1747
+
1748
+	/**
1749
+	 * @return EE_Form_Section_Proper
1750
+	 * @throws EE_Error
1751
+	 * @throws InvalidArgumentException
1752
+	 * @throws InvalidDataTypeException
1753
+	 * @throws InvalidInterfaceException
1754
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1755
+	 */
1756
+	protected function _generate_reg_status_change_form()
1757
+	{
1758
+		$reg_status_change_form_array = array(
1759
+			'name'            => 'reg_status_change_form',
1760
+			'html_id'         => 'reg-status-change-form',
1761
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1762
+			'subsections'     => array(
1763
+				'return'             => new EE_Hidden_Input(
1764
+					array(
1765
+						'name'    => 'return',
1766
+						'default' => 'view_registration',
1767
+					)
1768
+				),
1769
+				'REG_ID'             => new EE_Hidden_Input(
1770
+					array(
1771
+						'name'    => 'REG_ID',
1772
+						'default' => $this->_registration->ID(),
1773
+					)
1774
+				),
1775
+				'current_status'     => new EE_Form_Section_HTML(
1776
+					EEH_HTML::table(
1777
+						EEH_HTML::tr(
1778
+							EEH_HTML::th(
1779
+								EEH_HTML::label(
1780
+									EEH_HTML::strong(
1781
+										esc_html__('Current Registration Status', 'event_espresso')
1782
+									)
1783
+								)
1784
+							)
1785
+							. EEH_HTML::td(
1786
+								EEH_HTML::strong(
1787
+									$this->_registration->pretty_status(),
1788
+									'',
1789
+									'status-' . $this->_registration->status_ID(),
1790
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1791
+								)
1792
+							)
1793
+						)
1794
+					)
1795
+				)
1796
+			)
1797
+		);
1798
+		if (EE_Registry::instance()->CAP->current_user_can(
1799
+			'ee_edit_registration',
1800
+			'toggle_registration_status',
1801
+			$this->_registration->ID()
1802
+		)) {
1803
+			$reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1804
+				$this->_get_reg_statuses(),
1805
+				array(
1806
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1807
+					'default'         => $this->_registration->status_ID(),
1808
+				)
1809
+			);
1810
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1811
+				array(
1812
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1813
+					'default'         => false,
1814
+					'html_help_text'  => esc_html__(
1815
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1816
+						'event_espresso'
1817
+					)
1818
+				)
1819
+			);
1820
+			$reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1821
+				array(
1822
+					'html_class'      => 'button-primary',
1823
+					'html_label_text' => '&nbsp;',
1824
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1825
+				)
1826
+			);
1827
+		}
1828
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1829
+	}
1830
+
1831
+
1832
+	/**
1833
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1834
+	 *
1835
+	 * @return array
1836
+	 * @throws EE_Error
1837
+	 * @throws InvalidArgumentException
1838
+	 * @throws InvalidDataTypeException
1839
+	 * @throws InvalidInterfaceException
1840
+	 * @throws EntityNotFoundException
1841
+	 */
1842
+	protected function _get_reg_statuses()
1843
+	{
1844
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1845
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1846
+		// get current reg status
1847
+		$current_status = $this->_registration->status_ID();
1848
+		// is registration for free event? This will determine whether to display the pending payment option
1849
+		if ($current_status !== EEM_Registration::status_id_pending_payment
1850
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1851
+		) {
1852
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1853
+		}
1854
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1855
+	}
1856
+
1857
+
1858
+	/**
1859
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1860
+	 *
1861
+	 * @param bool $status REG status given for changing registrations to.
1862
+	 * @param bool $notify Whether to send messages notifications or not.
1863
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1864
+	 * @throws EE_Error
1865
+	 * @throws InvalidArgumentException
1866
+	 * @throws InvalidDataTypeException
1867
+	 * @throws InvalidInterfaceException
1868
+	 * @throws ReflectionException
1869
+	 * @throws RuntimeException
1870
+	 * @throws EntityNotFoundException
1871
+	 */
1872
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1873
+	{
1874
+		if (isset($this->_req_data['reg_status_change_form'])) {
1875
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1876
+				? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1877
+				: array();
1878
+		} else {
1879
+			$REG_IDs = isset($this->_req_data['_REG_ID'])
1880
+				? (array) $this->_req_data['_REG_ID']
1881
+				: array();
1882
+		}
1883
+		// sanitize $REG_IDs
1884
+		$REG_IDs = array_map('absint', $REG_IDs);
1885
+		// and remove empty entries
1886
+		$REG_IDs = array_filter($REG_IDs);
1887
+
1888
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1889
+
1890
+		/**
1891
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1892
+		 * Currently this value is used downstream by the _process_resend_registration method.
1893
+		 *
1894
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1895
+		 * @param bool                     $status           The status registrations were changed to.
1896
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1897
+		 * @param Registrations_Admin_Page $admin_page_object
1898
+		 */
1899
+		$this->_req_data['_REG_ID'] = apply_filters(
1900
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1901
+			$result['REG_ID'],
1902
+			$status,
1903
+			$result['success'],
1904
+			$this
1905
+		);
1906
+
1907
+		// notify?
1908
+		if ($notify
1909
+			&& $result['success']
1910
+			&& ! empty($this->_req_data['_REG_ID'])
1911
+			&& EE_Registry::instance()->CAP->current_user_can(
1912
+				'ee_send_message',
1913
+				'espresso_registrations_resend_registration'
1914
+			)
1915
+		) {
1916
+			$this->_process_resend_registration();
1917
+		}
1918
+		return $result;
1919
+	}
1920
+
1921
+
1922
+	/**
1923
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1924
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1925
+	 *
1926
+	 * @param array  $REG_IDs
1927
+	 * @param string $status
1928
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1929
+	 *                        slug sent with setting the registration status.
1930
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1931
+	 * @throws EE_Error
1932
+	 * @throws InvalidArgumentException
1933
+	 * @throws InvalidDataTypeException
1934
+	 * @throws InvalidInterfaceException
1935
+	 * @throws ReflectionException
1936
+	 * @throws RuntimeException
1937
+	 * @throws EntityNotFoundException
1938
+	 */
1939
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1940
+	{
1941
+		$success = false;
1942
+		// typecast $REG_IDs
1943
+		$REG_IDs = (array) $REG_IDs;
1944
+		if (! empty($REG_IDs)) {
1945
+			$success = true;
1946
+			// set default status if none is passed
1947
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1948
+			$status_context = $notify
1949
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1950
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1951
+			// loop through REG_ID's and change status
1952
+			foreach ($REG_IDs as $REG_ID) {
1953
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1954
+				if ($registration instanceof EE_Registration) {
1955
+					$registration->set_status(
1956
+						$status,
1957
+						false,
1958
+						new Context(
1959
+							$status_context,
1960
+							esc_html__(
1961
+								'Manually triggered status change on a Registration Admin Page route.',
1962
+								'event_espresso'
1963
+							)
1964
+						)
1965
+					);
1966
+					$result = $registration->save();
1967
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1968
+					$success = $result !== false ? $success : false;
1969
+				}
1970
+			}
1971
+		}
1972
+
1973
+		// return $success and processed registrations
1974
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1975
+	}
1976
+
1977
+
1978
+	/**
1979
+	 * Common logic for setting up success message and redirecting to appropriate route
1980
+	 *
1981
+	 * @param  string $STS_ID status id for the registration changed to
1982
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1983
+	 * @return void
1984
+	 * @throws EE_Error
1985
+	 */
1986
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1987
+	{
1988
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1989
+			: array('success' => false);
1990
+		$success = isset($result['success']) && $result['success'];
1991
+		// setup success message
1992
+		if ($success) {
1993
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1994
+				$msg = sprintf(
1995
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1996
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1997
+				);
1998
+			} else {
1999
+				$msg = sprintf(
2000
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
2001
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
2002
+				);
2003
+			}
2004
+			EE_Error::add_success($msg);
2005
+		} else {
2006
+			EE_Error::add_error(
2007
+				esc_html__(
2008
+					'Something went wrong, and the status was not changed',
2009
+					'event_espresso'
2010
+				),
2011
+				__FILE__,
2012
+				__LINE__,
2013
+				__FUNCTION__
2014
+			);
2015
+		}
2016
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2017
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2018
+		} else {
2019
+			$route = array('action' => 'default');
2020
+		}
2021
+		$route = $this->mergeExistingRequestParamsWithRedirectArgs($route);
2022
+		$this->_redirect_after_action($success, '', '', $route, true);
2023
+	}
2024
+
2025
+
2026
+	/**
2027
+	 * incoming reg status change from reg details page.
2028
+	 *
2029
+	 * @return void
2030
+	 */
2031
+	protected function _change_reg_status()
2032
+	{
2033
+		$this->_req_data['return'] = 'view_registration';
2034
+		// set notify based on whether the send notifications toggle is set or not
2035
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2036
+		// $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2037
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2038
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2039
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2040
+			case EEM_Registration::status_id_approved:
2041
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2042
+				$this->approve_registration($notify);
2043
+				break;
2044
+			case EEM_Registration::status_id_pending_payment:
2045
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2046
+				$this->pending_registration($notify);
2047
+				break;
2048
+			case EEM_Registration::status_id_not_approved:
2049
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2050
+				$this->not_approve_registration($notify);
2051
+				break;
2052
+			case EEM_Registration::status_id_declined:
2053
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2054
+				$this->decline_registration($notify);
2055
+				break;
2056
+			case EEM_Registration::status_id_cancelled:
2057
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2058
+				$this->cancel_registration($notify);
2059
+				break;
2060
+			case EEM_Registration::status_id_wait_list:
2061
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2062
+				$this->wait_list_registration($notify);
2063
+				break;
2064
+			case EEM_Registration::status_id_incomplete:
2065
+			default:
2066
+				$result['success'] = false;
2067
+				unset($this->_req_data['return']);
2068
+				$this->_reg_status_change_return('', false);
2069
+				break;
2070
+		}
2071
+	}
2072
+
2073
+
2074
+	/**
2075
+	 * Callback for bulk action routes.
2076
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2077
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
2078
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2079
+	 * when an action is happening on just a single registration).
2080
+	 *
2081
+	 * @param      $action
2082
+	 * @param bool $notify
2083
+	 */
2084
+	protected function bulk_action_on_registrations($action, $notify = false)
2085
+	{
2086
+		do_action(
2087
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2088
+			$this,
2089
+			$action,
2090
+			$notify
2091
+		);
2092
+		$method = $action . '_registration';
2093
+		if (method_exists($this, $method)) {
2094
+			$this->$method($notify);
2095
+		}
2096
+	}
2097
+
2098
+
2099
+	/**
2100
+	 * approve_registration
2101
+	 *
2102
+	 * @access protected
2103
+	 * @param bool $notify whether or not to notify the registrant about their approval.
2104
+	 * @return void
2105
+	 */
2106
+	protected function approve_registration($notify = false)
2107
+	{
2108
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2109
+	}
2110
+
2111
+
2112
+	/**
2113
+	 *        decline_registration
2114
+	 *
2115
+	 * @access protected
2116
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2117
+	 * @return void
2118
+	 */
2119
+	protected function decline_registration($notify = false)
2120
+	{
2121
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2122
+	}
2123
+
2124
+
2125
+	/**
2126
+	 *        cancel_registration
2127
+	 *
2128
+	 * @access protected
2129
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2130
+	 * @return void
2131
+	 */
2132
+	protected function cancel_registration($notify = false)
2133
+	{
2134
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 *        not_approve_registration
2140
+	 *
2141
+	 * @access protected
2142
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2143
+	 * @return void
2144
+	 */
2145
+	protected function not_approve_registration($notify = false)
2146
+	{
2147
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2148
+	}
2149
+
2150
+
2151
+	/**
2152
+	 *        decline_registration
2153
+	 *
2154
+	 * @access protected
2155
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2156
+	 * @return void
2157
+	 */
2158
+	protected function pending_registration($notify = false)
2159
+	{
2160
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2161
+	}
2162
+
2163
+
2164
+	/**
2165
+	 * waitlist_registration
2166
+	 *
2167
+	 * @access protected
2168
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2169
+	 * @return void
2170
+	 */
2171
+	protected function wait_list_registration($notify = false)
2172
+	{
2173
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2174
+	}
2175
+
2176
+
2177
+	/**
2178
+	 *        generates HTML for the Registration main meta box
2179
+	 *
2180
+	 * @access public
2181
+	 * @return void
2182
+	 * @throws DomainException
2183
+	 * @throws EE_Error
2184
+	 * @throws InvalidArgumentException
2185
+	 * @throws InvalidDataTypeException
2186
+	 * @throws InvalidInterfaceException
2187
+	 * @throws ReflectionException
2188
+	 * @throws EntityNotFoundException
2189
+	 */
2190
+	public function _reg_details_meta_box()
2191
+	{
2192
+		EEH_Autoloader::register_line_item_display_autoloaders();
2193
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2194
+		EE_Registry::instance()->load_helper('Line_Item');
2195
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2196
+			: EE_Transaction::new_instance();
2197
+		$this->_session = $transaction->session_data();
2198
+		$filters = new EE_Line_Item_Filter_Collection();
2199
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2200
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2201
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2202
+			$filters,
2203
+			$transaction->total_line_item()
2204
+		);
2205
+		$filtered_line_item_tree = $line_item_filter_processor->process();
2206
+		$line_item_display = new EE_Line_Item_Display(
2207
+			'reg_admin_table',
2208
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2209
+		);
2210
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2211
+			$filtered_line_item_tree,
2212
+			array('EE_Registration' => $this->_registration)
2213
+		);
2214
+		$attendee = $this->_registration->attendee();
2215
+		if (EE_Registry::instance()->CAP->current_user_can(
2216
+			'ee_read_transaction',
2217
+			'espresso_transactions_view_transaction'
2218
+		)) {
2219
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2220
+				EE_Admin_Page::add_query_args_and_nonce(
2221
+					array(
2222
+						'action' => 'view_transaction',
2223
+						'TXN_ID' => $transaction->ID(),
2224
+					),
2225
+					TXN_ADMIN_URL
2226
+				),
2227
+				esc_html__(' View Transaction', 'event_espresso'),
2228
+				'button secondary-button right',
2229
+				'dashicons dashicons-cart'
2230
+			);
2231
+		} else {
2232
+			$this->_template_args['view_transaction_button'] = '';
2233
+		}
2234
+		if ($attendee instanceof EE_Attendee
2235
+			&& EE_Registry::instance()->CAP->current_user_can(
2236
+				'ee_send_message',
2237
+				'espresso_registrations_resend_registration'
2238
+			)
2239
+		) {
2240
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2241
+				EE_Admin_Page::add_query_args_and_nonce(
2242
+					array(
2243
+						'action'      => 'resend_registration',
2244
+						'_REG_ID'     => $this->_registration->ID(),
2245
+						'redirect_to' => 'view_registration',
2246
+					),
2247
+					REG_ADMIN_URL
2248
+				),
2249
+				esc_html__(' Resend Registration', 'event_espresso'),
2250
+				'button secondary-button right',
2251
+				'dashicons dashicons-email-alt'
2252
+			);
2253
+		} else {
2254
+			$this->_template_args['resend_registration_button'] = '';
2255
+		}
2256
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2257
+		$payment = $transaction->get_first_related('Payment');
2258
+		$payment = ! $payment instanceof EE_Payment
2259
+			? EE_Payment::new_instance()
2260
+			: $payment;
2261
+		$payment_method = $payment->get_first_related('Payment_Method');
2262
+		$payment_method = ! $payment_method instanceof EE_Payment_Method
2263
+			? EE_Payment_Method::new_instance()
2264
+			: $payment_method;
2265
+		$reg_details = array(
2266
+			'payment_method'       => $payment_method->name(),
2267
+			'response_msg'         => $payment->gateway_response(),
2268
+			'registration_id'      => $this->_registration->get('REG_code'),
2269
+			'registration_session' => $this->_registration->session_ID(),
2270
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2271
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2272
+		);
2273
+		if (isset($reg_details['registration_id'])) {
2274
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2275
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2276
+				'Registration ID',
2277
+				'event_espresso'
2278
+			);
2279
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2280
+		}
2281
+		if (isset($reg_details['payment_method'])) {
2282
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2283
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2284
+				'Most Recent Payment Method',
2285
+				'event_espresso'
2286
+			);
2287
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2288
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2289
+			$this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2290
+				'Payment method response',
2291
+				'event_espresso'
2292
+			);
2293
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2294
+		}
2295
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2296
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2297
+			'Registration Session',
2298
+			'event_espresso'
2299
+		);
2300
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2301
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2302
+		$this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2303
+			'Registration placed from IP',
2304
+			'event_espresso'
2305
+		);
2306
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2307
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2308
+		$this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2309
+			'Registrant User Agent',
2310
+			'event_espresso'
2311
+		);
2312
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2313
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2314
+			array(
2315
+				'action'   => 'default',
2316
+				'event_id' => $this->_registration->event_ID(),
2317
+			),
2318
+			REG_ADMIN_URL
2319
+		);
2320
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2321
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2322
+		$template_path =
2323
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2324
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325
+	}
2326
+
2327
+
2328
+	/**
2329
+	 * generates HTML for the Registration Questions meta box.
2330
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2331
+	 * otherwise uses new forms system
2332
+	 *
2333
+	 * @access public
2334
+	 * @return void
2335
+	 * @throws DomainException
2336
+	 * @throws EE_Error
2337
+	 */
2338
+	public function _reg_questions_meta_box()
2339
+	{
2340
+		// allow someone to override this method entirely
2341
+		if (apply_filters(
2342
+			'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2343
+			true,
2344
+			$this,
2345
+			$this->_registration
2346
+		)) {
2347
+			$form = $this->_get_reg_custom_questions_form(
2348
+				$this->_registration->ID()
2349
+			);
2350
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2351
+				? $form->get_html_and_js()
2352
+				: '';
2353
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2355
+			$template_path =
2356
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2357
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358
+		}
2359
+	}
2360
+
2361
+
2362
+	/**
2363
+	 * form_before_question_group
2364
+	 *
2365
+	 * @deprecated    as of 4.8.32.rc.000
2366
+	 * @access        public
2367
+	 * @param        string $output
2368
+	 * @return        string
2369
+	 */
2370
+	public function form_before_question_group($output)
2371
+	{
2372
+		EE_Error::doing_it_wrong(
2373
+			__CLASS__ . '::' . __FUNCTION__,
2374
+			esc_html__(
2375
+				'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.',
2376
+				'event_espresso'
2377
+			),
2378
+			'4.8.32.rc.000'
2379
+		);
2380
+		return '
2381 2381
 	<table class="form-table ee-width-100">
2382 2382
 		<tbody>
2383 2383
 			';
2384
-    }
2385
-
2386
-
2387
-    /**
2388
-     * form_after_question_group
2389
-     *
2390
-     * @deprecated    as of 4.8.32.rc.000
2391
-     * @access        public
2392
-     * @param        string $output
2393
-     * @return        string
2394
-     */
2395
-    public function form_after_question_group($output)
2396
-    {
2397
-        EE_Error::doing_it_wrong(
2398
-            __CLASS__ . '::' . __FUNCTION__,
2399
-            esc_html__(
2400
-                '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.',
2401
-                'event_espresso'
2402
-            ),
2403
-            '4.8.32.rc.000'
2404
-        );
2405
-        return '
2384
+	}
2385
+
2386
+
2387
+	/**
2388
+	 * form_after_question_group
2389
+	 *
2390
+	 * @deprecated    as of 4.8.32.rc.000
2391
+	 * @access        public
2392
+	 * @param        string $output
2393
+	 * @return        string
2394
+	 */
2395
+	public function form_after_question_group($output)
2396
+	{
2397
+		EE_Error::doing_it_wrong(
2398
+			__CLASS__ . '::' . __FUNCTION__,
2399
+			esc_html__(
2400
+				'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.',
2401
+				'event_espresso'
2402
+			),
2403
+			'4.8.32.rc.000'
2404
+		);
2405
+		return '
2406 2406
 			<tr class="hide-if-no-js">
2407 2407
 				<th> </th>
2408 2408
 				<td class="reg-admin-edit-attendee-question-td">
2409 2409
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2410
-               . esc_attr__('click to edit question', 'event_espresso')
2411
-               . '">
2410
+			   . esc_attr__('click to edit question', 'event_espresso')
2411
+			   . '">
2412 2412
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2413
-               . esc_html__('edit the above question group', 'event_espresso')
2414
-               . '</span>
2413
+			   . esc_html__('edit the above question group', 'event_espresso')
2414
+			   . '</span>
2415 2415
 						<div class="dashicons dashicons-edit"></div>
2416 2416
 					</a>
2417 2417
 				</td>
@@ -2419,609 +2419,609 @@  discard block
 block discarded – undo
2419 2419
 		</tbody>
2420 2420
 	</table>
2421 2421
 ';
2422
-    }
2423
-
2424
-
2425
-    /**
2426
-     * form_form_field_label_wrap
2427
-     *
2428
-     * @deprecated    as of 4.8.32.rc.000
2429
-     * @access        public
2430
-     * @param        string $label
2431
-     * @return        string
2432
-     */
2433
-    public function form_form_field_label_wrap($label)
2434
-    {
2435
-        EE_Error::doing_it_wrong(
2436
-            __CLASS__ . '::' . __FUNCTION__,
2437
-            esc_html__(
2438
-                '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.',
2439
-                'event_espresso'
2440
-            ),
2441
-            '4.8.32.rc.000'
2442
-        );
2443
-        return '
2422
+	}
2423
+
2424
+
2425
+	/**
2426
+	 * form_form_field_label_wrap
2427
+	 *
2428
+	 * @deprecated    as of 4.8.32.rc.000
2429
+	 * @access        public
2430
+	 * @param        string $label
2431
+	 * @return        string
2432
+	 */
2433
+	public function form_form_field_label_wrap($label)
2434
+	{
2435
+		EE_Error::doing_it_wrong(
2436
+			__CLASS__ . '::' . __FUNCTION__,
2437
+			esc_html__(
2438
+				'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.',
2439
+				'event_espresso'
2440
+			),
2441
+			'4.8.32.rc.000'
2442
+		);
2443
+		return '
2444 2444
 			<tr>
2445 2445
 				<th>
2446 2446
 					' . $label . '
2447 2447
 				</th>';
2448
-    }
2449
-
2450
-
2451
-    /**
2452
-     * form_form_field_input__wrap
2453
-     *
2454
-     * @deprecated    as of 4.8.32.rc.000
2455
-     * @access        public
2456
-     * @param        string $input
2457
-     * @return        string
2458
-     */
2459
-    public function form_form_field_input__wrap($input)
2460
-    {
2461
-        EE_Error::doing_it_wrong(
2462
-            __CLASS__ . '::' . __FUNCTION__,
2463
-            esc_html__(
2464
-                '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.',
2465
-                'event_espresso'
2466
-            ),
2467
-            '4.8.32.rc.000'
2468
-        );
2469
-        return '
2448
+	}
2449
+
2450
+
2451
+	/**
2452
+	 * form_form_field_input__wrap
2453
+	 *
2454
+	 * @deprecated    as of 4.8.32.rc.000
2455
+	 * @access        public
2456
+	 * @param        string $input
2457
+	 * @return        string
2458
+	 */
2459
+	public function form_form_field_input__wrap($input)
2460
+	{
2461
+		EE_Error::doing_it_wrong(
2462
+			__CLASS__ . '::' . __FUNCTION__,
2463
+			esc_html__(
2464
+				'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.',
2465
+				'event_espresso'
2466
+			),
2467
+			'4.8.32.rc.000'
2468
+		);
2469
+		return '
2470 2470
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2471 2471
 					' . $input . '
2472 2472
 				</td>
2473 2473
 			</tr>';
2474
-    }
2475
-
2476
-
2477
-    /**
2478
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2479
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2480
-     * to display the page
2481
-     *
2482
-     * @access protected
2483
-     * @return void
2484
-     * @throws EE_Error
2485
-     */
2486
-    protected function _update_attendee_registration_form()
2487
-    {
2488
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2489
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2490
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2491
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2492
-            if ($success) {
2493
-                $what = esc_html__('Registration Form', 'event_espresso');
2494
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2495
-                    : array('action' => 'default');
2496
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2497
-            }
2498
-        }
2499
-    }
2500
-
2501
-
2502
-    /**
2503
-     * Gets the form for saving registrations custom questions (if done
2504
-     * previously retrieves the cached form object, which may have validation errors in it)
2505
-     *
2506
-     * @param int $REG_ID
2507
-     * @return EE_Registration_Custom_Questions_Form
2508
-     * @throws EE_Error
2509
-     * @throws InvalidArgumentException
2510
-     * @throws InvalidDataTypeException
2511
-     * @throws InvalidInterfaceException
2512
-     */
2513
-    protected function _get_reg_custom_questions_form($REG_ID)
2514
-    {
2515
-        if (! $this->_reg_custom_questions_form) {
2516
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2517
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518
-                EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519
-            );
2520
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2521
-        }
2522
-        return $this->_reg_custom_questions_form;
2523
-    }
2524
-
2525
-
2526
-    /**
2527
-     * Saves
2528
-     *
2529
-     * @access private
2530
-     * @param bool $REG_ID
2531
-     * @return bool
2532
-     * @throws EE_Error
2533
-     * @throws InvalidArgumentException
2534
-     * @throws InvalidDataTypeException
2535
-     * @throws InvalidInterfaceException
2536
-     */
2537
-    private function _save_reg_custom_questions_form($REG_ID = false)
2538
-    {
2539
-        if (! $REG_ID) {
2540
-            EE_Error::add_error(
2541
-                esc_html__(
2542
-                    'An error occurred. No registration ID was received.',
2543
-                    'event_espresso'
2544
-                ),
2545
-                __FILE__,
2546
-                __FUNCTION__,
2547
-                __LINE__
2548
-            );
2549
-        }
2550
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2551
-        $form->receive_form_submission($this->_req_data);
2552
-        $success = false;
2553
-        if ($form->is_valid()) {
2554
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
2555
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2556
-                    $where_conditions = array(
2557
-                        'QST_ID' => $question_id,
2558
-                        'REG_ID' => $REG_ID,
2559
-                    );
2560
-                    $possibly_new_values = array(
2561
-                        'ANS_value' => $input->normalized_value(),
2562
-                    );
2563
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
2564
-                    if ($answer instanceof EE_Answer) {
2565
-                        $success = $answer->save($possibly_new_values);
2566
-                    } else {
2567
-                        // insert it then
2568
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2569
-                        $answer = EE_Answer::new_instance($cols_n_vals);
2570
-                        $success = $answer->save();
2571
-                    }
2572
-                }
2573
-            }
2574
-        } else {
2575
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2576
-        }
2577
-        return $success;
2578
-    }
2579
-
2580
-
2581
-    /**
2582
-     *        generates HTML for the Registration main meta box
2583
-     *
2584
-     * @access public
2585
-     * @return void
2586
-     * @throws DomainException
2587
-     * @throws EE_Error
2588
-     * @throws InvalidArgumentException
2589
-     * @throws InvalidDataTypeException
2590
-     * @throws InvalidInterfaceException
2591
-     */
2592
-    public function _reg_attendees_meta_box()
2593
-    {
2594
-        $REG = EEM_Registration::instance();
2595
-        // get all other registrations on this transaction, and cache
2596
-        // the attendees for them so we don't have to run another query using force_join
2597
-        $registrations = $REG->get_all(
2598
-            array(
2599
-                array(
2600
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2601
-                    'REG_ID' => array('!=', $this->_registration->ID()),
2602
-                ),
2603
-                'force_join' => array('Attendee'),
2604
-                'default_where_conditions' => 'other_models_only',
2605
-            )
2606
-        );
2607
-        $this->_template_args['attendees'] = array();
2608
-        $this->_template_args['attendee_notice'] = '';
2609
-        if (empty($registrations)
2610
-            || (is_array($registrations)
2611
-                && ! EEH_Array::get_one_item_from_array($registrations))
2612
-        ) {
2613
-            EE_Error::add_error(
2614
-                esc_html__(
2615
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2616
-                    'event_espresso'
2617
-                ),
2618
-                __FILE__,
2619
-                __FUNCTION__,
2620
-                __LINE__
2621
-            );
2622
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2623
-        } else {
2624
-            $att_nmbr = 1;
2625
-            foreach ($registrations as $registration) {
2626
-                /* @var $registration EE_Registration */
2627
-                $attendee = $registration->attendee()
2628
-                    ? $registration->attendee()
2629
-                    : EEM_Attendee::instance()
2630
-                                  ->create_default_object();
2631
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2632
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2633
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2634
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2635
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2636
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2637
-                    ', ',
2638
-                    $attendee->full_address_as_array()
2639
-                );
2640
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2641
-                    array(
2642
-                        'action' => 'edit_attendee',
2643
-                        'post'   => $attendee->ID(),
2644
-                    ),
2645
-                    REG_ADMIN_URL
2646
-                );
2647
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2648
-                    ? $registration->event_obj()->name()
2649
-                    : '';
2650
-                $att_nmbr++;
2651
-            }
2652
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2653
-        }
2654
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2655
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2656
-    }
2657
-
2658
-
2659
-    /**
2660
-     *        generates HTML for the Edit Registration side meta box
2661
-     *
2662
-     * @access public
2663
-     * @return void
2664
-     * @throws DomainException
2665
-     * @throws EE_Error
2666
-     * @throws InvalidArgumentException
2667
-     * @throws InvalidDataTypeException
2668
-     * @throws InvalidInterfaceException
2669
-     */
2670
-    public function _reg_registrant_side_meta_box()
2671
-    {
2672
-        /*@var $attendee EE_Attendee */
2673
-        $att_check = $this->_registration->attendee();
2674
-        $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2675
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2676
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2677
-        // primary registration object (that way we know if we need to show create button or not)
2678
-        if (! $this->_registration->is_primary_registrant()) {
2679
-            $primary_registration = $this->_registration->get_primary_registration();
2680
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2681
-                : null;
2682
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2683
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2684
-                // custom attendee object so let's not worry about the primary reg.
2685
-                $primary_registration = null;
2686
-            }
2687
-        } else {
2688
-            $primary_registration = null;
2689
-        }
2690
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2691
-        $this->_template_args['fname'] = $attendee->fname();
2692
-        $this->_template_args['lname'] = $attendee->lname();
2693
-        $this->_template_args['email'] = $attendee->email();
2694
-        $this->_template_args['phone'] = $attendee->phone();
2695
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2696
-        // edit link
2697
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2698
-            array(
2699
-                'action' => 'edit_attendee',
2700
-                'post'   => $attendee->ID(),
2701
-            ),
2702
-            REG_ADMIN_URL
2703
-        );
2704
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2705
-        // create link
2706
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2707
-            ? EE_Admin_Page::add_query_args_and_nonce(
2708
-                array(
2709
-                    'action'  => 'duplicate_attendee',
2710
-                    '_REG_ID' => $this->_registration->ID(),
2711
-                ),
2712
-                REG_ADMIN_URL
2713
-            ) : '';
2714
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2715
-        $this->_template_args['att_check'] = $att_check;
2716
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2717
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2718
-    }
2719
-
2720
-
2721
-    /**
2722
-     * trash or restore registrations
2723
-     *
2724
-     * @param  boolean $trash whether to archive or restore
2725
-     * @return void
2726
-     * @throws EE_Error
2727
-     * @throws InvalidArgumentException
2728
-     * @throws InvalidDataTypeException
2729
-     * @throws InvalidInterfaceException
2730
-     * @throws RuntimeException
2731
-     * @access protected
2732
-     */
2733
-    protected function _trash_or_restore_registrations($trash = true)
2734
-    {
2735
-        // if empty _REG_ID then get out because there's nothing to do
2736
-        if (empty($this->_req_data['_REG_ID'])) {
2737
-            EE_Error::add_error(
2738
-                sprintf(
2739
-                    esc_html__(
2740
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2741
-                        'event_espresso'
2742
-                    ),
2743
-                    $trash ? 'trash' : 'restore'
2744
-                ),
2745
-                __FILE__,
2746
-                __LINE__,
2747
-                __FUNCTION__
2748
-            );
2749
-            $this->_redirect_after_action(false, '', '', array(), true);
2750
-        }
2751
-        $success = 0;
2752
-        $overwrite_msgs = false;
2753
-        // Checkboxes
2754
-        if (! is_array($this->_req_data['_REG_ID'])) {
2755
-            $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2756
-        }
2757
-        $reg_count = count($this->_req_data['_REG_ID']);
2758
-        // cycle thru checkboxes
2759
-        foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2760
-            /** @var EE_Registration $REG */
2761
-            $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2762
-            $payments = $REG->registration_payments();
2763
-            if (! empty($payments)) {
2764
-                $name = $REG->attendee() instanceof EE_Attendee
2765
-                    ? $REG->attendee()->full_name()
2766
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2767
-                $overwrite_msgs = true;
2768
-                EE_Error::add_error(
2769
-                    sprintf(
2770
-                        esc_html__(
2771
-                            '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.',
2772
-                            'event_espresso'
2773
-                        ),
2774
-                        $name
2775
-                    ),
2776
-                    __FILE__,
2777
-                    __FUNCTION__,
2778
-                    __LINE__
2779
-                );
2780
-                // can't trash this registration because it has payments.
2781
-                continue;
2782
-            }
2783
-            $updated = $trash ? $REG->delete() : $REG->restore();
2784
-            if ($updated) {
2785
-                $success++;
2786
-            }
2787
-        }
2788
-        $this->_redirect_after_action(
2789
-            $success === $reg_count, // were ALL registrations affected?
2790
-            $success > 1
2791
-                ? esc_html__('Registrations', 'event_espresso')
2792
-                : esc_html__('Registration', 'event_espresso'),
2793
-            $trash
2794
-                ? esc_html__('moved to the trash', 'event_espresso')
2795
-                : esc_html__('restored', 'event_espresso'),
2796
-            $this->mergeExistingRequestParamsWithRedirectArgs(array('action' => 'default')),
2797
-            $overwrite_msgs
2798
-        );
2799
-    }
2800
-
2801
-
2802
-    /**
2803
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2804
-     * registration but also.
2805
-     * 1. Removing relations to EE_Attendee
2806
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2807
-     * ALSO trashed.
2808
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2809
-     * 4. Removing relationships between all tickets and the related registrations
2810
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2811
-     * 6. Deleting permanently any related Checkins.
2812
-     *
2813
-     * @return void
2814
-     * @throws EE_Error
2815
-     * @throws InvalidArgumentException
2816
-     * @throws InvalidDataTypeException
2817
-     * @throws InvalidInterfaceException
2818
-     */
2819
-    protected function _delete_registrations()
2820
-    {
2821
-        $REG_MDL = EEM_Registration::instance();
2822
-        $success = 1;
2823
-        // Checkboxes
2824
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2825
-            // if array has more than one element than success message should be plural
2826
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2827
-            // cycle thru checkboxes
2828
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2829
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2830
-                if (! $REG instanceof EE_Registration) {
2831
-                    continue;
2832
-                }
2833
-                $deleted = $this->_delete_registration($REG);
2834
-                if (! $deleted) {
2835
-                    $success = 0;
2836
-                }
2837
-            }
2838
-        } else {
2839
-            // grab single id and delete
2840
-            $REG_ID = $this->_req_data['_REG_ID'];
2841
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2842
-            $deleted = $this->_delete_registration($REG);
2843
-            if (! $deleted) {
2844
-                $success = 0;
2845
-            }
2846
-        }
2847
-        $what = $success > 1
2848
-            ? esc_html__('Registrations', 'event_espresso')
2849
-            : esc_html__('Registration', 'event_espresso');
2850
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2851
-        $this->_redirect_after_action(
2852
-            $success,
2853
-            $what,
2854
-            $action_desc,
2855
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2856
-            true
2857
-        );
2858
-    }
2859
-
2860
-
2861
-    /**
2862
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2863
-     * models get affected.
2864
-     *
2865
-     * @param  EE_Registration $REG registration to be deleted permenantly
2866
-     * @return bool true = successful deletion, false = fail.
2867
-     * @throws EE_Error
2868
-     */
2869
-    protected function _delete_registration(EE_Registration $REG)
2870
-    {
2871
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2872
-        // registrations on the transaction that are NOT trashed.
2873
-        $TXN = $REG->get_first_related('Transaction');
2874
-        $REGS = $TXN->get_many_related('Registration');
2875
-        $all_trashed = true;
2876
-        foreach ($REGS as $registration) {
2877
-            if (! $registration->get('REG_deleted')) {
2878
-                $all_trashed = false;
2879
-            }
2880
-        }
2881
-        if (! $all_trashed) {
2882
-            EE_Error::add_error(
2883
-                esc_html__(
2884
-                    '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.',
2885
-                    'event_espresso'
2886
-                ),
2887
-                __FILE__,
2888
-                __FUNCTION__,
2889
-                __LINE__
2890
-            );
2891
-            return false;
2892
-        }
2893
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2894
-        // separately from THIS one).
2895
-        foreach ($REGS as $registration) {
2896
-            // delete related answers
2897
-            $registration->delete_related_permanently('Answer');
2898
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2899
-            $attendee = $registration->get_first_related('Attendee');
2900
-            if ($attendee instanceof EE_Attendee) {
2901
-                $registration->_remove_relation_to($attendee, 'Attendee');
2902
-            }
2903
-            // now remove relationships to tickets on this registration.
2904
-            $registration->_remove_relations('Ticket');
2905
-            // now delete permanently the checkins related to this registration.
2906
-            $registration->delete_related_permanently('Checkin');
2907
-            if ($registration->ID() === $REG->ID()) {
2908
-                continue;
2909
-            } //we don't want to delete permanently the existing registration just yet.
2910
-            // remove relation to transaction for these registrations if NOT the existing registrations
2911
-            $registration->_remove_relations('Transaction');
2912
-            // delete permanently any related messages.
2913
-            $registration->delete_related_permanently('Message');
2914
-            // now delete this registration permanently
2915
-            $registration->delete_permanently();
2916
-        }
2917
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2918
-        // (the transaction and line items should be all that's left).
2919
-        // delete the line items related to the transaction for this registration.
2920
-        $TXN->delete_related_permanently('Line_Item');
2921
-        // we need to remove all the relationships on the transaction
2922
-        $TXN->delete_related_permanently('Payment');
2923
-        $TXN->delete_related_permanently('Extra_Meta');
2924
-        $TXN->delete_related_permanently('Message');
2925
-        // now we can delete this REG permanently (and the transaction of course)
2926
-        $REG->delete_related_permanently('Transaction');
2927
-        return $REG->delete_permanently();
2928
-    }
2929
-
2930
-
2931
-    /**
2932
-     *    generates HTML for the Register New Attendee Admin page
2933
-     *
2934
-     * @access private
2935
-     * @throws DomainException
2936
-     * @throws EE_Error
2937
-     */
2938
-    public function new_registration()
2939
-    {
2940
-        if (! $this->_set_reg_event()) {
2941
-            throw new EE_Error(
2942
-                esc_html__(
2943
-                    'Unable to continue with registering because there is no Event ID in the request',
2944
-                    'event_espresso'
2945
-                )
2946
-            );
2947
-        }
2948
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2949
-        // gotta start with a clean slate if we're not coming here via ajax
2950
-        if (! defined('DOING_AJAX')
2951
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2952
-        ) {
2953
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2954
-        }
2955
-        $this->_template_args['event_name'] = '';
2956
-        // event name
2957
-        if ($this->_reg_event) {
2958
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2959
-            $edit_event_url = self::add_query_args_and_nonce(
2960
-                array(
2961
-                    'action' => 'edit',
2962
-                    'post'   => $this->_reg_event->ID(),
2963
-                ),
2964
-                EVENTS_ADMIN_URL
2965
-            );
2966
-            $edit_event_lnk = '<a href="'
2967
-                              . $edit_event_url
2968
-                              . '" title="'
2969
-                              . esc_attr__('Edit ', 'event_espresso')
2970
-                              . $this->_reg_event->name()
2971
-                              . '">'
2972
-                              . esc_html__('Edit Event', 'event_espresso')
2973
-                              . '</a>';
2974
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2975
-                                                   . $edit_event_lnk
2976
-                                                   . '</span>';
2977
-        }
2978
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2979
-        if (defined('DOING_AJAX')) {
2980
-            $this->_return_json();
2981
-        }
2982
-        // grab header
2983
-        $template_path =
2984
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2985
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2986
-            $template_path,
2987
-            $this->_template_args,
2988
-            true
2989
-        );
2990
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2991
-        // the details template wrapper
2992
-        $this->display_admin_page_with_sidebar();
2993
-    }
2994
-
2995
-
2996
-    /**
2997
-     * This returns the content for a registration step
2998
-     *
2999
-     * @access protected
3000
-     * @return string html
3001
-     * @throws DomainException
3002
-     * @throws EE_Error
3003
-     * @throws InvalidArgumentException
3004
-     * @throws InvalidDataTypeException
3005
-     * @throws InvalidInterfaceException
3006
-     */
3007
-    protected function _get_registration_step_content()
3008
-    {
3009
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3010
-            $warning_msg = sprintf(
3011
-                esc_html__(
3012
-                    '%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',
3013
-                    'event_espresso'
3014
-                ),
3015
-                '<br />',
3016
-                '<h3 class="important-notice">',
3017
-                '</h3>',
3018
-                '<div class="float-right">',
3019
-                '<span id="redirect_timer" class="important-notice">30</span>',
3020
-                '</div>',
3021
-                '<b>',
3022
-                '</b>'
3023
-            );
3024
-            return '
2474
+	}
2475
+
2476
+
2477
+	/**
2478
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2479
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2480
+	 * to display the page
2481
+	 *
2482
+	 * @access protected
2483
+	 * @return void
2484
+	 * @throws EE_Error
2485
+	 */
2486
+	protected function _update_attendee_registration_form()
2487
+	{
2488
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2489
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2490
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2491
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2492
+			if ($success) {
2493
+				$what = esc_html__('Registration Form', 'event_espresso');
2494
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2495
+					: array('action' => 'default');
2496
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2497
+			}
2498
+		}
2499
+	}
2500
+
2501
+
2502
+	/**
2503
+	 * Gets the form for saving registrations custom questions (if done
2504
+	 * previously retrieves the cached form object, which may have validation errors in it)
2505
+	 *
2506
+	 * @param int $REG_ID
2507
+	 * @return EE_Registration_Custom_Questions_Form
2508
+	 * @throws EE_Error
2509
+	 * @throws InvalidArgumentException
2510
+	 * @throws InvalidDataTypeException
2511
+	 * @throws InvalidInterfaceException
2512
+	 */
2513
+	protected function _get_reg_custom_questions_form($REG_ID)
2514
+	{
2515
+		if (! $this->_reg_custom_questions_form) {
2516
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2517
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518
+				EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519
+			);
2520
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2521
+		}
2522
+		return $this->_reg_custom_questions_form;
2523
+	}
2524
+
2525
+
2526
+	/**
2527
+	 * Saves
2528
+	 *
2529
+	 * @access private
2530
+	 * @param bool $REG_ID
2531
+	 * @return bool
2532
+	 * @throws EE_Error
2533
+	 * @throws InvalidArgumentException
2534
+	 * @throws InvalidDataTypeException
2535
+	 * @throws InvalidInterfaceException
2536
+	 */
2537
+	private function _save_reg_custom_questions_form($REG_ID = false)
2538
+	{
2539
+		if (! $REG_ID) {
2540
+			EE_Error::add_error(
2541
+				esc_html__(
2542
+					'An error occurred. No registration ID was received.',
2543
+					'event_espresso'
2544
+				),
2545
+				__FILE__,
2546
+				__FUNCTION__,
2547
+				__LINE__
2548
+			);
2549
+		}
2550
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2551
+		$form->receive_form_submission($this->_req_data);
2552
+		$success = false;
2553
+		if ($form->is_valid()) {
2554
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
2555
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2556
+					$where_conditions = array(
2557
+						'QST_ID' => $question_id,
2558
+						'REG_ID' => $REG_ID,
2559
+					);
2560
+					$possibly_new_values = array(
2561
+						'ANS_value' => $input->normalized_value(),
2562
+					);
2563
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
2564
+					if ($answer instanceof EE_Answer) {
2565
+						$success = $answer->save($possibly_new_values);
2566
+					} else {
2567
+						// insert it then
2568
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2569
+						$answer = EE_Answer::new_instance($cols_n_vals);
2570
+						$success = $answer->save();
2571
+					}
2572
+				}
2573
+			}
2574
+		} else {
2575
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2576
+		}
2577
+		return $success;
2578
+	}
2579
+
2580
+
2581
+	/**
2582
+	 *        generates HTML for the Registration main meta box
2583
+	 *
2584
+	 * @access public
2585
+	 * @return void
2586
+	 * @throws DomainException
2587
+	 * @throws EE_Error
2588
+	 * @throws InvalidArgumentException
2589
+	 * @throws InvalidDataTypeException
2590
+	 * @throws InvalidInterfaceException
2591
+	 */
2592
+	public function _reg_attendees_meta_box()
2593
+	{
2594
+		$REG = EEM_Registration::instance();
2595
+		// get all other registrations on this transaction, and cache
2596
+		// the attendees for them so we don't have to run another query using force_join
2597
+		$registrations = $REG->get_all(
2598
+			array(
2599
+				array(
2600
+					'TXN_ID' => $this->_registration->transaction_ID(),
2601
+					'REG_ID' => array('!=', $this->_registration->ID()),
2602
+				),
2603
+				'force_join' => array('Attendee'),
2604
+				'default_where_conditions' => 'other_models_only',
2605
+			)
2606
+		);
2607
+		$this->_template_args['attendees'] = array();
2608
+		$this->_template_args['attendee_notice'] = '';
2609
+		if (empty($registrations)
2610
+			|| (is_array($registrations)
2611
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2612
+		) {
2613
+			EE_Error::add_error(
2614
+				esc_html__(
2615
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2616
+					'event_espresso'
2617
+				),
2618
+				__FILE__,
2619
+				__FUNCTION__,
2620
+				__LINE__
2621
+			);
2622
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2623
+		} else {
2624
+			$att_nmbr = 1;
2625
+			foreach ($registrations as $registration) {
2626
+				/* @var $registration EE_Registration */
2627
+				$attendee = $registration->attendee()
2628
+					? $registration->attendee()
2629
+					: EEM_Attendee::instance()
2630
+								  ->create_default_object();
2631
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2632
+				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2633
+				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2634
+				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2635
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2636
+				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2637
+					', ',
2638
+					$attendee->full_address_as_array()
2639
+				);
2640
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2641
+					array(
2642
+						'action' => 'edit_attendee',
2643
+						'post'   => $attendee->ID(),
2644
+					),
2645
+					REG_ADMIN_URL
2646
+				);
2647
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2648
+					? $registration->event_obj()->name()
2649
+					: '';
2650
+				$att_nmbr++;
2651
+			}
2652
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2653
+		}
2654
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2655
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2656
+	}
2657
+
2658
+
2659
+	/**
2660
+	 *        generates HTML for the Edit Registration side meta box
2661
+	 *
2662
+	 * @access public
2663
+	 * @return void
2664
+	 * @throws DomainException
2665
+	 * @throws EE_Error
2666
+	 * @throws InvalidArgumentException
2667
+	 * @throws InvalidDataTypeException
2668
+	 * @throws InvalidInterfaceException
2669
+	 */
2670
+	public function _reg_registrant_side_meta_box()
2671
+	{
2672
+		/*@var $attendee EE_Attendee */
2673
+		$att_check = $this->_registration->attendee();
2674
+		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2675
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2676
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2677
+		// primary registration object (that way we know if we need to show create button or not)
2678
+		if (! $this->_registration->is_primary_registrant()) {
2679
+			$primary_registration = $this->_registration->get_primary_registration();
2680
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2681
+				: null;
2682
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2683
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2684
+				// custom attendee object so let's not worry about the primary reg.
2685
+				$primary_registration = null;
2686
+			}
2687
+		} else {
2688
+			$primary_registration = null;
2689
+		}
2690
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2691
+		$this->_template_args['fname'] = $attendee->fname();
2692
+		$this->_template_args['lname'] = $attendee->lname();
2693
+		$this->_template_args['email'] = $attendee->email();
2694
+		$this->_template_args['phone'] = $attendee->phone();
2695
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2696
+		// edit link
2697
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2698
+			array(
2699
+				'action' => 'edit_attendee',
2700
+				'post'   => $attendee->ID(),
2701
+			),
2702
+			REG_ADMIN_URL
2703
+		);
2704
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2705
+		// create link
2706
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2707
+			? EE_Admin_Page::add_query_args_and_nonce(
2708
+				array(
2709
+					'action'  => 'duplicate_attendee',
2710
+					'_REG_ID' => $this->_registration->ID(),
2711
+				),
2712
+				REG_ADMIN_URL
2713
+			) : '';
2714
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2715
+		$this->_template_args['att_check'] = $att_check;
2716
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2717
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2718
+	}
2719
+
2720
+
2721
+	/**
2722
+	 * trash or restore registrations
2723
+	 *
2724
+	 * @param  boolean $trash whether to archive or restore
2725
+	 * @return void
2726
+	 * @throws EE_Error
2727
+	 * @throws InvalidArgumentException
2728
+	 * @throws InvalidDataTypeException
2729
+	 * @throws InvalidInterfaceException
2730
+	 * @throws RuntimeException
2731
+	 * @access protected
2732
+	 */
2733
+	protected function _trash_or_restore_registrations($trash = true)
2734
+	{
2735
+		// if empty _REG_ID then get out because there's nothing to do
2736
+		if (empty($this->_req_data['_REG_ID'])) {
2737
+			EE_Error::add_error(
2738
+				sprintf(
2739
+					esc_html__(
2740
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2741
+						'event_espresso'
2742
+					),
2743
+					$trash ? 'trash' : 'restore'
2744
+				),
2745
+				__FILE__,
2746
+				__LINE__,
2747
+				__FUNCTION__
2748
+			);
2749
+			$this->_redirect_after_action(false, '', '', array(), true);
2750
+		}
2751
+		$success = 0;
2752
+		$overwrite_msgs = false;
2753
+		// Checkboxes
2754
+		if (! is_array($this->_req_data['_REG_ID'])) {
2755
+			$this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2756
+		}
2757
+		$reg_count = count($this->_req_data['_REG_ID']);
2758
+		// cycle thru checkboxes
2759
+		foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2760
+			/** @var EE_Registration $REG */
2761
+			$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2762
+			$payments = $REG->registration_payments();
2763
+			if (! empty($payments)) {
2764
+				$name = $REG->attendee() instanceof EE_Attendee
2765
+					? $REG->attendee()->full_name()
2766
+					: esc_html__('Unknown Attendee', 'event_espresso');
2767
+				$overwrite_msgs = true;
2768
+				EE_Error::add_error(
2769
+					sprintf(
2770
+						esc_html__(
2771
+							'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.',
2772
+							'event_espresso'
2773
+						),
2774
+						$name
2775
+					),
2776
+					__FILE__,
2777
+					__FUNCTION__,
2778
+					__LINE__
2779
+				);
2780
+				// can't trash this registration because it has payments.
2781
+				continue;
2782
+			}
2783
+			$updated = $trash ? $REG->delete() : $REG->restore();
2784
+			if ($updated) {
2785
+				$success++;
2786
+			}
2787
+		}
2788
+		$this->_redirect_after_action(
2789
+			$success === $reg_count, // were ALL registrations affected?
2790
+			$success > 1
2791
+				? esc_html__('Registrations', 'event_espresso')
2792
+				: esc_html__('Registration', 'event_espresso'),
2793
+			$trash
2794
+				? esc_html__('moved to the trash', 'event_espresso')
2795
+				: esc_html__('restored', 'event_espresso'),
2796
+			$this->mergeExistingRequestParamsWithRedirectArgs(array('action' => 'default')),
2797
+			$overwrite_msgs
2798
+		);
2799
+	}
2800
+
2801
+
2802
+	/**
2803
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2804
+	 * registration but also.
2805
+	 * 1. Removing relations to EE_Attendee
2806
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2807
+	 * ALSO trashed.
2808
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2809
+	 * 4. Removing relationships between all tickets and the related registrations
2810
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2811
+	 * 6. Deleting permanently any related Checkins.
2812
+	 *
2813
+	 * @return void
2814
+	 * @throws EE_Error
2815
+	 * @throws InvalidArgumentException
2816
+	 * @throws InvalidDataTypeException
2817
+	 * @throws InvalidInterfaceException
2818
+	 */
2819
+	protected function _delete_registrations()
2820
+	{
2821
+		$REG_MDL = EEM_Registration::instance();
2822
+		$success = 1;
2823
+		// Checkboxes
2824
+		if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2825
+			// if array has more than one element than success message should be plural
2826
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2827
+			// cycle thru checkboxes
2828
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2829
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2830
+				if (! $REG instanceof EE_Registration) {
2831
+					continue;
2832
+				}
2833
+				$deleted = $this->_delete_registration($REG);
2834
+				if (! $deleted) {
2835
+					$success = 0;
2836
+				}
2837
+			}
2838
+		} else {
2839
+			// grab single id and delete
2840
+			$REG_ID = $this->_req_data['_REG_ID'];
2841
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2842
+			$deleted = $this->_delete_registration($REG);
2843
+			if (! $deleted) {
2844
+				$success = 0;
2845
+			}
2846
+		}
2847
+		$what = $success > 1
2848
+			? esc_html__('Registrations', 'event_espresso')
2849
+			: esc_html__('Registration', 'event_espresso');
2850
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2851
+		$this->_redirect_after_action(
2852
+			$success,
2853
+			$what,
2854
+			$action_desc,
2855
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2856
+			true
2857
+		);
2858
+	}
2859
+
2860
+
2861
+	/**
2862
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2863
+	 * models get affected.
2864
+	 *
2865
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2866
+	 * @return bool true = successful deletion, false = fail.
2867
+	 * @throws EE_Error
2868
+	 */
2869
+	protected function _delete_registration(EE_Registration $REG)
2870
+	{
2871
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2872
+		// registrations on the transaction that are NOT trashed.
2873
+		$TXN = $REG->get_first_related('Transaction');
2874
+		$REGS = $TXN->get_many_related('Registration');
2875
+		$all_trashed = true;
2876
+		foreach ($REGS as $registration) {
2877
+			if (! $registration->get('REG_deleted')) {
2878
+				$all_trashed = false;
2879
+			}
2880
+		}
2881
+		if (! $all_trashed) {
2882
+			EE_Error::add_error(
2883
+				esc_html__(
2884
+					'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.',
2885
+					'event_espresso'
2886
+				),
2887
+				__FILE__,
2888
+				__FUNCTION__,
2889
+				__LINE__
2890
+			);
2891
+			return false;
2892
+		}
2893
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2894
+		// separately from THIS one).
2895
+		foreach ($REGS as $registration) {
2896
+			// delete related answers
2897
+			$registration->delete_related_permanently('Answer');
2898
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2899
+			$attendee = $registration->get_first_related('Attendee');
2900
+			if ($attendee instanceof EE_Attendee) {
2901
+				$registration->_remove_relation_to($attendee, 'Attendee');
2902
+			}
2903
+			// now remove relationships to tickets on this registration.
2904
+			$registration->_remove_relations('Ticket');
2905
+			// now delete permanently the checkins related to this registration.
2906
+			$registration->delete_related_permanently('Checkin');
2907
+			if ($registration->ID() === $REG->ID()) {
2908
+				continue;
2909
+			} //we don't want to delete permanently the existing registration just yet.
2910
+			// remove relation to transaction for these registrations if NOT the existing registrations
2911
+			$registration->_remove_relations('Transaction');
2912
+			// delete permanently any related messages.
2913
+			$registration->delete_related_permanently('Message');
2914
+			// now delete this registration permanently
2915
+			$registration->delete_permanently();
2916
+		}
2917
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2918
+		// (the transaction and line items should be all that's left).
2919
+		// delete the line items related to the transaction for this registration.
2920
+		$TXN->delete_related_permanently('Line_Item');
2921
+		// we need to remove all the relationships on the transaction
2922
+		$TXN->delete_related_permanently('Payment');
2923
+		$TXN->delete_related_permanently('Extra_Meta');
2924
+		$TXN->delete_related_permanently('Message');
2925
+		// now we can delete this REG permanently (and the transaction of course)
2926
+		$REG->delete_related_permanently('Transaction');
2927
+		return $REG->delete_permanently();
2928
+	}
2929
+
2930
+
2931
+	/**
2932
+	 *    generates HTML for the Register New Attendee Admin page
2933
+	 *
2934
+	 * @access private
2935
+	 * @throws DomainException
2936
+	 * @throws EE_Error
2937
+	 */
2938
+	public function new_registration()
2939
+	{
2940
+		if (! $this->_set_reg_event()) {
2941
+			throw new EE_Error(
2942
+				esc_html__(
2943
+					'Unable to continue with registering because there is no Event ID in the request',
2944
+					'event_espresso'
2945
+				)
2946
+			);
2947
+		}
2948
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2949
+		// gotta start with a clean slate if we're not coming here via ajax
2950
+		if (! defined('DOING_AJAX')
2951
+			&& (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2952
+		) {
2953
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2954
+		}
2955
+		$this->_template_args['event_name'] = '';
2956
+		// event name
2957
+		if ($this->_reg_event) {
2958
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2959
+			$edit_event_url = self::add_query_args_and_nonce(
2960
+				array(
2961
+					'action' => 'edit',
2962
+					'post'   => $this->_reg_event->ID(),
2963
+				),
2964
+				EVENTS_ADMIN_URL
2965
+			);
2966
+			$edit_event_lnk = '<a href="'
2967
+							  . $edit_event_url
2968
+							  . '" title="'
2969
+							  . esc_attr__('Edit ', 'event_espresso')
2970
+							  . $this->_reg_event->name()
2971
+							  . '">'
2972
+							  . esc_html__('Edit Event', 'event_espresso')
2973
+							  . '</a>';
2974
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2975
+												   . $edit_event_lnk
2976
+												   . '</span>';
2977
+		}
2978
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2979
+		if (defined('DOING_AJAX')) {
2980
+			$this->_return_json();
2981
+		}
2982
+		// grab header
2983
+		$template_path =
2984
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2985
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2986
+			$template_path,
2987
+			$this->_template_args,
2988
+			true
2989
+		);
2990
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2991
+		// the details template wrapper
2992
+		$this->display_admin_page_with_sidebar();
2993
+	}
2994
+
2995
+
2996
+	/**
2997
+	 * This returns the content for a registration step
2998
+	 *
2999
+	 * @access protected
3000
+	 * @return string html
3001
+	 * @throws DomainException
3002
+	 * @throws EE_Error
3003
+	 * @throws InvalidArgumentException
3004
+	 * @throws InvalidDataTypeException
3005
+	 * @throws InvalidInterfaceException
3006
+	 */
3007
+	protected function _get_registration_step_content()
3008
+	{
3009
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3010
+			$warning_msg = sprintf(
3011
+				esc_html__(
3012
+					'%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',
3013
+					'event_espresso'
3014
+				),
3015
+				'<br />',
3016
+				'<h3 class="important-notice">',
3017
+				'</h3>',
3018
+				'<div class="float-right">',
3019
+				'<span id="redirect_timer" class="important-notice">30</span>',
3020
+				'</div>',
3021
+				'<b>',
3022
+				'</b>'
3023
+			);
3024
+			return '
3025 3025
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
3026 3026
 	<script >
3027 3027
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -3034,856 +3034,856 @@  discard block
 block discarded – undo
3034 3034
 	        }
3035 3035
 	    }, 800 );
3036 3036
 	</script >';
3037
-        }
3038
-        $template_args = array(
3039
-            'title'                    => '',
3040
-            'content'                  => '',
3041
-            'step_button_text'         => '',
3042
-            'show_notification_toggle' => false,
3043
-        );
3044
-        // to indicate we're processing a new registration
3045
-        $hidden_fields = array(
3046
-            'processing_registration' => array(
3047
-                'type'  => 'hidden',
3048
-                'value' => 0,
3049
-            ),
3050
-            'event_id'                => array(
3051
-                'type'  => 'hidden',
3052
-                'value' => $this->_reg_event->ID(),
3053
-            ),
3054
-        );
3055
-        // if the cart is empty then we know we're at step one so we'll display ticket selector
3056
-        $cart = EE_Registry::instance()->SSN->cart();
3057
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3058
-        switch ($step) {
3059
-            case 'ticket':
3060
-                $hidden_fields['processing_registration']['value'] = 1;
3061
-                $template_args['title'] = esc_html__(
3062
-                    'Step One: Select the Ticket for this registration',
3063
-                    'event_espresso'
3064
-                );
3065
-                $template_args['content'] =
3066
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3067
-                $template_args['content'] .= '</div>';
3068
-                $template_args['step_button_text'] = esc_html__(
3069
-                    'Add Tickets and Continue to Registrant Details',
3070
-                    'event_espresso'
3071
-                );
3072
-                $template_args['show_notification_toggle'] = false;
3073
-                break;
3074
-            case 'questions':
3075
-                $hidden_fields['processing_registration']['value'] = 2;
3076
-                $template_args['title'] = esc_html__(
3077
-                    'Step Two: Add Registrant Details for this Registration',
3078
-                    'event_espresso'
3079
-                );
3080
-                // in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3081
-                // properly by the first process_reg_step run.
3082
-                $template_args['content'] =
3083
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
3084
-                $template_args['step_button_text'] = esc_html__(
3085
-                    'Save Registration and Continue to Details',
3086
-                    'event_espresso'
3087
-                );
3088
-                $template_args['show_notification_toggle'] = true;
3089
-                break;
3090
-        }
3091
-        // we come back to the process_registration_step route.
3092
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3093
-        return EEH_Template::display_template(
3094
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3095
-            $template_args,
3096
-            true
3097
-        );
3098
-    }
3099
-
3100
-
3101
-    /**
3102
-     *        set_reg_event
3103
-     *
3104
-     * @access private
3105
-     * @return bool
3106
-     * @throws EE_Error
3107
-     * @throws InvalidArgumentException
3108
-     * @throws InvalidDataTypeException
3109
-     * @throws InvalidInterfaceException
3110
-     */
3111
-    private function _set_reg_event()
3112
-    {
3113
-        if (is_object($this->_reg_event)) {
3114
-            return true;
3115
-        }
3116
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3117
-        if (! $EVT_ID) {
3118
-            return false;
3119
-        }
3120
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3121
-        return true;
3122
-    }
3123
-
3124
-
3125
-    /**
3126
-     * process_reg_step
3127
-     *
3128
-     * @access        public
3129
-     * @return string
3130
-     * @throws DomainException
3131
-     * @throws EE_Error
3132
-     * @throws InvalidArgumentException
3133
-     * @throws InvalidDataTypeException
3134
-     * @throws InvalidInterfaceException
3135
-     * @throws ReflectionException
3136
-     * @throws RuntimeException
3137
-     */
3138
-    public function process_reg_step()
3139
-    {
3140
-        EE_System::do_not_cache();
3141
-        $this->_set_reg_event();
3142
-        EE_Registry::instance()->REQ->set_espresso_page(true);
3143
-        EE_Registry::instance()->REQ->set('uts', time());
3144
-        // what step are we on?
3145
-        $cart = EE_Registry::instance()->SSN->cart();
3146
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3147
-        // if doing ajax then we need to verify the nonce
3148
-        if (defined('DOING_AJAX')) {
3149
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
3150
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3151
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3152
-        }
3153
-        switch ($step) {
3154
-            case 'ticket':
3155
-                // process ticket selection
3156
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3157
-                if ($success) {
3158
-                    EE_Error::add_success(
3159
-                        esc_html__(
3160
-                            'Tickets Selected. Now complete the registration.',
3161
-                            'event_espresso'
3162
-                        )
3163
-                    );
3164
-                } else {
3165
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
3166
-                }
3167
-                if (defined('DOING_AJAX')) {
3168
-                    $this->new_registration(); // display next step
3169
-                } else {
3170
-                    $query_args = array(
3171
-                        'action'                  => 'new_registration',
3172
-                        'processing_registration' => 1,
3173
-                        'event_id'                => $this->_reg_event->ID(),
3174
-                        'uts'                     => time(),
3175
-                    );
3176
-                    $this->_redirect_after_action(
3177
-                        false,
3178
-                        '',
3179
-                        '',
3180
-                        $query_args,
3181
-                        true
3182
-                    );
3183
-                }
3184
-                break;
3185
-            case 'questions':
3186
-                if (! isset(
3187
-                    $this->_req_data['txn_reg_status_change'],
3188
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
3189
-                )
3190
-                ) {
3191
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3192
-                }
3193
-                // process registration
3194
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3195
-                if ($cart instanceof EE_Cart) {
3196
-                    $grand_total = $cart->get_cart_grand_total();
3197
-                    if ($grand_total instanceof EE_Line_Item) {
3198
-                        $grand_total->save_this_and_descendants_to_txn();
3199
-                    }
3200
-                }
3201
-                if (! $transaction instanceof EE_Transaction) {
3202
-                    $query_args = array(
3203
-                        'action'                  => 'new_registration',
3204
-                        'processing_registration' => 2,
3205
-                        'event_id'                => $this->_reg_event->ID(),
3206
-                        'uts'                     => time(),
3207
-                    );
3208
-                    if (defined('DOING_AJAX')) {
3209
-                        // display registration form again because there are errors (maybe validation?)
3210
-                        $this->new_registration();
3211
-                        return;
3212
-                    } else {
3213
-                        $this->_redirect_after_action(
3214
-                            false,
3215
-                            '',
3216
-                            '',
3217
-                            $query_args,
3218
-                            true
3219
-                        );
3220
-                        return;
3221
-                    }
3222
-                }
3223
-                // maybe update status, and make sure to save transaction if not done already
3224
-                if (! $transaction->update_status_based_on_total_paid()) {
3225
-                    $transaction->save();
3226
-                }
3227
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3228
-                $this->_req_data = array();
3229
-                $query_args = array(
3230
-                    'action'        => 'redirect_to_txn',
3231
-                    'TXN_ID'        => $transaction->ID(),
3232
-                    'EVT_ID'        => $this->_reg_event->ID(),
3233
-                    'event_name'    => urlencode($this->_reg_event->name()),
3234
-                    'redirect_from' => 'new_registration',
3235
-                );
3236
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3237
-                break;
3238
-        }
3239
-        // what are you looking here for?  Should be nothing to do at this point.
3240
-    }
3241
-
3242
-
3243
-    /**
3244
-     * redirect_to_txn
3245
-     *
3246
-     * @access public
3247
-     * @return void
3248
-     * @throws EE_Error
3249
-     * @throws InvalidArgumentException
3250
-     * @throws InvalidDataTypeException
3251
-     * @throws InvalidInterfaceException
3252
-     */
3253
-    public function redirect_to_txn()
3254
-    {
3255
-        EE_System::do_not_cache();
3256
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3257
-        $query_args = array(
3258
-            'action' => 'view_transaction',
3259
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3260
-            'page'   => 'espresso_transactions',
3261
-        );
3262
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3263
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3264
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
3265
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
3266
-        }
3267
-        EE_Error::add_success(
3268
-            esc_html__(
3269
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3270
-                'event_espresso'
3271
-            )
3272
-        );
3273
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3274
-    }
3275
-
3276
-
3277
-    /**
3278
-     *        generates HTML for the Attendee Contact List
3279
-     *
3280
-     * @access protected
3281
-     * @return void
3282
-     */
3283
-    protected function _attendee_contact_list_table()
3284
-    {
3285
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3286
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3287
-        $this->display_admin_list_table_page_with_no_sidebar();
3288
-    }
3289
-
3290
-
3291
-    /**
3292
-     *        get_attendees
3293
-     *
3294
-     * @param      $per_page
3295
-     * @param bool $count whether to return count or data.
3296
-     * @param bool $trash
3297
-     * @return array
3298
-     * @throws EE_Error
3299
-     * @throws InvalidArgumentException
3300
-     * @throws InvalidDataTypeException
3301
-     * @throws InvalidInterfaceException
3302
-     * @access public
3303
-     */
3304
-    public function get_attendees($per_page, $count = false, $trash = false)
3305
-    {
3306
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3307
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3308
-        $ATT_MDL = EEM_Attendee::instance();
3309
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3310
-        switch ($this->_req_data['orderby']) {
3311
-            case 'ATT_ID':
3312
-                $orderby = 'ATT_ID';
3313
-                break;
3314
-            case 'ATT_fname':
3315
-                $orderby = 'ATT_fname';
3316
-                break;
3317
-            case 'ATT_email':
3318
-                $orderby = 'ATT_email';
3319
-                break;
3320
-            case 'ATT_city':
3321
-                $orderby = 'ATT_city';
3322
-                break;
3323
-            case 'STA_ID':
3324
-                $orderby = 'STA_ID';
3325
-                break;
3326
-            case 'CNT_ID':
3327
-                $orderby = 'CNT_ID';
3328
-                break;
3329
-            case 'Registration_Count':
3330
-                $orderby = 'Registration_Count';
3331
-                break;
3332
-            default:
3333
-                $orderby = 'ATT_lname';
3334
-        }
3335
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3336
-            ? $this->_req_data['order']
3337
-            : 'ASC';
3338
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3339
-            ? $this->_req_data['paged']
3340
-            : 1;
3341
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3342
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3343
-            ? $this->_req_data['perpage']
3344
-            : $per_page;
3345
-        $_where = array();
3346
-        if (! empty($this->_req_data['s'])) {
3347
-            $sstr = '%' . $this->_req_data['s'] . '%';
3348
-            $_where['OR'] = array(
3349
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3350
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3351
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3352
-                'ATT_fname'                         => array('LIKE', $sstr),
3353
-                'ATT_lname'                         => array('LIKE', $sstr),
3354
-                'ATT_short_bio'                     => array('LIKE', $sstr),
3355
-                'ATT_email'                         => array('LIKE', $sstr),
3356
-                'ATT_address'                       => array('LIKE', $sstr),
3357
-                'ATT_address2'                      => array('LIKE', $sstr),
3358
-                'ATT_city'                          => array('LIKE', $sstr),
3359
-                'Country.CNT_name'                  => array('LIKE', $sstr),
3360
-                'State.STA_name'                    => array('LIKE', $sstr),
3361
-                'ATT_phone'                         => array('LIKE', $sstr),
3362
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
3363
-                'Registration.REG_code'             => array('LIKE', $sstr),
3364
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
3365
-            );
3366
-        }
3367
-        $offset = ($current_page - 1) * $per_page;
3368
-        $limit = $count ? null : array($offset, $per_page);
3369
-        $query_args = array(
3370
-            $_where,
3371
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3372
-            'limit'         => $limit,
3373
-        );
3374
-        if (! $count) {
3375
-            $query_args['order_by'] = array($orderby => $sort);
3376
-        }
3377
-        if ($trash) {
3378
-            $query_args[0]['status'] = array('!=', 'publish');
3379
-            $all_attendees = $count
3380
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3381
-                : $ATT_MDL->get_all($query_args);
3382
-        } else {
3383
-            $query_args[0]['status'] = array('IN', array('publish'));
3384
-            $all_attendees = $count
3385
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3386
-                : $ATT_MDL->get_all($query_args);
3387
-        }
3388
-        return $all_attendees;
3389
-    }
3390
-
3391
-
3392
-    /**
3393
-     * This is just taking care of resending the registration confirmation
3394
-     *
3395
-     * @access protected
3396
-     * @return void
3397
-     */
3398
-    protected function _resend_registration()
3399
-    {
3400
-        $this->_process_resend_registration();
3401
-        $query_args = isset($this->_req_data['redirect_to'])
3402
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3403
-            : array('action' => 'default');
3404
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3405
-    }
3406
-
3407
-    /**
3408
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3409
-     * to use when selecting registrations
3410
-     *
3411
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3412
-     *                                                     the query parameters from the request
3413
-     * @return void ends the request with a redirect or download
3414
-     */
3415
-    public function _registrations_report_base($method_name_for_getting_query_params)
3416
-    {
3417
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3418
-            wp_redirect(
3419
-                EE_Admin_Page::add_query_args_and_nonce(
3420
-                    array(
3421
-                        'page'        => 'espresso_batch',
3422
-                        'batch'       => 'file',
3423
-                        'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3424
-                        'filters'     => urlencode(
3425
-                            serialize(
3426
-                                call_user_func(
3427
-                                    array($this, $method_name_for_getting_query_params),
3428
-                                    EEH_Array::is_set(
3429
-                                        $this->_req_data,
3430
-                                        'filters',
3431
-                                        array()
3432
-                                    )
3433
-                                )
3434
-                            )
3435
-                        ),
3436
-                        'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3437
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3438
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3439
-                    )
3440
-                )
3441
-            );
3442
-        } else {
3443
-            $new_request_args = array(
3444
-                'export' => 'report',
3445
-                'action' => 'registrations_report_for_event',
3446
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3447
-            );
3448
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
3449
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3450
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3451
-                $EE_Export = EE_Export::instance($this->_req_data);
3452
-                $EE_Export->export();
3453
-            }
3454
-        }
3455
-    }
3456
-
3457
-
3458
-    /**
3459
-     * Creates a registration report using only query parameters in the request
3460
-     *
3461
-     * @return void
3462
-     */
3463
-    public function _registrations_report()
3464
-    {
3465
-        $this->_registrations_report_base('_get_registration_query_parameters');
3466
-    }
3467
-
3468
-
3469
-    public function _contact_list_export()
3470
-    {
3471
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3472
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3473
-            $EE_Export = EE_Export::instance($this->_req_data);
3474
-            $EE_Export->export_attendees();
3475
-        }
3476
-    }
3477
-
3478
-
3479
-    public function _contact_list_report()
3480
-    {
3481
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3482
-            wp_redirect(
3483
-                EE_Admin_Page::add_query_args_and_nonce(
3484
-                    array(
3485
-                        'page'        => 'espresso_batch',
3486
-                        'batch'       => 'file',
3487
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3488
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3489
-                    )
3490
-                )
3491
-            );
3492
-        } else {
3493
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3494
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3495
-                $EE_Export = EE_Export::instance($this->_req_data);
3496
-                $EE_Export->report_attendees();
3497
-            }
3498
-        }
3499
-    }
3500
-
3501
-
3502
-
3503
-
3504
-
3505
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3506
-    /**
3507
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3508
-     *
3509
-     * @return void
3510
-     * @throws EE_Error
3511
-     * @throws InvalidArgumentException
3512
-     * @throws InvalidDataTypeException
3513
-     * @throws InvalidInterfaceException
3514
-     */
3515
-    protected function _duplicate_attendee()
3516
-    {
3517
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3518
-        // verify we have necessary info
3519
-        if (empty($this->_req_data['_REG_ID'])) {
3520
-            EE_Error::add_error(
3521
-                esc_html__(
3522
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3523
-                    'event_espresso'
3524
-                ),
3525
-                __FILE__,
3526
-                __LINE__,
3527
-                __FUNCTION__
3528
-            );
3529
-            $query_args = array('action' => $action);
3530
-            $this->_redirect_after_action('', '', '', $query_args, true);
3531
-        }
3532
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3533
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3534
-        $attendee = $registration->attendee();
3535
-        // remove relation of existing attendee on registration
3536
-        $registration->_remove_relation_to($attendee, 'Attendee');
3537
-        // new attendee
3538
-        $new_attendee = clone $attendee;
3539
-        $new_attendee->set('ATT_ID', 0);
3540
-        $new_attendee->save();
3541
-        // add new attendee to reg
3542
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3543
-        EE_Error::add_success(
3544
-            esc_html__(
3545
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3546
-                'event_espresso'
3547
-            )
3548
-        );
3549
-        // redirect to edit page for attendee
3550
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3551
-        $this->_redirect_after_action('', '', '', $query_args, true);
3552
-    }
3553
-
3554
-
3555
-    /**
3556
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3557
-     *
3558
-     * @param int     $post_id
3559
-     * @param WP_POST $post
3560
-     * @throws DomainException
3561
-     * @throws EE_Error
3562
-     * @throws InvalidArgumentException
3563
-     * @throws InvalidDataTypeException
3564
-     * @throws InvalidInterfaceException
3565
-     * @throws LogicException
3566
-     * @throws InvalidFormSubmissionException
3567
-     */
3568
-    protected function _insert_update_cpt_item($post_id, $post)
3569
-    {
3570
-        $success = true;
3571
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3572
-            ? EEM_Attendee::instance()->get_one_by_ID($post_id)
3573
-            : null;
3574
-        // for attendee updates
3575
-        if ($attendee instanceof EE_Attendee) {
3576
-            // note we should only be UPDATING attendees at this point.
3577
-            $updated_fields = array(
3578
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
3579
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
3580
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3581
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3582
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3583
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3584
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3585
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3586
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3587
-            );
3588
-            foreach ($updated_fields as $field => $value) {
3589
-                $attendee->set($field, $value);
3590
-            }
3591
-
3592
-            // process contact details metabox form handler (which will also save the attendee)
3593
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3594
-            $success = $contact_details_form->process($this->_req_data);
3595
-
3596
-            $attendee_update_callbacks = apply_filters(
3597
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3598
-                array()
3599
-            );
3600
-            foreach ($attendee_update_callbacks as $a_callback) {
3601
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3602
-                    throw new EE_Error(
3603
-                        sprintf(
3604
-                            esc_html__(
3605
-                                '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.',
3606
-                                'event_espresso'
3607
-                            ),
3608
-                            $a_callback
3609
-                        )
3610
-                    );
3611
-                }
3612
-            }
3613
-        }
3614
-
3615
-        if ($success === false) {
3616
-            EE_Error::add_error(
3617
-                esc_html__(
3618
-                    'Something went wrong with updating the meta table data for the registration.',
3619
-                    'event_espresso'
3620
-                ),
3621
-                __FILE__,
3622
-                __FUNCTION__,
3623
-                __LINE__
3624
-            );
3625
-        }
3626
-    }
3627
-
3628
-
3629
-    public function trash_cpt_item($post_id)
3630
-    {
3631
-    }
3632
-
3633
-
3634
-    public function delete_cpt_item($post_id)
3635
-    {
3636
-    }
3637
-
3638
-
3639
-    public function restore_cpt_item($post_id)
3640
-    {
3641
-    }
3642
-
3643
-
3644
-    protected function _restore_cpt_item($post_id, $revision_id)
3645
-    {
3646
-    }
3647
-
3648
-
3649
-    public function attendee_editor_metaboxes()
3650
-    {
3651
-        $this->verify_cpt_object();
3652
-        remove_meta_box(
3653
-            'postexcerpt',
3654
-            esc_html__('Excerpt', 'event_espresso'),
3655
-            'post_excerpt_meta_box',
3656
-            $this->_cpt_routes[ $this->_req_action ],
3657
-            'normal',
3658
-            'core'
3659
-        );
3660
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3661
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3662
-            add_meta_box(
3663
-                'postexcerpt',
3664
-                esc_html__('Short Biography', 'event_espresso'),
3665
-                'post_excerpt_meta_box',
3666
-                $this->_cpt_routes[ $this->_req_action ],
3667
-                'normal'
3668
-            );
3669
-        }
3670
-        if (post_type_supports('espresso_attendees', 'comments')) {
3671
-            add_meta_box(
3672
-                'commentsdiv',
3673
-                esc_html__('Notes on the Contact', 'event_espresso'),
3674
-                'post_comment_meta_box',
3675
-                $this->_cpt_routes[ $this->_req_action ],
3676
-                'normal',
3677
-                'core'
3678
-            );
3679
-        }
3680
-        add_meta_box(
3681
-            'attendee_contact_info',
3682
-            esc_html__('Contact Info', 'event_espresso'),
3683
-            array($this, 'attendee_contact_info'),
3684
-            $this->_cpt_routes[ $this->_req_action ],
3685
-            'side',
3686
-            'core'
3687
-        );
3688
-        add_meta_box(
3689
-            'attendee_details_address',
3690
-            esc_html__('Address Details', 'event_espresso'),
3691
-            array($this, 'attendee_address_details'),
3692
-            $this->_cpt_routes[ $this->_req_action ],
3693
-            'normal',
3694
-            'core'
3695
-        );
3696
-        add_meta_box(
3697
-            'attendee_registrations',
3698
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3699
-            array($this, 'attendee_registrations_meta_box'),
3700
-            $this->_cpt_routes[ $this->_req_action ],
3701
-            'normal',
3702
-            'high'
3703
-        );
3704
-    }
3705
-
3706
-
3707
-    /**
3708
-     * Metabox for attendee contact info
3709
-     *
3710
-     * @param  WP_Post $post wp post object
3711
-     * @return string attendee contact info ( and form )
3712
-     * @throws EE_Error
3713
-     * @throws InvalidArgumentException
3714
-     * @throws InvalidDataTypeException
3715
-     * @throws InvalidInterfaceException
3716
-     * @throws LogicException
3717
-     * @throws DomainException
3718
-     */
3719
-    public function attendee_contact_info($post)
3720
-    {
3721
-        // get attendee object ( should already have it )
3722
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3723
-        $form->enqueueStylesAndScripts();
3724
-        echo $form->display();
3725
-    }
3726
-
3727
-
3728
-    /**
3729
-     * Return form handler for the contact details metabox
3730
-     *
3731
-     * @param EE_Attendee $attendee
3732
-     * @return AttendeeContactDetailsMetaboxFormHandler
3733
-     * @throws DomainException
3734
-     * @throws InvalidArgumentException
3735
-     * @throws InvalidDataTypeException
3736
-     * @throws InvalidInterfaceException
3737
-     */
3738
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3739
-    {
3740
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3741
-    }
3742
-
3743
-
3744
-    /**
3745
-     * Metabox for attendee details
3746
-     *
3747
-     * @param  WP_Post $post wp post object
3748
-     * @throws DomainException
3749
-     */
3750
-    public function attendee_address_details($post)
3751
-    {
3752
-        // get attendee object (should already have it)
3753
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3754
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3755
-            new EE_Question_Form_Input(
3756
-                EE_Question::new_instance(
3757
-                    array(
3758
-                        'QST_ID'           => 0,
3759
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3760
-                        'QST_system'       => 'admin-state',
3761
-                    )
3762
-                ),
3763
-                EE_Answer::new_instance(
3764
-                    array(
3765
-                        'ANS_ID'    => 0,
3766
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3767
-                    )
3768
-                ),
3769
-                array(
3770
-                    'input_id'       => 'STA_ID',
3771
-                    'input_name'     => 'STA_ID',
3772
-                    'input_prefix'   => '',
3773
-                    'append_qstn_id' => false,
3774
-                )
3775
-            )
3776
-        );
3777
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3778
-            new EE_Question_Form_Input(
3779
-                EE_Question::new_instance(
3780
-                    array(
3781
-                        'QST_ID'           => 0,
3782
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3783
-                        'QST_system'       => 'admin-country',
3784
-                    )
3785
-                ),
3786
-                EE_Answer::new_instance(
3787
-                    array(
3788
-                        'ANS_ID'    => 0,
3789
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3790
-                    )
3791
-                ),
3792
-                array(
3793
-                    'input_id'       => 'CNT_ISO',
3794
-                    'input_name'     => 'CNT_ISO',
3795
-                    'input_prefix'   => '',
3796
-                    'append_qstn_id' => false,
3797
-                )
3798
-            )
3799
-        );
3800
-        $template =
3801
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3802
-        EEH_Template::display_template($template, $this->_template_args);
3803
-    }
3804
-
3805
-
3806
-    /**
3807
-     *        _attendee_details
3808
-     *
3809
-     * @access protected
3810
-     * @param $post
3811
-     * @return void
3812
-     * @throws DomainException
3813
-     * @throws EE_Error
3814
-     */
3815
-    public function attendee_registrations_meta_box($post)
3816
-    {
3817
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3818
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3819
-        $template =
3820
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3821
-        EEH_Template::display_template($template, $this->_template_args);
3822
-    }
3823
-
3824
-
3825
-    /**
3826
-     * add in the form fields for the attendee edit
3827
-     *
3828
-     * @param  WP_Post $post wp post object
3829
-     * @return string html for new form.
3830
-     * @throws DomainException
3831
-     */
3832
-    public function after_title_form_fields($post)
3833
-    {
3834
-        if ($post->post_type == 'espresso_attendees') {
3835
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3836
-            $template_args['attendee'] = $this->_cpt_model_obj;
3837
-            EEH_Template::display_template($template, $template_args);
3838
-        }
3839
-    }
3840
-
3841
-
3842
-    /**
3843
-     *        _trash_or_restore_attendee
3844
-     *
3845
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3846
-     * @return void
3847
-     * @throws EE_Error
3848
-     * @throws InvalidArgumentException
3849
-     * @throws InvalidDataTypeException
3850
-     * @throws InvalidInterfaceException
3851
-     * @access protected
3852
-     */
3853
-    protected function _trash_or_restore_attendees($trash = true)
3854
-    {
3855
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3856
-        $ATT_MDL = EEM_Attendee::instance();
3857
-        $success = 1;
3858
-        // Checkboxes
3859
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3860
-            // if array has more than one element than success message should be plural
3861
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3862
-            // cycle thru checkboxes
3863
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3864
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3865
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3866
-                if (! $updated) {
3867
-                    $success = 0;
3868
-                }
3869
-            }
3870
-        } else {
3871
-            // grab single id and delete
3872
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
3873
-            // get attendee
3874
-            $att = $ATT_MDL->get_one_by_ID($ATT_ID);
3875
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3876
-            $updated = $att->save();
3877
-            if (! $updated) {
3878
-                $success = 0;
3879
-            }
3880
-        }
3881
-        $what = $success > 1
3882
-            ? esc_html__('Contacts', 'event_espresso')
3883
-            : esc_html__('Contact', 'event_espresso');
3884
-        $action_desc = $trash
3885
-            ? esc_html__('moved to the trash', 'event_espresso')
3886
-            : esc_html__('restored', 'event_espresso');
3887
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3888
-    }
3037
+		}
3038
+		$template_args = array(
3039
+			'title'                    => '',
3040
+			'content'                  => '',
3041
+			'step_button_text'         => '',
3042
+			'show_notification_toggle' => false,
3043
+		);
3044
+		// to indicate we're processing a new registration
3045
+		$hidden_fields = array(
3046
+			'processing_registration' => array(
3047
+				'type'  => 'hidden',
3048
+				'value' => 0,
3049
+			),
3050
+			'event_id'                => array(
3051
+				'type'  => 'hidden',
3052
+				'value' => $this->_reg_event->ID(),
3053
+			),
3054
+		);
3055
+		// if the cart is empty then we know we're at step one so we'll display ticket selector
3056
+		$cart = EE_Registry::instance()->SSN->cart();
3057
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3058
+		switch ($step) {
3059
+			case 'ticket':
3060
+				$hidden_fields['processing_registration']['value'] = 1;
3061
+				$template_args['title'] = esc_html__(
3062
+					'Step One: Select the Ticket for this registration',
3063
+					'event_espresso'
3064
+				);
3065
+				$template_args['content'] =
3066
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3067
+				$template_args['content'] .= '</div>';
3068
+				$template_args['step_button_text'] = esc_html__(
3069
+					'Add Tickets and Continue to Registrant Details',
3070
+					'event_espresso'
3071
+				);
3072
+				$template_args['show_notification_toggle'] = false;
3073
+				break;
3074
+			case 'questions':
3075
+				$hidden_fields['processing_registration']['value'] = 2;
3076
+				$template_args['title'] = esc_html__(
3077
+					'Step Two: Add Registrant Details for this Registration',
3078
+					'event_espresso'
3079
+				);
3080
+				// in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3081
+				// properly by the first process_reg_step run.
3082
+				$template_args['content'] =
3083
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
3084
+				$template_args['step_button_text'] = esc_html__(
3085
+					'Save Registration and Continue to Details',
3086
+					'event_espresso'
3087
+				);
3088
+				$template_args['show_notification_toggle'] = true;
3089
+				break;
3090
+		}
3091
+		// we come back to the process_registration_step route.
3092
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3093
+		return EEH_Template::display_template(
3094
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3095
+			$template_args,
3096
+			true
3097
+		);
3098
+	}
3099
+
3100
+
3101
+	/**
3102
+	 *        set_reg_event
3103
+	 *
3104
+	 * @access private
3105
+	 * @return bool
3106
+	 * @throws EE_Error
3107
+	 * @throws InvalidArgumentException
3108
+	 * @throws InvalidDataTypeException
3109
+	 * @throws InvalidInterfaceException
3110
+	 */
3111
+	private function _set_reg_event()
3112
+	{
3113
+		if (is_object($this->_reg_event)) {
3114
+			return true;
3115
+		}
3116
+		$EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3117
+		if (! $EVT_ID) {
3118
+			return false;
3119
+		}
3120
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3121
+		return true;
3122
+	}
3123
+
3124
+
3125
+	/**
3126
+	 * process_reg_step
3127
+	 *
3128
+	 * @access        public
3129
+	 * @return string
3130
+	 * @throws DomainException
3131
+	 * @throws EE_Error
3132
+	 * @throws InvalidArgumentException
3133
+	 * @throws InvalidDataTypeException
3134
+	 * @throws InvalidInterfaceException
3135
+	 * @throws ReflectionException
3136
+	 * @throws RuntimeException
3137
+	 */
3138
+	public function process_reg_step()
3139
+	{
3140
+		EE_System::do_not_cache();
3141
+		$this->_set_reg_event();
3142
+		EE_Registry::instance()->REQ->set_espresso_page(true);
3143
+		EE_Registry::instance()->REQ->set('uts', time());
3144
+		// what step are we on?
3145
+		$cart = EE_Registry::instance()->SSN->cart();
3146
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3147
+		// if doing ajax then we need to verify the nonce
3148
+		if (defined('DOING_AJAX')) {
3149
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
3150
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3151
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3152
+		}
3153
+		switch ($step) {
3154
+			case 'ticket':
3155
+				// process ticket selection
3156
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3157
+				if ($success) {
3158
+					EE_Error::add_success(
3159
+						esc_html__(
3160
+							'Tickets Selected. Now complete the registration.',
3161
+							'event_espresso'
3162
+						)
3163
+					);
3164
+				} else {
3165
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
3166
+				}
3167
+				if (defined('DOING_AJAX')) {
3168
+					$this->new_registration(); // display next step
3169
+				} else {
3170
+					$query_args = array(
3171
+						'action'                  => 'new_registration',
3172
+						'processing_registration' => 1,
3173
+						'event_id'                => $this->_reg_event->ID(),
3174
+						'uts'                     => time(),
3175
+					);
3176
+					$this->_redirect_after_action(
3177
+						false,
3178
+						'',
3179
+						'',
3180
+						$query_args,
3181
+						true
3182
+					);
3183
+				}
3184
+				break;
3185
+			case 'questions':
3186
+				if (! isset(
3187
+					$this->_req_data['txn_reg_status_change'],
3188
+					$this->_req_data['txn_reg_status_change']['send_notifications']
3189
+				)
3190
+				) {
3191
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3192
+				}
3193
+				// process registration
3194
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3195
+				if ($cart instanceof EE_Cart) {
3196
+					$grand_total = $cart->get_cart_grand_total();
3197
+					if ($grand_total instanceof EE_Line_Item) {
3198
+						$grand_total->save_this_and_descendants_to_txn();
3199
+					}
3200
+				}
3201
+				if (! $transaction instanceof EE_Transaction) {
3202
+					$query_args = array(
3203
+						'action'                  => 'new_registration',
3204
+						'processing_registration' => 2,
3205
+						'event_id'                => $this->_reg_event->ID(),
3206
+						'uts'                     => time(),
3207
+					);
3208
+					if (defined('DOING_AJAX')) {
3209
+						// display registration form again because there are errors (maybe validation?)
3210
+						$this->new_registration();
3211
+						return;
3212
+					} else {
3213
+						$this->_redirect_after_action(
3214
+							false,
3215
+							'',
3216
+							'',
3217
+							$query_args,
3218
+							true
3219
+						);
3220
+						return;
3221
+					}
3222
+				}
3223
+				// maybe update status, and make sure to save transaction if not done already
3224
+				if (! $transaction->update_status_based_on_total_paid()) {
3225
+					$transaction->save();
3226
+				}
3227
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3228
+				$this->_req_data = array();
3229
+				$query_args = array(
3230
+					'action'        => 'redirect_to_txn',
3231
+					'TXN_ID'        => $transaction->ID(),
3232
+					'EVT_ID'        => $this->_reg_event->ID(),
3233
+					'event_name'    => urlencode($this->_reg_event->name()),
3234
+					'redirect_from' => 'new_registration',
3235
+				);
3236
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3237
+				break;
3238
+		}
3239
+		// what are you looking here for?  Should be nothing to do at this point.
3240
+	}
3241
+
3242
+
3243
+	/**
3244
+	 * redirect_to_txn
3245
+	 *
3246
+	 * @access public
3247
+	 * @return void
3248
+	 * @throws EE_Error
3249
+	 * @throws InvalidArgumentException
3250
+	 * @throws InvalidDataTypeException
3251
+	 * @throws InvalidInterfaceException
3252
+	 */
3253
+	public function redirect_to_txn()
3254
+	{
3255
+		EE_System::do_not_cache();
3256
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3257
+		$query_args = array(
3258
+			'action' => 'view_transaction',
3259
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3260
+			'page'   => 'espresso_transactions',
3261
+		);
3262
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3263
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3264
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
3265
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
3266
+		}
3267
+		EE_Error::add_success(
3268
+			esc_html__(
3269
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3270
+				'event_espresso'
3271
+			)
3272
+		);
3273
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3274
+	}
3275
+
3276
+
3277
+	/**
3278
+	 *        generates HTML for the Attendee Contact List
3279
+	 *
3280
+	 * @access protected
3281
+	 * @return void
3282
+	 */
3283
+	protected function _attendee_contact_list_table()
3284
+	{
3285
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3286
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3287
+		$this->display_admin_list_table_page_with_no_sidebar();
3288
+	}
3289
+
3290
+
3291
+	/**
3292
+	 *        get_attendees
3293
+	 *
3294
+	 * @param      $per_page
3295
+	 * @param bool $count whether to return count or data.
3296
+	 * @param bool $trash
3297
+	 * @return array
3298
+	 * @throws EE_Error
3299
+	 * @throws InvalidArgumentException
3300
+	 * @throws InvalidDataTypeException
3301
+	 * @throws InvalidInterfaceException
3302
+	 * @access public
3303
+	 */
3304
+	public function get_attendees($per_page, $count = false, $trash = false)
3305
+	{
3306
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3307
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3308
+		$ATT_MDL = EEM_Attendee::instance();
3309
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3310
+		switch ($this->_req_data['orderby']) {
3311
+			case 'ATT_ID':
3312
+				$orderby = 'ATT_ID';
3313
+				break;
3314
+			case 'ATT_fname':
3315
+				$orderby = 'ATT_fname';
3316
+				break;
3317
+			case 'ATT_email':
3318
+				$orderby = 'ATT_email';
3319
+				break;
3320
+			case 'ATT_city':
3321
+				$orderby = 'ATT_city';
3322
+				break;
3323
+			case 'STA_ID':
3324
+				$orderby = 'STA_ID';
3325
+				break;
3326
+			case 'CNT_ID':
3327
+				$orderby = 'CNT_ID';
3328
+				break;
3329
+			case 'Registration_Count':
3330
+				$orderby = 'Registration_Count';
3331
+				break;
3332
+			default:
3333
+				$orderby = 'ATT_lname';
3334
+		}
3335
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3336
+			? $this->_req_data['order']
3337
+			: 'ASC';
3338
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3339
+			? $this->_req_data['paged']
3340
+			: 1;
3341
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3342
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3343
+			? $this->_req_data['perpage']
3344
+			: $per_page;
3345
+		$_where = array();
3346
+		if (! empty($this->_req_data['s'])) {
3347
+			$sstr = '%' . $this->_req_data['s'] . '%';
3348
+			$_where['OR'] = array(
3349
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3350
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3351
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3352
+				'ATT_fname'                         => array('LIKE', $sstr),
3353
+				'ATT_lname'                         => array('LIKE', $sstr),
3354
+				'ATT_short_bio'                     => array('LIKE', $sstr),
3355
+				'ATT_email'                         => array('LIKE', $sstr),
3356
+				'ATT_address'                       => array('LIKE', $sstr),
3357
+				'ATT_address2'                      => array('LIKE', $sstr),
3358
+				'ATT_city'                          => array('LIKE', $sstr),
3359
+				'Country.CNT_name'                  => array('LIKE', $sstr),
3360
+				'State.STA_name'                    => array('LIKE', $sstr),
3361
+				'ATT_phone'                         => array('LIKE', $sstr),
3362
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
3363
+				'Registration.REG_code'             => array('LIKE', $sstr),
3364
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
3365
+			);
3366
+		}
3367
+		$offset = ($current_page - 1) * $per_page;
3368
+		$limit = $count ? null : array($offset, $per_page);
3369
+		$query_args = array(
3370
+			$_where,
3371
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3372
+			'limit'         => $limit,
3373
+		);
3374
+		if (! $count) {
3375
+			$query_args['order_by'] = array($orderby => $sort);
3376
+		}
3377
+		if ($trash) {
3378
+			$query_args[0]['status'] = array('!=', 'publish');
3379
+			$all_attendees = $count
3380
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3381
+				: $ATT_MDL->get_all($query_args);
3382
+		} else {
3383
+			$query_args[0]['status'] = array('IN', array('publish'));
3384
+			$all_attendees = $count
3385
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3386
+				: $ATT_MDL->get_all($query_args);
3387
+		}
3388
+		return $all_attendees;
3389
+	}
3390
+
3391
+
3392
+	/**
3393
+	 * This is just taking care of resending the registration confirmation
3394
+	 *
3395
+	 * @access protected
3396
+	 * @return void
3397
+	 */
3398
+	protected function _resend_registration()
3399
+	{
3400
+		$this->_process_resend_registration();
3401
+		$query_args = isset($this->_req_data['redirect_to'])
3402
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3403
+			: array('action' => 'default');
3404
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3405
+	}
3406
+
3407
+	/**
3408
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3409
+	 * to use when selecting registrations
3410
+	 *
3411
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3412
+	 *                                                     the query parameters from the request
3413
+	 * @return void ends the request with a redirect or download
3414
+	 */
3415
+	public function _registrations_report_base($method_name_for_getting_query_params)
3416
+	{
3417
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3418
+			wp_redirect(
3419
+				EE_Admin_Page::add_query_args_and_nonce(
3420
+					array(
3421
+						'page'        => 'espresso_batch',
3422
+						'batch'       => 'file',
3423
+						'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3424
+						'filters'     => urlencode(
3425
+							serialize(
3426
+								call_user_func(
3427
+									array($this, $method_name_for_getting_query_params),
3428
+									EEH_Array::is_set(
3429
+										$this->_req_data,
3430
+										'filters',
3431
+										array()
3432
+									)
3433
+								)
3434
+							)
3435
+						),
3436
+						'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3437
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3438
+						'return_url'  => urlencode($this->_req_data['return_url']),
3439
+					)
3440
+				)
3441
+			);
3442
+		} else {
3443
+			$new_request_args = array(
3444
+				'export' => 'report',
3445
+				'action' => 'registrations_report_for_event',
3446
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3447
+			);
3448
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
3449
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3450
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3451
+				$EE_Export = EE_Export::instance($this->_req_data);
3452
+				$EE_Export->export();
3453
+			}
3454
+		}
3455
+	}
3456
+
3457
+
3458
+	/**
3459
+	 * Creates a registration report using only query parameters in the request
3460
+	 *
3461
+	 * @return void
3462
+	 */
3463
+	public function _registrations_report()
3464
+	{
3465
+		$this->_registrations_report_base('_get_registration_query_parameters');
3466
+	}
3467
+
3468
+
3469
+	public function _contact_list_export()
3470
+	{
3471
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3472
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3473
+			$EE_Export = EE_Export::instance($this->_req_data);
3474
+			$EE_Export->export_attendees();
3475
+		}
3476
+	}
3477
+
3478
+
3479
+	public function _contact_list_report()
3480
+	{
3481
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3482
+			wp_redirect(
3483
+				EE_Admin_Page::add_query_args_and_nonce(
3484
+					array(
3485
+						'page'        => 'espresso_batch',
3486
+						'batch'       => 'file',
3487
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3488
+						'return_url'  => urlencode($this->_req_data['return_url']),
3489
+					)
3490
+				)
3491
+			);
3492
+		} else {
3493
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3494
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3495
+				$EE_Export = EE_Export::instance($this->_req_data);
3496
+				$EE_Export->report_attendees();
3497
+			}
3498
+		}
3499
+	}
3500
+
3501
+
3502
+
3503
+
3504
+
3505
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3506
+	/**
3507
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3508
+	 *
3509
+	 * @return void
3510
+	 * @throws EE_Error
3511
+	 * @throws InvalidArgumentException
3512
+	 * @throws InvalidDataTypeException
3513
+	 * @throws InvalidInterfaceException
3514
+	 */
3515
+	protected function _duplicate_attendee()
3516
+	{
3517
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3518
+		// verify we have necessary info
3519
+		if (empty($this->_req_data['_REG_ID'])) {
3520
+			EE_Error::add_error(
3521
+				esc_html__(
3522
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3523
+					'event_espresso'
3524
+				),
3525
+				__FILE__,
3526
+				__LINE__,
3527
+				__FUNCTION__
3528
+			);
3529
+			$query_args = array('action' => $action);
3530
+			$this->_redirect_after_action('', '', '', $query_args, true);
3531
+		}
3532
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3533
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3534
+		$attendee = $registration->attendee();
3535
+		// remove relation of existing attendee on registration
3536
+		$registration->_remove_relation_to($attendee, 'Attendee');
3537
+		// new attendee
3538
+		$new_attendee = clone $attendee;
3539
+		$new_attendee->set('ATT_ID', 0);
3540
+		$new_attendee->save();
3541
+		// add new attendee to reg
3542
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3543
+		EE_Error::add_success(
3544
+			esc_html__(
3545
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3546
+				'event_espresso'
3547
+			)
3548
+		);
3549
+		// redirect to edit page for attendee
3550
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3551
+		$this->_redirect_after_action('', '', '', $query_args, true);
3552
+	}
3553
+
3554
+
3555
+	/**
3556
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3557
+	 *
3558
+	 * @param int     $post_id
3559
+	 * @param WP_POST $post
3560
+	 * @throws DomainException
3561
+	 * @throws EE_Error
3562
+	 * @throws InvalidArgumentException
3563
+	 * @throws InvalidDataTypeException
3564
+	 * @throws InvalidInterfaceException
3565
+	 * @throws LogicException
3566
+	 * @throws InvalidFormSubmissionException
3567
+	 */
3568
+	protected function _insert_update_cpt_item($post_id, $post)
3569
+	{
3570
+		$success = true;
3571
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3572
+			? EEM_Attendee::instance()->get_one_by_ID($post_id)
3573
+			: null;
3574
+		// for attendee updates
3575
+		if ($attendee instanceof EE_Attendee) {
3576
+			// note we should only be UPDATING attendees at this point.
3577
+			$updated_fields = array(
3578
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
3579
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
3580
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3581
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3582
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3583
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3584
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3585
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3586
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3587
+			);
3588
+			foreach ($updated_fields as $field => $value) {
3589
+				$attendee->set($field, $value);
3590
+			}
3591
+
3592
+			// process contact details metabox form handler (which will also save the attendee)
3593
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3594
+			$success = $contact_details_form->process($this->_req_data);
3595
+
3596
+			$attendee_update_callbacks = apply_filters(
3597
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3598
+				array()
3599
+			);
3600
+			foreach ($attendee_update_callbacks as $a_callback) {
3601
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3602
+					throw new EE_Error(
3603
+						sprintf(
3604
+							esc_html__(
3605
+								'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.',
3606
+								'event_espresso'
3607
+							),
3608
+							$a_callback
3609
+						)
3610
+					);
3611
+				}
3612
+			}
3613
+		}
3614
+
3615
+		if ($success === false) {
3616
+			EE_Error::add_error(
3617
+				esc_html__(
3618
+					'Something went wrong with updating the meta table data for the registration.',
3619
+					'event_espresso'
3620
+				),
3621
+				__FILE__,
3622
+				__FUNCTION__,
3623
+				__LINE__
3624
+			);
3625
+		}
3626
+	}
3627
+
3628
+
3629
+	public function trash_cpt_item($post_id)
3630
+	{
3631
+	}
3632
+
3633
+
3634
+	public function delete_cpt_item($post_id)
3635
+	{
3636
+	}
3637
+
3638
+
3639
+	public function restore_cpt_item($post_id)
3640
+	{
3641
+	}
3642
+
3643
+
3644
+	protected function _restore_cpt_item($post_id, $revision_id)
3645
+	{
3646
+	}
3647
+
3648
+
3649
+	public function attendee_editor_metaboxes()
3650
+	{
3651
+		$this->verify_cpt_object();
3652
+		remove_meta_box(
3653
+			'postexcerpt',
3654
+			esc_html__('Excerpt', 'event_espresso'),
3655
+			'post_excerpt_meta_box',
3656
+			$this->_cpt_routes[ $this->_req_action ],
3657
+			'normal',
3658
+			'core'
3659
+		);
3660
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3661
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3662
+			add_meta_box(
3663
+				'postexcerpt',
3664
+				esc_html__('Short Biography', 'event_espresso'),
3665
+				'post_excerpt_meta_box',
3666
+				$this->_cpt_routes[ $this->_req_action ],
3667
+				'normal'
3668
+			);
3669
+		}
3670
+		if (post_type_supports('espresso_attendees', 'comments')) {
3671
+			add_meta_box(
3672
+				'commentsdiv',
3673
+				esc_html__('Notes on the Contact', 'event_espresso'),
3674
+				'post_comment_meta_box',
3675
+				$this->_cpt_routes[ $this->_req_action ],
3676
+				'normal',
3677
+				'core'
3678
+			);
3679
+		}
3680
+		add_meta_box(
3681
+			'attendee_contact_info',
3682
+			esc_html__('Contact Info', 'event_espresso'),
3683
+			array($this, 'attendee_contact_info'),
3684
+			$this->_cpt_routes[ $this->_req_action ],
3685
+			'side',
3686
+			'core'
3687
+		);
3688
+		add_meta_box(
3689
+			'attendee_details_address',
3690
+			esc_html__('Address Details', 'event_espresso'),
3691
+			array($this, 'attendee_address_details'),
3692
+			$this->_cpt_routes[ $this->_req_action ],
3693
+			'normal',
3694
+			'core'
3695
+		);
3696
+		add_meta_box(
3697
+			'attendee_registrations',
3698
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3699
+			array($this, 'attendee_registrations_meta_box'),
3700
+			$this->_cpt_routes[ $this->_req_action ],
3701
+			'normal',
3702
+			'high'
3703
+		);
3704
+	}
3705
+
3706
+
3707
+	/**
3708
+	 * Metabox for attendee contact info
3709
+	 *
3710
+	 * @param  WP_Post $post wp post object
3711
+	 * @return string attendee contact info ( and form )
3712
+	 * @throws EE_Error
3713
+	 * @throws InvalidArgumentException
3714
+	 * @throws InvalidDataTypeException
3715
+	 * @throws InvalidInterfaceException
3716
+	 * @throws LogicException
3717
+	 * @throws DomainException
3718
+	 */
3719
+	public function attendee_contact_info($post)
3720
+	{
3721
+		// get attendee object ( should already have it )
3722
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3723
+		$form->enqueueStylesAndScripts();
3724
+		echo $form->display();
3725
+	}
3726
+
3727
+
3728
+	/**
3729
+	 * Return form handler for the contact details metabox
3730
+	 *
3731
+	 * @param EE_Attendee $attendee
3732
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3733
+	 * @throws DomainException
3734
+	 * @throws InvalidArgumentException
3735
+	 * @throws InvalidDataTypeException
3736
+	 * @throws InvalidInterfaceException
3737
+	 */
3738
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3739
+	{
3740
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3741
+	}
3742
+
3743
+
3744
+	/**
3745
+	 * Metabox for attendee details
3746
+	 *
3747
+	 * @param  WP_Post $post wp post object
3748
+	 * @throws DomainException
3749
+	 */
3750
+	public function attendee_address_details($post)
3751
+	{
3752
+		// get attendee object (should already have it)
3753
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3754
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3755
+			new EE_Question_Form_Input(
3756
+				EE_Question::new_instance(
3757
+					array(
3758
+						'QST_ID'           => 0,
3759
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3760
+						'QST_system'       => 'admin-state',
3761
+					)
3762
+				),
3763
+				EE_Answer::new_instance(
3764
+					array(
3765
+						'ANS_ID'    => 0,
3766
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3767
+					)
3768
+				),
3769
+				array(
3770
+					'input_id'       => 'STA_ID',
3771
+					'input_name'     => 'STA_ID',
3772
+					'input_prefix'   => '',
3773
+					'append_qstn_id' => false,
3774
+				)
3775
+			)
3776
+		);
3777
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3778
+			new EE_Question_Form_Input(
3779
+				EE_Question::new_instance(
3780
+					array(
3781
+						'QST_ID'           => 0,
3782
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3783
+						'QST_system'       => 'admin-country',
3784
+					)
3785
+				),
3786
+				EE_Answer::new_instance(
3787
+					array(
3788
+						'ANS_ID'    => 0,
3789
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3790
+					)
3791
+				),
3792
+				array(
3793
+					'input_id'       => 'CNT_ISO',
3794
+					'input_name'     => 'CNT_ISO',
3795
+					'input_prefix'   => '',
3796
+					'append_qstn_id' => false,
3797
+				)
3798
+			)
3799
+		);
3800
+		$template =
3801
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3802
+		EEH_Template::display_template($template, $this->_template_args);
3803
+	}
3804
+
3805
+
3806
+	/**
3807
+	 *        _attendee_details
3808
+	 *
3809
+	 * @access protected
3810
+	 * @param $post
3811
+	 * @return void
3812
+	 * @throws DomainException
3813
+	 * @throws EE_Error
3814
+	 */
3815
+	public function attendee_registrations_meta_box($post)
3816
+	{
3817
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3818
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3819
+		$template =
3820
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3821
+		EEH_Template::display_template($template, $this->_template_args);
3822
+	}
3823
+
3824
+
3825
+	/**
3826
+	 * add in the form fields for the attendee edit
3827
+	 *
3828
+	 * @param  WP_Post $post wp post object
3829
+	 * @return string html for new form.
3830
+	 * @throws DomainException
3831
+	 */
3832
+	public function after_title_form_fields($post)
3833
+	{
3834
+		if ($post->post_type == 'espresso_attendees') {
3835
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3836
+			$template_args['attendee'] = $this->_cpt_model_obj;
3837
+			EEH_Template::display_template($template, $template_args);
3838
+		}
3839
+	}
3840
+
3841
+
3842
+	/**
3843
+	 *        _trash_or_restore_attendee
3844
+	 *
3845
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3846
+	 * @return void
3847
+	 * @throws EE_Error
3848
+	 * @throws InvalidArgumentException
3849
+	 * @throws InvalidDataTypeException
3850
+	 * @throws InvalidInterfaceException
3851
+	 * @access protected
3852
+	 */
3853
+	protected function _trash_or_restore_attendees($trash = true)
3854
+	{
3855
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3856
+		$ATT_MDL = EEM_Attendee::instance();
3857
+		$success = 1;
3858
+		// Checkboxes
3859
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3860
+			// if array has more than one element than success message should be plural
3861
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3862
+			// cycle thru checkboxes
3863
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3864
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3865
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3866
+				if (! $updated) {
3867
+					$success = 0;
3868
+				}
3869
+			}
3870
+		} else {
3871
+			// grab single id and delete
3872
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
3873
+			// get attendee
3874
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
3875
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3876
+			$updated = $att->save();
3877
+			if (! $updated) {
3878
+				$success = 0;
3879
+			}
3880
+		}
3881
+		$what = $success > 1
3882
+			? esc_html__('Contacts', 'event_espresso')
3883
+			: esc_html__('Contact', 'event_espresso');
3884
+		$action_desc = $trash
3885
+			? esc_html__('moved to the trash', 'event_espresso')
3886
+			: esc_html__('restored', 'event_espresso');
3887
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3888
+	}
3889 3889
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         // when adding a new registration...
66 66
         if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67 67
             EE_System::do_not_cache();
68
-            if (! isset($this->_req_data['processing_registration'])
68
+            if ( ! isset($this->_req_data['processing_registration'])
69 69
                 || absint($this->_req_data['processing_registration']) !== 1
70 70
             ) {
71 71
                 // and it's NOT the attendee information reg step
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         // style
659 659
         wp_register_style(
660 660
             'espresso_reg',
661
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
661
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
662 662
             array('ee-admin-css'),
663 663
             EVENT_ESPRESSO_VERSION
664 664
         );
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
         // script
667 667
         wp_register_script(
668 668
             'espresso_reg',
669
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
669
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
670 670
             array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671 671
             EVENT_ESPRESSO_VERSION,
672 672
             true
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
             'att_publish_text' => sprintf(
683 683
                 /* translators: The date and time */
684 684
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
685
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
685
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
686 686
             ),
687 687
         );
688 688
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
         wp_dequeue_style('espresso_reg');
706 706
         wp_register_style(
707 707
             'espresso_att',
708
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
709 709
             array('ee-admin-css'),
710 710
             EVENT_ESPRESSO_VERSION
711 711
         );
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
     {
718 718
         wp_register_script(
719 719
             'ee-spco-for-admin',
720
-            REG_ASSETS_URL . 'spco_for_admin.js',
720
+            REG_ASSETS_URL.'spco_for_admin.js',
721 721
             array('underscore', 'jquery'),
722 722
             EVENT_ESPRESSO_VERSION,
723 723
             true
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
         }
952 952
         $sc_items = array(
953 953
             'approved_status'   => array(
954
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
955 955
                 'desc'  => EEH_Template::pretty_status(
956 956
                     EEM_Registration::status_id_approved,
957 957
                     false,
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
                 ),
960 960
             ),
961 961
             'pending_status'    => array(
962
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
963 963
                 'desc'  => EEH_Template::pretty_status(
964 964
                     EEM_Registration::status_id_pending_payment,
965 965
                     false,
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
                 ),
968 968
             ),
969 969
             'wait_list'         => array(
970
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
971 971
                 'desc'  => EEH_Template::pretty_status(
972 972
                     EEM_Registration::status_id_wait_list,
973 973
                     false,
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
                 ),
976 976
             ),
977 977
             'incomplete_status' => array(
978
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
979 979
                 'desc'  => EEH_Template::pretty_status(
980 980
                     EEM_Registration::status_id_incomplete,
981 981
                     false,
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
                 ),
984 984
             ),
985 985
             'not_approved'      => array(
986
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
987 987
                 'desc'  => EEH_Template::pretty_status(
988 988
                     EEM_Registration::status_id_not_approved,
989 989
                     false,
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
                 ),
992 992
             ),
993 993
             'declined_status'   => array(
994
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
995 995
                 'desc'  => EEH_Template::pretty_status(
996 996
                     EEM_Registration::status_id_declined,
997 997
                     false,
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
                 ),
1000 1000
             ),
1001 1001
             'cancelled_status'  => array(
1002
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1003 1003
                 'desc'  => EEH_Template::pretty_status(
1004 1004
                     EEM_Registration::status_id_cancelled,
1005 1005
                     false,
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
                         'event_espresso'
1035 1035
                     ),
1036 1036
                     '<h3 style="line-height:1.5em;">',
1037
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
1038 1038
                         array(
1039 1039
                             'action' => 'edit_attendee',
1040 1040
                             'post'   => $ATT_ID,
1041 1041
                         ),
1042 1042
                         REG_ADMIN_URL
1043
-                    ) . '">' . $attendee->full_name() . '</a>',
1043
+                    ).'">'.$attendee->full_name().'</a>',
1044 1044
                     '</h3>'
1045 1045
                 );
1046 1046
             }
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
                 'espresso_registrations_new_registration',
1052 1052
                 $EVT_ID
1053 1053
             )) {
1054
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
+                $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1055 1055
                     'new_registration',
1056 1056
                     'add-registrant',
1057 1057
                     array('event_id' => $EVT_ID),
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
                 $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1092 1092
                 $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1093 1093
                 $this->_template_args['admin_page_header'] .= $datetime->name();
1094
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
+                $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )';
1095 1095
                 $this->_template_args['admin_page_header'] .= '</span></h3>';
1096 1096
             }
1097 1097
         }
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
             return true;
1118 1118
         }
1119 1119
         $REG = EEM_Registration::instance();
1120
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
+        $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1121 1121
         if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1122 1122
             return true;
1123 1123
         } else {
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
             'caps'                     => EEM_Registration::caps_read_admin,
1202 1202
             'default_where_conditions' => 'this_model_only',
1203 1203
         );
1204
-        if (! $count) {
1204
+        if ( ! $count) {
1205 1205
             $query_params = array_merge(
1206 1206
                 $query_params,
1207 1207
                 $this->_get_orderby_for_registrations_query(),
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
     protected function addAttendeeIdToWhereConditions(array $request)
1223 1223
     {
1224 1224
         $where = array();
1225
-        if (! empty($request['ATT_ID'])) {
1225
+        if ( ! empty($request['ATT_ID'])) {
1226 1226
             $where['ATT_ID'] = absint($request['ATT_ID']);
1227 1227
         }
1228 1228
         return $where;
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
     protected function _add_event_id_to_where_conditions(array $request)
1239 1239
     {
1240 1240
         $where = array();
1241
-        if (! empty($request['event_id'])) {
1241
+        if ( ! empty($request['event_id'])) {
1242 1242
             $where['EVT_ID'] = absint($request['event_id']);
1243 1243
         }
1244 1244
         return $where;
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
     protected function _add_category_id_to_where_conditions(array $request)
1255 1255
     {
1256 1256
         $where = array();
1257
-        if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1257
+        if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1258 1258
             $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1259 1259
         }
1260 1260
         return $where;
@@ -1270,10 +1270,10 @@  discard block
 block discarded – undo
1270 1270
     protected function _add_datetime_id_to_where_conditions(array $request)
1271 1271
     {
1272 1272
         $where = array();
1273
-        if (! empty($request['datetime_id'])) {
1273
+        if ( ! empty($request['datetime_id'])) {
1274 1274
             $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1275 1275
         }
1276
-        if (! empty($request['DTT_ID'])) {
1276
+        if ( ! empty($request['DTT_ID'])) {
1277 1277
             $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1278 1278
         }
1279 1279
         return $where;
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1300 1300
          * UNLESS viewing trashed registrations.
1301 1301
          */
1302
-        if (! empty($registration_status)) {
1302
+        if ( ! empty($registration_status)) {
1303 1303
             $where['STS_ID'] = $registration_status;
1304 1304
         } else {
1305 1305
             // make sure we exclude incomplete registrations, but only if not trashed.
@@ -1342,12 +1342,12 @@  discard block
 block discarded – undo
1342 1342
                 array(
1343 1343
                     EEM_Registration::instance()->convert_datetime_for_query(
1344 1344
                         'REG_date',
1345
-                        $now . ' 00:00:00',
1345
+                        $now.' 00:00:00',
1346 1346
                         'Y-m-d H:i:s'
1347 1347
                     ),
1348 1348
                     EEM_Registration::instance()->convert_datetime_for_query(
1349 1349
                         'REG_date',
1350
-                        $now . ' 23:59:59',
1350
+                        $now.' 23:59:59',
1351 1351
                         'Y-m-d H:i:s'
1352 1352
                     ),
1353 1353
                 ),
@@ -1360,12 +1360,12 @@  discard block
 block discarded – undo
1360 1360
                 array(
1361 1361
                     EEM_Registration::instance()->convert_datetime_for_query(
1362 1362
                         'REG_date',
1363
-                        $current_year_and_month . '-01 00:00:00',
1363
+                        $current_year_and_month.'-01 00:00:00',
1364 1364
                         'Y-m-d H:i:s'
1365 1365
                     ),
1366 1366
                     EEM_Registration::instance()->convert_datetime_for_query(
1367 1367
                         'REG_date',
1368
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1368
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
1369 1369
                         'Y-m-d H:i:s'
1370 1370
                     ),
1371 1371
                 ),
@@ -1380,18 +1380,18 @@  discard block
 block discarded – undo
1380 1380
                 : '';
1381 1381
             // if there is not a month or year then we can't go further
1382 1382
             if ($month_requested && $year_requested) {
1383
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1383
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
1384 1384
                 $where['REG_date'] = array(
1385 1385
                     'BETWEEN',
1386 1386
                     array(
1387 1387
                         EEM_Registration::instance()->convert_datetime_for_query(
1388 1388
                             'REG_date',
1389
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1389
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
1390 1390
                             'Y-m-d H:i:s'
1391 1391
                         ),
1392 1392
                         EEM_Registration::instance()->convert_datetime_for_query(
1393 1393
                             'REG_date',
1394
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1394
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
1395 1395
                             'Y-m-d H:i:s'
1396 1396
                         ),
1397 1397
                     ),
@@ -1411,8 +1411,8 @@  discard block
 block discarded – undo
1411 1411
     protected function _add_search_to_where_conditions(array $request)
1412 1412
     {
1413 1413
         $where = array();
1414
-        if (! empty($request['s'])) {
1415
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1414
+        if ( ! empty($request['s'])) {
1415
+            $search_string = '%'.sanitize_text_field($request['s']).'%';
1416 1416
             $where['OR*search_conditions'] = array(
1417 1417
                 'Event.EVT_name'                          => array('LIKE', $search_string),
1418 1418
                 'Event.EVT_desc'                          => array('LIKE', $search_string),
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
                 )
1649 1649
                 : '';
1650 1650
             // grab header
1651
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1651
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1652 1652
             $this->_template_args['REG_ID'] = $this->_registration->ID();
1653 1653
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1654 1654
                 $template_path,
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
                                 EEH_HTML::strong(
1787 1787
                                     $this->_registration->pretty_status(),
1788 1788
                                     '',
1789
-                                    'status-' . $this->_registration->status_ID(),
1789
+                                    'status-'.$this->_registration->status_ID(),
1790 1790
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1791 1791
                                 )
1792 1792
                             )
@@ -1842,14 +1842,14 @@  discard block
 block discarded – undo
1842 1842
     protected function _get_reg_statuses()
1843 1843
     {
1844 1844
         $reg_status_array = EEM_Registration::instance()->reg_status_array();
1845
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1845
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1846 1846
         // get current reg status
1847 1847
         $current_status = $this->_registration->status_ID();
1848 1848
         // is registration for free event? This will determine whether to display the pending payment option
1849 1849
         if ($current_status !== EEM_Registration::status_id_pending_payment
1850 1850
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1851 1851
         ) {
1852
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1852
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1853 1853
         }
1854 1854
         return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1855 1855
     }
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
         $success = false;
1942 1942
         // typecast $REG_IDs
1943 1943
         $REG_IDs = (array) $REG_IDs;
1944
-        if (! empty($REG_IDs)) {
1944
+        if ( ! empty($REG_IDs)) {
1945 1945
             $success = true;
1946 1946
             // set default status if none is passed
1947 1947
             $status = $status ? $status : EEM_Registration::status_id_pending_payment;
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
             $action,
2090 2090
             $notify
2091 2091
         );
2092
-        $method = $action . '_registration';
2092
+        $method = $action.'_registration';
2093 2093
         if (method_exists($this, $method)) {
2094 2094
             $this->$method($notify);
2095 2095
         }
@@ -2320,7 +2320,7 @@  discard block
 block discarded – undo
2320 2320
         $this->_template_args['REG_ID'] = $this->_registration->ID();
2321 2321
         $this->_template_args['event_id'] = $this->_registration->event_ID();
2322 2322
         $template_path =
2323
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2323
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2324 2324
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325 2325
     }
2326 2326
 
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354 2354
             $this->_template_args['REG_ID'] = $this->_registration->ID();
2355 2355
             $template_path =
2356
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2356
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2357 2357
             echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358 2358
         }
2359 2359
     }
@@ -2370,7 +2370,7 @@  discard block
 block discarded – undo
2370 2370
     public function form_before_question_group($output)
2371 2371
     {
2372 2372
         EE_Error::doing_it_wrong(
2373
-            __CLASS__ . '::' . __FUNCTION__,
2373
+            __CLASS__.'::'.__FUNCTION__,
2374 2374
             esc_html__(
2375 2375
                 '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.',
2376 2376
                 'event_espresso'
@@ -2395,7 +2395,7 @@  discard block
 block discarded – undo
2395 2395
     public function form_after_question_group($output)
2396 2396
     {
2397 2397
         EE_Error::doing_it_wrong(
2398
-            __CLASS__ . '::' . __FUNCTION__,
2398
+            __CLASS__.'::'.__FUNCTION__,
2399 2399
             esc_html__(
2400 2400
                 '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.',
2401 2401
                 'event_espresso'
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
     public function form_form_field_label_wrap($label)
2434 2434
     {
2435 2435
         EE_Error::doing_it_wrong(
2436
-            __CLASS__ . '::' . __FUNCTION__,
2436
+            __CLASS__.'::'.__FUNCTION__,
2437 2437
             esc_html__(
2438 2438
                 '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.',
2439 2439
                 'event_espresso'
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
         return '
2444 2444
 			<tr>
2445 2445
 				<th>
2446
-					' . $label . '
2446
+					' . $label.'
2447 2447
 				</th>';
2448 2448
     }
2449 2449
 
@@ -2459,7 +2459,7 @@  discard block
 block discarded – undo
2459 2459
     public function form_form_field_input__wrap($input)
2460 2460
     {
2461 2461
         EE_Error::doing_it_wrong(
2462
-            __CLASS__ . '::' . __FUNCTION__,
2462
+            __CLASS__.'::'.__FUNCTION__,
2463 2463
             esc_html__(
2464 2464
                 '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.',
2465 2465
                 'event_espresso'
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
         );
2469 2469
         return '
2470 2470
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2471
-					' . $input . '
2471
+					' . $input.'
2472 2472
 				</td>
2473 2473
 			</tr>';
2474 2474
     }
@@ -2512,8 +2512,8 @@  discard block
 block discarded – undo
2512 2512
      */
2513 2513
     protected function _get_reg_custom_questions_form($REG_ID)
2514 2514
     {
2515
-        if (! $this->_reg_custom_questions_form) {
2516
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2515
+        if ( ! $this->_reg_custom_questions_form) {
2516
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2517 2517
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518 2518
                 EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519 2519
             );
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
      */
2537 2537
     private function _save_reg_custom_questions_form($REG_ID = false)
2538 2538
     {
2539
-        if (! $REG_ID) {
2539
+        if ( ! $REG_ID) {
2540 2540
             EE_Error::add_error(
2541 2541
                 esc_html__(
2542 2542
                     'An error occurred. No registration ID was received.',
@@ -2628,30 +2628,30 @@  discard block
 block discarded – undo
2628 2628
                     ? $registration->attendee()
2629 2629
                     : EEM_Attendee::instance()
2630 2630
                                   ->create_default_object();
2631
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2632
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2633
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2634
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2635
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2636
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2631
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
2632
+                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();
2633
+                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();
2634
+                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();
2635
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2636
+                $this->_template_args['attendees'][$att_nmbr]['address'] = implode(
2637 2637
                     ', ',
2638 2638
                     $attendee->full_address_as_array()
2639 2639
                 );
2640
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2640
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2641 2641
                     array(
2642 2642
                         'action' => 'edit_attendee',
2643 2643
                         'post'   => $attendee->ID(),
2644 2644
                     ),
2645 2645
                     REG_ADMIN_URL
2646 2646
                 );
2647
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj() instanceof EE_Event
2647
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj() instanceof EE_Event
2648 2648
                     ? $registration->event_obj()->name()
2649 2649
                     : '';
2650 2650
                 $att_nmbr++;
2651 2651
             }
2652 2652
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2653 2653
         }
2654
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2654
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2655 2655
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2656 2656
     }
2657 2657
 
@@ -2675,11 +2675,11 @@  discard block
 block discarded – undo
2675 2675
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2676 2676
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2677 2677
         // primary registration object (that way we know if we need to show create button or not)
2678
-        if (! $this->_registration->is_primary_registrant()) {
2678
+        if ( ! $this->_registration->is_primary_registrant()) {
2679 2679
             $primary_registration = $this->_registration->get_primary_registration();
2680 2680
             $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2681 2681
                 : null;
2682
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2682
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2683 2683
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2684 2684
                 // custom attendee object so let's not worry about the primary reg.
2685 2685
                 $primary_registration = null;
@@ -2713,7 +2713,7 @@  discard block
 block discarded – undo
2713 2713
             ) : '';
2714 2714
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2715 2715
         $this->_template_args['att_check'] = $att_check;
2716
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2716
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2717 2717
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2718 2718
     }
2719 2719
 
@@ -2751,7 +2751,7 @@  discard block
 block discarded – undo
2751 2751
         $success = 0;
2752 2752
         $overwrite_msgs = false;
2753 2753
         // Checkboxes
2754
-        if (! is_array($this->_req_data['_REG_ID'])) {
2754
+        if ( ! is_array($this->_req_data['_REG_ID'])) {
2755 2755
             $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2756 2756
         }
2757 2757
         $reg_count = count($this->_req_data['_REG_ID']);
@@ -2760,7 +2760,7 @@  discard block
 block discarded – undo
2760 2760
             /** @var EE_Registration $REG */
2761 2761
             $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2762 2762
             $payments = $REG->registration_payments();
2763
-            if (! empty($payments)) {
2763
+            if ( ! empty($payments)) {
2764 2764
                 $name = $REG->attendee() instanceof EE_Attendee
2765 2765
                     ? $REG->attendee()->full_name()
2766 2766
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2821,17 +2821,17 @@  discard block
 block discarded – undo
2821 2821
         $REG_MDL = EEM_Registration::instance();
2822 2822
         $success = 1;
2823 2823
         // Checkboxes
2824
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2824
+        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2825 2825
             // if array has more than one element than success message should be plural
2826 2826
             $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2827 2827
             // cycle thru checkboxes
2828 2828
             while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2829 2829
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2830
-                if (! $REG instanceof EE_Registration) {
2830
+                if ( ! $REG instanceof EE_Registration) {
2831 2831
                     continue;
2832 2832
                 }
2833 2833
                 $deleted = $this->_delete_registration($REG);
2834
-                if (! $deleted) {
2834
+                if ( ! $deleted) {
2835 2835
                     $success = 0;
2836 2836
                 }
2837 2837
             }
@@ -2840,7 +2840,7 @@  discard block
 block discarded – undo
2840 2840
             $REG_ID = $this->_req_data['_REG_ID'];
2841 2841
             $REG = $REG_MDL->get_one_by_ID($REG_ID);
2842 2842
             $deleted = $this->_delete_registration($REG);
2843
-            if (! $deleted) {
2843
+            if ( ! $deleted) {
2844 2844
                 $success = 0;
2845 2845
             }
2846 2846
         }
@@ -2874,11 +2874,11 @@  discard block
 block discarded – undo
2874 2874
         $REGS = $TXN->get_many_related('Registration');
2875 2875
         $all_trashed = true;
2876 2876
         foreach ($REGS as $registration) {
2877
-            if (! $registration->get('REG_deleted')) {
2877
+            if ( ! $registration->get('REG_deleted')) {
2878 2878
                 $all_trashed = false;
2879 2879
             }
2880 2880
         }
2881
-        if (! $all_trashed) {
2881
+        if ( ! $all_trashed) {
2882 2882
             EE_Error::add_error(
2883 2883
                 esc_html__(
2884 2884
                     '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.',
@@ -2937,7 +2937,7 @@  discard block
 block discarded – undo
2937 2937
      */
2938 2938
     public function new_registration()
2939 2939
     {
2940
-        if (! $this->_set_reg_event()) {
2940
+        if ( ! $this->_set_reg_event()) {
2941 2941
             throw new EE_Error(
2942 2942
                 esc_html__(
2943 2943
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2947,8 +2947,8 @@  discard block
 block discarded – undo
2947 2947
         }
2948 2948
         EE_Registry::instance()->REQ->set_espresso_page(true);
2949 2949
         // gotta start with a clean slate if we're not coming here via ajax
2950
-        if (! defined('DOING_AJAX')
2951
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2950
+        if ( ! defined('DOING_AJAX')
2951
+            && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2952 2952
         ) {
2953 2953
             EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2954 2954
         }
@@ -2981,7 +2981,7 @@  discard block
 block discarded – undo
2981 2981
         }
2982 2982
         // grab header
2983 2983
         $template_path =
2984
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2984
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2985 2985
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2986 2986
             $template_path,
2987 2987
             $this->_template_args,
@@ -3022,7 +3022,7 @@  discard block
 block discarded – undo
3022 3022
                 '</b>'
3023 3023
             );
3024 3024
             return '
3025
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
3025
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
3026 3026
 	<script >
3027 3027
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
3028 3028
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
         // we come back to the process_registration_step route.
3092 3092
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3093 3093
         return EEH_Template::display_template(
3094
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3094
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
3095 3095
             $template_args,
3096 3096
             true
3097 3097
         );
@@ -3113,8 +3113,8 @@  discard block
 block discarded – undo
3113 3113
         if (is_object($this->_reg_event)) {
3114 3114
             return true;
3115 3115
         }
3116
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3117
-        if (! $EVT_ID) {
3116
+        $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3117
+        if ( ! $EVT_ID) {
3118 3118
             return false;
3119 3119
         }
3120 3120
         $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
@@ -3146,8 +3146,8 @@  discard block
 block discarded – undo
3146 3146
         $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3147 3147
         // if doing ajax then we need to verify the nonce
3148 3148
         if (defined('DOING_AJAX')) {
3149
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
3150
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3149
+            $nonce = isset($this->_req_data[$this->_req_nonce])
3150
+                ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
3151 3151
             $this->_verify_nonce($nonce, $this->_req_nonce);
3152 3152
         }
3153 3153
         switch ($step) {
@@ -3183,7 +3183,7 @@  discard block
 block discarded – undo
3183 3183
                 }
3184 3184
                 break;
3185 3185
             case 'questions':
3186
-                if (! isset(
3186
+                if ( ! isset(
3187 3187
                     $this->_req_data['txn_reg_status_change'],
3188 3188
                     $this->_req_data['txn_reg_status_change']['send_notifications']
3189 3189
                 )
@@ -3198,7 +3198,7 @@  discard block
 block discarded – undo
3198 3198
                         $grand_total->save_this_and_descendants_to_txn();
3199 3199
                     }
3200 3200
                 }
3201
-                if (! $transaction instanceof EE_Transaction) {
3201
+                if ( ! $transaction instanceof EE_Transaction) {
3202 3202
                     $query_args = array(
3203 3203
                         'action'                  => 'new_registration',
3204 3204
                         'processing_registration' => 2,
@@ -3221,7 +3221,7 @@  discard block
 block discarded – undo
3221 3221
                     }
3222 3222
                 }
3223 3223
                 // maybe update status, and make sure to save transaction if not done already
3224
-                if (! $transaction->update_status_based_on_total_paid()) {
3224
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3225 3225
                     $transaction->save();
3226 3226
                 }
3227 3227
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3304,7 +3304,7 @@  discard block
 block discarded – undo
3304 3304
     public function get_attendees($per_page, $count = false, $trash = false)
3305 3305
     {
3306 3306
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3307
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3307
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3308 3308
         $ATT_MDL = EEM_Attendee::instance();
3309 3309
         $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3310 3310
         switch ($this->_req_data['orderby']) {
@@ -3343,8 +3343,8 @@  discard block
 block discarded – undo
3343 3343
             ? $this->_req_data['perpage']
3344 3344
             : $per_page;
3345 3345
         $_where = array();
3346
-        if (! empty($this->_req_data['s'])) {
3347
-            $sstr = '%' . $this->_req_data['s'] . '%';
3346
+        if ( ! empty($this->_req_data['s'])) {
3347
+            $sstr = '%'.$this->_req_data['s'].'%';
3348 3348
             $_where['OR'] = array(
3349 3349
                 'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3350 3350
                 'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
             'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3372 3372
             'limit'         => $limit,
3373 3373
         );
3374
-        if (! $count) {
3374
+        if ( ! $count) {
3375 3375
             $query_args['order_by'] = array($orderby => $sort);
3376 3376
         }
3377 3377
         if ($trash) {
@@ -3414,7 +3414,7 @@  discard block
 block discarded – undo
3414 3414
      */
3415 3415
     public function _registrations_report_base($method_name_for_getting_query_params)
3416 3416
     {
3417
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3417
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3418 3418
             wp_redirect(
3419 3419
                 EE_Admin_Page::add_query_args_and_nonce(
3420 3420
                     array(
@@ -3446,8 +3446,8 @@  discard block
 block discarded – undo
3446 3446
                 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3447 3447
             );
3448 3448
             $this->_req_data = array_merge($this->_req_data, $new_request_args);
3449
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3450
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3449
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3450
+                require_once(EE_CLASSES.'EE_Export.class.php');
3451 3451
                 $EE_Export = EE_Export::instance($this->_req_data);
3452 3452
                 $EE_Export->export();
3453 3453
             }
@@ -3468,8 +3468,8 @@  discard block
 block discarded – undo
3468 3468
 
3469 3469
     public function _contact_list_export()
3470 3470
     {
3471
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3472
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3471
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3472
+            require_once(EE_CLASSES.'EE_Export.class.php');
3473 3473
             $EE_Export = EE_Export::instance($this->_req_data);
3474 3474
             $EE_Export->export_attendees();
3475 3475
         }
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
 
3479 3479
     public function _contact_list_report()
3480 3480
     {
3481
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3481
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3482 3482
             wp_redirect(
3483 3483
                 EE_Admin_Page::add_query_args_and_nonce(
3484 3484
                     array(
@@ -3490,8 +3490,8 @@  discard block
 block discarded – undo
3490 3490
                 )
3491 3491
             );
3492 3492
         } else {
3493
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3494
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3493
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3494
+                require_once(EE_CLASSES.'EE_Export.class.php');
3495 3495
                 $EE_Export = EE_Export::instance($this->_req_data);
3496 3496
                 $EE_Export->report_attendees();
3497 3497
             }
@@ -3577,7 +3577,7 @@  discard block
 block discarded – undo
3577 3577
             $updated_fields = array(
3578 3578
                 'ATT_fname'     => $this->_req_data['ATT_fname'],
3579 3579
                 'ATT_lname'     => $this->_req_data['ATT_lname'],
3580
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3580
+                'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
3581 3581
                 'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3582 3582
                 'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3583 3583
                 'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
@@ -3653,17 +3653,17 @@  discard block
 block discarded – undo
3653 3653
             'postexcerpt',
3654 3654
             esc_html__('Excerpt', 'event_espresso'),
3655 3655
             'post_excerpt_meta_box',
3656
-            $this->_cpt_routes[ $this->_req_action ],
3656
+            $this->_cpt_routes[$this->_req_action],
3657 3657
             'normal',
3658 3658
             'core'
3659 3659
         );
3660
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3660
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
3661 3661
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3662 3662
             add_meta_box(
3663 3663
                 'postexcerpt',
3664 3664
                 esc_html__('Short Biography', 'event_espresso'),
3665 3665
                 'post_excerpt_meta_box',
3666
-                $this->_cpt_routes[ $this->_req_action ],
3666
+                $this->_cpt_routes[$this->_req_action],
3667 3667
                 'normal'
3668 3668
             );
3669 3669
         }
@@ -3672,7 +3672,7 @@  discard block
 block discarded – undo
3672 3672
                 'commentsdiv',
3673 3673
                 esc_html__('Notes on the Contact', 'event_espresso'),
3674 3674
                 'post_comment_meta_box',
3675
-                $this->_cpt_routes[ $this->_req_action ],
3675
+                $this->_cpt_routes[$this->_req_action],
3676 3676
                 'normal',
3677 3677
                 'core'
3678 3678
             );
@@ -3681,7 +3681,7 @@  discard block
 block discarded – undo
3681 3681
             'attendee_contact_info',
3682 3682
             esc_html__('Contact Info', 'event_espresso'),
3683 3683
             array($this, 'attendee_contact_info'),
3684
-            $this->_cpt_routes[ $this->_req_action ],
3684
+            $this->_cpt_routes[$this->_req_action],
3685 3685
             'side',
3686 3686
             'core'
3687 3687
         );
@@ -3689,7 +3689,7 @@  discard block
 block discarded – undo
3689 3689
             'attendee_details_address',
3690 3690
             esc_html__('Address Details', 'event_espresso'),
3691 3691
             array($this, 'attendee_address_details'),
3692
-            $this->_cpt_routes[ $this->_req_action ],
3692
+            $this->_cpt_routes[$this->_req_action],
3693 3693
             'normal',
3694 3694
             'core'
3695 3695
         );
@@ -3697,7 +3697,7 @@  discard block
 block discarded – undo
3697 3697
             'attendee_registrations',
3698 3698
             esc_html__('Registrations for this Contact', 'event_espresso'),
3699 3699
             array($this, 'attendee_registrations_meta_box'),
3700
-            $this->_cpt_routes[ $this->_req_action ],
3700
+            $this->_cpt_routes[$this->_req_action],
3701 3701
             'normal',
3702 3702
             'high'
3703 3703
         );
@@ -3798,7 +3798,7 @@  discard block
 block discarded – undo
3798 3798
             )
3799 3799
         );
3800 3800
         $template =
3801
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3801
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3802 3802
         EEH_Template::display_template($template, $this->_template_args);
3803 3803
     }
3804 3804
 
@@ -3817,7 +3817,7 @@  discard block
 block discarded – undo
3817 3817
         $this->_template_args['attendee'] = $this->_cpt_model_obj;
3818 3818
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3819 3819
         $template =
3820
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3820
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3821 3821
         EEH_Template::display_template($template, $this->_template_args);
3822 3822
     }
3823 3823
 
@@ -3832,7 +3832,7 @@  discard block
 block discarded – undo
3832 3832
     public function after_title_form_fields($post)
3833 3833
     {
3834 3834
         if ($post->post_type == 'espresso_attendees') {
3835
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3835
+            $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3836 3836
             $template_args['attendee'] = $this->_cpt_model_obj;
3837 3837
             EEH_Template::display_template($template, $template_args);
3838 3838
         }
@@ -3856,14 +3856,14 @@  discard block
 block discarded – undo
3856 3856
         $ATT_MDL = EEM_Attendee::instance();
3857 3857
         $success = 1;
3858 3858
         // Checkboxes
3859
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3859
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3860 3860
             // if array has more than one element than success message should be plural
3861 3861
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3862 3862
             // cycle thru checkboxes
3863 3863
             while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3864 3864
                 $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3865 3865
                     : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3866
-                if (! $updated) {
3866
+                if ( ! $updated) {
3867 3867
                     $success = 0;
3868 3868
                 }
3869 3869
             }
@@ -3874,7 +3874,7 @@  discard block
 block discarded – undo
3874 3874
             $att = $ATT_MDL->get_one_by_ID($ATT_ID);
3875 3875
             $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3876 3876
             $updated = $att->save();
3877
-            if (! $updated) {
3877
+            if ( ! $updated) {
3878 3878
                 $success = 0;
3879 3879
             }
3880 3880
         }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page_Init.core.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     *        constructor
18
-     *
19
-     * @Constructor
20
-     * @access public
21
-     * @return void
22
-     */
23
-    public function __construct()
24
-    {
25
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
27
-            define('REG_PG_SLUG', 'espresso_registrations');
28
-            define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
35
-        }
36
-
37
-        parent::__construct();
38
-    }
39
-
40
-
41
-    protected function _set_init_properties()
42
-    {
43
-        $this->label = __('Registrations Overview', 'event_espresso');
44
-    }
45
-
46
-
47
-    protected function _set_menu_map()
48
-    {
49
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
50
-            array(
51
-                'menu_group'      => 'main',
52
-                'menu_order'      => 40,
53
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
54
-                'parent_slug'     => 'espresso_events',
55
-                'menu_slug'       => REG_PG_SLUG,
56
-                'menu_label'      => __('Registrations', 'event_espresso'),
57
-                'capability'      => 'ee_read_registrations',
58
-                'admin_init_page' => $this,
59
-            )
60
-        );
61
-    }
16
+	/**
17
+	 *        constructor
18
+	 *
19
+	 * @Constructor
20
+	 * @access public
21
+	 * @return void
22
+	 */
23
+	public function __construct()
24
+	{
25
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
+		if (! defined('REG_PG_SLUG')) {
27
+			define('REG_PG_SLUG', 'espresso_registrations');
28
+			define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
+			define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
+			define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
+			define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
+			define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
+			define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
+			define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
35
+		}
36
+
37
+		parent::__construct();
38
+	}
39
+
40
+
41
+	protected function _set_init_properties()
42
+	{
43
+		$this->label = __('Registrations Overview', 'event_espresso');
44
+	}
45
+
46
+
47
+	protected function _set_menu_map()
48
+	{
49
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
50
+			array(
51
+				'menu_group'      => 'main',
52
+				'menu_order'      => 40,
53
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
54
+				'parent_slug'     => 'espresso_events',
55
+				'menu_slug'       => REG_PG_SLUG,
56
+				'menu_label'      => __('Registrations', 'event_espresso'),
57
+				'capability'      => 'ee_read_registrations',
58
+				'admin_init_page' => $this,
59
+			)
60
+		);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@
 block discarded – undo
23 23
     public function __construct()
24 24
     {
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
26
+        if ( ! defined('REG_PG_SLUG')) {
27 27
             define('REG_PG_SLUG', 'espresso_registrations');
28 28
             define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
29
+            define('REG_ADMIN', EE_ADMIN_PAGES.'registrations/');
30
+            define('REG_ADMIN_URL', admin_url('admin.php?page='.REG_PG_SLUG));
31
+            define('REG_ASSETS_PATH', REG_ADMIN.'assets/');
32
+            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL.'registrations/assets/');
33
+            define('REG_TEMPLATE_PATH', REG_ADMIN.'templates/');
34
+            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registrations/templates/');
35 35
         }
36 36
 
37 37
         parent::__construct();
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -15,89 +15,89 @@
 block discarded – undo
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base
16 16
 {
17 17
 
18
-    /**
19
-     * EE_PMT_Paypal_Express constructor.
20
-     */
21
-    public function __construct($pm_instance = null)
22
-    {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
-        $this->_gateway = new EEG_Paypal_Express();
18
+	/**
19
+	 * EE_PMT_Paypal_Express constructor.
20
+	 */
21
+	public function __construct($pm_instance = null)
22
+	{
23
+		require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
+		$this->_gateway = new EEG_Paypal_Express();
25 25
 
26
-        $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
28
-        $this->_default_description = esc_html__(
29
-            // @codingStandardsIgnoreStart
30
-            'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
-            // @codingStandardsIgnoreEnd
32
-            'event_espresso'
33
-        );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
26
+		$this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
+		$this->_template_path = $this->file_folder() . 'templates/';
28
+		$this->_default_description = esc_html__(
29
+			// @codingStandardsIgnoreStart
30
+			'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
+			// @codingStandardsIgnoreEnd
32
+			'event_espresso'
33
+		);
34
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36
-        parent::__construct($pm_instance);
37
-    }
36
+		parent::__construct($pm_instance);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Adds the help tab.
42
-     *
43
-     * @see EE_PMT_Base::help_tabs_config()
44
-     * @return array
45
-     */
46
-    public function help_tabs_config()
47
-    {
48
-        return array(
49
-            $this->get_help_tab_name() => array(
50
-                'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
-                'filename' => 'payment_methods_overview_paypal_express'
52
-            )
53
-        );
54
-    }
40
+	/**
41
+	 * Adds the help tab.
42
+	 *
43
+	 * @see EE_PMT_Base::help_tabs_config()
44
+	 * @return array
45
+	 */
46
+	public function help_tabs_config()
47
+	{
48
+		return array(
49
+			$this->get_help_tab_name() => array(
50
+				'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
+				'filename' => 'payment_methods_overview_paypal_express'
52
+			)
53
+		);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * Gets the form for all the settings related to this payment method type.
59
-     *
60
-     * @return EE_Payment_Method_Form
61
-     */
62
-    public function generate_new_settings_form()
63
-    {
64
-        return new SettingsForm(array(), $this->get_help_tab_link());
65
-    }
57
+	/**
58
+	 * Gets the form for all the settings related to this payment method type.
59
+	 *
60
+	 * @return EE_Payment_Method_Form
61
+	 */
62
+	public function generate_new_settings_form()
63
+	{
64
+		return new SettingsForm(array(), $this->get_help_tab_link());
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Creates a billing form for this payment method type.
70
-     *
71
-     * @param \EE_Transaction $transaction
72
-     * @return \EE_Billing_Info_Form
73
-     */
74
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
75
-    {
76
-        if ($this->_pm_instance->debug_mode()) {
77
-            $form = new EE_Billing_Info_Form(
78
-                $this->_pm_instance,
79
-                array(
80
-                    'name' => 'paypal_express_Info_Form',
81
-                    'subsections' => array(
82
-                        'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
-                            array(
84
-                                'layout_strategy' => new EE_Template_Layout(
85
-                                    array(
86
-                                        'layout_template_file' => $this->_template_path
87
-                                                                    . 'paypal_express_debug_info.template.php',
88
-                                        'template_args'        => array(
89
-                                            'debug_mode' => $this->_pm_instance->debug_mode()
90
-                                        )
91
-                                    )
92
-                                )
93
-                            )
94
-                        )
95
-                    )
96
-                )
97
-            );
98
-            return $form;
99
-        }
68
+	/**
69
+	 * Creates a billing form for this payment method type.
70
+	 *
71
+	 * @param \EE_Transaction $transaction
72
+	 * @return \EE_Billing_Info_Form
73
+	 */
74
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
75
+	{
76
+		if ($this->_pm_instance->debug_mode()) {
77
+			$form = new EE_Billing_Info_Form(
78
+				$this->_pm_instance,
79
+				array(
80
+					'name' => 'paypal_express_Info_Form',
81
+					'subsections' => array(
82
+						'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
+							array(
84
+								'layout_strategy' => new EE_Template_Layout(
85
+									array(
86
+										'layout_template_file' => $this->_template_path
87
+																	. 'paypal_express_debug_info.template.php',
88
+										'template_args'        => array(
89
+											'debug_mode' => $this->_pm_instance->debug_mode()
90
+										)
91
+									)
92
+								)
93
+							)
94
+						)
95
+					)
96
+				)
97
+			);
98
+			return $form;
99
+		}
100 100
 
101
-        return false;
102
-    }
101
+		return false;
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Express();
25 25
 
26 26
         $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
27
+        $this->_template_path = $this->file_folder().'templates/';
28 28
         $this->_default_description = esc_html__(
29 29
             // @codingStandardsIgnoreStart
30 30
             'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31 31
             // @codingStandardsIgnoreEnd
32 32
             'event_espresso'
33 33
         );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34
+        $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36 36
         parent::__construct($pm_instance);
37 37
     }
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -27,136 +27,136 @@
 block discarded – undo
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     *
32
-     * @param EE_Payment_Method $pm_instance
33
-     * @return EE_PMT_Invoice
34
-     */
35
-    public function __construct($pm_instance = null)
36
-    {
37
-        $this->_pretty_name = esc_html__("Invoice", 'event_espresso');
38
-        $this->_default_description = sprintf(
39
-            esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
40
-            '<br />'
41
-        );
42
-        parent::__construct($pm_instance);
43
-        $this->_default_button_url = $this->file_url().'lib/invoice-logo.png';
44
-    }
30
+	/**
31
+	 *
32
+	 * @param EE_Payment_Method $pm_instance
33
+	 * @return EE_PMT_Invoice
34
+	 */
35
+	public function __construct($pm_instance = null)
36
+	{
37
+		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
38
+		$this->_default_description = sprintf(
39
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
40
+			'<br />'
41
+		);
42
+		parent::__construct($pm_instance);
43
+		$this->_default_button_url = $this->file_url().'lib/invoice-logo.png';
44
+	}
45 45
 
46 46
 
47 47
 
48
-    /**
49
-     * Creates the billing form for this payment method type
50
-     * @param \EE_Transaction $transaction
51
-     * @return NULL
52
-     */
53
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
54
-    {
55
-        return null;
56
-    }
48
+	/**
49
+	 * Creates the billing form for this payment method type
50
+	 * @param \EE_Transaction $transaction
51
+	 * @return NULL
52
+	 */
53
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
54
+	{
55
+		return null;
56
+	}
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * Gets the form for all the settings related to this payment method type
62
-     * @return EE_Payment_Method_Form
63
-     */
64
-    public function generate_new_settings_form()
65
-    {
66
-        $pdf_payee_input_name = 'pdf_payee_name';
67
-        $confirmation_text_input_name = 'page_confirmation_text';
68
-        $form =  new EE_Payment_Method_Form(array(
60
+	/**
61
+	 * Gets the form for all the settings related to this payment method type
62
+	 * @return EE_Payment_Method_Form
63
+	 */
64
+	public function generate_new_settings_form()
65
+	{
66
+		$pdf_payee_input_name = 'pdf_payee_name';
67
+		$confirmation_text_input_name = 'page_confirmation_text';
68
+		$form =  new EE_Payment_Method_Form(array(
69 69
 //              'payment_method_type' => $this,
70
-                'extra_meta_inputs'=>array(
71
-                    $pdf_payee_input_name => new EE_Text_Input(array(
72
-                        'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
73
-                    )),
74
-                    'pdf_payee_email' => new EE_Email_Input(array(
75
-                        'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
76
-                    )),
77
-                    'pdf_payee_tax_number' => new EE_Text_Input(array(
78
-                        'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
79
-                        )),
80
-                    'pdf_payee_address' => new EE_Text_Area_Input(array(
81
-                        'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
-                    )),
84
-                    'pdf_instructions'=>new EE_Text_Area_Input(array(
85
-                        'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86
-                        'default'=>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
88
-                    )),
89
-                    'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
90
-                        'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
91
-                        'default'=>  EE_Config::instance()->organization->logo_url,
92
-                        'html_help_text'=>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
93
-                    )),
94
-                    $confirmation_text_input_name =>new EE_Text_Area_Input(array(
95
-                        'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96
-                        'default'=>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
98
-                    )),
99
-                    'page_extra_info'=>new EE_Text_Area_Input(array(
100
-                        'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
102
-                    )),
103
-                ),
104
-                'include'=>array(
105
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
107
-                    $confirmation_text_input_name, 'page_extra_info'),
108
-            ));
109
-        $form->add_subsections(
110
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111
-            $pdf_payee_input_name
112
-        );
113
-        $form->add_subsections(
114
-            array( 'header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115
-            $confirmation_text_input_name
116
-        );
117
-        return $form;
118
-    }
70
+				'extra_meta_inputs'=>array(
71
+					$pdf_payee_input_name => new EE_Text_Input(array(
72
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
73
+					)),
74
+					'pdf_payee_email' => new EE_Email_Input(array(
75
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
76
+					)),
77
+					'pdf_payee_tax_number' => new EE_Text_Input(array(
78
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
79
+						)),
80
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
81
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
+					)),
84
+					'pdf_instructions'=>new EE_Text_Area_Input(array(
85
+						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86
+						'default'=>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
88
+					)),
89
+					'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
90
+						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
91
+						'default'=>  EE_Config::instance()->organization->logo_url,
92
+						'html_help_text'=>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
93
+					)),
94
+					$confirmation_text_input_name =>new EE_Text_Area_Input(array(
95
+						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96
+						'default'=>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
98
+					)),
99
+					'page_extra_info'=>new EE_Text_Area_Input(array(
100
+						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
102
+					)),
103
+				),
104
+				'include'=>array(
105
+					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
107
+					$confirmation_text_input_name, 'page_extra_info'),
108
+			));
109
+		$form->add_subsections(
110
+			array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111
+			$pdf_payee_input_name
112
+		);
113
+		$form->add_subsections(
114
+			array( 'header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115
+			$confirmation_text_input_name
116
+		);
117
+		return $form;
118
+	}
119 119
 
120 120
 
121 121
 
122
-    /**
123
-     * Adds the help tab
124
-     * @see EE_PMT_Base::help_tabs_config()
125
-     * @return array
126
-     */
127
-    public function help_tabs_config()
128
-    {
129
-        return array(
130
-            $this->get_help_tab_name() => array(
131
-                'title' => esc_html__('Invoice Settings', 'event_espresso'),
132
-                'filename' => 'payment_methods_overview_invoice'
133
-            ),
134
-        );
135
-    }
122
+	/**
123
+	 * Adds the help tab
124
+	 * @see EE_PMT_Base::help_tabs_config()
125
+	 * @return array
126
+	 */
127
+	public function help_tabs_config()
128
+	{
129
+		return array(
130
+			$this->get_help_tab_name() => array(
131
+				'title' => esc_html__('Invoice Settings', 'event_espresso'),
132
+				'filename' => 'payment_methods_overview_invoice'
133
+			),
134
+		);
135
+	}
136 136
 
137 137
 
138
-    /**
139
-     * For adding any html output above the payment overview.
140
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
141
-     * Other gateways may want to override this, such as offline gateways.
142
-     *
143
-     * @param \EE_Payment $payment
144
-     * @return string
145
-     */
146
-    public function payment_overview_content(EE_Payment $payment)
147
-    {
148
-        return EEH_Template::locate_template(
149
-            'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
150
-            array_merge(
151
-                array(
152
-                    'payment_method'            => $this->_pm_instance,
153
-                    'payment'                       => $payment,
154
-                    'page_confirmation_text'                    => '',
155
-                    'page_extra_info'   => '',
156
-                    'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
157
-                ),
158
-                $this->_pm_instance->all_extra_meta_array()
159
-            )
160
-        );
161
-    }
138
+	/**
139
+	 * For adding any html output above the payment overview.
140
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
141
+	 * Other gateways may want to override this, such as offline gateways.
142
+	 *
143
+	 * @param \EE_Payment $payment
144
+	 * @return string
145
+	 */
146
+	public function payment_overview_content(EE_Payment $payment)
147
+	{
148
+		return EEH_Template::locate_template(
149
+			'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
150
+			array_merge(
151
+				array(
152
+					'payment_method'            => $this->_pm_instance,
153
+					'payment'                       => $payment,
154
+					'page_confirmation_text'                    => '',
155
+					'page_extra_info'   => '',
156
+					'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
157
+				),
158
+				$this->_pm_instance->all_extra_meta_array()
159
+			)
160
+		);
161
+	}
162 162
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $pdf_payee_input_name = 'pdf_payee_name';
67 67
         $confirmation_text_input_name = 'page_confirmation_text';
68
-        $form =  new EE_Payment_Method_Form(array(
68
+        $form = new EE_Payment_Method_Form(array(
69 69
 //              'payment_method_type' => $this,
70 70
                 'extra_meta_inputs'=>array(
71 71
                     $pdf_payee_input_name => new EE_Text_Input(array(
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
                         )),
80 80
                     'pdf_payee_address' => new EE_Text_Area_Input(array(
81 81
                         'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                     )),
84 84
                     'pdf_instructions'=>new EE_Text_Area_Input(array(
85 85
                         'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86 86
                         'default'=>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
87
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
88 88
                     )),
89 89
                     'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
90 90
                         'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
                     $confirmation_text_input_name =>new EE_Text_Area_Input(array(
95 95
                         'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96 96
                         'default'=>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
97
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
98 98
                     )),
99 99
                     'page_extra_info'=>new EE_Text_Area_Input(array(
100 100
                         'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
101
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
102 102
                     )),
103 103
                 ),
104 104
                 'include'=>array(
105
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
105
+                    'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
106
+                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
107 107
                     $confirmation_text_input_name, 'page_extra_info'),
108 108
             ));
109 109
         $form->add_subsections(
110
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110
+            array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111 111
             $pdf_payee_input_name
112 112
         );
113 113
         $form->add_subsections(
114
-            array( 'header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114
+            array('header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115 115
             $confirmation_text_input_name
116 116
         );
117 117
         return $form;
Please login to merge, or discard this patch.