1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2
|
|
|
/** |
3
|
|
|
* Event Espresso |
4
|
|
|
* |
5
|
|
|
* Event Registration and Management Plugin for WordPress |
6
|
|
|
* |
7
|
|
|
* @ package Event Espresso |
8
|
|
|
* @ author Seth Shoultes |
9
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
10
|
|
|
* @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
11
|
|
|
* @ link {@link http://www.eventespresso.com} |
12
|
|
|
* @ since 4.0 |
13
|
|
|
* |
14
|
|
|
* ------------------------------------------------------------------------ |
15
|
|
|
* |
16
|
|
|
* Registrations_Admin_Page class |
17
|
|
|
* |
18
|
|
|
* @package Event Espresso |
19
|
|
|
* @subpackage includes/core/admin/transactions/Registrations_Admin_Page.core.php |
20
|
|
|
* @author Brent Christensen |
21
|
|
|
* |
22
|
|
|
* ------------------------------------------------------------------------ |
23
|
|
|
*/ |
24
|
|
|
class Registrations_Admin_Page extends EE_Admin_Page_CPT { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var EE_Registration |
28
|
|
|
*/ |
29
|
|
|
private $_registration; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var EE_Event |
33
|
|
|
*/ |
34
|
|
|
private $_reg_event; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var EE_Session |
38
|
|
|
*/ |
39
|
|
|
private $_session; |
40
|
|
|
private static $_reg_status; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Form for displaying the custom questions for this registration. |
44
|
|
|
* This gets used a few times throughout the request so its best to cache it |
45
|
|
|
* @var EE_Registration_Custom_Questions_Form |
46
|
|
|
*/ |
47
|
|
|
protected $_reg_custom_questions_form = null; |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* constructor |
53
|
|
|
* |
54
|
|
|
* @Constructor |
55
|
|
|
* @access public |
56
|
|
|
* @param bool $routing |
57
|
|
|
* @return Registrations_Admin_Page |
|
|
|
|
58
|
|
|
*/ |
59
|
|
|
public function __construct( $routing = TRUE ) { |
60
|
|
|
parent::__construct( $routing ); |
61
|
|
|
add_action( 'wp_loaded', array( $this, 'wp_loaded' )); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public function wp_loaded() { |
67
|
|
|
// when adding a new registration... |
68
|
|
|
if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) { |
69
|
|
|
EE_System::do_not_cache(); |
70
|
|
|
if ( |
71
|
|
|
! isset( $this->_req_data[ 'processing_registration' ] ) |
72
|
|
|
|| absint( $this->_req_data[ 'processing_registration' ] ) !== 1 |
73
|
|
|
) { |
74
|
|
|
// and it's NOT the attendee information reg step |
75
|
|
|
// force cookie expiration by setting time to last week |
76
|
|
|
setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' ); |
77
|
|
|
// and update the global |
78
|
|
|
$_COOKIE[ 'ee_registration_added' ] = 0; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
|
85
|
|
|
|
86
|
|
|
|
87
|
|
|
|
88
|
|
|
protected function _init_page_props() { |
89
|
|
|
$this->page_slug = REG_PG_SLUG; |
90
|
|
|
$this->_admin_base_url = REG_ADMIN_URL; |
91
|
|
|
$this->_admin_base_path = REG_ADMIN; |
92
|
|
|
$this->page_label = __('Registrations', 'event_espresso'); |
93
|
|
|
$this->_cpt_routes = array( |
94
|
|
|
'add_new_attendee' => 'espresso_attendees', |
95
|
|
|
'edit_attendee' => 'espresso_attendees', |
96
|
|
|
'insert_attendee' => 'espresso_attendees', |
97
|
|
|
'update_attendee' => 'espresso_attendees' |
98
|
|
|
); |
99
|
|
|
$this->_cpt_model_names = array( |
100
|
|
|
'add_new_attendee' => 'EEM_Attendee', |
101
|
|
|
'edit_attendee' => 'EEM_Attendee' |
102
|
|
|
); |
103
|
|
|
$this->_cpt_edit_routes = array( |
104
|
|
|
'espresso_attendees' => 'edit_attendee' |
105
|
|
|
); |
106
|
|
|
$this->_pagenow_map = array( |
107
|
|
|
'add_new_attendee' => 'post-new.php', |
108
|
|
|
'edit_attendee' => 'post.php', |
109
|
|
|
'trash' => 'post.php' |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 ); |
113
|
|
|
//add filters so that the comment urls don't take users to a confusing 404 page |
114
|
|
|
add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
public function clear_comment_link( $link, $comment, $args ) { |
|
|
|
|
119
|
|
|
//gotta make sure this only happens on this route |
120
|
|
|
$post_type = get_post_type( $comment->comment_post_ID); |
121
|
|
|
if ( $post_type == 'espresso_attendees' ) |
122
|
|
|
return '#commentsdiv'; |
123
|
|
|
return $link; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
protected function _ajax_hooks() { |
128
|
|
|
//todo: all hooks for registrations ajax goes in here |
129
|
|
|
add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' )); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
|
134
|
|
|
|
135
|
|
|
|
136
|
|
|
protected function _define_page_props() { |
137
|
|
|
$this->_admin_page_title = $this->page_label; |
138
|
|
|
$this->_labels = array( |
139
|
|
|
'buttons' => array( |
140
|
|
|
'add-registrant' => __('Add New Registration', 'event_espresso'), |
141
|
|
|
'add-attendee' => __('Add Contact', 'event_espresso'), |
142
|
|
|
'edit' => __('Edit Contact', 'event_espresso'), |
143
|
|
|
'report'=> __("Event Registrations CSV Report", "event_espresso"), |
144
|
|
|
'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ), |
145
|
|
|
'contact_list_report' => __( 'Contact List Report', 'event_espresso' ), |
146
|
|
|
'contact_list_export'=> __("Export Data", "event_espresso"), |
147
|
|
|
), |
148
|
|
|
'publishbox' => array( |
149
|
|
|
'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
150
|
|
|
'edit_attendee' => __("Update Contact Record", 'event_espresso') |
151
|
|
|
), |
152
|
|
|
'hide_add_button_on_cpt_route' => array( |
153
|
|
|
'edit_attendee' => true |
154
|
|
|
) |
155
|
|
|
); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
|
160
|
|
|
|
161
|
|
|
|
162
|
|
|
|
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* grab url requests and route them |
166
|
|
|
* @access private |
167
|
|
|
* @return void |
168
|
|
|
*/ |
169
|
|
|
public function _set_page_routes() { |
170
|
|
|
|
171
|
|
|
$this->_get_registration_status_array(); |
172
|
|
|
|
173
|
|
|
$reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
174
|
|
|
$att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0; |
175
|
|
|
$att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
176
|
|
|
|
177
|
|
|
$this->_page_routes = array( |
178
|
|
|
|
179
|
|
|
'default' => array( |
180
|
|
|
'func' => '_registrations_overview_list_table', |
181
|
|
|
'capability' => 'ee_read_registrations' |
182
|
|
|
), |
183
|
|
|
|
184
|
|
|
'view_registration' => array( |
185
|
|
|
'func' => '_registration_details', |
186
|
|
|
'capability' => 'ee_read_registration', |
187
|
|
|
'obj_id' => $reg_id |
188
|
|
|
), |
189
|
|
|
|
190
|
|
|
'edit_registration' => array( |
191
|
|
|
'func' => '_update_attendee_registration_form', |
192
|
|
|
'noheader' => TRUE, |
193
|
|
|
'headers_sent_route'=>'view_registration', |
194
|
|
|
'capability' => 'ee_edit_registration', |
195
|
|
|
'obj_id' => $reg_id, |
196
|
|
|
'_REG_ID' => $reg_id, |
197
|
|
|
), |
198
|
|
|
|
199
|
|
|
'trash_registrations' => array( |
200
|
|
|
'func' => '_trash_or_restore_registrations', |
201
|
|
|
'args' => array('trash' => TRUE), |
202
|
|
|
'noheader' => TRUE, |
203
|
|
|
'capability' => 'ee_delete_registrations' |
204
|
|
|
), |
205
|
|
|
|
206
|
|
|
'restore_registrations' => array( |
207
|
|
|
'func' => '_trash_or_restore_registrations', |
208
|
|
|
'args' => array( 'trash' => FALSE ), |
209
|
|
|
'noheader' => TRUE, |
210
|
|
|
'capability' => 'ee_delete_registrations' |
211
|
|
|
), |
212
|
|
|
|
213
|
|
|
'delete_registrations' => array( |
214
|
|
|
'func' => '_delete_registrations', |
215
|
|
|
'noheader' => TRUE, |
216
|
|
|
'capability' => 'ee_delete_registrations' |
217
|
|
|
), |
218
|
|
|
|
219
|
|
|
'new_registration' => array( |
220
|
|
|
'func' => 'new_registration', |
221
|
|
|
'capability' => 'ee_edit_registrations' |
222
|
|
|
), |
223
|
|
|
|
224
|
|
|
'process_reg_step' => array( |
225
|
|
|
'func' => 'process_reg_step', |
226
|
|
|
'noheader' => TRUE, |
227
|
|
|
'capability' => 'ee_edit_registrations' |
228
|
|
|
), |
229
|
|
|
|
230
|
|
|
'redirect_to_txn' => array( |
231
|
|
|
'func' => 'redirect_to_txn', |
232
|
|
|
'noheader' => TRUE, |
233
|
|
|
'capability' => 'ee_edit_registrations' |
234
|
|
|
), |
235
|
|
|
|
236
|
|
|
'change_reg_status' => array( |
237
|
|
|
'func' => '_change_reg_status', |
238
|
|
|
'noheader' => TRUE, |
239
|
|
|
'capability' => 'ee_edit_registration', |
240
|
|
|
'obj_id' => $reg_id |
241
|
|
|
), |
242
|
|
|
|
243
|
|
|
'approve_registration' => array( |
244
|
|
|
'func' => 'approve_registration', |
245
|
|
|
'noheader' => TRUE, |
246
|
|
|
'capability' => 'ee_edit_registration', |
247
|
|
|
'obj_id' => $reg_id |
248
|
|
|
), |
249
|
|
|
|
250
|
|
|
'approve_and_notify_registration' => array( |
251
|
|
|
'func' => 'approve_registration', |
252
|
|
|
'noheader' => TRUE, |
253
|
|
|
'args' => array(TRUE), |
254
|
|
|
'capability' => 'ee_edit_registration', |
255
|
|
|
'obj_id' => $reg_id |
256
|
|
|
), |
257
|
|
|
|
258
|
|
|
'decline_registration' => array( |
259
|
|
|
'func' => 'decline_registration', |
260
|
|
|
'noheader' => TRUE, |
261
|
|
|
'capability' => 'ee_edit_registration', |
262
|
|
|
'obj_id' => $reg_id |
263
|
|
|
), |
264
|
|
|
|
265
|
|
|
'decline_and_notify_registration' => array( |
266
|
|
|
'func' => 'decline_registration', |
267
|
|
|
'noheader' => TRUE, |
268
|
|
|
'args' => array(TRUE), |
269
|
|
|
'capability' => 'ee_edit_registration', |
270
|
|
|
'obj_id' => $reg_id |
271
|
|
|
), |
272
|
|
|
|
273
|
|
|
'pending_registration' => array( |
274
|
|
|
'func' => 'pending_registration', |
275
|
|
|
'noheader' => TRUE, |
276
|
|
|
'capability' => 'ee_edit_registration', |
277
|
|
|
'obj_id' => $reg_id |
278
|
|
|
), |
279
|
|
|
|
280
|
|
|
'pending_and_notify_registration' => array( |
281
|
|
|
'func' => 'pending_registration', |
282
|
|
|
'noheader' => TRUE, |
283
|
|
|
'args' => array(TRUE), |
284
|
|
|
'capability' => 'ee_edit_registration', |
285
|
|
|
'obj_id' => $reg_id |
286
|
|
|
), |
287
|
|
|
|
288
|
|
|
'no_approve_registration' => array( |
289
|
|
|
'func' => 'not_approve_registration', |
290
|
|
|
'noheader' => TRUE, |
291
|
|
|
'capability' => 'ee_edit_registration', |
292
|
|
|
'obj_id' => $reg_id |
293
|
|
|
), |
294
|
|
|
|
295
|
|
|
'no_approve_and_notify_registration' => array( |
296
|
|
|
'func' => 'not_approve_registration', |
297
|
|
|
'noheader' => TRUE, |
298
|
|
|
'args' => array(TRUE), |
299
|
|
|
'capability' => 'ee_edit_registration', |
300
|
|
|
'obj_id' => $reg_id |
301
|
|
|
), |
302
|
|
|
|
303
|
|
|
'cancel_registration' => array( |
304
|
|
|
'func' => 'cancel_registration', |
305
|
|
|
'noheader' => TRUE, |
306
|
|
|
'capability' => 'ee_edit_registration', |
307
|
|
|
'obj_id' => $reg_id |
308
|
|
|
), |
309
|
|
|
|
310
|
|
|
'cancel_and_notify_registration' => array( |
311
|
|
|
'func' => 'cancel_registration', |
312
|
|
|
'noheader' => TRUE, |
313
|
|
|
'args' => array(TRUE), |
314
|
|
|
'capability' => 'ee_edit_registration', |
315
|
|
|
'obj_id' => $reg_id |
316
|
|
|
), |
317
|
|
|
|
318
|
|
|
'contact_list' => array( |
319
|
|
|
'func' => '_attendee_contact_list_table', |
320
|
|
|
'capability' => 'ee_read_contacts' |
321
|
|
|
), |
322
|
|
|
|
323
|
|
|
|
324
|
|
|
'add_new_attendee' => array( |
325
|
|
|
'func' => '_create_new_cpt_item', |
326
|
|
|
'args' => array( |
327
|
|
|
'new_attendee' => TRUE, |
328
|
|
|
'capability' => 'ee_edit_contacts' |
329
|
|
|
) |
330
|
|
|
), |
331
|
|
|
|
332
|
|
|
'edit_attendee' => array( |
333
|
|
|
'func' => '_edit_cpt_item', |
334
|
|
|
'capability' => 'ee_edit_contacts', |
335
|
|
|
'obj_id' => $att_id |
336
|
|
|
), |
337
|
|
|
|
338
|
|
|
'duplicate_attendee' => array( |
339
|
|
|
'func' => '_duplicate_attendee', |
340
|
|
|
'noheader' => TRUE, |
341
|
|
|
'capability' => 'ee_edit_contacts', |
342
|
|
|
'obj_id' => $att_id |
343
|
|
|
), |
344
|
|
|
|
345
|
|
|
'insert_attendee' => array( |
346
|
|
|
'func' => '_insert_or_update_attendee', |
347
|
|
|
'args' => array( |
348
|
|
|
'new_attendee' => TRUE |
349
|
|
|
), |
350
|
|
|
'noheader' => TRUE, |
351
|
|
|
'capability' => 'ee_edit_contacts' |
352
|
|
|
), |
353
|
|
|
|
354
|
|
|
'update_attendee' => array( |
355
|
|
|
'func' => '_insert_or_update_attendee', |
356
|
|
|
'args' => array( |
357
|
|
|
'new_attendee' => FALSE |
358
|
|
|
), |
359
|
|
|
'noheader' => TRUE, |
360
|
|
|
'capability' => 'ee_edit_contacts', |
361
|
|
|
'obj_id' => $att_id |
362
|
|
|
), |
363
|
|
|
|
364
|
|
|
'trash_attendees' => array( |
365
|
|
|
'func' => '_trash_or_restore_attendees', |
366
|
|
|
'args' => array( |
367
|
|
|
'trash' => TRUE |
368
|
|
|
), |
369
|
|
|
'noheader' => TRUE, |
370
|
|
|
'capability' => 'ee_delete_contacts', |
371
|
|
|
'obj_id' => $att_id |
372
|
|
|
), |
373
|
|
|
|
374
|
|
|
'restore_attendees' => array( |
375
|
|
|
'func' => '_trash_or_restore_attendees', |
376
|
|
|
'args' => array( |
377
|
|
|
'trash' => FALSE |
378
|
|
|
), |
379
|
|
|
'noheader' => TRUE, |
380
|
|
|
'capability' => 'ee_delete_contacts', |
381
|
|
|
'obj_id' => $att_id |
382
|
|
|
), |
383
|
|
|
'resend_registration' => array( |
384
|
|
|
'func' => '_resend_registration', |
385
|
|
|
'noheader' => TRUE, |
386
|
|
|
'capability' => 'ee_send_message' |
387
|
|
|
), |
388
|
|
|
'registrations_report'=>array( |
389
|
|
|
'func'=>'_registrations_report', |
390
|
|
|
'noheader'=> TRUE, |
391
|
|
|
'capability' => 'ee_read_registrations' |
392
|
|
|
), |
393
|
|
|
'contact_list_export'=>array( |
394
|
|
|
'func'=>'_contact_list_export', |
395
|
|
|
'noheader'=>TRUE, |
396
|
|
|
'capability' => 'export' |
397
|
|
|
), |
398
|
|
|
'contact_list_report' => array( |
399
|
|
|
'func'=> '_contact_list_report', |
400
|
|
|
'noheader' => TRUE, |
401
|
|
|
'capability' => 'ee_read_contacts', |
402
|
|
|
) |
403
|
|
|
); |
404
|
|
|
|
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
|
408
|
|
|
|
409
|
|
|
|
410
|
|
|
|
411
|
|
|
protected function _set_page_config() { |
412
|
|
|
$this->_page_config = array( |
413
|
|
|
|
414
|
|
|
'default' => array( |
415
|
|
|
'nav' => array( |
416
|
|
|
'label' => __('Overview', 'event_espresso'), |
417
|
|
|
'order' => 5 |
418
|
|
|
), |
419
|
|
|
'help_tabs' => array( |
420
|
|
|
'registrations_overview_help_tab' => array( |
421
|
|
|
'title' => __('Registrations Overview', 'event_espresso'), |
422
|
|
|
'filename' => 'registrations_overview' |
423
|
|
|
), |
424
|
|
|
'registrations_overview_table_column_headings_help_tab' => array( |
425
|
|
|
'title' => __('Registrations Table Column Headings', 'event_espresso'), |
426
|
|
|
'filename' => 'registrations_overview_table_column_headings' |
427
|
|
|
), |
428
|
|
|
'registrations_overview_filters_help_tab' => array( |
429
|
|
|
'title' => __('Registration Filters', 'event_espresso'), |
430
|
|
|
'filename' => 'registrations_overview_filters' |
431
|
|
|
), |
432
|
|
|
'registrations_overview_views_help_tab' => array( |
433
|
|
|
'title' => __('Registration Views', 'event_espresso'), |
434
|
|
|
'filename' => 'registrations_overview_views' |
435
|
|
|
), |
436
|
|
|
'registrations_regoverview_other_help_tab' => array( |
437
|
|
|
'title' => __('Registrations Other', 'event_espresso'), |
438
|
|
|
'filename' => 'registrations_overview_other' |
439
|
|
|
) |
440
|
|
|
), |
441
|
|
|
'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
442
|
|
|
'qtips' => array('Registration_List_Table_Tips'), |
443
|
|
|
'list_table' => 'EE_Registrations_List_Table', |
444
|
|
|
'require_nonce' => FALSE |
445
|
|
|
), |
446
|
|
|
|
447
|
|
|
'view_registration' => array( |
448
|
|
|
'nav' => array( |
449
|
|
|
'label' => __('REG Details', 'event_espresso'), |
450
|
|
|
'order' => 15, |
451
|
|
|
'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
452
|
|
|
'persistent' => FALSE |
453
|
|
|
), |
454
|
|
|
'help_tabs' => array( |
455
|
|
|
'registrations_details_help_tab' => array( |
456
|
|
|
'title' => __('Registration Details', 'event_espresso'), |
457
|
|
|
'filename' => 'registrations_details' |
458
|
|
|
), |
459
|
|
|
'registrations_details_table_help_tab' => array( |
460
|
|
|
'title' => __('Registration Details Table', 'event_espresso'), |
461
|
|
|
'filename' => 'registrations_details_table' |
462
|
|
|
), |
463
|
|
|
'registrations_details_form_answers_help_tab' => array( |
464
|
|
|
'title' => __('Registration Form Answers', 'event_espresso'), |
465
|
|
|
'filename' => 'registrations_details_form_answers' |
466
|
|
|
), |
467
|
|
|
'registrations_details_registrant_details_help_tab' => array( |
468
|
|
|
'title' => __('Contact Details', 'event_espresso'), |
469
|
|
|
'filename' => 'registrations_details_registrant_details' |
470
|
|
|
) |
471
|
|
|
), |
472
|
|
|
'help_tour' => array( 'Registration_Details_Help_Tour' ), |
473
|
|
|
'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ), |
474
|
|
|
'require_nonce' => FALSE |
475
|
|
|
), |
476
|
|
|
|
477
|
|
|
'new_registration' => array( |
478
|
|
|
'nav' => array( |
479
|
|
|
'label' => __('Add New Registration', 'event_espresso'), |
480
|
|
|
'url' => '#', |
481
|
|
|
'order' => 15, |
482
|
|
|
'persistent' => FALSE |
483
|
|
|
), |
484
|
|
|
'metaboxes' => $this->_default_espresso_metaboxes, |
485
|
|
|
'labels' => array( |
486
|
|
|
'publishbox' => __('Save Registration', 'event_espresso') |
487
|
|
|
), |
488
|
|
|
'require_nonce' => FALSE |
489
|
|
|
), |
490
|
|
|
|
491
|
|
|
'add_new_attendee' => array( |
492
|
|
|
'nav' => array( |
493
|
|
|
'label' => __('Add Contact', 'event_espresso'), |
494
|
|
|
'order' => 15, |
495
|
|
|
'persistent' => FALSE |
496
|
|
|
), |
497
|
|
|
'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ), |
498
|
|
|
'require_nonce' => FALSE |
499
|
|
|
), |
500
|
|
|
|
501
|
|
|
'edit_attendee' => array( |
502
|
|
|
'nav' => array( |
503
|
|
|
'label' => __('Edit Contact', 'event_espresso'), |
504
|
|
|
'order' => 15, |
505
|
|
|
'persistent' => FALSE, |
506
|
|
|
'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
507
|
|
|
), |
508
|
|
|
'metaboxes' => array('attendee_editor_metaboxes'), |
509
|
|
|
'require_nonce' => FALSE |
510
|
|
|
), |
511
|
|
|
|
512
|
|
|
'contact_list' => array( |
513
|
|
|
'nav' => array( |
514
|
|
|
'label' => __('Contact List', 'event_espresso'), |
515
|
|
|
'order' => 20 |
516
|
|
|
), |
517
|
|
|
'list_table' => 'EE_Attendee_Contact_List_Table', |
518
|
|
|
'help_tabs' => array( |
519
|
|
|
'registrations_contact_list_help_tab' => array( |
520
|
|
|
'title' => __('Registrations Contact List', 'event_espresso'), |
521
|
|
|
'filename' => 'registrations_contact_list' |
522
|
|
|
), |
523
|
|
|
'registrations_contact-list_table_column_headings_help_tab' => array( |
524
|
|
|
'title' => __('Contact List Table Column Headings', 'event_espresso'), |
525
|
|
|
'filename' => 'registrations_contact_list_table_column_headings' |
526
|
|
|
), |
527
|
|
|
'registrations_contact_list_views_help_tab' => array( |
528
|
|
|
'title' => __('Contact List Views', 'event_espresso'), |
529
|
|
|
'filename' => 'registrations_contact_list_views' |
530
|
|
|
), |
531
|
|
|
'registrations_contact_list_other_help_tab' => array( |
532
|
|
|
'title' => __('Contact List Other', 'event_espresso'), |
533
|
|
|
'filename' => 'registrations_contact_list_other' |
534
|
|
|
) |
535
|
|
|
), |
536
|
|
|
'help_tour' => array( 'Contact_List_Help_Tour' ), |
537
|
|
|
'metaboxes' => array(), |
538
|
|
|
'require_nonce' => FALSE |
539
|
|
|
), |
540
|
|
|
|
541
|
|
|
//override default cpt routes |
542
|
|
|
'create_new' => '', |
543
|
|
|
'edit' => '' |
544
|
|
|
|
545
|
|
|
); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* The below methods aren't used by this class currently |
551
|
|
|
*/ |
552
|
|
|
protected function _add_screen_options() {} |
553
|
|
|
protected function _add_feature_pointers() {} |
554
|
|
|
public function admin_init() { |
555
|
|
|
EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' ); |
556
|
|
|
} |
557
|
|
|
public function admin_notices() {} |
558
|
|
|
public function admin_footer_scripts() {} |
559
|
|
|
|
560
|
|
|
|
561
|
|
|
|
562
|
|
|
|
563
|
|
|
|
564
|
|
|
|
565
|
|
|
|
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* get list of registration statuses |
569
|
|
|
* @access private |
570
|
|
|
* @return void |
571
|
|
|
*/ |
572
|
|
|
private function _get_registration_status_array() { |
573
|
|
|
self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
|
577
|
|
|
|
578
|
|
|
|
579
|
|
|
protected function _add_screen_options_default() { |
580
|
|
|
$this->_per_page_screen_option(); |
581
|
|
|
} |
582
|
|
|
|
583
|
|
View Code Duplication |
protected function _add_screen_options_contact_list() { |
|
|
|
|
584
|
|
|
$page_title = $this->_admin_page_title; |
585
|
|
|
$this->_admin_page_title = __("Contacts", 'event_espresso'); |
586
|
|
|
$this->_per_page_screen_option(); |
587
|
|
|
$this->_admin_page_title = $page_title; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
|
591
|
|
|
|
592
|
|
|
|
593
|
|
View Code Duplication |
public function load_scripts_styles() { |
|
|
|
|
594
|
|
|
//style |
595
|
|
|
//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
596
|
|
|
wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
597
|
|
|
wp_enqueue_style('espresso_reg'); |
598
|
|
|
|
599
|
|
|
//script |
600
|
|
|
wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
601
|
|
|
wp_enqueue_script('espresso_reg'); |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
|
605
|
|
|
|
606
|
|
|
public function load_scripts_styles_edit_attendee() { |
607
|
|
|
//stuff to only show up on our attendee edit details page. |
608
|
|
|
$attendee_details_translations = array( |
609
|
|
|
'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') ) |
610
|
|
|
); |
611
|
|
|
wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations ); |
612
|
|
|
wp_enqueue_script('jquery-validate'); |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
|
616
|
|
|
public function load_scripts_styles_view_registration() { |
617
|
|
|
//styles |
618
|
|
|
wp_enqueue_style('espresso-ui-theme'); |
619
|
|
|
//scripts |
620
|
|
|
$this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
621
|
|
|
$this->_reg_custom_questions_form->wp_enqueue_scripts( true ); |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
|
625
|
|
|
|
626
|
|
|
|
627
|
|
|
|
628
|
|
|
|
629
|
|
|
public function load_scripts_styles_contact_list() { |
630
|
|
|
wp_deregister_style('espresso_reg'); |
631
|
|
|
wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
632
|
|
|
wp_enqueue_style('espresso_att'); |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
|
636
|
|
|
|
637
|
|
|
|
638
|
|
|
|
639
|
|
|
public function load_scripts_styles_new_registration() { |
640
|
|
|
wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
641
|
|
|
wp_enqueue_script('ee-spco-for-admin'); |
642
|
|
|
add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
643
|
|
|
EE_Form_Section_Proper::wp_enqueue_scripts(); |
644
|
|
|
EED_Ticket_Selector::load_tckt_slctr_assets(); |
645
|
|
|
EE_Datepicker_Input::enqueue_styles_and_scripts(); |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
|
649
|
|
|
|
650
|
|
|
|
651
|
|
|
|
652
|
|
|
public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() { |
653
|
|
|
add_filter('FHEE_load_EE_messages', '__return_true'); |
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
|
657
|
|
|
|
658
|
|
|
public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() { |
659
|
|
|
add_filter('FHEE_load_EE_messages', '__return_true'); |
660
|
|
|
} |
661
|
|
|
|
662
|
|
|
|
663
|
|
|
|
664
|
|
|
protected function _set_list_table_views_default() { |
665
|
|
|
|
666
|
|
|
//for notification related bulk actions we need to make sure only active messengers have an option. |
667
|
|
|
EED_Messages::set_autoloaders(); |
668
|
|
|
/** @type EE_Message_Resource_Manager $message_resource_manager */ |
669
|
|
|
$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
670
|
|
|
$active_mts = $message_resource_manager->list_of_active_message_types(); |
671
|
|
|
//key= bulk_action_slug, value= message type. |
672
|
|
|
$match_array = array( |
673
|
|
|
'approve_registration' => 'registration', |
674
|
|
|
'decline_registration' => 'declined_registration', |
675
|
|
|
'pending_registration' => 'pending_approval', |
676
|
|
|
'no_approve_registration' => 'not_approved_registration', |
677
|
|
|
'cancel_registration' => 'cancelled_registration' |
678
|
|
|
); |
679
|
|
|
|
680
|
|
|
/** setup reg status bulk actions **/ |
681
|
|
|
$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
|
|
|
682
|
|
View Code Duplication |
if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
683
|
|
|
$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso'); |
684
|
|
|
} |
685
|
|
|
$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
686
|
|
View Code Duplication |
if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
687
|
|
|
$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso'); |
688
|
|
|
} |
689
|
|
|
$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
690
|
|
View Code Duplication |
if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
691
|
|
|
$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso'); |
692
|
|
|
} |
693
|
|
|
$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
694
|
|
View Code Duplication |
if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
695
|
|
|
$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso'); |
696
|
|
|
} |
697
|
|
|
$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
698
|
|
View Code Duplication |
if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
699
|
|
|
$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso'); |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
$this->_views = array( |
703
|
|
|
'all' => array( |
704
|
|
|
'slug' => 'all', |
705
|
|
|
'label' => __('View All Registrations', 'event_espresso'), |
706
|
|
|
'count' => 0, |
707
|
|
|
'bulk_action' => array_merge( $def_reg_status_actions, array( |
708
|
|
|
'trash_registrations' => __('Trash Registrations', 'event_espresso') |
709
|
|
|
) ) |
710
|
|
|
), |
711
|
|
|
'month' => array( |
712
|
|
|
'slug' => 'month', |
713
|
|
|
'label' => __('This Month', 'event_espresso'), |
714
|
|
|
'count' => 0, |
715
|
|
|
'bulk_action' => array_merge( $def_reg_status_actions, array( |
716
|
|
|
'trash_registrations' => __('Trash Registrations', 'event_espresso') |
717
|
|
|
)) |
718
|
|
|
), |
719
|
|
|
'today' => array( |
720
|
|
|
'slug' => 'today', |
721
|
|
|
'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ), |
722
|
|
|
'count' => 0, |
723
|
|
|
'bulk_action' => array_merge( $def_reg_status_actions, array( |
724
|
|
|
'trash_registrations' => __('Trash Registrations', 'event_espresso') |
725
|
|
|
)) |
726
|
|
|
) |
727
|
|
|
); |
728
|
|
|
|
729
|
|
|
if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) { |
730
|
|
|
$this->_views['incomplete'] = array( |
731
|
|
|
'slug' => 'incomplete', |
732
|
|
|
'label' => __('Incomplete', 'event_espresso'), |
733
|
|
|
'count' => 0, |
734
|
|
|
'bulk_action' => array( |
735
|
|
|
'trash_registrations' => __('Trash Registrations', 'event_espresso') |
736
|
|
|
) |
737
|
|
|
); |
738
|
|
|
$this->_views['trash'] = array( |
739
|
|
|
'slug' => 'trash', |
740
|
|
|
'label' => __('Trash', 'event_espresso'), |
741
|
|
|
'count' => 0, |
742
|
|
|
'bulk_action' => array( |
743
|
|
|
'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
744
|
|
|
'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso') |
745
|
|
|
) |
746
|
|
|
); |
747
|
|
|
} |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
|
751
|
|
|
|
752
|
|
|
|
753
|
|
|
protected function _set_list_table_views_contact_list() { |
754
|
|
|
$this->_views = array( |
755
|
|
|
'in_use' => array( |
756
|
|
|
'slug' => 'in_use', |
757
|
|
|
'label' => __('In Use', 'event_espresso'), |
758
|
|
|
'count' => 0, |
759
|
|
|
'bulk_action' => array( |
760
|
|
|
'trash_attendees' => __('Move to Trash', 'event_espresso'), |
761
|
|
|
) |
762
|
|
|
) |
763
|
|
|
); |
764
|
|
|
|
765
|
|
|
if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) { |
766
|
|
|
$this->_views['trash'] = array( |
767
|
|
|
'slug' => 'trash', |
768
|
|
|
'label' => __('Trash', 'event_espresso'), |
769
|
|
|
'count' => 0, |
770
|
|
|
'bulk_action' => array( |
771
|
|
|
'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
772
|
|
|
) |
773
|
|
|
); |
774
|
|
|
} |
775
|
|
|
} |
776
|
|
|
|
777
|
|
|
|
778
|
|
|
|
779
|
|
|
|
780
|
|
|
|
781
|
|
|
protected function _registration_legend_items() { |
782
|
|
|
$fc_items = array( |
783
|
|
|
'star-icon' => array( |
784
|
|
|
'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
785
|
|
|
'desc' => __('This is the Primary Registrant', 'event_espresso') |
786
|
|
|
), |
787
|
|
|
'view_details' => array( |
788
|
|
|
'class' => 'dashicons dashicons-clipboard', |
789
|
|
|
'desc' => __('View Registration Details', 'event_espresso') |
790
|
|
|
), |
791
|
|
|
'edit_attendee' => array( |
792
|
|
|
'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
793
|
|
|
'desc' => __('Edit Contact Details', 'event_espresso') |
794
|
|
|
), |
795
|
|
|
'view_transaction' => array( |
796
|
|
|
'class' => 'dashicons dashicons-cart', |
797
|
|
|
'desc' => __('View Transaction Details', 'event_espresso') |
798
|
|
|
), |
799
|
|
|
'view_invoice' => array( |
800
|
|
|
'class' => 'dashicons dashicons-media-spreadsheet', |
801
|
|
|
'desc' => __('View Transaction Invoice', 'event_espresso') |
802
|
|
|
), |
803
|
|
|
); |
804
|
|
|
if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
805
|
|
|
$fc_items['resend_registration'] = array( |
806
|
|
|
'class' => 'dashicons dashicons-email-alt', |
807
|
|
|
'desc' => __('Resend Registration Details', 'event_espresso') |
808
|
|
|
); |
809
|
|
|
} else { |
810
|
|
|
$fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' ); |
811
|
|
|
} |
812
|
|
|
|
813
|
|
View Code Duplication |
if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
814
|
|
|
$related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
815
|
|
|
if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
816
|
|
|
$fc_items['view_related_messages'] = array( |
817
|
|
|
'class' => $related_for_icon['css_class'], |
818
|
|
|
'desc' => $related_for_icon['label'], |
819
|
|
|
); |
820
|
|
|
} |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
$sc_items = array( |
824
|
|
|
'approved_status' => array( |
825
|
|
|
'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
826
|
|
|
'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
827
|
|
|
), |
828
|
|
|
'pending_status' => array( |
829
|
|
|
'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
830
|
|
|
'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
831
|
|
|
), |
832
|
|
|
'incomplete_status' => array( |
833
|
|
|
'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
834
|
|
|
'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' ) |
835
|
|
|
), |
836
|
|
|
'not_approved' => array( |
837
|
|
|
'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
838
|
|
|
'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
839
|
|
|
), |
840
|
|
|
'declined_status' => array( |
841
|
|
|
'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
842
|
|
|
'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
843
|
|
|
), |
844
|
|
|
'cancelled_status' => array( |
845
|
|
|
'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
846
|
|
|
'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
847
|
|
|
) |
848
|
|
|
); |
849
|
|
|
return array_merge( $fc_items, $sc_items ); |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
|
853
|
|
|
|
854
|
|
|
/*************************************** REGISTRATION OVERVIEW ***************************************/ |
855
|
|
|
|
856
|
|
|
|
857
|
|
|
|
858
|
|
|
|
859
|
|
|
|
860
|
|
|
|
861
|
|
|
protected function _registrations_overview_list_table() { |
862
|
|
|
$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE; |
863
|
|
|
if ( $EVT_ID ) { |
864
|
|
|
if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID ) ) { |
865
|
|
|
$this->_admin_page_title .= $this->get_action_link_or_button( 'new_registration', 'add-registrant', array( 'event_id' => $EVT_ID ), 'add-new-h2' ); |
866
|
|
|
} |
867
|
|
|
$event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
868
|
|
|
$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce( array('action' => 'edit', 'post' => $event->ID() ), EVENTS_ADMIN_URL ) . '">' . $event->get('EVT_name') . '</a>', '</h2>' ) : ''; |
869
|
|
|
} |
870
|
|
|
$this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() ); |
871
|
|
|
$this->display_admin_list_table_page_with_no_sidebar(); |
872
|
|
|
} |
873
|
|
|
|
874
|
|
|
|
875
|
|
|
|
876
|
|
|
|
877
|
|
|
/** |
878
|
|
|
* This sets the _registration property for the registration details screen |
879
|
|
|
* |
880
|
|
|
* @access private |
881
|
|
|
* @return bool |
882
|
|
|
*/ |
883
|
|
|
private function _set_registration_object() { |
884
|
|
|
//get out if we've already set the object |
885
|
|
|
if ( is_object( $this->_registration )) { |
886
|
|
|
return TRUE; |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
$REG = EEM_Registration::instance(); |
890
|
|
|
|
891
|
|
|
$REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
892
|
|
|
|
893
|
|
|
if ( $this->_registration = $REG->get_one_by_ID( $REG_ID )) |
|
|
|
|
894
|
|
|
return TRUE; |
895
|
|
|
else { |
896
|
|
|
$error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID ); |
897
|
|
|
EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
898
|
|
|
$this->_registration = NULL; |
899
|
|
|
return FALSE; |
900
|
|
|
} |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
|
904
|
|
|
|
905
|
|
|
/** |
906
|
|
|
* get registrations for given parameters (used by list table) |
907
|
|
|
* |
908
|
|
|
* @param int $per_page how many registrations displayed per page |
909
|
|
|
* @param boolean $count return the count or objects |
910
|
|
|
* @param boolean $this_month whether to return for just this month |
911
|
|
|
* @param boolean $today whether to return results for just today |
912
|
|
|
* @throws \EE_Error |
913
|
|
|
* @return mixed (int|array) int = count || array of registration objects |
914
|
|
|
*/ |
915
|
|
|
public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) { |
916
|
|
|
$EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE; |
917
|
|
|
$CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE; |
918
|
|
|
$reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE; |
919
|
|
|
$month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april |
920
|
|
|
$today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
921
|
|
|
$this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
922
|
|
|
$start_date = FALSE; |
923
|
|
|
$end_date = FALSE; |
924
|
|
|
$_where = array(); |
925
|
|
|
$trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
926
|
|
|
$incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
927
|
|
|
|
928
|
|
|
//set orderby |
929
|
|
|
$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
930
|
|
|
|
931
|
|
|
|
932
|
|
|
switch ( $this->_req_data['orderby'] ) { |
933
|
|
|
case '_REG_ID': |
934
|
|
|
$orderby = 'REG_ID'; |
935
|
|
|
break; |
936
|
|
|
case '_Reg_status': |
937
|
|
|
$orderby = 'STS_ID'; |
938
|
|
|
break; |
939
|
|
|
case 'ATT_fname': |
940
|
|
|
$orderby = 'Attendee.ATT_lname'; |
941
|
|
|
break; |
942
|
|
|
case 'event_name': |
943
|
|
|
$orderby = 'Event.EVT_name'; |
944
|
|
|
break; |
945
|
|
|
case 'DTT_EVT_start': |
946
|
|
|
$orderby = 'Event.Datetime.DTT_EVT_start'; |
947
|
|
|
break; |
948
|
|
|
default: //'REG_date' |
949
|
|
|
$orderby = 'REG_date'; |
950
|
|
|
} |
951
|
|
|
|
952
|
|
|
$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
953
|
|
|
$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
954
|
|
|
$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
955
|
|
|
|
956
|
|
|
|
957
|
|
|
$offset = ($current_page-1)*$per_page; |
958
|
|
|
$limit = $count ? NULL : array( $offset, $per_page ); |
959
|
|
|
|
960
|
|
|
if($EVT_ID){ |
961
|
|
|
$_where['EVT_ID']=$EVT_ID; |
962
|
|
|
} |
963
|
|
|
if($CAT_ID){ |
964
|
|
|
$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
965
|
|
|
} |
966
|
|
|
if ( $incomplete ) { |
967
|
|
|
$_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
968
|
|
|
} else if ( ! $trash) { |
969
|
|
|
$_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
970
|
|
|
} |
971
|
|
|
if($reg_status){ |
972
|
|
|
$_where['STS_ID'] = $reg_status; |
973
|
|
|
} |
974
|
|
|
|
975
|
|
|
|
976
|
|
|
|
977
|
|
|
$this_year_r = date('Y', current_time('timestamp')); |
978
|
|
|
|
979
|
|
|
|
980
|
|
|
$time_start = ' 00:00:00'; |
981
|
|
|
$time_end = ' 23:59:59'; |
982
|
|
|
|
983
|
|
|
if($today_a || $today ){ |
984
|
|
|
$curdate = date('Y-m-d', current_time('timestamp')); |
985
|
|
|
$_where['REG_date']= array('BETWEEN', |
986
|
|
|
array( |
987
|
|
|
EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ), |
988
|
|
|
EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ), |
989
|
|
|
)); |
990
|
|
|
}elseif($this_month_a || $this_month){ |
991
|
|
|
$this_month_r = date('m', current_time('timestamp')); |
992
|
|
|
$days_this_month = date( 't', current_time('timestamp') ); |
993
|
|
|
$_where['REG_date']= array('BETWEEN', |
994
|
|
|
array( |
995
|
|
|
EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ), |
996
|
|
|
EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ) |
997
|
|
|
)); |
998
|
|
|
}elseif($month_range){ |
999
|
|
|
$pieces = explode(' ', $this->_req_data['month_range'], 3); |
1000
|
|
|
$month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : ''; |
1001
|
|
|
$year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
1002
|
|
|
$days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01') ); |
1003
|
|
|
$_where['REG_date']= array('BETWEEN', |
1004
|
|
|
array( EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s' ) ) ); |
1005
|
|
|
}elseif($start_date && $end_date){ |
1006
|
|
|
throw new EE_Error("not yet supported"); |
1007
|
|
|
}elseif($start_date){ |
1008
|
|
|
throw new EE_Error("not yet supported"); |
1009
|
|
|
}elseif($end_date){ |
1010
|
|
|
throw new EE_Error("not yet supported"); |
1011
|
|
|
} |
1012
|
|
|
|
1013
|
|
|
if ( ! empty( $this->_req_data['s'] ) ) { |
1014
|
|
|
$sstr = '%' . $this->_req_data['s'] . '%'; |
1015
|
|
|
$_where['OR'] = array( |
1016
|
|
|
'Event.EVT_name' => array( 'LIKE', $sstr), |
1017
|
|
|
'Event.EVT_desc' => array( 'LIKE', $sstr ), |
1018
|
|
|
'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
1019
|
|
|
'Attendee.ATT_full_name' => array( 'LIKE', $sstr ), |
1020
|
|
|
'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
1021
|
|
|
'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
1022
|
|
|
'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
1023
|
|
|
'Attendee.ATT_email' => array('LIKE', $sstr ), |
1024
|
|
|
'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
1025
|
|
|
'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
1026
|
|
|
'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
1027
|
|
|
'REG_final_price' => array( 'LIKE', $sstr ), |
1028
|
|
|
'REG_code' => array( 'LIKE', $sstr ), |
1029
|
|
|
'REG_count' => array( 'LIKE' , $sstr ), |
1030
|
|
|
'REG_group_size' => array( 'LIKE' , $sstr ), |
1031
|
|
|
'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
1032
|
|
|
'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
1033
|
|
|
'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr ) |
1034
|
|
|
); |
1035
|
|
|
} |
1036
|
|
|
|
1037
|
|
|
//capability checks |
1038
|
|
|
if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) { |
1039
|
|
|
$_where['AND'] = array( |
1040
|
|
|
'Event.EVT_wp_user' => get_current_user_id() |
1041
|
|
|
); |
1042
|
|
|
} |
1043
|
|
|
|
1044
|
|
|
|
1045
|
|
|
if( $count ){ |
1046
|
|
|
if ( $trash ) { |
1047
|
|
|
return EEM_Registration::instance()->count_deleted( array( $_where )); |
1048
|
|
|
} else if ( $incomplete ) { |
1049
|
|
|
return EEM_Registration::instance()->count( array( $_where )); |
1050
|
|
|
} else { |
1051
|
|
|
return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' )); |
1052
|
|
|
} |
1053
|
|
|
} else { |
1054
|
|
|
//make sure we remove default where conditions cause all registrations matching query are returned |
1055
|
|
|
$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' ); |
1056
|
|
|
if ( $per_page !== -1 ) { |
1057
|
|
|
$query_params['limit'] = $limit; |
1058
|
|
|
} |
1059
|
|
|
$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
1060
|
|
|
|
1061
|
|
|
|
1062
|
|
|
if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
1063
|
|
|
$first_registration = $registrations[0]; |
1064
|
|
|
//EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
1065
|
|
|
$event_name = $first_registration->event_obj()->name(); |
1066
|
|
|
$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
|
|
|
1067
|
|
|
// edit event link |
1068
|
|
View Code Duplication |
if ( $event_name != '' ) { |
1069
|
|
|
$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
1070
|
|
|
$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
1071
|
|
|
$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
1072
|
|
|
} |
1073
|
|
|
|
1074
|
|
|
$back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
1075
|
|
|
$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
1076
|
|
|
|
1077
|
|
|
$this->_template_args['before_admin_page_content'] = ' |
1078
|
|
|
<div id="admin-page-header"> |
1079
|
|
|
<h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
1080
|
|
|
<h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
1081
|
|
|
<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
1082
|
|
|
</div> |
1083
|
|
|
'; |
1084
|
|
|
|
1085
|
|
|
} |
1086
|
|
|
return $registrations; |
1087
|
|
|
} |
1088
|
|
|
} |
1089
|
|
|
|
1090
|
|
|
|
1091
|
|
|
|
1092
|
|
|
|
1093
|
|
|
|
1094
|
|
|
|
1095
|
|
|
public function get_registration_status_array() { |
1096
|
|
|
return self::$_reg_status; |
1097
|
|
|
} |
1098
|
|
|
|
1099
|
|
|
|
1100
|
|
|
|
1101
|
|
|
|
1102
|
|
|
/*************************************** REGISTRATION DETAILS ***************************************/ |
1103
|
|
|
|
1104
|
|
|
|
1105
|
|
|
|
1106
|
|
|
|
1107
|
|
|
|
1108
|
|
|
/** |
1109
|
|
|
* generates HTML for the View Registration Details Admin page |
1110
|
|
|
* @access protected |
1111
|
|
|
* @return void |
1112
|
|
|
*/ |
1113
|
|
|
protected function _registration_details() { |
1114
|
|
|
|
1115
|
|
|
$this->_template_args = array(); |
1116
|
|
|
|
1117
|
|
|
$this->_set_registration_object(); |
1118
|
|
|
|
1119
|
|
|
if ( is_object( $this->_registration )) { |
1120
|
|
|
$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1121
|
|
|
$this->_session = $transaction->session_data(); |
1122
|
|
|
|
1123
|
|
|
$event_id = $this->_registration->event_ID(); |
1124
|
|
|
|
1125
|
|
|
|
1126
|
|
|
$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
1127
|
|
|
$this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' ); |
1128
|
|
|
|
1129
|
|
|
$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime( 'REG_date' ); |
1130
|
|
|
$this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' ); |
1131
|
|
|
|
1132
|
|
|
$this->_template_args['grand_total'] = $transaction->total(); |
1133
|
|
|
|
1134
|
|
|
$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1135
|
|
|
// link back to overview |
1136
|
|
|
$this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
1137
|
|
|
$this->_template_args['registration'] = $this->_registration; |
1138
|
|
|
$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL ); |
1139
|
|
|
$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) ); |
1140
|
|
|
$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) ); |
1141
|
|
|
|
1142
|
|
|
//next and previous links |
1143
|
|
|
$next_reg = $this->_registration->next(null, array(), 'REG_ID' ); |
1144
|
|
|
$this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : ''; |
1145
|
|
|
$previous_reg = $this->_registration->previous( null, array(), 'REG_ID' ); |
1146
|
|
|
$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : ''; |
1147
|
|
|
|
1148
|
|
|
// grab header |
1149
|
|
|
$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
1150
|
|
|
$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
1151
|
|
|
|
1152
|
|
|
} else { |
1153
|
|
|
|
1154
|
|
|
$this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
|
|
|
1155
|
|
|
|
1156
|
|
|
} |
1157
|
|
|
|
1158
|
|
|
// the details template wrapper |
1159
|
|
|
$this->display_admin_page_with_sidebar(); |
1160
|
|
|
|
1161
|
|
|
} |
1162
|
|
|
|
1163
|
|
|
|
1164
|
|
|
|
1165
|
|
|
|
1166
|
|
|
|
1167
|
|
|
|
1168
|
|
|
protected function _registration_details_metaboxes() { |
1169
|
|
|
do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this ); |
1170
|
|
|
$this->_set_registration_object(); |
1171
|
|
|
$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
1172
|
|
|
add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' ); |
|
|
|
|
1173
|
|
|
add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
|
|
|
1174
|
|
|
if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) { |
1175
|
|
|
add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
|
|
|
1176
|
|
|
} |
1177
|
|
|
add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' ); |
|
|
|
|
1178
|
|
|
if ( $this->_registration->group_size() > 1 ) { |
1179
|
|
|
add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
|
|
|
1180
|
|
|
} |
1181
|
|
|
} |
1182
|
|
|
|
1183
|
|
|
|
1184
|
|
|
|
1185
|
|
|
|
1186
|
|
|
|
1187
|
|
|
|
1188
|
|
|
/** |
1189
|
|
|
* _set_approve_or_decline_reg_status_buttons |
1190
|
|
|
* @access protected |
1191
|
|
|
* @return string |
1192
|
|
|
*/ |
1193
|
|
|
public function set_reg_status_buttons_metabox() { |
1194
|
|
|
|
1195
|
|
|
//is registration for free event OR for a completed transaction? This will determine whether the set to pending option is shown. |
1196
|
|
|
$is_complete = $this->_registration->transaction()->is_completed(); |
1197
|
|
|
|
1198
|
|
|
//let's get an array of all possible buttons that we can just reference |
1199
|
|
|
$status_buttons = $this->_get_reg_status_buttons(); |
1200
|
|
|
$template_args[ 'reg_status_value' ] = $this->_registration->pretty_status(); |
|
|
|
|
1201
|
|
|
$template_args[ 'reg_status_class' ] = 'status-' . $this->_registration->status_ID(); |
1202
|
|
|
$template_args['attendee'] = $this->_registration->attendee(); |
1203
|
|
|
$template = REG_TEMPLATE_PATH . 'reg_status_change_buttons.template.php'; |
1204
|
|
|
if ( $this->_set_registration_object() ) { |
1205
|
|
|
$current_status = $this->_registration->status_ID(); |
1206
|
|
|
unset( $status_buttons[$current_status] ); |
1207
|
|
|
if ( $current_status != EEM_Registration::status_id_pending_payment && $is_complete ) { |
1208
|
|
|
unset( $status_buttons[EEM_Registration::status_id_pending_payment] ); |
1209
|
|
|
} |
1210
|
|
|
$template_args['status_buttons'] = implode( "\n", $status_buttons ); |
1211
|
|
|
} |
1212
|
|
|
$template_args['form_url'] = REG_ADMIN_URL; |
1213
|
|
|
$template_args['REG_ID'] = $this->_registration->ID(); |
1214
|
|
|
$template_args['nonce'] = wp_nonce_field( 'change_reg_status_nonce', 'change_reg_status_nonce', FALSE, FALSE ); |
1215
|
|
|
|
1216
|
|
|
EEH_Template::display_template( $template, $template_args ); |
1217
|
|
|
|
1218
|
|
|
} |
1219
|
|
|
|
1220
|
|
|
|
1221
|
|
|
|
1222
|
|
|
|
1223
|
|
|
/** |
1224
|
|
|
* Returns an array of all the buttons for the various statuses and switch status actions |
1225
|
|
|
* @return array |
1226
|
|
|
*/ |
1227
|
|
|
private function _get_reg_status_buttons() { |
1228
|
|
|
|
1229
|
|
|
$buttons = array( |
1230
|
|
|
EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) . '">', |
1231
|
|
|
EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_pending_payment . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) . '">', |
1232
|
|
|
EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_not_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) . '">', |
1233
|
|
|
EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_declined . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) . '">', |
1234
|
|
|
EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_cancelled . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) . '">', |
1235
|
|
|
); |
1236
|
|
|
return $buttons; |
1237
|
|
|
} |
1238
|
|
|
|
1239
|
|
|
|
1240
|
|
|
/** |
1241
|
|
|
* This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
1242
|
|
|
* |
1243
|
|
|
* @param bool $status REG status given for changing registrations to. |
1244
|
|
|
* @param bool $notify Whether to send messages notifications or not. |
1245
|
|
|
* |
1246
|
|
|
* @return array (array with reg_id(s) updated and whether update was successful. |
1247
|
|
|
*/ |
1248
|
|
|
protected function _set_registration_status_from_request( $status = false, $notify = false ) { |
1249
|
|
|
$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? (array) $this->_req_data['_REG_ID'] : array(); |
1250
|
|
|
|
1251
|
|
|
$success = $this->_set_registration_status( $REG_ID, $status ); |
|
|
|
|
1252
|
|
|
|
1253
|
|
|
//notify? |
1254
|
|
|
if ( $success && $notify && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
|
|
|
|
1255
|
|
|
$this->_process_resend_registration(); |
1256
|
|
|
} |
1257
|
|
|
|
1258
|
|
|
return $success; |
1259
|
|
|
} |
1260
|
|
|
|
1261
|
|
|
|
1262
|
|
|
|
1263
|
|
|
/** |
1264
|
|
|
* Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an array). |
1265
|
|
|
* |
1266
|
|
|
* Note, this method does NOT take care of possible notifications. That is required by calling code. |
1267
|
|
|
* |
1268
|
|
|
* @param bool $REG_ID |
1269
|
|
|
* @param bool $status |
1270
|
|
|
* @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations). |
1271
|
|
|
*/ |
1272
|
|
|
protected function _set_registration_status( $REG_ID, $status = false ) { |
1273
|
|
|
$success = true; |
1274
|
|
|
// set default status if none is passed |
1275
|
|
|
$status = $status ? $status : EEM_Registration::status_id_pending_payment; |
1276
|
|
|
|
1277
|
|
|
//typecast and sanitize reg_id |
1278
|
|
|
$reg_ids = array_filter( (array) $REG_ID, 'absint' ); |
1279
|
|
|
|
1280
|
|
|
//loop through REG_ID's and change status |
1281
|
|
|
foreach ( $reg_ids as $r_id ) { |
1282
|
|
|
$registration = EEM_Registration::instance()->get_one_by_ID( $r_id ); |
1283
|
|
|
if ( $registration instanceof EE_Registration ) { |
1284
|
|
|
$registration->set_status( $status ); |
1285
|
|
|
$result = $registration->save(); |
1286
|
|
|
|
1287
|
|
|
//verifying explicit fails because update *may* just return 0 for 0 rows affected |
1288
|
|
|
$success = $success !== false && $result !== false; |
1289
|
|
|
} |
1290
|
|
|
} |
1291
|
|
|
|
1292
|
|
|
//reset _req_data['_REG_ID'] for any potential future messages notifications |
1293
|
|
|
$this->_req_data['_REG_ID'] = $reg_ids; |
1294
|
|
|
|
1295
|
|
|
//return $success and processed registrations |
1296
|
|
|
return array( 'REG_ID' => $reg_ids, 'success' => $success ); |
1297
|
|
|
} |
1298
|
|
|
|
1299
|
|
|
|
1300
|
|
|
|
1301
|
|
|
|
1302
|
|
|
/** |
1303
|
|
|
* Common logic for setting up success message and redirecting to appropriate route |
1304
|
|
|
* @param string $STS_ID status id for the registration changed to |
1305
|
|
|
* @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
1306
|
|
|
* @return void |
1307
|
|
|
*/ |
1308
|
|
|
protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
1309
|
|
|
|
1310
|
|
|
$result = ! empty( $STS_ID ) ? $this->_set_registration_status_from_request( $STS_ID, $notify ) : array( 'success' => false ); |
|
|
|
|
1311
|
|
|
|
1312
|
|
|
|
1313
|
|
|
$success = isset( $result['success'] ) && $result['success']; |
1314
|
|
|
|
1315
|
|
|
//setup success message |
1316
|
|
|
if ( $success ) { |
1317
|
|
|
$msg = is_array( $result['REG_ID'] ) && count( $result['REG_ID'] ) > 1 ? sprintf( __('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) : sprintf( __('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) ; |
1318
|
|
|
EE_Error::add_success( $msg ); |
1319
|
|
|
} else { |
1320
|
|
|
EE_Error::add_error( __('Something went wrong, and the status was not changed', 'event_espresso' ), __FILE__, __LINE__, __FUNCTION__ ); |
1321
|
|
|
} |
1322
|
|
|
|
1323
|
|
|
$route = isset( $this->_req_data['return'] ) && $this->_req_data['return'] == 'view_registration' ? array( 'action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0] ) : array( 'action' => 'default' ); |
1324
|
|
|
//unset nonces |
1325
|
|
|
foreach ( $this->_req_data as $ref => $value ) { |
1326
|
|
|
if ( strpos( $ref, 'nonce' ) !== false ) { |
1327
|
|
|
unset( $this->_req_data[$ref] ); |
1328
|
|
|
continue; |
1329
|
|
|
} |
1330
|
|
|
|
1331
|
|
|
$value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value ); |
1332
|
|
|
$this->_req_data[$ref] = $value; |
1333
|
|
|
} |
1334
|
|
|
|
1335
|
|
|
//merge request vars so that the reloaded list table contains any existing filter query params |
1336
|
|
|
$route = array_merge( $this->_req_data, $route ); |
1337
|
|
|
|
1338
|
|
|
$this->_redirect_after_action( false, '', '', $route, true ); |
|
|
|
|
1339
|
|
|
} |
1340
|
|
|
|
1341
|
|
|
|
1342
|
|
|
|
1343
|
|
|
/** |
1344
|
|
|
* incoming reg status change from reg details page. |
1345
|
|
|
* @return void |
1346
|
|
|
*/ |
1347
|
|
|
protected function _change_reg_status() { |
1348
|
|
|
$this->_req_data['return'] = 'view_registration'; |
1349
|
|
|
//set notify based on whether the send notifications toggle is set or not |
1350
|
|
|
$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
1351
|
|
|
$this->_req_data[ '_reg_status_id' ] = isset( $this->_req_data[ '_reg_status_id' ] ) ? $this->_req_data[ '_reg_status_id' ] : ''; |
1352
|
|
|
|
1353
|
|
|
switch ( $this->_req_data['_reg_status_id'] ) { |
1354
|
|
|
case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) : |
1355
|
|
|
$this->approve_registration( $notify ); |
1356
|
|
|
break; |
1357
|
|
|
case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) : |
1358
|
|
|
$this->pending_registration( $notify ); |
1359
|
|
|
break; |
1360
|
|
|
case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) : |
1361
|
|
|
$this->not_approve_registration( $notify ); |
1362
|
|
|
break; |
1363
|
|
|
case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) : |
1364
|
|
|
$this->decline_registration( $notify ); |
1365
|
|
|
break; |
1366
|
|
|
case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) : |
1367
|
|
|
$this->cancel_registration( $notify ); |
1368
|
|
|
break; |
1369
|
|
|
default : |
1370
|
|
|
$result['success'] = false; |
|
|
|
|
1371
|
|
|
unset( $this->_req_data['return'] ); |
1372
|
|
|
$this->_reg_status_change_return( '', false ); |
1373
|
|
|
break; |
1374
|
|
|
} |
1375
|
|
|
} |
1376
|
|
|
|
1377
|
|
|
|
1378
|
|
|
|
1379
|
|
|
/** |
1380
|
|
|
* approve_registration |
1381
|
|
|
* @access protected |
1382
|
|
|
* @param bool $notify whether or not to notify the registrant about their approval. |
1383
|
|
|
* @return void |
1384
|
|
|
*/ |
1385
|
|
|
protected function approve_registration( $notify = false ) { |
1386
|
|
|
$this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify ); |
1387
|
|
|
} |
1388
|
|
|
|
1389
|
|
|
|
1390
|
|
|
|
1391
|
|
|
|
1392
|
|
|
/** |
1393
|
|
|
* decline_registration |
1394
|
|
|
* @access protected |
1395
|
|
|
* @param bool $notify whether or not to notify the registrant about their approval. |
1396
|
|
|
* @return void |
1397
|
|
|
*/ |
1398
|
|
|
protected function decline_registration( $notify = false ) { |
1399
|
|
|
$this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify ); |
1400
|
|
|
} |
1401
|
|
|
|
1402
|
|
|
|
1403
|
|
|
|
1404
|
|
|
|
1405
|
|
|
/** |
1406
|
|
|
* cancel_registration |
1407
|
|
|
* @access protected |
1408
|
|
|
* @param bool $notify whether or not to notify the registrant about their approval. |
1409
|
|
|
* @return void |
1410
|
|
|
*/ |
1411
|
|
|
protected function cancel_registration( $notify = false ) { |
1412
|
|
|
$this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify ); |
1413
|
|
|
} |
1414
|
|
|
|
1415
|
|
|
|
1416
|
|
|
|
1417
|
|
|
|
1418
|
|
|
|
1419
|
|
|
/** |
1420
|
|
|
* not_approve_registration |
1421
|
|
|
* @access protected |
1422
|
|
|
* @param bool $notify whether or not to notify the registrant about their approval. |
1423
|
|
|
* @return void |
1424
|
|
|
*/ |
1425
|
|
|
protected function not_approve_registration( $notify = false ) { |
1426
|
|
|
$this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify ); |
1427
|
|
|
} |
1428
|
|
|
|
1429
|
|
|
|
1430
|
|
|
|
1431
|
|
|
/** |
1432
|
|
|
* decline_registration |
1433
|
|
|
* @access protected |
1434
|
|
|
* @param bool $notify whether or not to notify the registrant about their approval. |
1435
|
|
|
* @return void |
1436
|
|
|
*/ |
1437
|
|
|
protected function pending_registration( $notify = false ) { |
1438
|
|
|
$this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify ); |
1439
|
|
|
} |
1440
|
|
|
|
1441
|
|
|
|
1442
|
|
|
|
1443
|
|
|
|
1444
|
|
|
/** |
1445
|
|
|
* generates HTML for the Registration main meta box |
1446
|
|
|
* @access public |
1447
|
|
|
* @return void |
1448
|
|
|
*/ |
1449
|
|
|
public function _reg_details_meta_box() { |
1450
|
|
|
EEH_Autoloader::register_line_item_display_autoloaders(); |
1451
|
|
|
EEH_Autoloader::register_line_item_filter_autoloaders(); |
1452
|
|
|
EE_Registry::instance()->load_Helper( 'Line_Item' ); |
1453
|
|
|
$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1454
|
|
|
$this->_session = $transaction->session_data(); |
1455
|
|
|
|
1456
|
|
|
$filters = new EE_Line_Item_Filter_Collection(); |
1457
|
|
|
$filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) ); |
1458
|
|
|
$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
1459
|
|
|
$line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() ); |
1460
|
|
|
$filtered_line_item_tree = $line_item_filter_processor->process(); |
1461
|
|
|
|
1462
|
|
|
$this->_template_args['REG_ID'] = $this->_registration->ID(); |
1463
|
|
|
$line_item_display = new EE_Line_Item_Display( 'reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy' ); |
1464
|
|
|
$this->_template_args['line_item_table'] = $line_item_display->display_line_item( $filtered_line_item_tree, array( 'EE_Registration' => $this->_registration ) ); |
|
|
|
|
1465
|
|
|
|
1466
|
|
|
|
1467
|
|
|
$attendee = $this->_registration->attendee(); |
1468
|
|
|
|
1469
|
|
|
|
1470
|
|
|
$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID() ), TXN_ADMIN_URL ), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart' ) : ''; |
1471
|
|
|
$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration' ), REG_ADMIN_URL ), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt' ) : ''; |
1472
|
|
|
|
1473
|
|
|
|
1474
|
|
|
$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1475
|
|
|
$payment = $transaction->get_first_related( 'Payment' ); |
1476
|
|
|
$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
1477
|
|
|
$payment_method = $payment->get_first_related( 'Payment_Method' ); |
1478
|
|
|
$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method; |
1479
|
|
|
$reg_status_class = 'status-' . $this->_registration->status_ID(); |
|
|
|
|
1480
|
|
|
$reg_details = array( |
1481
|
|
|
'payment_method' => $payment_method->name(), |
1482
|
|
|
'response_msg' => $payment->gateway_response(), |
1483
|
|
|
'registration_id' => $this->_registration->get( 'REG_code' ), |
1484
|
|
|
'registration_session' => $this->_registration->session_ID(), |
1485
|
|
|
'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '', |
1486
|
|
|
'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '', |
1487
|
|
|
); |
1488
|
|
|
|
1489
|
|
|
|
1490
|
|
|
if ( isset( $reg_details['registration_id'] )) { |
1491
|
|
|
$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
1492
|
|
|
$this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' ); |
1493
|
|
|
$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
1494
|
|
|
} |
1495
|
|
|
|
1496
|
|
|
if ( isset( $reg_details['payment_method'] ) ) { |
1497
|
|
|
$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
1498
|
|
|
$this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' ); |
1499
|
|
|
$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
1500
|
|
|
$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
1501
|
|
|
$this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' ); |
1502
|
|
|
$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
1503
|
|
|
} |
1504
|
|
|
|
1505
|
|
|
$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
1506
|
|
|
$this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' ); |
1507
|
|
|
$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
1508
|
|
|
|
1509
|
|
|
$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
1510
|
|
|
$this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' ); |
1511
|
|
|
$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
1512
|
|
|
|
1513
|
|
|
$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
1514
|
|
|
$this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' ); |
1515
|
|
|
$this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
1516
|
|
|
|
1517
|
|
|
$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL ); |
1518
|
|
|
|
1519
|
|
|
$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
1520
|
|
|
echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
1521
|
|
|
|
1522
|
|
|
} |
1523
|
|
|
|
1524
|
|
|
/** |
1525
|
|
|
* generates HTML for the Registration Questions meta box. |
1526
|
|
|
* If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
1527
|
|
|
* otherwise uses new forms system |
1528
|
|
|
* |
1529
|
|
|
* @access public |
1530
|
|
|
* @return void |
1531
|
|
|
*/ |
1532
|
|
|
public function _reg_questions_meta_box() { |
1533
|
|
|
//allow someone to override this method entirely |
1534
|
|
|
if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
1535
|
|
|
$form = $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
1536
|
|
|
$this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : ''; |
|
|
|
|
1537
|
|
|
$this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
1538
|
|
|
$this->_template_args['REG_ID'] = $this->_registration->ID(); |
1539
|
|
|
|
1540
|
|
|
$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
1541
|
|
|
echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
1542
|
|
|
} |
1543
|
|
|
} |
1544
|
|
|
|
1545
|
|
|
|
1546
|
|
|
|
1547
|
|
|
/** |
1548
|
|
|
* form_before_question_group |
1549
|
|
|
* |
1550
|
|
|
* @deprecated as of 4.8.32.rc.000 |
1551
|
|
|
* @access public |
1552
|
|
|
* @param string $output |
1553
|
|
|
* @return string |
1554
|
|
|
*/ |
1555
|
|
View Code Duplication |
public function form_before_question_group( $output ) { |
|
|
|
|
1556
|
|
|
EE_Error::doing_it_wrong( |
1557
|
|
|
__CLASS__ . '::' . __FUNCTION__, |
1558
|
|
|
__( 'This method would have been protected but was used on a filter callback' |
1559
|
|
|
. 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1560
|
|
|
'event_espresso' ), |
1561
|
|
|
'4.8.32.rc.000' |
1562
|
|
|
); |
1563
|
|
|
return ' |
1564
|
|
|
<table class="form-table ee-width-100"> |
1565
|
|
|
<tbody> |
1566
|
|
|
'; |
1567
|
|
|
} |
1568
|
|
|
|
1569
|
|
|
|
1570
|
|
|
|
1571
|
|
|
/** |
1572
|
|
|
* form_after_question_group |
1573
|
|
|
* |
1574
|
|
|
* @deprecated as of 4.8.32.rc.000 |
1575
|
|
|
* @access public |
1576
|
|
|
* @param string $output |
1577
|
|
|
* @return string |
1578
|
|
|
*/ |
1579
|
|
|
public function form_after_question_group( $output ) { |
|
|
|
|
1580
|
|
|
EE_Error::doing_it_wrong( |
1581
|
|
|
__CLASS__ . '::' . __FUNCTION__, |
1582
|
|
|
__( 'This method would have been protected but was used on a filter callback' |
1583
|
|
|
. 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1584
|
|
|
'event_espresso' ), |
1585
|
|
|
'4.8.32.rc.000' |
1586
|
|
|
); |
1587
|
|
|
return ' |
1588
|
|
|
<tr class="hide-if-no-js"> |
1589
|
|
|
<th> </th> |
1590
|
|
|
<td class="reg-admin-edit-attendee-question-td"> |
1591
|
|
|
<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '"> |
1592
|
|
|
<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span> |
1593
|
|
|
<div class="dashicons dashicons-edit"></div> |
1594
|
|
|
</a> |
1595
|
|
|
</td> |
1596
|
|
|
</tr> |
1597
|
|
|
</tbody> |
1598
|
|
|
</table> |
1599
|
|
|
'; |
1600
|
|
|
} |
1601
|
|
|
|
1602
|
|
|
|
1603
|
|
|
|
1604
|
|
|
/** |
1605
|
|
|
* form_form_field_label_wrap |
1606
|
|
|
* |
1607
|
|
|
* @deprecated as of 4.8.32.rc.000 |
1608
|
|
|
* @access public |
1609
|
|
|
* @param string $label |
1610
|
|
|
* @return string |
1611
|
|
|
*/ |
1612
|
|
View Code Duplication |
public function form_form_field_label_wrap( $label ) { |
|
|
|
|
1613
|
|
|
EE_Error::doing_it_wrong( |
1614
|
|
|
__CLASS__ . '::' . __FUNCTION__, |
1615
|
|
|
__( 'This method would have been protected but was used on a filter callback' |
1616
|
|
|
. 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1617
|
|
|
'event_espresso' ), |
1618
|
|
|
'4.8.32.rc.000' |
1619
|
|
|
); |
1620
|
|
|
return ' |
1621
|
|
|
<tr> |
1622
|
|
|
<th> |
1623
|
|
|
' . $label . ' |
1624
|
|
|
</th>'; |
1625
|
|
|
} |
1626
|
|
|
|
1627
|
|
|
|
1628
|
|
|
|
1629
|
|
|
/** |
1630
|
|
|
* form_form_field_input__wrap |
1631
|
|
|
* |
1632
|
|
|
* @deprecated as of 4.8.32.rc.000 |
1633
|
|
|
* @access public |
1634
|
|
|
* @param string $input |
1635
|
|
|
* @return string |
1636
|
|
|
*/ |
1637
|
|
View Code Duplication |
public function form_form_field_input__wrap( $input ) { |
|
|
|
|
1638
|
|
|
EE_Error::doing_it_wrong( |
1639
|
|
|
__CLASS__ . '::' . __FUNCTION__, |
1640
|
|
|
__( 'This method would have been protected but was used on a filter callback' |
1641
|
|
|
. 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1642
|
|
|
'event_espresso' ), |
1643
|
|
|
'4.8.32.rc.000' |
1644
|
|
|
); |
1645
|
|
|
return ' |
1646
|
|
|
<td class="reg-admin-attendee-questions-input-td disabled-input"> |
1647
|
|
|
' . $input . ' |
1648
|
|
|
</td> |
1649
|
|
|
</tr>'; |
1650
|
|
|
} |
1651
|
|
|
|
1652
|
|
|
/** |
1653
|
|
|
* Updates the registration's custom questions according to the form info, if the form is submitted. |
1654
|
|
|
* If it's not a post, the "view_registrations" route will be called next on the SAME request |
1655
|
|
|
* to display the page |
1656
|
|
|
* |
1657
|
|
|
* @access protected |
1658
|
|
|
* @return void |
1659
|
|
|
*/ |
1660
|
|
|
protected function _update_attendee_registration_form() { |
1661
|
|
|
do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this ); |
1662
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
1663
|
|
|
$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
1664
|
|
|
$success = $this->_save_reg_custom_questions_form( $REG_ID ); |
1665
|
|
|
if( $success ) { |
|
|
|
|
1666
|
|
|
$what = __('Registration Form', 'event_espresso'); |
1667
|
|
|
$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
1668
|
|
|
$this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
1669
|
|
|
} |
1670
|
|
|
} |
1671
|
|
|
} |
1672
|
|
|
|
1673
|
|
|
/** |
1674
|
|
|
* Gets the form for saving registrations custom questions (if done |
1675
|
|
|
* previously retrieves the cached form object, which may have validation errors in it) |
1676
|
|
|
* @param int $REG_ID |
1677
|
|
|
* @return EE_Registration_Custom_Questions_Form |
1678
|
|
|
*/ |
1679
|
|
|
protected function _get_reg_custom_questions_form( $REG_ID ) { |
1680
|
|
|
if( ! $this->_reg_custom_questions_form ) { |
1681
|
|
|
require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' ); |
1682
|
|
|
$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) ); |
|
|
|
|
1683
|
|
|
$this->_reg_custom_questions_form->_construct_finalize( null, null ); |
|
|
|
|
1684
|
|
|
} |
1685
|
|
|
return $this->_reg_custom_questions_form; |
1686
|
|
|
} |
1687
|
|
|
|
1688
|
|
|
|
1689
|
|
|
|
1690
|
|
|
/** |
1691
|
|
|
* Saves |
1692
|
|
|
* @access private |
1693
|
|
|
* @param bool $REG_ID |
1694
|
|
|
* @return bool |
1695
|
|
|
*/ |
1696
|
|
|
private function _save_reg_custom_questions_form( $REG_ID = FALSE ) { |
1697
|
|
|
|
1698
|
|
|
if ( ! $REG_ID) { |
1699
|
|
|
EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
1700
|
|
|
} |
1701
|
|
|
$form = $this->_get_reg_custom_questions_form( $REG_ID ); |
|
|
|
|
1702
|
|
|
$form->receive_form_submission( $this->_req_data ); |
1703
|
|
|
$success = false; |
1704
|
|
|
if( $form->is_valid() ) { |
1705
|
|
|
foreach( $form->subforms() as $question_group_id => $question_group_form ) { |
1706
|
|
|
foreach( $question_group_form->inputs() as $question_id => $input ) { |
1707
|
|
|
$where_conditions = array( |
1708
|
|
|
'QST_ID' => $question_id, |
1709
|
|
|
'REG_ID' => $REG_ID |
1710
|
|
|
); |
1711
|
|
|
$possibly_new_values = array( |
1712
|
|
|
'ANS_value' => $input->normalized_value() |
1713
|
|
|
); |
1714
|
|
|
$answer = EEM_Answer::instance()->get_one( array( $where_conditions ) ); |
1715
|
|
|
if( $answer instanceof EE_Answer ) { |
1716
|
|
|
$success = $answer->save( $possibly_new_values ); |
1717
|
|
|
} else { |
1718
|
|
|
//insert it then |
1719
|
|
|
$cols_n_vals = array_merge( $where_conditions, $possibly_new_values ); |
1720
|
|
|
$answer = EE_Answer::new_instance( $cols_n_vals ); |
1721
|
|
|
$success = $answer->save(); |
1722
|
|
|
} |
1723
|
|
|
} |
1724
|
|
|
} |
1725
|
|
|
} else { |
1726
|
|
|
EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ ); |
1727
|
|
|
} |
1728
|
|
|
return $success; |
1729
|
|
|
} |
1730
|
|
|
|
1731
|
|
|
/** |
1732
|
|
|
* generates HTML for the Registration main meta box |
1733
|
|
|
* @access public |
1734
|
|
|
* @return void |
1735
|
|
|
*/ |
1736
|
|
|
public function _reg_attendees_meta_box() { |
1737
|
|
|
|
1738
|
|
|
$REG = EEM_Registration::instance(); |
1739
|
|
|
//get all other registrations on this transaction, and cache |
1740
|
|
|
//the attendees for them so we don't have to run another query using force_join |
1741
|
|
|
$registrations = $REG->get_all(array( |
1742
|
|
|
array( |
1743
|
|
|
'TXN_ID'=>$this->_registration->transaction_ID(), |
1744
|
|
|
'REG_ID'=>array('!=',$this->_registration->ID()) |
1745
|
|
|
), |
1746
|
|
|
'force_join'=>array('Attendee'))); |
1747
|
|
|
|
1748
|
|
|
$this->_template_args['attendees'] = array(); |
1749
|
|
|
$this->_template_args['attendee_notice'] = ''; |
1750
|
|
|
if ( empty( $registrations) || ( is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations) ) ) { |
1751
|
|
|
EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
1752
|
|
|
$this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
1753
|
|
|
} else { |
1754
|
|
|
|
1755
|
|
|
$att_nmbr = 1; |
1756
|
|
|
foreach ( $registrations as $registration ) { |
1757
|
|
|
/* @var $registration EE_Registration */ |
1758
|
|
|
$attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object(); |
1759
|
|
|
$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
|
|
|
1760
|
|
|
$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
|
|
|
1761
|
|
|
$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
|
|
|
1762
|
|
|
$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
1763
|
|
|
|
1764
|
|
|
$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() ); |
|
|
|
|
1765
|
|
|
|
1766
|
|
|
$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
1767
|
|
|
|
1768
|
|
|
$att_nmbr++; |
1769
|
|
|
} |
1770
|
|
|
|
1771
|
|
|
//EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
1772
|
|
|
|
1773
|
|
|
$this->_template_args['event_name'] = $this->_registration->event_obj()->name(); |
1774
|
|
|
$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1775
|
|
|
|
1776
|
|
|
// $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
1777
|
|
|
} |
1778
|
|
|
$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
1779
|
|
|
echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
1780
|
|
|
|
1781
|
|
|
} |
1782
|
|
|
|
1783
|
|
|
|
1784
|
|
|
|
1785
|
|
|
|
1786
|
|
|
|
1787
|
|
|
|
1788
|
|
|
/** |
1789
|
|
|
* generates HTML for the Edit Registration side meta box |
1790
|
|
|
* @access public |
1791
|
|
|
* @return void |
1792
|
|
|
*/ |
1793
|
|
|
public function _reg_registrant_side_meta_box() { |
1794
|
|
|
|
1795
|
|
|
/*@var $attendee EE_Attendee */ |
1796
|
|
|
$att_check = $this->_registration->attendee(); |
1797
|
|
|
$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
1798
|
|
|
|
1799
|
|
|
//now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show cereate button or not) |
1800
|
|
|
if ( ! $this->_registration->is_primary_registrant() ) { |
1801
|
|
|
$primary_registration = $this->_registration->get_primary_registration(); |
1802
|
|
|
$primary_attendee = $primary_registration->attendee(); |
1803
|
|
|
|
1804
|
|
|
if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) { |
1805
|
|
|
//in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
1806
|
|
|
$primary_registration = NULL; |
1807
|
|
|
} |
1808
|
|
|
} else { |
1809
|
|
|
$primary_registration = NULL; |
1810
|
|
|
} |
1811
|
|
|
|
1812
|
|
|
$this->_template_args['ATT_ID'] = $attendee->ID(); |
1813
|
|
|
$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
|
|
|
1814
|
|
|
$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
|
|
|
1815
|
|
|
$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
|
|
|
1816
|
|
|
$this->_template_args['phone'] = $attendee->phone(); |
|
|
|
|
1817
|
|
|
|
1818
|
|
|
$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee ); |
1819
|
|
|
|
1820
|
|
|
|
1821
|
|
|
//edit link |
1822
|
|
|
$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
1823
|
|
|
$this->_template_args['att_edit_label'] = __('View/Edit Contact' ); |
1824
|
|
|
|
1825
|
|
|
//create link |
1826
|
|
|
$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): ''; |
1827
|
|
|
$this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
1828
|
|
|
|
1829
|
|
|
$this->_template_args['att_check'] = $att_check; |
1830
|
|
|
|
1831
|
|
|
|
1832
|
|
|
$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
1833
|
|
|
echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
1834
|
|
|
} |
1835
|
|
|
|
1836
|
|
|
|
1837
|
|
|
|
1838
|
|
|
|
1839
|
|
|
|
1840
|
|
|
/** |
1841
|
|
|
* trash or restore registrations |
1842
|
|
|
* @param boolean $trash whether to archive or restore |
1843
|
|
|
* @access protected |
1844
|
|
|
* @return void |
1845
|
|
|
*/ |
1846
|
|
|
protected function _trash_or_restore_registrations( $trash = TRUE ) { |
1847
|
|
|
$REGM = EEM_Registration::instance(); |
1848
|
|
|
|
1849
|
|
|
$success = 1; |
1850
|
|
|
$error = 0; |
1851
|
|
|
|
1852
|
|
|
$tickets = array(); |
1853
|
|
|
$dtts = array(); |
1854
|
|
|
|
1855
|
|
|
//if empty _REG_ID then get out because there's nothing to do |
1856
|
|
View Code Duplication |
if ( empty( $this->_req_data['_REG_ID'] ) ) { |
1857
|
|
|
$msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso'); |
1858
|
|
|
EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ ); |
1859
|
|
|
$this->_redirect_after_action(FALSE, '', '', array(), TRUE ); |
|
|
|
|
1860
|
|
|
} |
1861
|
|
|
|
1862
|
|
|
//Checkboxes |
1863
|
|
|
if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
1864
|
|
|
// if array has more than one element than success message should be plural |
1865
|
|
|
$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
1866
|
|
|
// cycle thru checkboxes |
1867
|
|
|
while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
|
|
|
1868
|
|
|
|
1869
|
|
|
$REG = $REGM->get_one_by_ID($REG_ID); |
1870
|
|
|
$payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
1871
|
|
|
if ( $payment_count > 0 ) { |
1872
|
|
|
$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ); |
|
|
|
|
1873
|
|
|
$error = 1; |
1874
|
|
|
$success = 0; |
1875
|
|
|
EE_Error::add_error( sprintf( __('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.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ ); |
1876
|
|
|
continue; //can't trash this registration because it has payments. |
1877
|
|
|
} |
1878
|
|
|
$ticket = $REG->get_first_related('Ticket'); |
1879
|
|
|
$tickets[$ticket->ID()] = $ticket; |
1880
|
|
|
$dtt = $ticket->get_many_related('Datetime'); |
1881
|
|
|
$dtts = array_merge($dtts, $dtt); |
1882
|
|
|
|
1883
|
|
|
$updated = $trash ? $REG->delete() : $REG->restore(); |
|
|
|
|
1884
|
|
|
if ( !$updated ) { |
1885
|
|
|
$success = 0; |
1886
|
|
|
} else { |
1887
|
|
|
$success = 2; |
1888
|
|
|
}/**/ |
1889
|
|
|
} |
1890
|
|
|
|
1891
|
|
|
} else { |
1892
|
|
|
// grab single id and delete |
1893
|
|
|
$REG_ID = absint($this->_req_data['_REG_ID']); |
1894
|
|
|
$REG = $REGM->get_one_by_ID($REG_ID); |
1895
|
|
|
$ticket = $REG->get_first_related('Ticket'); |
1896
|
|
|
$tickets[$ticket->ID()] = $ticket; |
1897
|
|
|
$dtts = $ticket->get_many_related('Datetime'); |
1898
|
|
|
$updated = $trash ? $REG->delete() : $REG->restore(); |
|
|
|
|
1899
|
|
|
if ( ! $updated ) { |
1900
|
|
|
$success = 0; |
1901
|
|
|
} |
1902
|
|
|
|
1903
|
|
|
} |
1904
|
|
|
|
1905
|
|
|
//now let's update counts |
1906
|
|
|
EEM_Ticket::instance()->update_tickets_sold($tickets); |
1907
|
|
|
EEM_Datetime::instance()->update_sold($dtts); |
1908
|
|
|
|
1909
|
|
|
$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
1910
|
|
|
$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
1911
|
|
|
$overwrite_msgs = $error ? TRUE : FALSE; |
1912
|
|
|
$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs ); |
1913
|
|
|
} |
1914
|
|
|
|
1915
|
|
|
|
1916
|
|
|
|
1917
|
|
|
|
1918
|
|
|
|
1919
|
|
|
/** |
1920
|
|
|
* This is used to permanently delete registrations. Note, this will handle not only deleting permanently the registration but also. |
1921
|
|
|
* |
1922
|
|
|
* 1. Removing relations to EE_Attendee |
1923
|
|
|
* 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are ALSO trashed. |
1924
|
|
|
* 3. Deleting permanently any related Line items but only if the above conditions are met. |
1925
|
|
|
* 4. Removing relationships between all tickets and the related registrations |
1926
|
|
|
* 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
1927
|
|
|
* 6. Deleting permanently any related Checkins. |
1928
|
|
|
* @return void |
1929
|
|
|
*/ |
1930
|
|
|
protected function _delete_registrations() { |
1931
|
|
|
$REG_MDL = EEM_Registration::instance(); |
1932
|
|
|
|
1933
|
|
|
$success = 1; |
1934
|
|
|
|
1935
|
|
|
//Checkboxes |
1936
|
|
|
if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
1937
|
|
|
// if array has more than one element than success message should be plural |
1938
|
|
|
$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
1939
|
|
|
// cycle thru checkboxes |
1940
|
|
|
while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
|
|
|
1941
|
|
|
$REG = $REG_MDL->get_one_by_ID($REG_ID); |
1942
|
|
|
if ( ! $REG instanceof EE_Registration ) |
1943
|
|
|
continue; |
1944
|
|
|
$deleted = $this->_delete_registration($REG); |
1945
|
|
|
if ( !$deleted ) { |
1946
|
|
|
$success = 0; |
1947
|
|
|
} |
1948
|
|
|
} |
1949
|
|
|
|
1950
|
|
|
} else { |
1951
|
|
|
// grab single id and delete |
1952
|
|
|
$REG_ID = $this->_req_data['_REG_ID']; |
1953
|
|
|
$REG = $REG_MDL->get_one_by_ID($REG_ID); |
1954
|
|
|
$deleted = $this->_delete_registration($REG); |
|
|
|
|
1955
|
|
|
if ( ! $deleted ) { |
|
|
|
|
1956
|
|
|
$success = 0; |
1957
|
|
|
} |
1958
|
|
|
|
1959
|
|
|
} |
1960
|
|
|
|
1961
|
|
|
$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
1962
|
|
|
$action_desc = __( 'permanently deleted.', 'event_espresso' ); |
1963
|
|
|
$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE ); |
1964
|
|
|
} |
1965
|
|
|
|
1966
|
|
|
|
1967
|
|
|
|
1968
|
|
|
|
1969
|
|
|
|
1970
|
|
|
/** |
1971
|
|
|
* handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what models get affected. |
1972
|
|
|
* @param EE_Registration $REG registration to be deleted permenantly |
1973
|
|
|
* @return boolean true = successful deletion, false = fail. |
1974
|
|
|
*/ |
1975
|
|
|
protected function _delete_registration( EE_Registration $REG ) { |
1976
|
|
|
//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
1977
|
|
|
$TXN = $REG->get_first_related('Transaction'); |
1978
|
|
|
$REGS = $TXN->get_many_related('Registration'); |
1979
|
|
|
|
1980
|
|
|
$all_trashed = TRUE; |
1981
|
|
|
foreach ( $REGS as $registration ) { |
1982
|
|
|
if ( ! $registration->get('REG_deleted') ) |
1983
|
|
|
$all_trashed = FALSE; |
1984
|
|
|
} |
1985
|
|
|
|
1986
|
|
|
if ( ! $all_trashed ) { |
1987
|
|
|
EE_Error::add_error( __('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
1988
|
|
|
return false; |
1989
|
|
|
} |
1990
|
|
|
|
1991
|
|
|
//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
1992
|
|
|
foreach ( $REGS as $registration ) { |
1993
|
|
|
|
1994
|
|
|
//delete related answers |
1995
|
|
|
$registration->delete_related_permanently('Answer'); |
1996
|
|
|
|
1997
|
|
|
//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
1998
|
|
|
$attendee = $registration->get_first_related('Attendee'); |
1999
|
|
|
if ( $attendee instanceof EE_Attendee ) { |
2000
|
|
|
$registration->_remove_relation_to($attendee, 'Attendee'); |
2001
|
|
|
} |
2002
|
|
|
|
2003
|
|
|
//now remove relationships to tickets on this registration. |
2004
|
|
|
$registration->_remove_relations('Ticket'); |
2005
|
|
|
|
2006
|
|
|
//now delete permanently the checkins related to this registration. |
2007
|
|
|
$registration->delete_related_permanently('Checkin'); |
2008
|
|
|
|
2009
|
|
|
if ( $registration->ID() === $REG->ID() ) |
2010
|
|
|
continue; //we don't want to delete permanently the existing registration just yet. |
2011
|
|
|
|
2012
|
|
|
//remove relation to transaction for these registrations if NOT the existing registrations |
2013
|
|
|
$registration->_remove_relations('Transaction'); |
2014
|
|
|
|
2015
|
|
|
//now delete this registration permanently |
2016
|
|
|
$registration->delete_permanently(); |
2017
|
|
|
} |
2018
|
|
|
|
2019
|
|
|
//now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
2020
|
|
|
//delete the line items related to the transaction for this registration. |
2021
|
|
|
$TXN->delete_related_permanently('Line_Item'); |
2022
|
|
|
|
2023
|
|
|
//we need to remove all the relationships on the transaction |
2024
|
|
|
$TXN->delete_related_permanently('Payment'); |
2025
|
|
|
$TXN->delete_related_permanently('Extra_Meta'); |
2026
|
|
|
|
2027
|
|
|
//now we can delete this REG permanently (and the transaction of course) |
2028
|
|
|
$REG->delete_related_permanently('Transaction'); |
2029
|
|
|
return $REG->delete_permanently(); |
2030
|
|
|
} |
2031
|
|
|
|
2032
|
|
|
|
2033
|
|
|
|
2034
|
|
|
/** |
2035
|
|
|
* generates HTML for the Register New Attendee Admin page |
2036
|
|
|
* |
2037
|
|
|
* @access private |
2038
|
|
|
* @throws \EE_Error |
2039
|
|
|
* @return void |
2040
|
|
|
*/ |
2041
|
|
|
public function new_registration() { |
2042
|
|
|
if ( ! $this->_set_reg_event() ) { |
2043
|
|
|
throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') ); |
2044
|
|
|
} |
2045
|
|
|
EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
2046
|
|
|
// gotta start with a clean slate if we're not coming here via ajax |
2047
|
|
|
if ( |
2048
|
|
|
! defined('DOING_AJAX' ) |
2049
|
|
|
&& ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ) ) |
2050
|
|
|
) { |
2051
|
|
|
EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
2052
|
|
|
} |
2053
|
|
|
|
2054
|
|
|
$this->_template_args['event_name'] = '' ; |
2055
|
|
|
// event name |
2056
|
|
|
if ( $this->_reg_event ) { |
2057
|
|
|
$this->_template_args['event_name'] = $this->_reg_event->name(); |
2058
|
|
|
$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL ); |
2059
|
|
|
$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
2060
|
|
|
$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
2061
|
|
|
} |
2062
|
|
|
|
2063
|
|
|
$this->_template_args['step_content'] = $this->_get_registration_step_content(); |
2064
|
|
|
|
2065
|
|
|
if ( defined('DOING_AJAX' ) ) { |
2066
|
|
|
$this->_return_json(); |
2067
|
|
|
} |
2068
|
|
|
// grab header |
2069
|
|
|
$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
2070
|
|
|
$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
2071
|
|
|
|
2072
|
|
|
//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
2073
|
|
|
// the details template wrapper |
2074
|
|
|
$this->display_admin_page_with_sidebar(); |
2075
|
|
|
} |
2076
|
|
|
|
2077
|
|
|
|
2078
|
|
|
|
2079
|
|
|
|
2080
|
|
|
/** |
2081
|
|
|
* This returns the content for a registration step |
2082
|
|
|
* |
2083
|
|
|
* @access protected |
2084
|
|
|
* @return string html |
2085
|
|
|
*/ |
2086
|
|
|
protected function _get_registration_step_content() { |
2087
|
|
|
if ( isset( $_COOKIE[ 'ee_registration_added' ] ) && $_COOKIE[ 'ee_registration_added' ] ) { |
2088
|
|
|
$warning_msg = sprintf( |
2089
|
|
|
__( |
2090
|
|
|
'%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', |
2091
|
|
|
'event_espresso' |
2092
|
|
|
), |
2093
|
|
|
'<br />', |
2094
|
|
|
'<h3 class="important-notice">', |
2095
|
|
|
'</h3>', |
2096
|
|
|
'<div class="float-right">', |
2097
|
|
|
'<span id="redirect_timer" class="important-notice">30</span>', |
2098
|
|
|
'</div>', |
2099
|
|
|
'<b>', |
2100
|
|
|
'</b>' |
2101
|
|
|
); |
2102
|
|
|
return ' |
2103
|
|
|
<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
2104
|
|
|
<script > |
2105
|
|
|
// WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
2106
|
|
|
// after just adding a new registration... we gotta try to put a stop to that !!! |
2107
|
|
|
var timer = 30; |
2108
|
|
|
setInterval( function () { |
2109
|
|
|
jQuery("#redirect_timer").html( parseInt( timer ) ); |
2110
|
|
|
if ( --timer < 0 ) { |
2111
|
|
|
window.history.forward() |
2112
|
|
|
} |
2113
|
|
|
}, 800 ); |
2114
|
|
|
</script >'; |
2115
|
|
|
} |
2116
|
|
|
$template_args = array( |
2117
|
|
|
'title' => '', |
2118
|
|
|
'content' => '', |
2119
|
|
|
'step_button_text' => '', |
2120
|
|
|
'show_notification_toggle' => false |
2121
|
|
|
); |
2122
|
|
|
//to indicate we're processing a new registration |
2123
|
|
|
$hidden_fields = array( |
2124
|
|
|
'processing_registration' => array( |
2125
|
|
|
'type' => 'hidden', |
2126
|
|
|
'value' => 0 |
2127
|
|
|
), |
2128
|
|
|
'event_id' => array( |
2129
|
|
|
'type' => 'hidden', |
2130
|
|
|
'value' => $this->_reg_event->ID() |
2131
|
|
|
) |
2132
|
|
|
); |
2133
|
|
|
|
2134
|
|
|
//if the cart is empty then we know we're at step one so we'll display ticket selector |
2135
|
|
|
$cart = EE_Registry::instance()->SSN->cart(); |
2136
|
|
|
$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2137
|
|
|
|
2138
|
|
|
switch ( $step ) { |
2139
|
|
|
case 'ticket' : |
2140
|
|
|
$hidden_fields['processing_registration']['value'] = 1; |
2141
|
|
|
$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
2142
|
|
|
$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event ); |
2143
|
|
|
$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso'); |
2144
|
|
|
$template_args['show_notification_toggle'] = FALSE; |
2145
|
|
|
break; |
2146
|
|
|
case 'questions' : |
2147
|
|
|
$hidden_fields[ 'processing_registration' ][ 'value' ] = 2; |
2148
|
|
|
$template_args['title'] = __('Step Two: Add Registrant Details for this Registration', 'event_espresso'); |
2149
|
|
|
//in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
2150
|
|
|
$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
2151
|
|
|
$template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso'); |
2152
|
|
|
$template_args['show_notification_toggle'] = TRUE; |
2153
|
|
|
break; |
2154
|
|
|
} |
2155
|
|
|
|
2156
|
|
|
$this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route. |
2157
|
|
|
|
2158
|
|
|
return EEH_Template::display_template( |
2159
|
|
|
REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
2160
|
|
|
); |
2161
|
|
|
} |
2162
|
|
|
|
2163
|
|
|
|
2164
|
|
|
|
2165
|
|
|
|
2166
|
|
|
|
2167
|
|
|
|
2168
|
|
|
/** |
2169
|
|
|
* set_reg_event |
2170
|
|
|
* @access private |
2171
|
|
|
* @return boolean |
2172
|
|
|
*/ |
2173
|
|
|
private function _set_reg_event() { |
2174
|
|
|
if ( is_object( $this->_reg_event )) { |
2175
|
|
|
return TRUE; |
2176
|
|
|
} |
2177
|
|
|
$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE; |
2178
|
|
|
if ( ! $EVT_ID ) { |
2179
|
|
|
return FALSE; |
2180
|
|
|
} |
2181
|
|
|
|
2182
|
|
|
$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
|
|
|
2183
|
|
|
return TRUE; |
2184
|
|
|
} |
2185
|
|
|
|
2186
|
|
|
|
2187
|
|
|
|
2188
|
|
|
|
2189
|
|
|
|
2190
|
|
|
/** |
2191
|
|
|
* process_reg_step |
2192
|
|
|
* |
2193
|
|
|
* @access public |
2194
|
|
|
* @return string |
2195
|
|
|
*/ |
2196
|
|
|
public function process_reg_step() { |
2197
|
|
|
EE_System::do_not_cache(); |
2198
|
|
|
$this->_set_reg_event(); |
2199
|
|
|
EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
2200
|
|
|
|
2201
|
|
|
//what step are we on? |
2202
|
|
|
$cart = EE_Registry::instance()->SSN->cart(); |
2203
|
|
|
$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2204
|
|
|
|
2205
|
|
|
//if doing ajax then we need to verify the nonce |
2206
|
|
View Code Duplication |
if ( defined( 'DOING_AJAX' ) ) { |
2207
|
|
|
$nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : ''; |
2208
|
|
|
$this->_verify_nonce( $nonce, $this->_req_nonce ); |
2209
|
|
|
} |
2210
|
|
|
|
2211
|
|
|
switch ( $step ) { |
2212
|
|
|
|
2213
|
|
|
case 'ticket' : |
2214
|
|
|
//process ticket selection |
2215
|
|
|
$success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
2216
|
|
|
if ( $success ) { |
2217
|
|
|
EE_Error::add_success( __('Tickets Selected. Now complete the registration.'), 'event_espresso'); |
2218
|
|
|
} else { |
2219
|
|
|
$query_args['step_error'] = $this->_req_data['step_error'] = TRUE; |
|
|
|
|
2220
|
|
|
} |
2221
|
|
|
if ( defined('DOING_AJAX') ) { |
2222
|
|
|
$this->new_registration(); //display next step |
2223
|
|
|
} else { |
2224
|
|
|
$query_args['action'] = 'new_registration'; |
|
|
|
|
2225
|
|
|
$query_args['processing_registration'] = 1; |
2226
|
|
|
$query_args['event_id'] = $this->_reg_event->ID(); |
2227
|
|
|
$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
|
|
|
2228
|
|
|
} |
2229
|
|
|
break; |
2230
|
|
|
|
2231
|
|
|
case 'questions' : |
2232
|
|
|
if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) { |
2233
|
|
|
add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 ); |
2234
|
|
|
} |
2235
|
|
|
//process registration |
2236
|
|
|
$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
2237
|
|
|
if ( $cart instanceof EE_Cart ) { |
2238
|
|
|
$grand_total = $cart->get_cart_grand_total(); |
2239
|
|
|
if ( $grand_total instanceof EE_Line_Item ) { |
2240
|
|
|
$grand_total->save_this_and_descendants_to_txn(); |
2241
|
|
|
} |
2242
|
|
|
} |
2243
|
|
|
if ( ! $transaction instanceof EE_Transaction ) { |
2244
|
|
|
$query_args = array( |
2245
|
|
|
'action' => 'new_registration', |
2246
|
|
|
'processing_registration' => 2, |
2247
|
|
|
'event_id' => $this->_reg_event->ID() |
2248
|
|
|
); |
2249
|
|
|
|
2250
|
|
|
if ( defined('DOING_AJAX' )) { |
2251
|
|
|
//display registration form again because there are errors (maybe validation?) |
2252
|
|
|
$this->new_registration(); |
2253
|
|
|
return; |
2254
|
|
|
} else { |
2255
|
|
|
$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
|
|
|
2256
|
|
|
return; |
2257
|
|
|
} |
2258
|
|
|
} |
2259
|
|
|
/** @type EE_Transaction_Payments $transaction_payments */ |
2260
|
|
|
$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
2261
|
|
|
// maybe update status, and make sure to save transaction if not done already |
2262
|
|
|
if ( ! $transaction_payments->update_transaction_status_based_on_total_paid( $transaction )) { |
2263
|
|
|
$transaction->save(); |
2264
|
|
|
} |
2265
|
|
|
EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
2266
|
|
|
$this->_req_data = array(); |
2267
|
|
|
$query_args = array( |
2268
|
|
|
'action' => 'redirect_to_txn', |
2269
|
|
|
'TXN_ID' => $transaction->ID(), |
2270
|
|
|
'EVT_ID' => $this->_reg_event->ID(), |
2271
|
|
|
'event_name' => urlencode( $this->_reg_event->name() ), |
2272
|
|
|
'redirect_from' => 'new_registration' |
2273
|
|
|
); |
2274
|
|
|
$this->_redirect_after_action( false, '', '', $query_args, true ); |
|
|
|
|
2275
|
|
|
break; |
2276
|
|
|
} |
2277
|
|
|
|
2278
|
|
|
//what are you looking here for? Should be nothing to do at this point. |
2279
|
|
|
} |
2280
|
|
|
|
2281
|
|
|
|
2282
|
|
|
|
2283
|
|
|
/** |
2284
|
|
|
* redirect_to_txn |
2285
|
|
|
* |
2286
|
|
|
* @access public |
2287
|
|
|
* @return void |
2288
|
|
|
*/ |
2289
|
|
|
public function redirect_to_txn() { |
2290
|
|
|
EE_System::do_not_cache(); |
2291
|
|
|
EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
2292
|
|
|
$query_args = array( |
2293
|
|
|
'action' => 'view_transaction', |
2294
|
|
|
'TXN_ID' => isset( $this->_req_data['TXN_ID'] ) ? absint( $this->_req_data[ 'TXN_ID' ] ) : 0, |
2295
|
|
|
'page' => 'espresso_transactions' |
2296
|
|
|
); |
2297
|
|
|
if ( isset( $this->_req_data[ 'EVT_ID' ], $this->_req_data[ 'redirect_from' ] ) ) { |
2298
|
|
|
$query_args['EVT_ID'] = $this->_req_data[ 'EVT_ID' ]; |
2299
|
|
|
$query_args['event_name'] = urlencode( $this->_req_data[ 'event_name' ] ); |
2300
|
|
|
$query_args['redirect_from'] = $this->_req_data[ 'redirect_from' ]; |
2301
|
|
|
} |
2302
|
|
|
EE_Error::add_success( |
2303
|
|
|
__( 'Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso' ) |
2304
|
|
|
); |
2305
|
|
|
$this->_redirect_after_action( false, '', '', $query_args, true ); |
|
|
|
|
2306
|
|
|
} |
2307
|
|
|
|
2308
|
|
|
|
2309
|
|
|
|
2310
|
|
|
/** |
2311
|
|
|
* generates HTML for the Attendee Contact List |
2312
|
|
|
* @access protected |
2313
|
|
|
* @return void |
2314
|
|
|
*/ |
2315
|
|
|
protected function _attendee_contact_list_table() { |
2316
|
|
|
do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
2317
|
|
|
$this->_search_btn_label = __('Contacts', 'event_espresso'); |
2318
|
|
|
$this->display_admin_list_table_page_with_no_sidebar(); |
2319
|
|
|
} |
2320
|
|
|
|
2321
|
|
|
|
2322
|
|
|
|
2323
|
|
|
|
2324
|
|
|
|
2325
|
|
|
/** |
2326
|
|
|
* get_attendees |
2327
|
|
|
* @param bool $count whether to return count or data. |
2328
|
|
|
* @access public |
2329
|
|
|
* @return array |
2330
|
|
|
*/ |
2331
|
|
|
public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
2332
|
|
|
|
2333
|
|
|
do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
2334
|
|
|
require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' ); |
2335
|
|
|
$ATT_MDL = EEM_Attendee::instance(); |
2336
|
|
|
|
2337
|
|
|
$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
2338
|
|
|
|
2339
|
|
|
switch ($this->_req_data['orderby']) { |
2340
|
|
|
case 'ATT_ID': |
2341
|
|
|
$orderby = 'ATT_ID'; |
2342
|
|
|
break; |
2343
|
|
|
case 'ATT_fname': |
2344
|
|
|
$orderby = 'ATT_fname'; |
2345
|
|
|
break; |
2346
|
|
|
case 'ATT_email': |
2347
|
|
|
$orderby = 'ATT_email'; |
2348
|
|
|
break; |
2349
|
|
|
case 'ATT_city': |
2350
|
|
|
$orderby = 'ATT_city'; |
2351
|
|
|
break; |
2352
|
|
|
case 'STA_ID': |
2353
|
|
|
$orderby = 'STA_ID'; |
2354
|
|
|
break; |
2355
|
|
|
case 'CNT_ID': |
2356
|
|
|
$orderby = 'CNT_ID'; |
2357
|
|
|
break; |
2358
|
|
|
default: |
2359
|
|
|
$orderby = 'ATT_lname'; |
2360
|
|
|
} |
2361
|
|
|
|
2362
|
|
|
$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
2363
|
|
|
|
2364
|
|
|
$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
2365
|
|
|
$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
2366
|
|
|
$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
2367
|
|
|
|
2368
|
|
|
$_where = array(); |
2369
|
|
|
|
2370
|
|
|
if ( isset( $this->_req_data['s'] ) ) { |
2371
|
|
|
$sstr = '%' . $this->_req_data['s'] . '%'; |
2372
|
|
|
$_where['OR'] = array( |
2373
|
|
|
'Registration.Event.EVT_name' => array( 'LIKE', $sstr), |
2374
|
|
|
'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ), |
2375
|
|
|
'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
2376
|
|
|
'ATT_fname' => array( 'LIKE', $sstr ), |
2377
|
|
|
'ATT_lname' => array( 'LIKE', $sstr ), |
2378
|
|
|
'ATT_short_bio' => array( 'LIKE', $sstr ), |
2379
|
|
|
'ATT_email' => array('LIKE', $sstr ), |
2380
|
|
|
'ATT_address' => array( 'LIKE', $sstr ), |
2381
|
|
|
'ATT_address2' => array( 'LIKE', $sstr ), |
2382
|
|
|
'ATT_city' => array( 'LIKE', $sstr ), |
2383
|
|
|
'Country.CNT_name' => array( 'LIKE', $sstr ), |
2384
|
|
|
'State.STA_name' => array('LIKE', $sstr ), |
2385
|
|
|
'ATT_phone' => array( 'LIKE', $sstr ), |
2386
|
|
|
'Registration.REG_final_price' => array( 'LIKE', $sstr ), |
2387
|
|
|
'Registration.REG_code' => array( 'LIKE', $sstr ), |
2388
|
|
|
'Registration.REG_count' => array( 'LIKE' , $sstr ), |
2389
|
|
|
'Registration.REG_group_size' => array( 'LIKE' , $sstr ) |
2390
|
|
|
); |
2391
|
|
|
} |
2392
|
|
|
|
2393
|
|
|
|
2394
|
|
|
$offset = ($current_page-1)*$per_page; |
2395
|
|
|
$limit = $count ? NULL : array( $offset, $per_page ); |
2396
|
|
|
|
2397
|
|
|
if ( $trash ) { |
2398
|
|
|
$_where['status'] = array( '!=', 'publish' ); |
2399
|
|
|
$all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
2400
|
|
|
} else { |
2401
|
|
|
$_where['status'] = array( 'IN', array( 'publish' ) ); |
2402
|
|
|
$all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit)) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) ); |
2403
|
|
|
} |
2404
|
|
|
|
2405
|
|
|
return $all_attendees; |
2406
|
|
|
} |
2407
|
|
|
|
2408
|
|
|
|
2409
|
|
|
|
2410
|
|
|
|
2411
|
|
|
/** |
2412
|
|
|
* This is just taking care of resending the registration confirmation |
2413
|
|
|
* |
2414
|
|
|
* @access protected |
2415
|
|
|
* @return void |
2416
|
|
|
*/ |
2417
|
|
|
protected function _resend_registration() { |
2418
|
|
|
$this->_process_resend_registration(); |
2419
|
|
|
$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array( |
2420
|
|
|
'action' => 'default' |
2421
|
|
|
); |
2422
|
|
|
$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE ); |
|
|
|
|
2423
|
|
|
} |
2424
|
|
|
|
2425
|
|
|
|
2426
|
|
|
|
2427
|
|
|
|
2428
|
|
|
|
2429
|
|
|
|
2430
|
|
|
public function _registrations_report(){ |
2431
|
|
|
if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
2432
|
|
|
wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
2433
|
|
|
array( |
2434
|
|
|
'page' => 'espresso_batch', |
2435
|
|
|
'batch' => 'file', |
2436
|
|
|
'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
2437
|
|
|
'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ), |
2438
|
|
|
'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
2439
|
|
|
)) ); |
2440
|
|
|
} else { |
2441
|
|
|
$new_request_args = array( |
2442
|
|
|
'export' => 'report', |
2443
|
|
|
'action' => 'registrations_report_for_event', |
2444
|
|
|
'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
2445
|
|
|
); |
2446
|
|
|
$this->_req_data = array_merge($this->_req_data, $new_request_args); |
2447
|
|
|
|
2448
|
|
|
if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
2449
|
|
|
require_once(EE_CLASSES . 'EE_Export.class.php'); |
2450
|
|
|
$EE_Export = EE_Export::instance($this->_req_data); |
2451
|
|
|
$EE_Export->export(); |
2452
|
|
|
} |
2453
|
|
|
} |
2454
|
|
|
} |
2455
|
|
|
|
2456
|
|
|
|
2457
|
|
|
|
2458
|
|
|
public function _contact_list_export(){ |
2459
|
|
|
if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
2460
|
|
|
require_once(EE_CLASSES . 'EE_Export.class.php'); |
2461
|
|
|
$EE_Export = EE_Export::instance($this->_req_data); |
2462
|
|
|
$EE_Export->export_attendees(); |
2463
|
|
|
} |
2464
|
|
|
} |
2465
|
|
|
|
2466
|
|
|
public function _contact_list_report(){ |
2467
|
|
|
if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
2468
|
|
|
wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
2469
|
|
|
array( |
2470
|
|
|
'page' => 'espresso_batch', |
2471
|
|
|
'batch' => 'file', |
2472
|
|
|
'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ), |
2473
|
|
|
'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
2474
|
|
|
)) ); |
2475
|
|
|
} else { |
2476
|
|
|
if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
2477
|
|
|
require_once(EE_CLASSES . 'EE_Export.class.php'); |
2478
|
|
|
$EE_Export = EE_Export::instance($this->_req_data); |
2479
|
|
|
$EE_Export->report_attendees(); |
2480
|
|
|
} |
2481
|
|
|
} |
2482
|
|
|
} |
2483
|
|
|
|
2484
|
|
|
|
2485
|
|
|
|
2486
|
|
|
|
2487
|
|
|
|
2488
|
|
|
|
2489
|
|
|
/*************************************** ATTENDEE DETAILS ***************************************/ |
2490
|
|
|
|
2491
|
|
|
|
2492
|
|
|
/** |
2493
|
|
|
* This duplicates the attendee object for the given incoming registration id and attendee_id. |
2494
|
|
|
* @return void |
2495
|
|
|
*/ |
2496
|
|
|
protected function _duplicate_attendee() { |
2497
|
|
|
$action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default'; |
2498
|
|
|
//verify we have necessary info |
2499
|
|
View Code Duplication |
if ( empty($this->_req_data['_REG_ID'] ) ) { |
2500
|
|
|
EE_Error::add_error( __('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__ ); |
2501
|
|
|
$query_args = array( 'action' => $action ); |
2502
|
|
|
$this->_redirect_after_action('', '', '', $query_args, TRUE); |
2503
|
|
|
} |
2504
|
|
|
|
2505
|
|
|
//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
2506
|
|
|
$registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] ); |
2507
|
|
|
$attendee = $registration->attendee(); |
|
|
|
|
2508
|
|
|
|
2509
|
|
|
//remove relation of existing attendee on registration |
2510
|
|
|
$registration->_remove_relation_to($attendee, 'Attendee' ); |
2511
|
|
|
//new attendee |
2512
|
|
|
$new_attendee = clone $attendee; |
2513
|
|
|
$new_attendee->set( 'ATT_ID', 0 ); |
2514
|
|
|
$new_attendee->save(); |
2515
|
|
|
|
2516
|
|
|
//add new attendee to reg |
2517
|
|
|
$registration->_add_relation_to( $new_attendee, 'Attendee'); |
2518
|
|
|
|
2519
|
|
|
EE_Error::add_success( __('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso') ); |
2520
|
|
|
|
2521
|
|
|
//redirect to edit page for attendee |
2522
|
|
|
$query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' ); |
2523
|
|
|
|
2524
|
|
|
$this->_redirect_after_action( '', '', '', $query_args, TRUE ); |
2525
|
|
|
} |
2526
|
|
|
|
2527
|
|
|
|
2528
|
|
|
//related to cpt routes |
2529
|
|
|
protected function _insert_update_cpt_item($post_id, $post) { |
2530
|
|
|
$success = true; |
2531
|
|
|
$attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id ); |
2532
|
|
|
//for attendee updates |
2533
|
|
|
if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) { |
|
|
|
|
2534
|
|
|
//note we should only be UPDATING attendees at this point. |
2535
|
|
|
$updated_fields = array( |
2536
|
|
|
'ATT_fname' => $this->_req_data['ATT_fname'], |
2537
|
|
|
'ATT_lname' => $this->_req_data['ATT_lname'], |
2538
|
|
|
'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
2539
|
|
|
'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
2540
|
|
|
'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
2541
|
|
|
'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '', |
2542
|
|
|
'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '', |
2543
|
|
|
'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '', |
2544
|
|
|
'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '', |
2545
|
|
|
'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '', |
2546
|
|
|
'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : '' |
2547
|
|
|
); |
2548
|
|
|
foreach ( $updated_fields as $field => $value ) { |
2549
|
|
|
$attendee->set($field, $value); |
2550
|
|
|
} |
2551
|
|
|
|
2552
|
|
|
$success = $attendee->save(); |
2553
|
|
|
|
2554
|
|
|
$attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() ); |
2555
|
|
|
foreach ( $attendee_update_callbacks as $a_callback ) { |
2556
|
|
|
if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) { |
2557
|
|
|
throw new EE_Error( sprintf( __('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.', 'event_espresso'), $a_callback ) ); |
2558
|
|
|
} |
2559
|
|
|
} |
2560
|
|
|
} |
2561
|
|
|
|
2562
|
|
|
if ( $success === FALSE ) |
2563
|
|
|
EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
2564
|
|
|
|
2565
|
|
|
} |
2566
|
|
|
|
2567
|
|
|
|
2568
|
|
|
|
2569
|
|
|
|
2570
|
|
|
public function trash_cpt_item($post_id) {} |
2571
|
|
|
public function delete_cpt_item($post_id) {} |
2572
|
|
|
public function restore_cpt_item($post_id) {} |
2573
|
|
|
protected function _restore_cpt_item($post_id, $revision_id) {} |
2574
|
|
|
|
2575
|
|
|
|
2576
|
|
|
public function attendee_editor_metaboxes() { |
2577
|
|
|
|
2578
|
|
|
$this->verify_cpt_object(); |
2579
|
|
|
|
2580
|
|
|
remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2581
|
|
|
remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2582
|
|
|
|
2583
|
|
View Code Duplication |
if ( post_type_supports( 'espresso_attendees', 'excerpt') ) { |
2584
|
|
|
add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' ); |
2585
|
|
|
} |
2586
|
|
|
|
2587
|
|
View Code Duplication |
if ( post_type_supports( 'espresso_attendees', 'comments') ) { |
2588
|
|
|
add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2589
|
|
|
} |
2590
|
|
|
|
2591
|
|
|
add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
2592
|
|
|
add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' ); |
2593
|
|
|
add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
2594
|
|
|
} |
2595
|
|
|
|
2596
|
|
|
|
2597
|
|
|
/** |
2598
|
|
|
* Metabox for attendee contact info |
2599
|
|
|
* @param WP_Post $post wp post object |
2600
|
|
|
* @return string attendee contact info ( and form ) |
2601
|
|
|
*/ |
2602
|
|
|
public function attendee_contact_info( $post ) { |
|
|
|
|
2603
|
|
|
//get attendee object ( should already have it ) |
2604
|
|
|
$this->_template_args['attendee'] = $this->_cpt_model_obj; |
2605
|
|
|
$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
2606
|
|
|
EEH_Template::display_template($template, $this->_template_args); |
2607
|
|
|
} |
2608
|
|
|
|
2609
|
|
|
|
2610
|
|
|
|
2611
|
|
|
/** |
2612
|
|
|
* Metabox for attendee details |
2613
|
|
|
* @param WP_Post $post wp post object |
2614
|
|
|
* @return string attendee address details (and form) |
2615
|
|
|
*/ |
2616
|
|
|
public function attendee_address_details($post) { |
|
|
|
|
2617
|
|
|
//get attendee object (should already have it) |
2618
|
|
|
$this->_template_args['attendee'] = $this->_cpt_model_obj; |
2619
|
|
|
$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
2620
|
|
|
new EE_Question_Form_Input( |
2621
|
|
|
EE_Question::new_instance( array( |
2622
|
|
|
'QST_ID' => 0, |
2623
|
|
|
'QST_display_text' => __('State/Province', 'event_espresso'), |
2624
|
|
|
'QST_system' => 'admin-state' |
2625
|
|
|
)), |
2626
|
|
|
EE_Answer::new_instance( array( |
2627
|
|
|
'ANS_ID' => 0, |
2628
|
|
|
'ANS_value' => $this->_cpt_model_obj->state_ID() |
|
|
|
|
2629
|
|
|
)), |
2630
|
|
|
array( |
2631
|
|
|
'input_id' => 'STA_ID', |
2632
|
|
|
'input_name' => 'STA_ID', |
2633
|
|
|
'input_prefix' => '', |
2634
|
|
|
'append_qstn_id' => FALSE |
2635
|
|
|
) |
2636
|
|
|
)); |
2637
|
|
|
$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
2638
|
|
|
new EE_Question_Form_Input( |
2639
|
|
|
EE_Question::new_instance( array( |
2640
|
|
|
'QST_ID' => 0, |
2641
|
|
|
'QST_display_text' => __('Country', 'event_espresso'), |
2642
|
|
|
'QST_system' => 'admin-country' |
2643
|
|
|
)), |
2644
|
|
|
EE_Answer::new_instance( array( |
2645
|
|
|
'ANS_ID' => 0, |
2646
|
|
|
'ANS_value' => $this->_cpt_model_obj->country_ID() |
|
|
|
|
2647
|
|
|
)), |
2648
|
|
|
array( |
2649
|
|
|
'input_id' => 'CNT_ISO', |
2650
|
|
|
'input_name' => 'CNT_ISO', |
2651
|
|
|
'input_prefix' => '', |
2652
|
|
|
'append_qstn_id' => FALSE |
2653
|
|
|
) |
2654
|
|
|
)); |
2655
|
|
|
$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
2656
|
|
|
EEH_Template::display_template($template, $this->_template_args ); |
2657
|
|
|
|
2658
|
|
|
} |
2659
|
|
|
|
2660
|
|
|
|
2661
|
|
|
/** |
2662
|
|
|
* _attendee_details |
2663
|
|
|
* @access protected |
2664
|
|
|
* @return void |
2665
|
|
|
*/ |
2666
|
|
|
public function attendee_registrations_meta_box( $post ) { |
|
|
|
|
2667
|
|
|
|
2668
|
|
|
$this->_template_args['attendee'] = $this->_cpt_model_obj; |
2669
|
|
|
$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
2670
|
|
|
$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
2671
|
|
|
EEH_Template::display_template($template, $this->_template_args); |
2672
|
|
|
|
2673
|
|
|
} |
2674
|
|
|
|
2675
|
|
|
|
2676
|
|
|
|
2677
|
|
|
|
2678
|
|
|
/** |
2679
|
|
|
* add in the form fields for the attendee edit |
2680
|
|
|
* @param WP_Post $post wp post object |
2681
|
|
|
* @return string html for new form. |
2682
|
|
|
*/ |
2683
|
|
|
public function after_title_form_fields($post) { |
2684
|
|
|
if ( $post->post_type == 'espresso_attendees' ) { |
2685
|
|
|
$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
2686
|
|
|
$template_args['attendee'] = $this->_cpt_model_obj; |
|
|
|
|
2687
|
|
|
EEH_Template::display_template($template, $template_args); |
2688
|
|
|
} |
2689
|
|
|
} |
2690
|
|
|
|
2691
|
|
|
|
2692
|
|
|
|
2693
|
|
|
|
2694
|
|
|
|
2695
|
|
|
|
2696
|
|
|
/** |
2697
|
|
|
* _trash_or_restore_attendee |
2698
|
|
|
* @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
2699
|
|
|
* @access protected |
2700
|
|
|
* @return void |
2701
|
|
|
*/ |
2702
|
|
|
protected function _trash_or_restore_attendees( $trash = TRUE ) { |
2703
|
|
|
|
2704
|
|
|
do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
2705
|
|
|
|
2706
|
|
|
$ATT_MDL = EEM_Attendee::instance(); |
2707
|
|
|
|
2708
|
|
|
$success = 1; |
2709
|
|
|
//Checkboxes |
2710
|
|
|
if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
2711
|
|
|
// if array has more than one element than success message should be plural |
2712
|
|
|
$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
2713
|
|
|
// cycle thru checkboxes |
2714
|
|
|
while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
|
|
|
2715
|
|
|
$updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID); |
2716
|
|
|
if ( !$updated ) { |
2717
|
|
|
$success = 0; |
2718
|
|
|
} |
2719
|
|
|
} |
2720
|
|
|
|
2721
|
|
|
} else { |
2722
|
|
|
// grab single id and delete |
2723
|
|
|
$ATT_ID = absint($this->_req_data['ATT_ID']); |
2724
|
|
|
//get attendee |
2725
|
|
|
$att = $ATT_MDL->get_one_by_ID( $ATT_ID ); |
2726
|
|
|
$updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
|
|
|
2727
|
|
|
$updated = $att->save(); |
2728
|
|
|
if ( ! $updated ) { |
2729
|
|
|
$success = 0; |
2730
|
|
|
} |
2731
|
|
|
|
2732
|
|
|
} |
2733
|
|
|
|
2734
|
|
|
$what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' ); |
2735
|
|
|
$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
2736
|
|
|
$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) ); |
2737
|
|
|
|
2738
|
|
|
} |
2739
|
|
|
|
2740
|
|
|
} |
2741
|
|
|
|
2742
|
|
|
|
2743
|
|
|
|
2744
|
|
|
// end of file: includes/core/admin/transactions/Registrations_Admin_Page.core.php |
2745
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.