Completed
Branch FET-10766-extract-activation-d... (99f7dd)
by
unknown
134:15 queued 121:56
created
core/db_classes/EE_Attendee.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
     /**
580 580
      * returns any events attached to this attendee ($_Event property);
581 581
      *
582
-     * @return array
582
+     * @return EE_Base_Class[]
583 583
      */
584 584
     public function events()
585 585
     {
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
      * used to save the billing info
595 595
      *
596 596
      * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
597
-     * @return EE_Form_Section_Proper|null
597
+     * @return null|EE_Billing_Info_Form
598 598
      */
599 599
     public function billing_info_for_payment_method($payment_method)
600 600
     {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 /**
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35 35
     {
36
-        if (! isset($fieldValues['ATT_full_name'])) {
37
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
36
+        if ( ! isset($fieldValues['ATT_full_name'])) {
37
+            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
38 38
             $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
-            $fieldValues['ATT_full_name'] = $fname . $lname;
39
+            $fieldValues['ATT_full_name'] = $fname.$lname;
40 40
         }
41
-        if (! isset($fieldValues['ATT_slug'])) {
41
+        if ( ! isset($fieldValues['ATT_slug'])) {
42 42
             //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43 43
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44 44
         }
45
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
45
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46 46
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47 47
         }
48 48
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function full_name($apply_html_entities = false)
253 253
     {
254
-        $full_name = $this->fname() . ' ' . $this->lname();
254
+        $full_name = $this->fname().' '.$this->lname();
255 255
         return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256 256
     }
257 257
 
@@ -282,22 +282,22 @@  discard block
 block discarded – undo
282 282
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
283 283
         foreach ($initial_address_fields as $address_field_name) {
284 284
             $address_fields_value = $this->get($address_field_name);
285
-            if (! empty($address_fields_value)) {
285
+            if ( ! empty($address_fields_value)) {
286 286
                 $full_address_array[] = $address_fields_value;
287 287
             }
288 288
         }
289 289
         //now handle state and country
290 290
         $state_obj = $this->state_obj();
291
-        if (! empty($state_obj)) {
291
+        if ( ! empty($state_obj)) {
292 292
             $full_address_array[] = $state_obj->name();
293 293
         }
294 294
         $country_obj = $this->country_obj();
295
-        if (! empty($country_obj)) {
295
+        if ( ! empty($country_obj)) {
296 296
             $full_address_array[] = $country_obj->name();
297 297
         }
298 298
         //lastly get the xip
299 299
         $zip_value = $this->zip();
300
-        if (! empty($zip_value)) {
300
+        if ( ! empty($zip_value)) {
301 301
             $full_address_array[] = $zip_value;
302 302
         }
303 303
         return $full_address_array;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     public function get_most_recent_registration_for_event($event_id)
532 532
     {
533 533
         return $this->get_first_related('Registration',
534
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
534
+            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))); //, '=', 'OBJECT_K' );
535 535
     }
536 536
 
537 537
 
@@ -557,11 +557,11 @@  discard block
 block discarded – undo
557 557
     public function billing_info_for_payment_method($payment_method)
558 558
     {
559 559
         $pm_type = $payment_method->type_obj();
560
-        if (! $pm_type instanceof EE_PMT_Base) {
560
+        if ( ! $pm_type instanceof EE_PMT_Base) {
561 561
             return null;
562 562
         }
563 563
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
564
-        if (! $billing_info) {
564
+        if ( ! $billing_info) {
565 565
             return null;
566 566
         }
567 567
         $billing_form = $pm_type->billing_form();
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
     public function get_billing_info_postmeta_name($payment_method)
583 583
     {
584 584
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
585
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
585
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
586 586
         } else {
587 587
             return null;
588 588
         }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
      */
600 600
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
601 601
     {
602
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
602
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
603 603
             EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
604 604
             return false;
605 605
         }
Please login to merge, or discard this patch.
Indentation   +660 added lines, -660 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -23,665 +23,665 @@  discard block
 block discarded – undo
23 23
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
24 24
 {
25 25
 
26
-    /**
27
-     * Sets some dynamic defaults
28
-     *
29
-     * @param array  $fieldValues
30
-     * @param bool   $bydb
31
-     * @param string $timezone
32
-     * @param array  $date_formats
33
-     */
34
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
-    {
36
-        if (! isset($fieldValues['ATT_full_name'])) {
37
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
-            $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
-            $fieldValues['ATT_full_name'] = $fname . $lname;
40
-        }
41
-        if (! isset($fieldValues['ATT_slug'])) {
42
-            //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
-        }
45
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
-        }
48
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
-    }
50
-
51
-
52
-    /**
53
-     * @param array  $props_n_values          incoming values
54
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
-     *                                        used.)
56
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
-     *                                        date_format and the second value is the time format
58
-     * @return EE_Attendee
59
-     */
60
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
-    {
62
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param array  $props_n_values  incoming values from the database
69
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
-     *                                the website will be used.
71
-     * @return EE_Attendee
72
-     */
73
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
-    {
75
-        return new self($props_n_values, true, $timezone);
76
-    }
77
-
78
-
79
-    /**
80
-     *        Set Attendee First Name
81
-     *
82
-     * @access        public
83
-     * @param string $fname
84
-     */
85
-    public function set_fname($fname = '')
86
-    {
87
-        $this->set('ATT_fname', $fname);
88
-    }
89
-
90
-
91
-    /**
92
-     *        Set Attendee Last Name
93
-     *
94
-     * @access        public
95
-     * @param string $lname
96
-     */
97
-    public function set_lname($lname = '')
98
-    {
99
-        $this->set('ATT_lname', $lname);
100
-    }
101
-
102
-
103
-    /**
104
-     *        Set Attendee Address
105
-     *
106
-     * @access        public
107
-     * @param string $address
108
-     */
109
-    public function set_address($address = '')
110
-    {
111
-        $this->set('ATT_address', $address);
112
-    }
113
-
114
-
115
-    /**
116
-     *        Set Attendee Address2
117
-     *
118
-     * @access        public
119
-     * @param        string $address2
120
-     */
121
-    public function set_address2($address2 = '')
122
-    {
123
-        $this->set('ATT_address2', $address2);
124
-    }
125
-
126
-
127
-    /**
128
-     *        Set Attendee City
129
-     *
130
-     * @access        public
131
-     * @param        string $city
132
-     */
133
-    public function set_city($city = '')
134
-    {
135
-        $this->set('ATT_city', $city);
136
-    }
137
-
138
-
139
-    /**
140
-     *        Set Attendee State ID
141
-     *
142
-     * @access        public
143
-     * @param        int $STA_ID
144
-     */
145
-    public function set_state($STA_ID = 0)
146
-    {
147
-        $this->set('STA_ID', $STA_ID);
148
-    }
149
-
150
-
151
-    /**
152
-     *        Set Attendee Country ISO Code
153
-     *
154
-     * @access        public
155
-     * @param        string $CNT_ISO
156
-     */
157
-    public function set_country($CNT_ISO = '')
158
-    {
159
-        $this->set('CNT_ISO', $CNT_ISO);
160
-    }
161
-
162
-
163
-    /**
164
-     *        Set Attendee Zip/Postal Code
165
-     *
166
-     * @access        public
167
-     * @param        string $zip
168
-     */
169
-    public function set_zip($zip = '')
170
-    {
171
-        $this->set('ATT_zip', $zip);
172
-    }
173
-
174
-
175
-    /**
176
-     *        Set Attendee Email Address
177
-     *
178
-     * @access        public
179
-     * @param        string $email
180
-     */
181
-    public function set_email($email = '')
182
-    {
183
-        $this->set('ATT_email', $email);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Phone
189
-     *
190
-     * @access        public
191
-     * @param        string $phone
192
-     */
193
-    public function set_phone($phone = '')
194
-    {
195
-        $this->set('ATT_phone', $phone);
196
-    }
197
-
198
-
199
-    /**
200
-     *        set deleted
201
-     *
202
-     * @access        public
203
-     * @param        bool $ATT_deleted
204
-     */
205
-    public function set_deleted($ATT_deleted = false)
206
-    {
207
-        $this->set('ATT_deleted', $ATT_deleted);
208
-    }
209
-
210
-
211
-    /**
212
-     * Returns the value for the post_author id saved with the cpt
213
-     *
214
-     * @since 4.5.0
215
-     * @return int
216
-     */
217
-    public function wp_user()
218
-    {
219
-        return $this->get('ATT_author');
220
-    }
221
-
222
-
223
-    /**
224
-     *        get Attendee First Name
225
-     *
226
-     * @access        public
227
-     * @return string
228
-     */
229
-    public function fname()
230
-    {
231
-        return $this->get('ATT_fname');
232
-    }
233
-
234
-
235
-    /**
236
-     * echoes out the attendee's first name
237
-     *
238
-     * @return void
239
-     */
240
-    public function e_full_name()
241
-    {
242
-        echo $this->full_name();
243
-    }
244
-
245
-
246
-    /**
247
-     * Returns the first and last name concatenated together with a space.
248
-     *
249
-     * @param bool $apply_html_entities
250
-     * @return string
251
-     */
252
-    public function full_name($apply_html_entities = false)
253
-    {
254
-        $full_name = $this->fname() . ' ' . $this->lname();
255
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256
-    }
257
-
258
-
259
-    /**
260
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
261
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
262
-     * attendee.
263
-     *
264
-     * @param bool $apply_html_entities
265
-     * @return string
266
-     */
267
-    public function ATT_full_name($apply_html_entities = false)
268
-    {
269
-        return $apply_html_entities
270
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
271
-            : $this->get('ATT_full_name');
272
-    }
273
-
274
-
275
-    /**
276
-     *        get Attendee Last Name
277
-     *
278
-     * @access        public
279
-     * @return string
280
-     */
281
-    public function lname()
282
-    {
283
-        return $this->get('ATT_lname');
284
-    }
285
-
286
-
287
-    /**
288
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
289
-     *
290
-     * @return array numerically indexed, with each part of the address that is known.
291
-     * Eg, if the user only responded to state and country,
292
-     * it would be array(0=>'Alabama',1=>'USA')
293
-     * @return array
294
-     */
295
-    public function full_address_as_array()
296
-    {
297
-        $full_address_array     = array();
298
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
299
-        foreach ($initial_address_fields as $address_field_name) {
300
-            $address_fields_value = $this->get($address_field_name);
301
-            if (! empty($address_fields_value)) {
302
-                $full_address_array[] = $address_fields_value;
303
-            }
304
-        }
305
-        //now handle state and country
306
-        $state_obj = $this->state_obj();
307
-        if (! empty($state_obj)) {
308
-            $full_address_array[] = $state_obj->name();
309
-        }
310
-        $country_obj = $this->country_obj();
311
-        if (! empty($country_obj)) {
312
-            $full_address_array[] = $country_obj->name();
313
-        }
314
-        //lastly get the xip
315
-        $zip_value = $this->zip();
316
-        if (! empty($zip_value)) {
317
-            $full_address_array[] = $zip_value;
318
-        }
319
-        return $full_address_array;
320
-    }
321
-
322
-
323
-    /**
324
-     *        get Attendee Address
325
-     *
326
-     * @return string
327
-     */
328
-    public function address()
329
-    {
330
-        return $this->get('ATT_address');
331
-    }
332
-
333
-
334
-    /**
335
-     *        get Attendee Address2
336
-     *
337
-     * @return string
338
-     */
339
-    public function address2()
340
-    {
341
-        return $this->get('ATT_address2');
342
-    }
343
-
344
-
345
-    /**
346
-     *        get Attendee City
347
-     *
348
-     * @return string
349
-     */
350
-    public function city()
351
-    {
352
-        return $this->get('ATT_city');
353
-    }
354
-
355
-
356
-    /**
357
-     *        get Attendee State ID
358
-     *
359
-     * @return string
360
-     */
361
-    public function state_ID()
362
-    {
363
-        return $this->get('STA_ID');
364
-    }
365
-
366
-
367
-    /**
368
-     * @return string
369
-     */
370
-    public function state_abbrev()
371
-    {
372
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
373
-    }
374
-
375
-
376
-    /**
377
-     * Gets the state set to this attendee
378
-     *
379
-     * @return EE_State
380
-     */
381
-    public function state_obj()
382
-    {
383
-        return $this->get_first_related('State');
384
-    }
385
-
386
-
387
-    /**
388
-     * Returns the state's name, otherwise 'Unknown'
389
-     *
390
-     * @return string
391
-     */
392
-    public function state_name()
393
-    {
394
-        if ($this->state_obj()) {
395
-            return $this->state_obj()->name();
396
-        } else {
397
-            return '';
398
-        }
399
-    }
400
-
401
-
402
-    /**
403
-     * either displays the state abbreviation or the state name, as determined
404
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
405
-     * defaults to abbreviation
406
-     *
407
-     * @return string
408
-     */
409
-    public function state()
410
-    {
411
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
412
-            return $this->state_abbrev();
413
-        } else {
414
-            return $this->state_name();
415
-        }
416
-    }
417
-
418
-
419
-    /**
420
-     *    get Attendee Country ISO Code
421
-     *
422
-     * @return string
423
-     */
424
-    public function country_ID()
425
-    {
426
-        return $this->get('CNT_ISO');
427
-    }
428
-
429
-
430
-    /**
431
-     * Gets country set for this attendee
432
-     *
433
-     * @return EE_Country
434
-     */
435
-    public function country_obj()
436
-    {
437
-        return $this->get_first_related('Country');
438
-    }
439
-
440
-
441
-    /**
442
-     * Returns the country's name if known, otherwise 'Unknown'
443
-     *
444
-     * @return string
445
-     */
446
-    public function country_name()
447
-    {
448
-        if ($this->country_obj()) {
449
-            return $this->country_obj()->name();
450
-        } else {
451
-            return '';
452
-        }
453
-    }
454
-
455
-
456
-    /**
457
-     * either displays the country ISO2 code or the country name, as determined
458
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
459
-     * defaults to abbreviation
460
-     *
461
-     * @return string
462
-     */
463
-    public function country()
464
-    {
465
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
466
-            return $this->country_ID();
467
-        } else {
468
-            return $this->country_name();
469
-        }
470
-    }
471
-
472
-
473
-    /**
474
-     *        get Attendee Zip/Postal Code
475
-     *
476
-     * @return string
477
-     */
478
-    public function zip()
479
-    {
480
-        return $this->get('ATT_zip');
481
-    }
482
-
483
-
484
-    /**
485
-     *        get Attendee Email Address
486
-     *
487
-     * @return string
488
-     */
489
-    public function email()
490
-    {
491
-        return $this->get('ATT_email');
492
-    }
493
-
494
-
495
-    /**
496
-     *        get Attendee Phone #
497
-     *
498
-     * @return string
499
-     */
500
-    public function phone()
501
-    {
502
-        return $this->get('ATT_phone');
503
-    }
504
-
505
-
506
-    /**
507
-     *    get deleted
508
-     *
509
-     * @return        bool
510
-     */
511
-    public function deleted()
512
-    {
513
-        return $this->get('ATT_deleted');
514
-    }
515
-
516
-
517
-    /**
518
-     * Gets registrations of this attendee
519
-     *
520
-     * @param array $query_params
521
-     * @return EE_Registration[]
522
-     */
523
-    public function get_registrations($query_params = array())
524
-    {
525
-        return $this->get_many_related('Registration', $query_params);
526
-    }
527
-
528
-
529
-    /**
530
-     * Gets the most recent registration of this attendee
531
-     *
532
-     * @return EE_Registration
533
-     */
534
-    public function get_most_recent_registration()
535
-    {
536
-        return $this->get_first_related('Registration',
537
-            array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
538
-    }
539
-
540
-
541
-    /**
542
-     * Gets the most recent registration for this attend at this event
543
-     *
544
-     * @param int $event_id
545
-     * @return EE_Registration
546
-     */
547
-    public function get_most_recent_registration_for_event($event_id)
548
-    {
549
-        return $this->get_first_related('Registration',
550
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
551
-    }
552
-
553
-
554
-    /**
555
-     * returns any events attached to this attendee ($_Event property);
556
-     *
557
-     * @return array
558
-     */
559
-    public function events()
560
-    {
561
-        return $this->get_many_related('Event');
562
-    }
563
-
564
-
565
-    /**
566
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
567
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
568
-     * used to save the billing info
569
-     *
570
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
571
-     * @return EE_Form_Section_Proper|null
572
-     */
573
-    public function billing_info_for_payment_method($payment_method)
574
-    {
575
-        $pm_type = $payment_method->type_obj();
576
-        if (! $pm_type instanceof EE_PMT_Base) {
577
-            return null;
578
-        }
579
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
580
-        if (! $billing_info) {
581
-            return null;
582
-        }
583
-        $billing_form = $pm_type->billing_form();
584
-        if ($billing_form instanceof EE_Form_Section_Proper) {
585
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
586
-        }
587
-        return $billing_form;
588
-    }
589
-
590
-
591
-    /**
592
-     * Gets the postmeta key that holds this attendee's billing info for the
593
-     * specified payment method
594
-     *
595
-     * @param EE_Payment_Method $payment_method
596
-     * @return string
597
-     */
598
-    public function get_billing_info_postmeta_name($payment_method)
599
-    {
600
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
601
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
602
-        } else {
603
-            return null;
604
-        }
605
-    }
606
-
607
-
608
-    /**
609
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
610
-     * retrieve it
611
-     *
612
-     * @param EE_Billing_Attendee_Info_Form $billing_form
613
-     * @param EE_Payment_Method             $payment_method
614
-     * @return boolean
615
-     */
616
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
617
-    {
618
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
619
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
620
-            return false;
621
-        }
622
-        $billing_form->clean_sensitive_data();
623
-        return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
624
-            $billing_form->input_values(true));
625
-    }
626
-
627
-
628
-    /**
629
-     * Return the link to the admin details for the object.
630
-     *
631
-     * @return string
632
-     */
633
-    public function get_admin_details_link()
634
-    {
635
-        return $this->get_admin_edit_link();
636
-    }
637
-
638
-
639
-    /**
640
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
641
-     *
642
-     * @return string
643
-     */
644
-    public function get_admin_edit_link()
645
-    {
646
-        EE_Registry::instance()->load_helper('URL');
647
-        return EEH_URL::add_query_args_and_nonce(
648
-            array(
649
-                'page'   => 'espresso_registrations',
650
-                'action' => 'edit_attendee',
651
-                'post'   => $this->ID(),
652
-            ),
653
-            admin_url('admin.php')
654
-        );
655
-    }
656
-
657
-
658
-    /**
659
-     * Returns the link to a settings page for the object.
660
-     *
661
-     * @return string
662
-     */
663
-    public function get_admin_settings_link()
664
-    {
665
-        return $this->get_admin_edit_link();
666
-    }
667
-
668
-
669
-    /**
670
-     * Returns the link to the "overview" for the object (typically the "list table" view).
671
-     *
672
-     * @return string
673
-     */
674
-    public function get_admin_overview_link()
675
-    {
676
-        EE_Registry::instance()->load_helper('URL');
677
-        return EEH_URL::add_query_args_and_nonce(
678
-            array(
679
-                'page'   => 'espresso_registrations',
680
-                'action' => 'contact_list',
681
-            ),
682
-            admin_url('admin.php')
683
-        );
684
-    }
26
+	/**
27
+	 * Sets some dynamic defaults
28
+	 *
29
+	 * @param array  $fieldValues
30
+	 * @param bool   $bydb
31
+	 * @param string $timezone
32
+	 * @param array  $date_formats
33
+	 */
34
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
+	{
36
+		if (! isset($fieldValues['ATT_full_name'])) {
37
+			$fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
+			$lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
+			$fieldValues['ATT_full_name'] = $fname . $lname;
40
+		}
41
+		if (! isset($fieldValues['ATT_slug'])) {
42
+			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
+		}
45
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
+		}
48
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
+	}
50
+
51
+
52
+	/**
53
+	 * @param array  $props_n_values          incoming values
54
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
+	 *                                        used.)
56
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
+	 *                                        date_format and the second value is the time format
58
+	 * @return EE_Attendee
59
+	 */
60
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
+	{
62
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param array  $props_n_values  incoming values from the database
69
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
+	 *                                the website will be used.
71
+	 * @return EE_Attendee
72
+	 */
73
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
+	{
75
+		return new self($props_n_values, true, $timezone);
76
+	}
77
+
78
+
79
+	/**
80
+	 *        Set Attendee First Name
81
+	 *
82
+	 * @access        public
83
+	 * @param string $fname
84
+	 */
85
+	public function set_fname($fname = '')
86
+	{
87
+		$this->set('ATT_fname', $fname);
88
+	}
89
+
90
+
91
+	/**
92
+	 *        Set Attendee Last Name
93
+	 *
94
+	 * @access        public
95
+	 * @param string $lname
96
+	 */
97
+	public function set_lname($lname = '')
98
+	{
99
+		$this->set('ATT_lname', $lname);
100
+	}
101
+
102
+
103
+	/**
104
+	 *        Set Attendee Address
105
+	 *
106
+	 * @access        public
107
+	 * @param string $address
108
+	 */
109
+	public function set_address($address = '')
110
+	{
111
+		$this->set('ATT_address', $address);
112
+	}
113
+
114
+
115
+	/**
116
+	 *        Set Attendee Address2
117
+	 *
118
+	 * @access        public
119
+	 * @param        string $address2
120
+	 */
121
+	public function set_address2($address2 = '')
122
+	{
123
+		$this->set('ATT_address2', $address2);
124
+	}
125
+
126
+
127
+	/**
128
+	 *        Set Attendee City
129
+	 *
130
+	 * @access        public
131
+	 * @param        string $city
132
+	 */
133
+	public function set_city($city = '')
134
+	{
135
+		$this->set('ATT_city', $city);
136
+	}
137
+
138
+
139
+	/**
140
+	 *        Set Attendee State ID
141
+	 *
142
+	 * @access        public
143
+	 * @param        int $STA_ID
144
+	 */
145
+	public function set_state($STA_ID = 0)
146
+	{
147
+		$this->set('STA_ID', $STA_ID);
148
+	}
149
+
150
+
151
+	/**
152
+	 *        Set Attendee Country ISO Code
153
+	 *
154
+	 * @access        public
155
+	 * @param        string $CNT_ISO
156
+	 */
157
+	public function set_country($CNT_ISO = '')
158
+	{
159
+		$this->set('CNT_ISO', $CNT_ISO);
160
+	}
161
+
162
+
163
+	/**
164
+	 *        Set Attendee Zip/Postal Code
165
+	 *
166
+	 * @access        public
167
+	 * @param        string $zip
168
+	 */
169
+	public function set_zip($zip = '')
170
+	{
171
+		$this->set('ATT_zip', $zip);
172
+	}
173
+
174
+
175
+	/**
176
+	 *        Set Attendee Email Address
177
+	 *
178
+	 * @access        public
179
+	 * @param        string $email
180
+	 */
181
+	public function set_email($email = '')
182
+	{
183
+		$this->set('ATT_email', $email);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Phone
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $phone
192
+	 */
193
+	public function set_phone($phone = '')
194
+	{
195
+		$this->set('ATT_phone', $phone);
196
+	}
197
+
198
+
199
+	/**
200
+	 *        set deleted
201
+	 *
202
+	 * @access        public
203
+	 * @param        bool $ATT_deleted
204
+	 */
205
+	public function set_deleted($ATT_deleted = false)
206
+	{
207
+		$this->set('ATT_deleted', $ATT_deleted);
208
+	}
209
+
210
+
211
+	/**
212
+	 * Returns the value for the post_author id saved with the cpt
213
+	 *
214
+	 * @since 4.5.0
215
+	 * @return int
216
+	 */
217
+	public function wp_user()
218
+	{
219
+		return $this->get('ATT_author');
220
+	}
221
+
222
+
223
+	/**
224
+	 *        get Attendee First Name
225
+	 *
226
+	 * @access        public
227
+	 * @return string
228
+	 */
229
+	public function fname()
230
+	{
231
+		return $this->get('ATT_fname');
232
+	}
233
+
234
+
235
+	/**
236
+	 * echoes out the attendee's first name
237
+	 *
238
+	 * @return void
239
+	 */
240
+	public function e_full_name()
241
+	{
242
+		echo $this->full_name();
243
+	}
244
+
245
+
246
+	/**
247
+	 * Returns the first and last name concatenated together with a space.
248
+	 *
249
+	 * @param bool $apply_html_entities
250
+	 * @return string
251
+	 */
252
+	public function full_name($apply_html_entities = false)
253
+	{
254
+		$full_name = $this->fname() . ' ' . $this->lname();
255
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256
+	}
257
+
258
+
259
+	/**
260
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
261
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
262
+	 * attendee.
263
+	 *
264
+	 * @param bool $apply_html_entities
265
+	 * @return string
266
+	 */
267
+	public function ATT_full_name($apply_html_entities = false)
268
+	{
269
+		return $apply_html_entities
270
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
271
+			: $this->get('ATT_full_name');
272
+	}
273
+
274
+
275
+	/**
276
+	 *        get Attendee Last Name
277
+	 *
278
+	 * @access        public
279
+	 * @return string
280
+	 */
281
+	public function lname()
282
+	{
283
+		return $this->get('ATT_lname');
284
+	}
285
+
286
+
287
+	/**
288
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
289
+	 *
290
+	 * @return array numerically indexed, with each part of the address that is known.
291
+	 * Eg, if the user only responded to state and country,
292
+	 * it would be array(0=>'Alabama',1=>'USA')
293
+	 * @return array
294
+	 */
295
+	public function full_address_as_array()
296
+	{
297
+		$full_address_array     = array();
298
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
299
+		foreach ($initial_address_fields as $address_field_name) {
300
+			$address_fields_value = $this->get($address_field_name);
301
+			if (! empty($address_fields_value)) {
302
+				$full_address_array[] = $address_fields_value;
303
+			}
304
+		}
305
+		//now handle state and country
306
+		$state_obj = $this->state_obj();
307
+		if (! empty($state_obj)) {
308
+			$full_address_array[] = $state_obj->name();
309
+		}
310
+		$country_obj = $this->country_obj();
311
+		if (! empty($country_obj)) {
312
+			$full_address_array[] = $country_obj->name();
313
+		}
314
+		//lastly get the xip
315
+		$zip_value = $this->zip();
316
+		if (! empty($zip_value)) {
317
+			$full_address_array[] = $zip_value;
318
+		}
319
+		return $full_address_array;
320
+	}
321
+
322
+
323
+	/**
324
+	 *        get Attendee Address
325
+	 *
326
+	 * @return string
327
+	 */
328
+	public function address()
329
+	{
330
+		return $this->get('ATT_address');
331
+	}
332
+
333
+
334
+	/**
335
+	 *        get Attendee Address2
336
+	 *
337
+	 * @return string
338
+	 */
339
+	public function address2()
340
+	{
341
+		return $this->get('ATT_address2');
342
+	}
343
+
344
+
345
+	/**
346
+	 *        get Attendee City
347
+	 *
348
+	 * @return string
349
+	 */
350
+	public function city()
351
+	{
352
+		return $this->get('ATT_city');
353
+	}
354
+
355
+
356
+	/**
357
+	 *        get Attendee State ID
358
+	 *
359
+	 * @return string
360
+	 */
361
+	public function state_ID()
362
+	{
363
+		return $this->get('STA_ID');
364
+	}
365
+
366
+
367
+	/**
368
+	 * @return string
369
+	 */
370
+	public function state_abbrev()
371
+	{
372
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
373
+	}
374
+
375
+
376
+	/**
377
+	 * Gets the state set to this attendee
378
+	 *
379
+	 * @return EE_State
380
+	 */
381
+	public function state_obj()
382
+	{
383
+		return $this->get_first_related('State');
384
+	}
385
+
386
+
387
+	/**
388
+	 * Returns the state's name, otherwise 'Unknown'
389
+	 *
390
+	 * @return string
391
+	 */
392
+	public function state_name()
393
+	{
394
+		if ($this->state_obj()) {
395
+			return $this->state_obj()->name();
396
+		} else {
397
+			return '';
398
+		}
399
+	}
400
+
401
+
402
+	/**
403
+	 * either displays the state abbreviation or the state name, as determined
404
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
405
+	 * defaults to abbreviation
406
+	 *
407
+	 * @return string
408
+	 */
409
+	public function state()
410
+	{
411
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
412
+			return $this->state_abbrev();
413
+		} else {
414
+			return $this->state_name();
415
+		}
416
+	}
417
+
418
+
419
+	/**
420
+	 *    get Attendee Country ISO Code
421
+	 *
422
+	 * @return string
423
+	 */
424
+	public function country_ID()
425
+	{
426
+		return $this->get('CNT_ISO');
427
+	}
428
+
429
+
430
+	/**
431
+	 * Gets country set for this attendee
432
+	 *
433
+	 * @return EE_Country
434
+	 */
435
+	public function country_obj()
436
+	{
437
+		return $this->get_first_related('Country');
438
+	}
439
+
440
+
441
+	/**
442
+	 * Returns the country's name if known, otherwise 'Unknown'
443
+	 *
444
+	 * @return string
445
+	 */
446
+	public function country_name()
447
+	{
448
+		if ($this->country_obj()) {
449
+			return $this->country_obj()->name();
450
+		} else {
451
+			return '';
452
+		}
453
+	}
454
+
455
+
456
+	/**
457
+	 * either displays the country ISO2 code or the country name, as determined
458
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
459
+	 * defaults to abbreviation
460
+	 *
461
+	 * @return string
462
+	 */
463
+	public function country()
464
+	{
465
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
466
+			return $this->country_ID();
467
+		} else {
468
+			return $this->country_name();
469
+		}
470
+	}
471
+
472
+
473
+	/**
474
+	 *        get Attendee Zip/Postal Code
475
+	 *
476
+	 * @return string
477
+	 */
478
+	public function zip()
479
+	{
480
+		return $this->get('ATT_zip');
481
+	}
482
+
483
+
484
+	/**
485
+	 *        get Attendee Email Address
486
+	 *
487
+	 * @return string
488
+	 */
489
+	public function email()
490
+	{
491
+		return $this->get('ATT_email');
492
+	}
493
+
494
+
495
+	/**
496
+	 *        get Attendee Phone #
497
+	 *
498
+	 * @return string
499
+	 */
500
+	public function phone()
501
+	{
502
+		return $this->get('ATT_phone');
503
+	}
504
+
505
+
506
+	/**
507
+	 *    get deleted
508
+	 *
509
+	 * @return        bool
510
+	 */
511
+	public function deleted()
512
+	{
513
+		return $this->get('ATT_deleted');
514
+	}
515
+
516
+
517
+	/**
518
+	 * Gets registrations of this attendee
519
+	 *
520
+	 * @param array $query_params
521
+	 * @return EE_Registration[]
522
+	 */
523
+	public function get_registrations($query_params = array())
524
+	{
525
+		return $this->get_many_related('Registration', $query_params);
526
+	}
527
+
528
+
529
+	/**
530
+	 * Gets the most recent registration of this attendee
531
+	 *
532
+	 * @return EE_Registration
533
+	 */
534
+	public function get_most_recent_registration()
535
+	{
536
+		return $this->get_first_related('Registration',
537
+			array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
538
+	}
539
+
540
+
541
+	/**
542
+	 * Gets the most recent registration for this attend at this event
543
+	 *
544
+	 * @param int $event_id
545
+	 * @return EE_Registration
546
+	 */
547
+	public function get_most_recent_registration_for_event($event_id)
548
+	{
549
+		return $this->get_first_related('Registration',
550
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
551
+	}
552
+
553
+
554
+	/**
555
+	 * returns any events attached to this attendee ($_Event property);
556
+	 *
557
+	 * @return array
558
+	 */
559
+	public function events()
560
+	{
561
+		return $this->get_many_related('Event');
562
+	}
563
+
564
+
565
+	/**
566
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
567
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
568
+	 * used to save the billing info
569
+	 *
570
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
571
+	 * @return EE_Form_Section_Proper|null
572
+	 */
573
+	public function billing_info_for_payment_method($payment_method)
574
+	{
575
+		$pm_type = $payment_method->type_obj();
576
+		if (! $pm_type instanceof EE_PMT_Base) {
577
+			return null;
578
+		}
579
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
580
+		if (! $billing_info) {
581
+			return null;
582
+		}
583
+		$billing_form = $pm_type->billing_form();
584
+		if ($billing_form instanceof EE_Form_Section_Proper) {
585
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
586
+		}
587
+		return $billing_form;
588
+	}
589
+
590
+
591
+	/**
592
+	 * Gets the postmeta key that holds this attendee's billing info for the
593
+	 * specified payment method
594
+	 *
595
+	 * @param EE_Payment_Method $payment_method
596
+	 * @return string
597
+	 */
598
+	public function get_billing_info_postmeta_name($payment_method)
599
+	{
600
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
601
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
602
+		} else {
603
+			return null;
604
+		}
605
+	}
606
+
607
+
608
+	/**
609
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
610
+	 * retrieve it
611
+	 *
612
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
613
+	 * @param EE_Payment_Method             $payment_method
614
+	 * @return boolean
615
+	 */
616
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
617
+	{
618
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
619
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
620
+			return false;
621
+		}
622
+		$billing_form->clean_sensitive_data();
623
+		return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
624
+			$billing_form->input_values(true));
625
+	}
626
+
627
+
628
+	/**
629
+	 * Return the link to the admin details for the object.
630
+	 *
631
+	 * @return string
632
+	 */
633
+	public function get_admin_details_link()
634
+	{
635
+		return $this->get_admin_edit_link();
636
+	}
637
+
638
+
639
+	/**
640
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
641
+	 *
642
+	 * @return string
643
+	 */
644
+	public function get_admin_edit_link()
645
+	{
646
+		EE_Registry::instance()->load_helper('URL');
647
+		return EEH_URL::add_query_args_and_nonce(
648
+			array(
649
+				'page'   => 'espresso_registrations',
650
+				'action' => 'edit_attendee',
651
+				'post'   => $this->ID(),
652
+			),
653
+			admin_url('admin.php')
654
+		);
655
+	}
656
+
657
+
658
+	/**
659
+	 * Returns the link to a settings page for the object.
660
+	 *
661
+	 * @return string
662
+	 */
663
+	public function get_admin_settings_link()
664
+	{
665
+		return $this->get_admin_edit_link();
666
+	}
667
+
668
+
669
+	/**
670
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
671
+	 *
672
+	 * @return string
673
+	 */
674
+	public function get_admin_overview_link()
675
+	{
676
+		EE_Registry::instance()->load_helper('URL');
677
+		return EEH_URL::add_query_args_and_nonce(
678
+			array(
679
+				'page'   => 'espresso_registrations',
680
+				'action' => 'contact_list',
681
+			),
682
+			admin_url('admin.php')
683
+		);
684
+	}
685 685
 
686 686
 
687 687
 }
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -588,6 +588,7 @@  discard block
 block discarded – undo
588 588
 	 * @param EE_Registration $registration
589 589
 	 * @param EE_Question     $question
590 590
 	 * @param                 mixed EE_Answer|NULL      $answer
591
+	 * @param EE_Answer $answer
591 592
 	 * @return EE_Form_Input_Base
592 593
 	 * @throws \EE_Error
593 594
 	 */
@@ -1190,7 +1191,7 @@  discard block
 block discarded – undo
1190 1191
 	 *
1191 1192
 	 * @param EE_Registration $registration
1192 1193
 	 * @param array           $attendee_data
1193
-	 * @return boolean|EE_Attendee
1194
+	 * @return EE_Attendee
1194 1195
 	 * @throws \EE_Error
1195 1196
 	 */
1196 1197
 	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1012,7 +1012,7 @@
 block discarded – undo
1012 1012
 					$this->_associate_registration_with_transaction( $registration );
1013 1013
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1014 1014
 
1015
-			}  else {
1015
+			} else {
1016 1016
 				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1017 1017
 				// remove malformed data
1018 1018
 				unset( $valid_data[ $reg_url_link ] );
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Reg_Step_Attendee_Information
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	core
10
- * @author 				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Reg_Step_Attendee_Information
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage 	core
10
+  * @author 				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step {
15 15
 
16 16
 	/**
@@ -135,28 +135,28 @@  discard block
 block discarded – undo
135 135
 					$registration instanceof EE_Registration
136 136
 					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
137 137
 				) {
138
-                    $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139
-                    if ( ! $this->checkout->admin_request) {
140
-                        $template_args['registrations'][$registration->reg_url_link()] = $registration;
141
-                        $template_args['ticket_count'][$registration->ticket()->ID()] = isset(
142
-                            $template_args['ticket_count'][$registration->ticket()->ID()]
143
-                        )
144
-                            ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
145
-                            : 1;
146
-                        $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
147
-                            $this->checkout->cart->get_grand_total(),
148
-                            'Ticket',
149
-                            array($registration->ticket()->ID())
150
-                        );
151
-                        $ticket_line_item = is_array($ticket_line_item)
152
-                            ? reset($ticket_line_item)
153
-                            : $ticket_line_item;
154
-                        $template_args['ticket_line_item'][$registration->ticket()->ID()] =
155
-                            $Line_Item_Display->display_line_item($ticket_line_item);
156
-                    }
157
-                    if ($registration->is_primary_registrant()) {
158
-                        $primary_registrant = $registration->reg_url_link();
159
-                    }
138
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139
+					if ( ! $this->checkout->admin_request) {
140
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
141
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
142
+							$template_args['ticket_count'][$registration->ticket()->ID()]
143
+						)
144
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
145
+							: 1;
146
+						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
147
+							$this->checkout->cart->get_grand_total(),
148
+							'Ticket',
149
+							array($registration->ticket()->ID())
150
+						);
151
+						$ticket_line_item = is_array($ticket_line_item)
152
+							? reset($ticket_line_item)
153
+							: $ticket_line_item;
154
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] =
155
+							$Line_Item_Display->display_line_item($ticket_line_item);
156
+					}
157
+					if ($registration->is_primary_registrant()) {
158
+						$primary_registrant = $registration->reg_url_link();
159
+					}
160 160
 				}
161 161
 			}
162 162
 			// print_copy_info ?
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 				// generate hidden input
169 169
 				if (
170 170
 					isset( $subsections[ $primary_registrant ] )
171
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
171
+					 && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
172 172
 				) {
173 173
 					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
174 174
 				}
@@ -196,42 +196,42 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 
199
-    /**
199
+	/**
200 200
 	 * @param EE_Registration $registration
201 201
 	 * @return EE_Form_Section_Base
202 202
 	 * @throws \EE_Error
203 203
 	 */
204 204
 	private function _registrations_reg_form( EE_Registration $registration ) {
205 205
 		static $attendee_nmbr = 1;
206
-        $form_args = array();
206
+		$form_args = array();
207 207
 		// verify that registration has valid event
208 208
 		if ( $registration->event() instanceof EE_Event ) {
209 209
 			$question_groups = $registration->event()->question_groups(
210
-                array(
211
-                    array(
212
-                        'Event.EVT_ID'                     => $registration->event()->ID(),
213
-                        'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
214
-                    ),
215
-                    'order_by' => array('QSG_order' => 'ASC')
216
-                )
217
-            );
210
+				array(
211
+					array(
212
+						'Event.EVT_ID'                     => $registration->event()->ID(),
213
+						'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
214
+					),
215
+					'order_by' => array('QSG_order' => 'ASC')
216
+				)
217
+			);
218 218
 			if ( $question_groups ) {
219
-                // array of params to pass to parent constructor
220
-                $form_args = array(
221
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
222
-                    'html_class'      => 'ee-reg-form-attendee-dv',
223
-                    'html_style'      => $this->checkout->admin_request
224
-                        ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
225
-                        : '',
226
-                    'subsections'     => array(),
227
-                    'layout_strategy' => new EE_Fieldset_Section_Layout(
228
-                        array(
229
-                            'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
230
-                            'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
231
-                        )
232
-                    )
233
-                );
234
-                foreach ( $question_groups as $question_group ) {
219
+				// array of params to pass to parent constructor
220
+				$form_args = array(
221
+					'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
222
+					'html_class'      => 'ee-reg-form-attendee-dv',
223
+					'html_style'      => $this->checkout->admin_request
224
+						? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
225
+						: '',
226
+					'subsections'     => array(),
227
+					'layout_strategy' => new EE_Fieldset_Section_Layout(
228
+						array(
229
+							'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
230
+							'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
231
+						)
232
+					)
233
+				);
234
+				foreach ( $question_groups as $question_group ) {
235 235
 					if ( $question_group instanceof EE_Question_Group ) {
236 236
 						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
237 237
 							$registration,
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
 						);
240 240
 					}
241 241
 				}
242
-                // add hidden input
243
-                $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
244
-                    $registration
245
-                );
246
-                // if we have question groups for additional attendees, then display the copy options
242
+				// add hidden input
243
+				$form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input(
244
+					$registration
245
+				);
246
+				// if we have question groups for additional attendees, then display the copy options
247 247
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
248
-                if ($registration->is_primary_registrant()) {
249
-                    // generate hidden input
250
-                    $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
251
-                }
252
-            }
248
+				if ($registration->is_primary_registrant()) {
249
+					// generate hidden input
250
+					$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
251
+				}
252
+			}
253 253
 		}
254
-        $attendee_nmbr++;
254
+		$attendee_nmbr++;
255 255
 		return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML();
256 256
 	}
257 257
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 					if ( isset( $valid_data[ $reg_url_link ] ) ) {
885 885
 						// do we need to copy basic info from primary attendee ?
886 886
 						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
887
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
887
+										&& absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
888 888
 							? true
889 889
 							: false;
890 890
 						// filter form input data for this registration
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 		) ) {
1055 1055
 			return true;
1056 1056
 		}
1057
-        /*
1057
+		/*
1058 1058
          * $answer_cache_id is the key used to find the EE_Answer we want
1059 1059
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1060 1060
          */
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 			? $form_input . '-' . $registration->reg_url_link()
1063 1063
 			: $form_input;
1064 1064
 		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1065
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1065
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1066 1066
 			? true
1067 1067
 			: false;
1068 1068
 		//rename form_inputs if they are EE_Attendee properties
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 		// then attempt to copy them from the primary attendee
1183 1183
 		if (
1184 1184
 			$this->checkout->primary_attendee_obj instanceof EE_Attendee
1185
-            && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1185
+			&& ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1186 1186
 		) {
1187 1187
 			return $this->checkout->primary_attendee_obj;
1188 1188
 		}
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
 		}
1301 1301
 		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1302 1302
 			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1303
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1303
+				 || empty( $attendee_data[ $critical_attendee_detail ] )
1304 1304
 			) {
1305 1305
 				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1306 1306
 					$critical_attendee_detail
Please login to merge, or discard this patch.
Spacing   +211 added lines, -212 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 	 * @access    public
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 */
44
-	public function __construct( EE_Checkout $checkout ) {
44
+	public function __construct(EE_Checkout $checkout) {
45 45
 		$this->_slug = 'attendee_information';
46 46
 		$this->_name = __('Attendee Information', 'event_espresso');
47
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
47
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
48 48
 		$this->checkout = $checkout;
49 49
 		$this->_reset_success_message();
50 50
 		$this->set_instructions(
51
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
51
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
52 52
 		);
53 53
 	}
54 54
 
55 55
 
56 56
 
57 57
 	public function translate_js_strings() {
58
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
58
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
59 59
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
60 60
 			' is a required question. Please enter a value for at least one of the options.',
61 61
 			'event_espresso'
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		// calculate taxes
116 116
 		$Line_Item_Display->display_line_item(
117 117
 			$this->checkout->cart->get_grand_total(),
118
-			array( 'set_tax_rate' => true )
118
+			array('set_tax_rate' => true)
119 119
 		);
120 120
 		/** @var $subsections EE_Form_Section_Proper[] */
121 121
 		$subsections = array(
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 			'ticket_count' 	=> array()
128 128
 		);
129 129
 		// grab the saved registrations from the transaction
130
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
131
-		if ( $registrations ) {
132
-			foreach ( $registrations as $registration ) {
130
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
131
+		if ($registrations) {
132
+			foreach ($registrations as $registration) {
133 133
 				// can this registration be processed during this visit ?
134 134
 				if (
135 135
 					$registration instanceof EE_Registration
136
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
136
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
137 137
 				) {
138 138
                     $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
139 139
                     if ( ! $this->checkout->admin_request) {
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 				}
161 161
 			}
162 162
 			// print_copy_info ?
163
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
163
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
164 164
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
165 165
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
166 166
 					? $this->_copy_attendee_info_form()
167 167
 					: $this->_auto_copy_attendee_info();
168 168
 				// generate hidden input
169 169
 				if (
170
-					isset( $subsections[ $primary_registrant ] )
171
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
170
+					isset($subsections[$primary_registrant])
171
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
172 172
 				) {
173
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
173
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
174 174
 				}
175 175
 			}
176 176
 
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
 				'html_id' 					=> $this->reg_form_name(),
183 183
 				'subsections' 			=> $subsections,
184 184
 				'layout_strategy'		=> $this->checkout->admin_request ?
185
-					new EE_Div_Per_Section_Layout() :
186
-					new EE_Template_Layout(
185
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
187 186
 						array(
188 187
 							'layout_template_file' 	=> $this->_template, // layout_template
189 188
 							'template_args' 				=> $template_args
@@ -201,11 +200,11 @@  discard block
 block discarded – undo
201 200
 	 * @return EE_Form_Section_Base
202 201
 	 * @throws \EE_Error
203 202
 	 */
204
-	private function _registrations_reg_form( EE_Registration $registration ) {
203
+	private function _registrations_reg_form(EE_Registration $registration) {
205 204
 		static $attendee_nmbr = 1;
206 205
         $form_args = array();
207 206
 		// verify that registration has valid event
208
-		if ( $registration->event() instanceof EE_Event ) {
207
+		if ($registration->event() instanceof EE_Event) {
209 208
 			$question_groups = $registration->event()->question_groups(
210 209
                 array(
211 210
                     array(
@@ -215,10 +214,10 @@  discard block
 block discarded – undo
215 214
                     'order_by' => array('QSG_order' => 'ASC')
216 215
                 )
217 216
             );
218
-			if ( $question_groups ) {
217
+			if ($question_groups) {
219 218
                 // array of params to pass to parent constructor
220 219
                 $form_args = array(
221
-                    'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
220
+                    'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
222 221
                     'html_class'      => 'ee-reg-form-attendee-dv',
223 222
                     'html_style'      => $this->checkout->admin_request
224 223
                         ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -231,9 +230,9 @@  discard block
 block discarded – undo
231 230
                         )
232 231
                     )
233 232
                 );
234
-                foreach ( $question_groups as $question_group ) {
235
-					if ( $question_group instanceof EE_Question_Group ) {
236
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
233
+                foreach ($question_groups as $question_group) {
234
+					if ($question_group instanceof EE_Question_Group) {
235
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
237 236
 							$registration,
238 237
 							$question_group
239 238
 						);
@@ -252,7 +251,7 @@  discard block
 block discarded – undo
252 251
             }
253 252
 		}
254 253
         $attendee_nmbr++;
255
-		return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML();
254
+		return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML();
256 255
 	}
257 256
 
258 257
 
@@ -273,7 +272,7 @@  discard block
 block discarded – undo
273 272
 		// generate hidden input
274 273
 		return new EE_Hidden_Input(
275 274
 			array(
276
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
275
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
277 276
 				'default' => $additional_attendee_reg_info
278 277
 			)
279 278
 		);
@@ -287,26 +286,26 @@  discard block
 block discarded – undo
287 286
 	 * @return EE_Form_Section_Proper
288 287
 	 * @throws \EE_Error
289 288
 	 */
290
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
289
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
291 290
 		// array of params to pass to parent constructor
292 291
 		$form_args = array(
293
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
292
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
294 293
 			'html_class'      => $this->checkout->admin_request
295 294
 				? 'form-table ee-reg-form-qstn-grp-dv'
296 295
 				: 'ee-reg-form-qstn-grp-dv',
297
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
296
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
298 297
 			'subsections'     => array(
299
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
298
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
300 299
 			),
301 300
 			'layout_strategy' => $this->checkout->admin_request
302 301
 				? new EE_Admin_Two_Column_Layout()
303 302
 				: new EE_Div_Per_Section_Layout()
304 303
 		);
305 304
 		// where params
306
-		$query_params = array( 'QST_deleted' => 0 );
305
+		$query_params = array('QST_deleted' => 0);
307 306
 		// don't load admin only questions on the frontend
308
-		if ( ! $this->checkout->admin_request ) {
309
-			$query_params['QST_admin_only'] = array( '!=', true );
307
+		if ( ! $this->checkout->admin_request) {
308
+			$query_params['QST_admin_only'] = array('!=', true);
310 309
 		}
311 310
 		$questions = $question_group->get_many_related(
312 311
 			'Question',
@@ -328,10 +327,10 @@  discard block
 block discarded – undo
328 327
 			)
329 328
 		);
330 329
 		// loop thru questions
331
-		foreach ( $questions as $question ) {
332
-			if( $question instanceof EE_Question ){
330
+		foreach ($questions as $question) {
331
+			if ($question instanceof EE_Question) {
333 332
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
334
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
333
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
335 334
 			}
336 335
 		}
337 336
 		$form_args['subsections'] = apply_filters(
@@ -352,7 +351,7 @@  discard block
 block discarded – undo
352 351
 			)
353 352
 		);
354 353
 //		d( $form_args );
355
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
354
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
356 355
 		return apply_filters(
357 356
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
358 357
 			$question_group_reg_form,
@@ -369,11 +368,11 @@  discard block
 block discarded – undo
369 368
 	 * @param EE_Question_Group $question_group
370 369
 	 * @return 	EE_Form_Section_HTML
371 370
 	 */
372
-	private function _question_group_header( EE_Question_Group $question_group ){
371
+	private function _question_group_header(EE_Question_Group $question_group) {
373 372
 		$html = '';
374 373
 		// group_name
375
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
376
-			if ( $this->checkout->admin_request ) {
374
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
375
+			if ($this->checkout->admin_request) {
377 376
 				$html .= EEH_HTML::br();
378 377
 				$html .= EEH_HTML::h3(
379 378
 					$question_group->name(),
@@ -387,7 +386,7 @@  discard block
 block discarded – undo
387 386
 			}
388 387
 		}
389 388
 		// group_desc
390
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
389
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
391 390
 			$html .= EEH_HTML::p(
392 391
 				$question_group->desc(),
393 392
 				'',
@@ -397,7 +396,7 @@  discard block
 block discarded – undo
397 396
 			);
398 397
 
399 398
 		}
400
-		return new EE_Form_Section_HTML( $html );
399
+		return new EE_Form_Section_HTML($html);
401 400
 	}
402 401
 
403 402
 
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 	 * @return    EE_Form_Section_Proper
408 407
 	 * @throws \EE_Error
409 408
 	 */
410
-	private function _copy_attendee_info_form(){
409
+	private function _copy_attendee_info_form() {
411 410
 		// array of params to pass to parent constructor
412 411
 		return new EE_Form_Section_Proper(
413 412
 			array(
@@ -436,7 +435,7 @@  discard block
 block discarded – undo
436 435
 	private function _auto_copy_attendee_info() {
437 436
 		return new EE_Form_Section_HTML(
438 437
 			EEH_Template::locate_template(
439
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
438
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
440 439
 				apply_filters(
441 440
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
442 441
 					array()
@@ -460,32 +459,32 @@  discard block
 block discarded – undo
460 459
 		$copy_attendee_info_inputs = array();
461 460
 		$prev_ticket = NULL;
462 461
 		// grab the saved registrations from the transaction
463
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
464
-		foreach ( $registrations as $registration ) {
462
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
463
+		foreach ($registrations as $registration) {
465 464
 			// for all  attendees other than the primary attendee
466
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
465
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
467 466
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
468
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
467
+				if ($registration->ticket()->ID() !== $prev_ticket) {
469 468
 					$item_name = $registration->ticket()->name();
470 469
 					$item_name .= $registration->ticket()->description() !== ''
471
-						? ' - ' . $registration->ticket()->description()
470
+						? ' - '.$registration->ticket()->description()
472 471
 						: '';
473
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
474
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
472
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
473
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
475 474
 					);
476 475
 					$prev_ticket = $registration->ticket()->ID();
477 476
 				}
478 477
 
479
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
478
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
480 479
 				EE_Checkbox_Multi_Input(
481 480
 					array(
482 481
 						$registration->ID() => sprintf(
483
-							__( 'Attendee #%s', 'event_espresso' ),
482
+							__('Attendee #%s', 'event_espresso'),
484 483
 							$registration->count()
485 484
 						)
486 485
 					),
487 486
 					array(
488
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
487
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
489 488
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
490 489
 						'display_html_label_text' => false
491 490
 					)
@@ -505,7 +504,7 @@  discard block
 block discarded – undo
505 504
 	 * @return    EE_Form_Input_Base
506 505
 	 * @throws \EE_Error
507 506
 	 */
508
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
507
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
509 508
 		// generate hidden input
510 509
 		return new EE_Hidden_Input(
511 510
 			array(
@@ -524,7 +523,7 @@  discard block
 block discarded – undo
524 523
 	 * @return    EE_Form_Input_Base
525 524
 	 * @throws \EE_Error
526 525
 	 */
527
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
526
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
528 527
 
529 528
 		// if this question was for an attendee detail, then check for that answer
530 529
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -533,32 +532,32 @@  discard block
 block discarded – undo
533 532
 		);
534 533
 		$answer = $answer_value === null
535 534
 			? EEM_Answer::instance()->get_one(
536
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
535
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
537 536
 			)
538 537
 			: null;
539 538
 		// if NOT returning to edit an existing registration
540 539
 		// OR if this question is for an attendee property
541 540
 		// OR we still don't have an EE_Answer object
542
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
541
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
543 542
 			// create an EE_Answer object for storing everything in
544
-			$answer = EE_Answer::new_instance ( array(
543
+			$answer = EE_Answer::new_instance(array(
545 544
 				'QST_ID'=> $question->ID(),
546 545
 				'REG_ID'=> $registration->ID()
547 546
 			));
548 547
 		}
549 548
 		// verify instance
550
-		if( $answer instanceof EE_Answer ){
551
-			if ( ! empty( $answer_value )) {
552
-				$answer->set( 'ANS_value', $answer_value );
549
+		if ($answer instanceof EE_Answer) {
550
+			if ( ! empty($answer_value)) {
551
+				$answer->set('ANS_value', $answer_value);
553 552
 			}
554
-			$answer->cache( 'Question', $question );
553
+			$answer->cache('Question', $question);
555 554
 			//remember system ID had a bug where sometimes it could be null
556
-			$answer_cache_id =$question->is_system_question()
557
-				? $question->system_ID() . '-' . $registration->reg_url_link()
558
-				: $question->ID() . '-' . $registration->reg_url_link();
559
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
555
+			$answer_cache_id = $question->is_system_question()
556
+				? $question->system_ID().'-'.$registration->reg_url_link()
557
+				: $question->ID().'-'.$registration->reg_url_link();
558
+			$registration->cache('Answer', $answer, $answer_cache_id);
560 559
 		}
561
-		return $this->_generate_question_input( $registration, $question, $answer );
560
+		return $this->_generate_question_input($registration, $question, $answer);
562 561
 
563 562
 	}
564 563
 
@@ -571,46 +570,46 @@  discard block
 block discarded – undo
571 570
 	 * @return EE_Form_Input_Base
572 571
 	 * @throws \EE_Error
573 572
 	 */
574
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
573
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
575 574
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
576
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
575
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
577 576
 		add_filter(
578 577
 			'FHEE__EE_Question__generate_form_input__country_options',
579
-			array( $this, 'use_cached_countries_for_form_input' ),
578
+			array($this, 'use_cached_countries_for_form_input'),
580 579
 			10,
581 580
 			4
582 581
 		);
583 582
 		add_filter(
584 583
 			'FHEE__EE_Question__generate_form_input__state_options',
585
-			array( $this, 'use_cached_states_for_form_input' ),
584
+			array($this, 'use_cached_states_for_form_input'),
586 585
 			10,
587 586
 			4
588 587
 		);
589 588
 		$input_constructor_args = array(
590
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
591
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
592
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
593
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
589
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
590
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
591
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
592
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
594 593
 			'html_label_class'	=> 'ee-reg-qstn',
595 594
 		);
596
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
597
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
598
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
599
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
600
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
595
+		$input_constructor_args['html_label_id'] .= '-lbl';
596
+		if ($answer instanceof EE_Answer && $answer->ID()) {
597
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
598
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
599
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
601 600
 		}
602
-		$form_input =  $question->generate_form_input(
601
+		$form_input = $question->generate_form_input(
603 602
 			$registration,
604 603
 			$answer,
605 604
 			$input_constructor_args
606 605
 		);
607 606
 		remove_filter(
608 607
 			'FHEE__EE_Question__generate_form_input__country_options',
609
-			array( $this, 'use_cached_countries_for_form_input' )
608
+			array($this, 'use_cached_countries_for_form_input')
610 609
 		);
611 610
 		remove_filter(
612 611
 			'FHEE__EE_Question__generate_form_input__state_options',
613
-			array( $this, 'use_cached_states_for_form_input' )
612
+			array($this, 'use_cached_states_for_form_input')
614 613
 		);
615 614
 		return $form_input;
616 615
 	}
@@ -632,22 +631,22 @@  discard block
 block discarded – undo
632 631
 		\EE_Registration $registration = null,
633 632
 		\EE_Answer $answer = null
634 633
 	) {
635
-		$country_options = array( '' => '' );
634
+		$country_options = array('' => '');
636 635
 		// get possibly cached list of countries
637 636
 		$countries = $this->checkout->action === 'process_reg_step'
638 637
 			? EEM_Country::instance()->get_all_countries()
639 638
 			: EEM_Country::instance()->get_all_active_countries();
640
-		if ( ! empty( $countries )) {
641
-			foreach( $countries as $country ){
642
-				if ( $country instanceof EE_Country ) {
643
-					$country_options[ $country->ID() ] = $country->name();
639
+		if ( ! empty($countries)) {
640
+			foreach ($countries as $country) {
641
+				if ($country instanceof EE_Country) {
642
+					$country_options[$country->ID()] = $country->name();
644 643
 				}
645 644
 			}
646 645
 		}
647
-		if( $question instanceof EE_Question
648
-			&& $registration instanceof EE_Registration ) {
646
+		if ($question instanceof EE_Question
647
+			&& $registration instanceof EE_Registration) {
649 648
 			$answer = EEM_Answer::instance()->get_one(
650
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
649
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
651 650
 			);
652 651
 		} else {
653 652
 			$answer = EE_Answer::new_instance();
@@ -680,14 +679,14 @@  discard block
 block discarded – undo
680 679
 		\EE_Registration $registration = null,
681 680
 		\EE_Answer $answer = null
682 681
 	) {
683
-		$state_options = array( '' => array( '' => ''));
682
+		$state_options = array('' => array('' => ''));
684 683
 		$states = $this->checkout->action === 'process_reg_step'
685 684
 			? EEM_State::instance()->get_all_states()
686 685
 			: EEM_State::instance()->get_all_active_states();
687
-		if ( ! empty( $states )) {
688
-			foreach( $states as $state ){
689
-				if ( $state instanceof EE_State ) {
690
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
686
+		if ( ! empty($states)) {
687
+			foreach ($states as $state) {
688
+				if ($state instanceof EE_State) {
689
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
691 690
 				}
692 691
 			}
693 692
 		}
@@ -715,24 +714,24 @@  discard block
 block discarded – undo
715 714
 	 * @throws \EE_Error
716 715
 	 */
717 716
 	public function process_reg_step() {
718
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
717
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
719 718
 		// grab validated data from form
720 719
 		$valid_data = $this->checkout->current_step->valid_data();
721 720
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
722 721
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
723 722
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
724
-		if ( empty( $valid_data ))  {
723
+		if (empty($valid_data)) {
725 724
 			EE_Error::add_error(
726
-				__( 'No valid question responses were received.', 'event_espresso' ),
725
+				__('No valid question responses were received.', 'event_espresso'),
727 726
 				__FILE__,
728 727
 				__FUNCTION__,
729 728
 				__LINE__
730 729
 			);
731 730
 			return false;
732 731
 		}
733
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
732
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
734 733
 			EE_Error::add_error(
735
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
734
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
736 735
 				__FILE__,
737 736
 				__FUNCTION__,
738 737
 				__LINE__
@@ -740,11 +739,11 @@  discard block
 block discarded – undo
740 739
 			return false;
741 740
 		}
742 741
 		// get cached registrations
743
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
742
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
744 743
 		// verify we got the goods
745
-		if ( empty( $registrations )) {
744
+		if (empty($registrations)) {
746 745
 			EE_Error::add_error(
747
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
746
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
748 747
 				__FILE__,
749 748
 				__FUNCTION__,
750 749
 				__LINE__
@@ -752,15 +751,15 @@  discard block
 block discarded – undo
752 751
 			return false;
753 752
 		}
754 753
 		// extract attendee info from form data and save to model objects
755
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
754
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
756 755
 		// if first pass thru SPCO,
757 756
 		// then let's check processed registrations against the total number of tickets in the cart
758
-		if ( $registrations_processed === false ) {
757
+		if ($registrations_processed === false) {
759 758
 			// but return immediately if the previous step exited early due to errors
760 759
 			return false;
761
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
760
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
762 761
 			// generate a correctly translated string for all possible singular/plural combinations
763
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
762
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
764 763
 				$error_msg = sprintf(
765 764
 					__(
766 765
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -769,7 +768,7 @@  discard block
 block discarded – undo
769 768
 					$this->checkout->total_ticket_count,
770 769
 					$registrations_processed
771 770
 				);
772
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
771
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
773 772
 				$error_msg = sprintf(
774 773
 					__(
775 774
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -788,17 +787,17 @@  discard block
 block discarded – undo
788 787
 					$registrations_processed
789 788
 				);
790 789
 			}
791
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
790
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
792 791
 			return false;
793 792
 		}
794 793
 		// mark this reg step as completed
795 794
 		$this->set_completed();
796 795
 		$this->_set_success_message(
797
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
796
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
798 797
 		);
799 798
 		//do action in case a plugin wants to do something with the data submitted in step 1.
800 799
 		//passes EE_Single_Page_Checkout, and it's posted data
801
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
800
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
802 801
 		return true;
803 802
 	}
804 803
 
@@ -812,9 +811,9 @@  discard block
 block discarded – undo
812 811
 	 * @return boolean | int
813 812
 	 * @throws \EE_Error
814 813
 	 */
815
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
814
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
816 815
 		// load resources and set some defaults
817
-		EE_Registry::instance()->load_model( 'Attendee' );
816
+		EE_Registry::instance()->load_model('Attendee');
818 817
 		// holder for primary registrant attendee object
819 818
 		$this->checkout->primary_attendee_obj = NULL;
820 819
 		// array for tracking reg form data for the primary registrant
@@ -831,9 +830,9 @@  discard block
 block discarded – undo
831 830
 		// attendee counter
832 831
 		$att_nmbr = 0;
833 832
 		// grab the saved registrations from the transaction
834
-		foreach ( $registrations  as $registration ) {
833
+		foreach ($registrations  as $registration) {
835 834
 			// verify EE_Registration object
836
-			if ( ! $registration instanceof EE_Registration ) {
835
+			if ( ! $registration instanceof EE_Registration) {
837 836
 				EE_Error::add_error(
838 837
 					__(
839 838
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -848,12 +847,12 @@  discard block
 block discarded – undo
848 847
 			/** @var string $reg_url_link */
849 848
 			$reg_url_link = $registration->reg_url_link();
850 849
 			// reg_url_link exists ?
851
-			if ( ! empty( $reg_url_link ) ) {
850
+			if ( ! empty($reg_url_link)) {
852 851
 				// should this registration be processed during this visit ?
853
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
852
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
854 853
 					// if NOT revisiting, then let's save the registration now,
855 854
 					// so that we have a REG_ID to use when generating other objects
856
-					if ( ! $this->checkout->revisit ) {
855
+					if ( ! $this->checkout->revisit) {
857 856
 						$registration->save();
858 857
 					}
859 858
 					/**
@@ -863,7 +862,7 @@  discard block
 block discarded – undo
863 862
 					 * @var bool   if true is returned by the plugin then the
864 863
 					 *      		registration processing is halted.
865 864
 					 */
866
-					if ( apply_filters(
865
+					if (apply_filters(
867 866
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
868 867
 						false,
869 868
 						$att_nmbr,
@@ -871,38 +870,38 @@  discard block
 block discarded – undo
871 870
 						$registrations,
872 871
 						$valid_data,
873 872
 						$this
874
-					) ) {
873
+					)) {
875 874
 						return false;
876 875
 					}
877 876
 
878 877
 					// Houston, we have a registration!
879 878
 					$att_nmbr++;
880
-					$this->_attendee_data[ $reg_url_link ] = array();
879
+					$this->_attendee_data[$reg_url_link] = array();
881 880
 					// grab any existing related answer objects
882 881
 					$this->_registration_answers = $registration->answers();
883 882
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
884
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
883
+					if (isset($valid_data[$reg_url_link])) {
885 884
 						// do we need to copy basic info from primary attendee ?
886
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
887
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
885
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
886
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
888 887
 							? true
889 888
 							: false;
890 889
 						// filter form input data for this registration
891
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
890
+						$valid_data[$reg_url_link] = (array) apply_filters(
892 891
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
893
-							$valid_data[ $reg_url_link ]
892
+							$valid_data[$reg_url_link]
894 893
 						);
895 894
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
896
-						if ( isset( $valid_data['primary_attendee'] )) {
897
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
895
+						if (isset($valid_data['primary_attendee'])) {
896
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
898 897
 								? $valid_data['primary_attendee']
899 898
 								: false;
900
-							unset( $valid_data['primary_attendee'] );
899
+							unset($valid_data['primary_attendee']);
901 900
 						}
902 901
 						// now loop through our array of valid post data && process attendee reg forms
903
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
904
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
905
-								foreach ( $form_inputs as $form_input => $input_value ) {
902
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
903
+							if ( ! in_array($form_section, $non_input_form_sections)) {
904
+								foreach ($form_inputs as $form_input => $input_value) {
906 905
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
907 906
 									// check for critical inputs
908 907
 									if (
@@ -916,16 +915,16 @@  discard block
 block discarded – undo
916 915
 									// store a bit of data about the primary attendee
917 916
 									if (
918 917
 										$att_nmbr === 1
919
-										&& ! empty( $input_value )
918
+										&& ! empty($input_value)
920 919
 										&& $reg_url_link === $primary_registrant['line_item_id']
921 920
 									) {
922
-										$primary_registrant[ $form_input ] = $input_value;
921
+										$primary_registrant[$form_input] = $input_value;
923 922
 									} else if (
924 923
 										$copy_primary
925 924
 										&& $input_value === null
926
-										&& isset( $primary_registrant[ $form_input ] )
925
+										&& isset($primary_registrant[$form_input])
927 926
 									) {
928
-										$input_value = $primary_registrant[ $form_input ];
927
+										$input_value = $primary_registrant[$form_input];
929 928
 									}
930 929
 									// now attempt to save the input data
931 930
 									if (
@@ -967,55 +966,55 @@  discard block
 block discarded – undo
967 966
 						// have we met before?
968 967
 						$attendee = $this->_find_existing_attendee(
969 968
 							$registration,
970
-							$this->_attendee_data[ $reg_url_link ]
969
+							$this->_attendee_data[$reg_url_link]
971 970
 						);
972 971
 						// did we find an already existing record for this attendee ?
973
-						if ( $attendee instanceof EE_Attendee ) {
972
+						if ($attendee instanceof EE_Attendee) {
974 973
 							$attendee = $this->_update_existing_attendee_data(
975 974
 								$attendee,
976
-								$this->_attendee_data[ $reg_url_link ]
975
+								$this->_attendee_data[$reg_url_link]
977 976
 							);
978 977
 						} else {
979 978
 							// ensure critical details are set for additional attendees
980
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
979
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
981 980
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
982
-									$this->_attendee_data[ $reg_url_link ]
981
+									$this->_attendee_data[$reg_url_link]
983 982
 								)
984
-								: $this->_attendee_data[ $reg_url_link ];
983
+								: $this->_attendee_data[$reg_url_link];
985 984
 							$attendee = $this->_create_new_attendee(
986 985
 								$registration,
987
-								$this->_attendee_data[ $reg_url_link ]
986
+								$this->_attendee_data[$reg_url_link]
988 987
 							);
989 988
 						}
990 989
 						// who's #1 ?
991
-						if ( $att_nmbr === 1 ) {
990
+						if ($att_nmbr === 1) {
992 991
 							$this->checkout->primary_attendee_obj = $attendee;
993 992
 						}
994 993
 					}
995 994
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
996 995
 					// add relation to registration, set attendee ID, and cache attendee
997
-					$this->_associate_attendee_with_registration( $registration, $attendee );
996
+					$this->_associate_attendee_with_registration($registration, $attendee);
998 997
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
999
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1000
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
998
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
999
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1001 1000
 						return false;
1002 1001
 					}
1003 1002
 					/** @type EE_Registration_Processor $registration_processor */
1004
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1003
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1005 1004
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1006
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1005
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1007 1006
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1008 1007
 					$this->checkout->transaction->toggle_failed_transaction_status();
1009 1008
 					// if we've gotten this far, then let's save what we have
1010 1009
 					$registration->save();
1011 1010
 					// add relation between TXN and registration
1012
-					$this->_associate_registration_with_transaction( $registration );
1011
+					$this->_associate_registration_with_transaction($registration);
1013 1012
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1014 1013
 
1015
-			}  else {
1016
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1014
+			} else {
1015
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1017 1016
 				// remove malformed data
1018
-				unset( $valid_data[ $reg_url_link ] );
1017
+				unset($valid_data[$reg_url_link]);
1019 1018
 				return false;
1020 1019
 			}
1021 1020
 
@@ -1044,14 +1043,14 @@  discard block
 block discarded – undo
1044 1043
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1045 1044
 		// allow for plugins to hook in and do their own processing of the form input.
1046 1045
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1047
-		if ( apply_filters(
1046
+		if (apply_filters(
1048 1047
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1049 1048
 			false,
1050 1049
 			$registration,
1051 1050
 			$form_input,
1052 1051
 			$input_value,
1053 1052
 			$this
1054
-		) ) {
1053
+		)) {
1055 1054
 			return true;
1056 1055
 		}
1057 1056
         /*
@@ -1059,14 +1058,14 @@  discard block
 block discarded – undo
1059 1058
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
1060 1059
          */
1061 1060
 		$answer_cache_id = $this->checkout->reg_url_link
1062
-			? $form_input . '-' . $registration->reg_url_link()
1061
+			? $form_input.'-'.$registration->reg_url_link()
1063 1062
 			: $form_input;
1064
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1065
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1063
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1064
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1066 1065
 			? true
1067 1066
 			: false;
1068 1067
 		//rename form_inputs if they are EE_Attendee properties
1069
-		switch( (string)$form_input ) {
1068
+		switch ((string) $form_input) {
1070 1069
 
1071 1070
 			case 'state' :
1072 1071
 			case 'STA_ID' :
@@ -1081,32 +1080,32 @@  discard block
 block discarded – undo
1081 1080
 				break;
1082 1081
 
1083 1082
 			default :
1084
-				$ATT_input = 'ATT_' . $form_input;
1083
+				$ATT_input = 'ATT_'.$form_input;
1085 1084
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1086
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1087
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1085
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1086
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1088 1087
 		}
1089 1088
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1090 1089
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1091 1090
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1092 1091
 		// if this form input has a corresponding attendee property
1093
-		if ( $attendee_property ) {
1094
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1095
-			if ( $answer_is_obj ) {
1092
+		if ($attendee_property) {
1093
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1094
+			if ($answer_is_obj) {
1096 1095
 				// and delete the corresponding answer since we won't be storing this data in that object
1097
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1098
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1096
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1097
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1099 1098
 			}
1100 1099
 			return true;
1101
-		} elseif ( $answer_is_obj ) {
1100
+		} elseif ($answer_is_obj) {
1102 1101
 			// save this data to the answer object
1103
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1104
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1102
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1103
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1105 1104
 			return $result !== false ? true : false;
1106 1105
 		} else {
1107
-			foreach ( $this->_registration_answers as $answer ) {
1108
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1109
-					$answer->set_value( $input_value );
1106
+			foreach ($this->_registration_answers as $answer) {
1107
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1108
+					$answer->set_value($input_value);
1110 1109
 					$result = $answer->save();
1111 1110
 					return $result !== false ? true : false;
1112 1111
 				}
@@ -1128,15 +1127,15 @@  discard block
 block discarded – undo
1128 1127
 		$form_input = '',
1129 1128
 		$input_value = ''
1130 1129
 	) {
1131
-		if ( empty( $input_value ) ) {
1130
+		if (empty($input_value)) {
1132 1131
 			// if the form input isn't marked as being required, then just return
1133
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1132
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1134 1133
 				return true;
1135 1134
 			}
1136
-			switch ( $form_input ) {
1135
+			switch ($form_input) {
1137 1136
 				case 'fname' :
1138 1137
 					EE_Error::add_error(
1139
-						__( 'First Name is a required value.', 'event_espresso' ),
1138
+						__('First Name is a required value.', 'event_espresso'),
1140 1139
 						__FILE__,
1141 1140
 						__FUNCTION__,
1142 1141
 						__LINE__
@@ -1145,7 +1144,7 @@  discard block
 block discarded – undo
1145 1144
 					break;
1146 1145
 				case 'lname' :
1147 1146
 					EE_Error::add_error(
1148
-						__( 'Last Name is a required value.', 'event_espresso' ),
1147
+						__('Last Name is a required value.', 'event_espresso'),
1149 1148
 						__FILE__,
1150 1149
 						__FUNCTION__,
1151 1150
 						__LINE__
@@ -1154,7 +1153,7 @@  discard block
 block discarded – undo
1154 1153
 					break;
1155 1154
 				case 'email' :
1156 1155
 					EE_Error::add_error(
1157
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1156
+						__('Please enter a valid email address.', 'event_espresso'),
1158 1157
 						__FILE__,
1159 1158
 						__FUNCTION__,
1160 1159
 						__LINE__
@@ -1176,30 +1175,30 @@  discard block
 block discarded – undo
1176 1175
 	 * @return boolean|EE_Attendee
1177 1176
 	 * @throws \EE_Error
1178 1177
 	 */
1179
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1178
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1180 1179
 		$existing_attendee = null;
1181 1180
 		// if none of the critical properties are set in the incoming attendee data...
1182 1181
 		// then attempt to copy them from the primary attendee
1183 1182
 		if (
1184 1183
 			$this->checkout->primary_attendee_obj instanceof EE_Attendee
1185
-            && ! isset( $attendee_data['ATT_fname'], $attendee_data['ATT_email'] )
1184
+            && ! isset($attendee_data['ATT_fname'], $attendee_data['ATT_email'])
1186 1185
 		) {
1187 1186
 			return $this->checkout->primary_attendee_obj;
1188 1187
 		}
1189 1188
 		// does this attendee already exist in the db ?
1190 1189
 		// we're searching using a combination of first name, last name, AND email address
1191
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1190
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1192 1191
 			? $attendee_data['ATT_fname']
1193 1192
 			: '';
1194
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1193
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1195 1194
 			? $attendee_data['ATT_lname']
1196 1195
 			: '';
1197
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1196
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1198 1197
 			? $attendee_data['ATT_email']
1199 1198
 			: '';
1200 1199
 		// but only if those have values
1201
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1202
-			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee( array(
1200
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1201
+			$existing_attendee = EEM_Attendee::instance()->find_existing_attendee(array(
1203 1202
 				'ATT_fname' => $ATT_fname,
1204 1203
 				'ATT_lname' => $ATT_lname,
1205 1204
 				'ATT_email' => $ATT_email
@@ -1223,13 +1222,13 @@  discard block
 block discarded – undo
1223 1222
 	 * @return \EE_Attendee
1224 1223
 	 * @throws \EE_Error
1225 1224
 	 */
1226
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1225
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1227 1226
 		// first remove fname, lname, and email from attendee data
1228
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1227
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1229 1228
 		// now loop thru what's left and add to attendee CPT
1230
-		foreach ( $attendee_data as $property_name => $property_value ) {
1231
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1232
-				$existing_attendee->set( $property_name, $property_value );
1229
+		foreach ($attendee_data as $property_name => $property_value) {
1230
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1231
+				$existing_attendee->set($property_name, $property_value);
1233 1232
 			}
1234 1233
 		}
1235 1234
 		// better save that now
@@ -1247,11 +1246,11 @@  discard block
 block discarded – undo
1247 1246
 	 * @return void
1248 1247
 	 * @throws \EE_Error
1249 1248
 	 */
1250
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1249
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1251 1250
 		// add relation to attendee
1252
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1253
-		$registration->set_attendee_id( $attendee->ID() );
1254
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1251
+		$registration->_add_relation_to($attendee, 'Attendee');
1252
+		$registration->set_attendee_id($attendee->ID());
1253
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1255 1254
 	}
1256 1255
 
1257 1256
 
@@ -1263,10 +1262,10 @@  discard block
 block discarded – undo
1263 1262
 	 * @return void
1264 1263
 	 * @throws \EE_Error
1265 1264
 	 */
1266
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1265
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1267 1266
 		// add relation to attendee
1268
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1269
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1267
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1268
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1270 1269
 	}
1271 1270
 
1272 1271
 
@@ -1279,14 +1278,14 @@  discard block
 block discarded – undo
1279 1278
 	 * @return array
1280 1279
 	 * @throws \EE_Error
1281 1280
 	 */
1282
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1281
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1283 1282
 		// bare minimum critical details include first name, last name, email address
1284
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1283
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1285 1284
 		// add address info to critical details?
1286
-		if ( apply_filters(
1285
+		if (apply_filters(
1287 1286
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1288 1287
 			false
1289
-		) ) {
1288
+		)) {
1290 1289
 			$address_details = array(
1291 1290
 				'ATT_address',
1292 1291
 				'ATT_address2',
@@ -1296,13 +1295,13 @@  discard block
 block discarded – undo
1296 1295
 				'ATT_zip',
1297 1296
 				'ATT_phone'
1298 1297
 			);
1299
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1298
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1300 1299
 		}
1301
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1302
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1303
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1300
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1301
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1302
+			     || empty($attendee_data[$critical_attendee_detail])
1304 1303
 			) {
1305
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1304
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1306 1305
 					$critical_attendee_detail
1307 1306
 				);
1308 1307
 			}
@@ -1320,11 +1319,11 @@  discard block
 block discarded – undo
1320 1319
 	 * @return \EE_Attendee
1321 1320
 	 * @throws \EE_Error
1322 1321
 	 */
1323
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1322
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1324 1323
 		// create new attendee object
1325
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1324
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1326 1325
 		// set author to event creator
1327
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1326
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1328 1327
 		$new_attendee->save();
1329 1328
 		return $new_attendee;
1330 1329
 	}
@@ -1341,7 +1340,7 @@  discard block
 block discarded – undo
1341 1340
 	 */
1342 1341
 	public function update_reg_step() {
1343 1342
 		// save everything
1344
-		if ( $this->process_reg_step() ) {
1343
+		if ($this->process_reg_step()) {
1345 1344
 			$this->checkout->redirect = true;
1346 1345
 			$this->checkout->redirect_url = add_query_arg(
1347 1346
 				array(
@@ -1350,7 +1349,7 @@  discard block
 block discarded – undo
1350 1349
 				),
1351 1350
 				$this->checkout->thank_you_page_url
1352 1351
 			);
1353
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1352
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1354 1353
 			return true;
1355 1354
 		}
1356 1355
 		return false;
Please login to merge, or discard this patch.
templates/reg_admin_details_main_meta_box_reg_details.template.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@
 block discarded – undo
1 1
 <div id="admin-primary-mbox-reg-details-dv" class="admin-primary-mbox-dv">
2 2
 
3
-	<?php do_action( 'AHEE__reg_admin_details_main_meta_box_reg_details__top', $REG_ID ); ?>
3
+	<?php do_action('AHEE__reg_admin_details_main_meta_box_reg_details__top', $REG_ID); ?>
4 4
 	<?php echo $resend_registration_button; ?>
5 5
 	<?php echo $view_transaction_button; ?>
6 6
 	<br/>
7 7
 
8
-	<h3 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-clipboard"></span><?php _e( 'Registration Items', 'event_espresso' );?></h3>
8
+	<h3 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-clipboard"></span><?php _e('Registration Items', 'event_espresso'); ?></h3>
9 9
 
10 10
 	<?php echo $line_item_table; ?>
11 11
 
12 12
 	<a id="display-additional-registration-session-info" class="display-the-hidden smaller-text" rel="additional-registration-session-info">
13
-		<span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional registration session details', 'event_espresso' );?>
13
+		<span class="dashicons dashicons-plus-alt"></span><?php _e('view additional registration session details', 'event_espresso'); ?>
14 14
 	</a>
15 15
 
16 16
 	<div id="additional-registration-session-info-dv" class="hidden">
17 17
 
18 18
 		<a id="hide-additional-registration-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-registration-session-info">
19
-			<span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional registration session details', 'event_espresso' );?>
19
+			<span class="dashicons dashicons-dismiss"></span><?php _e('hide additional registration session details', 'event_espresso'); ?>
20 20
 		</a>
21 21
 	<br class="clear"/>
22 22
 
23
-		<h3 class="admin-primary-mbox-h4"><?php _e( 'Registration Session Details', 'event_espresso' );?></h3>
23
+		<h3 class="admin-primary-mbox-h4"><?php _e('Registration Session Details', 'event_espresso'); ?></h3>
24 24
 
25 25
 		<table id="admin-primary-mbox-reg-extra-session-info-tbl" class="form-table skinny-rows">
26 26
 			<tbody>
27
-			<?php foreach ( $reg_details as $key => $reg_detail ) : ?>
27
+			<?php foreach ($reg_details as $key => $reg_detail) : ?>
28 28
 				<tr>
29 29
 					<th>
30
-						<label for="<?php echo $key;?>"><?php echo $reg_detail['label'];?></label>
30
+						<label for="<?php echo $key; ?>"><?php echo $reg_detail['label']; ?></label>
31 31
 					</th>
32 32
 					<td>
33
-						<?php echo $reg_detail['value'];?>
33
+						<?php echo $reg_detail['value']; ?>
34 34
 					</td>
35 35
 				</tr>
36 36
 			<?php endforeach; // $reg_details?>
Please login to merge, or discard this patch.
core/db_models/EEM_Line_Item.model.php 3 patches
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -105,41 +105,41 @@  discard block
 block discarded – undo
105 105
 	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
106 106
 	 * @return \EEM_Line_Item
107 107
 	 */
108
-	protected function __construct( $timezone ) {
109
-		$this->singular_item = __('Line Item','event_espresso');
110
-		$this->plural_item = __('Line Items','event_espresso');
108
+	protected function __construct($timezone) {
109
+		$this->singular_item = __('Line Item', 'event_espresso');
110
+		$this->plural_item = __('Line Items', 'event_espresso');
111 111
 
112 112
 		$this->_tables = array(
113
-			'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID')
113
+			'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID')
114 114
 		);
115
-		$line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) );
115
+		$line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event'));
116 116
 		$this->_fields = array(
117 117
 			'Line_Item' => array(
118
-				'LIN_ID' 				=> new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ),
119
-				'LIN_code' 			=> new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ),
120
-				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ),
121
-				'LIN_name' 			=> new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ),
122
-				'LIN_desc' 			=> new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ),
123
-				'LIN_unit_price' 	=> new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ),
124
-				'LIN_percent' 		=> new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ),
125
-				'LIN_is_taxable' 	=> new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ),
126
-				'LIN_order' 			=> new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ),
127
-				'LIN_total' 			=> new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ),
128
-				'LIN_quantity' 	=> new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ),
129
-				'LIN_parent' 		=> new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ),
130
-				'LIN_type' 			=> new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array(
118
+				'LIN_ID' 				=> new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")),
119
+				'LIN_code' 			=> new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE),
120
+				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'),
121
+				'LIN_name' 			=> new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''),
122
+				'LIN_desc' 			=> new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE),
123
+				'LIN_unit_price' 	=> new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0),
124
+				'LIN_percent' 		=> new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0),
125
+				'LIN_is_taxable' 	=> new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE),
126
+				'LIN_order' 			=> new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1),
127
+				'LIN_total' 			=> new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0),
128
+				'LIN_quantity' 	=> new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1),
129
+				'LIN_parent' 		=> new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL),
130
+				'LIN_type' 			=> new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array(
131 131
 						self::type_line_item		=>  __("Line Item", "event_espresso"),
132 132
 						self::type_sub_line_item	=>  __("Sub-Item", "event_espresso"),
133 133
 						self::type_sub_total		=>  __("Subtotal", "event_espresso"),
134 134
 						self::type_tax_sub_total 	=> __("Tax Subtotal", "event_espresso"),
135 135
 						self::type_tax					=>  __("Tax", "event_espresso"),
136 136
 						self::type_total				=>  __("Total", "event_espresso"),
137
-						self::type_cancellation	=> __( 'Cancellation', 'event_espresso' )
137
+						self::type_cancellation	=> __('Cancellation', 'event_espresso')
138 138
 					)
139 139
 				),
140
-				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ),
141
-				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ),
142
-				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
140
+				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for),
141
+				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for),
142
+				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
143 143
 			)
144 144
 		);
145 145
 		$this->_model_relations = array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		);
151 151
 		$this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
152 152
 		$this->_caps_slug = 'transactions';
153
-		parent::__construct( $timezone );
153
+		parent::__construct($timezone);
154 154
 	}
155 155
 
156 156
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 * @param EE_Transaction|int $transaction
162 162
 	 * @return EE_Line_Item[]
163 163
 	 */
164
-	public function get_all_of_type_for_transaction( $line_item_type, $transaction ){
165
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
166
-		return $this->get_all( array( array(
164
+	public function get_all_of_type_for_transaction($line_item_type, $transaction) {
165
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
166
+		return $this->get_all(array(array(
167 167
 			'LIN_type' => $line_item_type,
168 168
 			'TXN_ID' => $transaction
169 169
 		)));
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 	 * @param EE_Transaction|int $transaction
178 178
 	 * @return EE_Line_Item[]
179 179
 	 */
180
-	public function get_all_non_ticket_line_items_for_transaction( $transaction ) {
181
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
182
-		return $this->get_all( array( array(
180
+	public function get_all_non_ticket_line_items_for_transaction($transaction) {
181
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
182
+		return $this->get_all(array(array(
183 183
 			'LIN_type' => self::type_line_item,
184 184
 			'TXN_ID' => $transaction,
185 185
 			'OR' => array(
186
-				'OBJ_type*notticket' => array( '!=', 'Ticket'),
187
-				'OBJ_type*null' => array( 'IS_NULL' ))
186
+				'OBJ_type*notticket' => array('!=', 'Ticket'),
187
+				'OBJ_type*null' => array('IS_NULL'))
188 188
 		)));
189 189
 	}
190 190
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * because if there are spam bots afoot there will be LOTS of line items
195 195
 	 * @return int count of how many deleted
196 196
 	 */
197
-	public function delete_line_items_with_no_transaction(){
197
+	public function delete_line_items_with_no_transaction() {
198 198
 		/** @type WPDB $wpdb */
199 199
 		global $wpdb;
200 200
 		$time_to_leave_alone = apply_filters(
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 		);
203 203
 		$query = $wpdb->prepare(
204 204
 				'DELETE li
205
-				FROM ' . $this->table() . ' li
206
-				LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID
205
+				FROM ' . $this->table().' li
206
+				LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID
207 207
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
208 208
 				// use GMT time because that's what TXN_timestamps are in
209
-				date(  'Y-m-d H:i:s', time() - $time_to_leave_alone )
209
+				date('Y-m-d H:i:s', time() - $time_to_leave_alone)
210 210
 				);
211
-		return $wpdb->query( $query );
211
+		return $wpdb->query($query);
212 212
 	}
213 213
 
214 214
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 * @param \EE_Base_Class $object
222 222
 	 * @return EE_Line_Item[]
223 223
 	 */
224
-	public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){
225
-		return $this->get_all( array( array(
224
+	public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) {
225
+		return $this->get_all(array(array(
226 226
 			'TXN_ID' 		=> $TXN_ID,
227
-			'OBJ_type' 	=> str_replace( 'EE_', '', get_class( $object )),
227
+			'OBJ_type' 	=> str_replace('EE_', '', get_class($object)),
228 228
 			'OBJ_ID' 		=> $object->ID()
229 229
 		)));
230 230
 	}
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 * @param array $OBJ_IDs
241 241
 	 * @return EE_Line_Item[]
242 242
 	 */
243
-	public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){
243
+	public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) {
244 244
 		$query_params = array(
245 245
 			'OBJ_type' 	=> $OBJ_type,
246 246
 			// if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
247
-			'OBJ_ID' 		=> is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs
247
+			'OBJ_ID' 		=> is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs
248 248
 		);
249
-		if ( $TXN_ID ) {
249
+		if ($TXN_ID) {
250 250
 			$query_params['TXN_ID'] = $TXN_ID;
251 251
 		}
252
-		return $this->get_all( array( $query_params ));
252
+		return $this->get_all(array($query_params));
253 253
 	}
254 254
 
255 255
 
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	 * @param EE_Transaction $transaction
261 261
 	 * @return EE_Line_Item[]
262 262
 	 */
263
-	public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) {
264
-		return $this->get_all( array(
263
+	public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) {
264
+		return $this->get_all(array(
265 265
 		   array(
266 266
 			   'TXN_ID'   => $transaction->ID(),
267 267
 			   'OBJ_type' => 'Ticket',
268 268
 		   )
269
-	   ) );
269
+	   ));
270 270
 	}
271 271
 
272 272
 
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
 	 * @param int $TKT_ID
279 279
 	 * @return \EE_Line_Item
280 280
 	 */
281
-	public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) {
282
-		return $this->get_one( array(
281
+	public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) {
282
+		return $this->get_one(array(
283 283
 		   array(
284
-			   'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ),
284
+			   'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
285 285
 			   'OBJ_ID'   => $TKT_ID,
286 286
 			   'OBJ_type' => 'Ticket',
287 287
 		   )
288
-	   ) );
288
+	   ));
289 289
 	}
290 290
 
291 291
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param EE_Promotion $promotion
301 301
 	 * @return EE_Line_Item
302 302
 	 */
303
-	public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) {
304
-		return $this->get_one( array(
303
+	public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) {
304
+		return $this->get_one(array(
305 305
 			array(
306 306
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
307 307
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 	 * @param EE_Line_Item $parent_line_item
323 323
 	 * @return EE_Line_Item[]
324 324
 	 */
325
-	public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) {
326
-		return $this->get_all( array(
325
+	public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) {
326
+		return $this->get_all(array(
327 327
 			array(
328 328
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
329 329
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 * @param EE_Registration $registration
341 341
 	 * @return EE_Line_ITem
342 342
 	 */
343
-	public function get_line_item_for_registration( EE_Registration $registration ) {
344
-		return $this->get_one( $this->line_item_for_registration_query_params( $registration ));
343
+	public function get_line_item_for_registration(EE_Registration $registration) {
344
+		return $this->get_one($this->line_item_for_registration_query_params($registration));
345 345
 	}
346 346
 
347 347
 	/**
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 	 * @param array $original_query_params any extra query params you'd like to be merged with
351 351
 	 * @return array like EEM_Base::get_all()'s $query_params
352 352
 	 */
353
-	public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) {
354
-		return array_replace_recursive( $original_query_params, array(
353
+	public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) {
354
+		return array_replace_recursive($original_query_params, array(
355 355
 			array(
356 356
 				'OBJ_ID' => $registration->ticket_ID(),
357 357
 				'OBJ_type' => 'Ticket',
358 358
 				'TXN_ID' => $registration->transaction_ID()
359 359
 			)
360
-		) );
360
+		));
361 361
 	}
362 362
 
363 363
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -362,62 +362,62 @@
 block discarded – undo
362 362
 
363 363
 
364 364
 
365
-    /**
366
-     * @return EE_Base_Class[]|EE_Line_Item[]
367
-     * @throws \EE_Error
368
-     */
369
-    public function get_total_line_items_with_no_transaction()
370
-    {
371
-        return $this->get_total_line_items_for_carts();
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * @return EE_Base_Class[]|EE_Line_Item[]
378
-     * @throws \EE_Error
379
-     */
380
-    public function get_total_line_items_for_active_carts()
381
-    {
382
-        return $this->get_total_line_items_for_carts(false);
383
-    }
384
-
385
-
386
-
387
-    /**
388
-     * @return EE_Base_Class[]|EE_Line_Item[]
389
-     * @throws \EE_Error
390
-     */
391
-    public function get_total_line_items_for_expired_carts()
392
-    {
393
-        return $this->get_total_line_items_for_carts(true);
394
-    }
395
-
396
-
397
-
398
-    /**
399
-     * Returns an array of grand total line items where the TXN_ID is 0.
400
-     * If $expired is set to true, then only line items for expired sessions will be returned.
401
-     * If $expired is set to false, then only line items for active sessions will be returned.
402
-     *
403
-     * @param bool|null $expired
404
-     * @return EE_Base_Class[]|EE_Line_Item[]
405
-     * @throws \EE_Error
406
-     */
407
-    private function get_total_line_items_for_carts($expired = null)
408
-    {
409
-        $where_params = array(
410
-            'TXN_ID'        => 0,
411
-            'LIN_type'      => 'total',
412
-        );
413
-        if ($expired !== null) {
414
-            $where_params['LIN_timestamp'] = array(
415
-                $expired ? '<=' : '>',
416
-                time() - EE_Registry::instance()->SSN->lifespan(),
417
-            );
418
-        }
419
-        return $this->get_all(array($where_params));
420
-    }
365
+	/**
366
+	 * @return EE_Base_Class[]|EE_Line_Item[]
367
+	 * @throws \EE_Error
368
+	 */
369
+	public function get_total_line_items_with_no_transaction()
370
+	{
371
+		return $this->get_total_line_items_for_carts();
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * @return EE_Base_Class[]|EE_Line_Item[]
378
+	 * @throws \EE_Error
379
+	 */
380
+	public function get_total_line_items_for_active_carts()
381
+	{
382
+		return $this->get_total_line_items_for_carts(false);
383
+	}
384
+
385
+
386
+
387
+	/**
388
+	 * @return EE_Base_Class[]|EE_Line_Item[]
389
+	 * @throws \EE_Error
390
+	 */
391
+	public function get_total_line_items_for_expired_carts()
392
+	{
393
+		return $this->get_total_line_items_for_carts(true);
394
+	}
395
+
396
+
397
+
398
+	/**
399
+	 * Returns an array of grand total line items where the TXN_ID is 0.
400
+	 * If $expired is set to true, then only line items for expired sessions will be returned.
401
+	 * If $expired is set to false, then only line items for active sessions will be returned.
402
+	 *
403
+	 * @param bool|null $expired
404
+	 * @return EE_Base_Class[]|EE_Line_Item[]
405
+	 * @throws \EE_Error
406
+	 */
407
+	private function get_total_line_items_for_carts($expired = null)
408
+	{
409
+		$where_params = array(
410
+			'TXN_ID'        => 0,
411
+			'LIN_type'      => 'total',
412
+		);
413
+		if ($expired !== null) {
414
+			$where_params['LIN_timestamp'] = array(
415
+				$expired ? '<=' : '>',
416
+				time() - EE_Registry::instance()->SSN->lifespan(),
417
+			);
418
+		}
419
+		return $this->get_all(array($where_params));
420
+	}
421 421
 
422 422
 
423 423
 
Please login to merge, or discard this patch.
core/db_models/EEM_Registration.model.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -373,7 +373,7 @@
 block discarded – undo
373 373
      * @param    int $ATT_ID
374 374
      * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
375 375
      *                         attendee number is required
376
-     * @return        mixed        array on success, FALSE on fail
376
+     * @return        null|EE_Base_Class        array on success, FALSE on fail
377 377
      */
378 378
     public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
379 379
     {
Please login to merge, or discard this patch.
Indentation   +749 added lines, -749 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\services\database\TableAnalysis;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -17,737 +17,737 @@  discard block
 block discarded – undo
17 17
 class EEM_Registration extends EEM_Soft_Delete_Base
18 18
 {
19 19
 
20
-    // private instance of the Registration object
21
-    protected static $_instance = null;
22
-
23
-    /**
24
-     * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values
25
-     * are status codes (eg, approved, cancelled, etc)
26
-     *
27
-     * @var array
28
-     */
29
-    private static $_reg_status;
30
-
31
-    /**
32
-     * The value of REG_count for a primary registrant
33
-     */
34
-    const PRIMARY_REGISTRANT_COUNT = 1;
35
-
36
-    /**
37
-     * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration.
38
-     * Initial status for registrations when they are first created
39
-     * Payments are NOT allowed.
40
-     * Automatically toggled to whatever the default Event registration status is upon completion of the attendee
41
-     * information reg step NO space reserved. Registration is NOT active
42
-     */
43
-    const status_id_incomplete = 'RIC';
44
-
45
-    /**
46
-     * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration.
47
-     * Payments are NOT allowed.
48
-     * Event Admin must manually toggle STS_ID for it to change
49
-     * No space reserved.
50
-     * Registration is active
51
-     */
52
-    const status_id_not_approved = 'RNA';
53
-
54
-    /**
55
-     * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT .
56
-     * Payments are allowed.
57
-     * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
58
-     * No space reserved.
59
-     * Registration is active
60
-     */
61
-    const status_id_pending_payment = 'RPP';
62
-
63
-    /**
64
-     * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST .
65
-     * Payments are allowed.
66
-     * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
67
-     * No space reserved.
68
-     * Registration is active
69
-     */
70
-    const status_id_wait_list = 'RWL';
71
-
72
-    /**
73
-     * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration.
74
-     * the TXN may or may not be completed ( paid in full )
75
-     * Payments are allowed.
76
-     * A space IS reserved.
77
-     * Registration is active
78
-     */
79
-    const status_id_approved = 'RAP';
80
-
81
-    /**
82
-     * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee.
83
-     * Payments are NOT allowed.
84
-     * NO space reserved.
85
-     * Registration is NOT active
86
-     */
87
-    const status_id_cancelled = 'RCN';
88
-
89
-    /**
90
-     * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin
91
-     * Payments are NOT allowed.
92
-     * No space reserved.
93
-     * Registration is NOT active
94
-     */
95
-    const status_id_declined = 'RDC';
96
-
97
-    /**
98
-     * @var TableAnalysis $table_analysis
99
-     */
100
-    protected $_table_analysis;
101
-
102
-
103
-
104
-    /**
105
-     *    private constructor to prevent direct creation
106
-     *
107
-     * @Constructor
108
-     * @access protected
109
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
110
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
111
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
112
-     *                         timezone in the 'timezone_string' wp option)
113
-     */
114
-    protected function __construct($timezone = null)
115
-    {
116
-        $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
117
-        $this->singular_item = __('Registration', 'event_espresso');
118
-        $this->plural_item = __('Registrations', 'event_espresso');
119
-        $this->_tables = array(
120
-            'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'),
121
-        );
122
-        $this->_fields = array(
123
-            'Registration' => array(
124
-                'REG_ID'           => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
125
-                'EVT_ID'           => new EE_Foreign_Key_Int_Field(
126
-                    'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'
127
-                ),
128
-                'ATT_ID'           => new EE_Foreign_Key_Int_Field(
129
-                    'ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'
130
-                ),
131
-                'TXN_ID'           => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'),
132
-                    false, 0, 'Transaction'
133
-                ),
134
-                'TKT_ID'           => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false,
135
-                    0, 'Ticket'
136
-                ),
137
-                'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
138
-                    false, EEM_Registration::status_id_incomplete, 'Status'
139
-                ),
140
-                'REG_date'         => new EE_Datetime_Field('REG_date',
141
-                    __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone
142
-                ),
143
-                'REG_final_price'  => new EE_Money_Field('REG_final_price',
144
-                    __('Registration\'s share of the transaction total', 'event_espresso'), false, 0
145
-                ),
146
-                'REG_paid'         => new EE_Money_Field('REG_paid',
147
-                    __('Amount paid to date towards registration', 'event_espresso'), false, 0
148
-                ),
149
-                'REG_session'      => new EE_Plain_Text_Field('REG_session',
150
-                    __('Session ID of registration', 'event_espresso'), false, ''
151
-                ),
152
-                'REG_code'         => new EE_Plain_Text_Field('REG_code',
153
-                    __('Unique Code for this registration', 'event_espresso'), false, ''
154
-                ),
155
-                'REG_url_link'     => new EE_Plain_Text_Field('REG_url_link',
156
-                    __('String to be used in URL for identifying registration', 'event_espresso'), false, ''
157
-                ),
158
-                'REG_count'        => new EE_Integer_Field('REG_count',
159
-                    __('Count of this registration in the group registration ', 'event_espresso'), true, 1
160
-                ),
161
-                'REG_group_size'   => new EE_Integer_Field('REG_group_size',
162
-                    __('Number of registrations on this group', 'event_espresso'), false, 1
163
-                ),
164
-                'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going',
165
-                    __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false
166
-                ),
167
-                'REG_deleted'      => new EE_Trashed_Flag_Field(
168
-                    'REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'),
169
-                    false, false
170
-                ),
171
-            ),
172
-        );
173
-        $this->_model_relations = array(
174
-            'Event'                => new EE_Belongs_To_Relation(),
175
-            'Attendee'             => new EE_Belongs_To_Relation(),
176
-            'Transaction'          => new EE_Belongs_To_Relation(),
177
-            'Ticket'               => new EE_Belongs_To_Relation(),
178
-            'Status'               => new EE_Belongs_To_Relation(),
179
-            'Answer'               => new EE_Has_Many_Relation(),
180
-            'Checkin'              => new EE_Has_Many_Relation(),
181
-            'Registration_Payment' => new EE_Has_Many_Relation(),
182
-            'Payment'              => new EE_HABTM_Relation('Registration_Payment'),
183
-            'Message'              => new EE_Has_Many_Any_Relation(false)
184
-            //allow deletes even if there are messages in the queue related
185
-        );
186
-        $this->_model_chain_to_wp_user = 'Event';
187
-        parent::__construct($timezone);
188
-    }
189
-
190
-
191
-
192
-    /**
193
-     * reg_statuses_that_allow_payment
194
-     * a filterable list of registration statuses that allow a registrant to make a payment
195
-     *
196
-     * @access public
197
-     * @return array
198
-     */
199
-    public static function reg_statuses_that_allow_payment()
200
-    {
201
-        return apply_filters(
202
-            'FHEE__EEM_Registration__reg_statuses_that_allow_payment',
203
-            array(
204
-                EEM_Registration::status_id_approved,
205
-                EEM_Registration::status_id_pending_payment,
206
-                EEM_Registration::status_id_wait_list,
207
-            )
208
-        );
209
-    }
210
-
211
-
212
-
213
-    /**
214
-     * inactive_reg_statuses
215
-     * a filterable list of registration statuses that are considered active
216
-     *
217
-     * @access public
218
-     * @return array
219
-     */
220
-    public static function active_reg_statuses()
221
-    {
222
-        return apply_filters(
223
-            'FHEE__EEM_Registration__reg_statuses_that_allow_payment',
224
-            array(
225
-                EEM_Registration::status_id_approved,
226
-                EEM_Registration::status_id_pending_payment,
227
-                EEM_Registration::status_id_wait_list,
228
-                EEM_Registration::status_id_not_approved,
229
-            )
230
-        );
231
-    }
232
-
233
-
234
-
235
-    /**
236
-     * inactive_reg_statuses
237
-     * a filterable list of registration statuses that are not considered active
238
-     *
239
-     * @access public
240
-     * @return array
241
-     */
242
-    public static function inactive_reg_statuses()
243
-    {
244
-        return apply_filters(
245
-            'FHEE__EEM_Registration__reg_statuses_that_allow_payment',
246
-            array(
247
-                EEM_Registration::status_id_incomplete,
248
-                EEM_Registration::status_id_cancelled,
249
-                EEM_Registration::status_id_declined,
250
-            )
251
-        );
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *    closed_reg_statuses
258
-     *    a filterable list of registration statuses that are considered "closed"
259
-     * meaning they should not be considered in any calculations involving monies owing
260
-     *
261
-     * @access public
262
-     * @return array
263
-     */
264
-    public static function closed_reg_statuses()
265
-    {
266
-        return apply_filters(
267
-            'FHEE__EEM_Registration__closed_reg_statuses',
268
-            array(
269
-                EEM_Registration::status_id_cancelled,
270
-                EEM_Registration::status_id_declined,
271
-            )
272
-        );
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     *        get list of registration statuses
279
-     *
280
-     * @access public
281
-     * @param array $exclude    The status ids to exclude from the returned results
282
-     * @param bool  $translated If true will return the values as singular localized strings
283
-     * @return array
284
-     */
285
-    public static function reg_status_array($exclude = array(), $translated = false)
286
-    {
287
-        EEM_Registration::instance()->_get_registration_status_array($exclude);
288
-        return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence')
289
-            : self::$_reg_status;
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     *    get list of registration statuses
296
-     *
297
-     * @access private
298
-     * @param array $exclude
299
-     * @return array
300
-     */
301
-    private function _get_registration_status_array($exclude = array())
302
-    {
303
-        //in the very rare circumstance that we are deleting a model's table's data
304
-        //and the table hasn't actually been created, this could have an error
305
-        /** @type WPDB $wpdb */
306
-        global $wpdb;
307
-        if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
308
-            $results = $wpdb->get_results(
309
-                "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'"
310
-            );
311
-            self::$_reg_status = array();
312
-            foreach ($results as $status) {
313
-                if ( ! in_array($status->STS_ID, $exclude)) {
314
-                    self::$_reg_status[$status->STS_ID] = $status->STS_code;
315
-                }
316
-            }
317
-        }
318
-    }
319
-
320
-
321
-
322
-    /**
323
-     * Gets the injected table analyzer, or throws an exception
324
-     *
325
-     * @return TableAnalysis
326
-     * @throws \EE_Error
327
-     */
328
-    protected function _get_table_analysis()
329
-    {
330
-        if ($this->_table_analysis instanceof TableAnalysis) {
331
-            return $this->_table_analysis;
332
-        } else {
333
-            throw new \EE_Error(
334
-                sprintf(
335
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
336
-                    get_class($this)
337
-                )
338
-            );
339
-        }
340
-    }
341
-
342
-
343
-
344
-    /**
345
-     * This returns a wpdb->results array of all registration date month and years matching the incoming query params
346
-     * and grouped by month and year.
347
-     *
348
-     * @param  array $where_params Array of query_params as described in the comments for EEM_Base::get_all()
349
-     * @return array
350
-     * @throws \EE_Error
351
-     */
352
-    public function get_reg_months_and_years($where_params)
353
-    {
354
-        $query_params[0] = $where_params;
355
-        $query_params['group_by'] = array('reg_year', 'reg_month');
356
-        $query_params['order_by'] = array('REG_date' => 'DESC');
357
-        $columns_to_select = array(
358
-            'reg_year'  => array('YEAR(REG_date)', '%s'),
359
-            'reg_month' => array('MONTHNAME(REG_date)', '%s'),
360
-        );
361
-        return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
362
-    }
363
-
364
-
365
-
366
-    /**
367
-     *        retrieve ALL registrations for a particular Attendee from db
368
-     *
369
-     * @access        public
370
-     * @param        int $ATT_ID
371
-     * @return    EE_Registration[]
372
-     */
373
-    public function get_all_registrations_for_attendee($ATT_ID = 0)
374
-    {
375
-        if ( ! $ATT_ID) {
376
-            return false;
377
-        }
378
-        return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
379
-    }
380
-
381
-
382
-
383
-    /**
384
-     * Gets a registration given their REG_url_link. Yes, this should usually
385
-     * be passed via a GET parameter.
386
-     *
387
-     * @param string $REG_url_link
388
-     * @return EE_Registration
389
-     */
390
-    public function get_registration_for_reg_url_link($REG_url_link)
391
-    {
392
-        if ( ! $REG_url_link) {
393
-            return false;
394
-        }
395
-        return $this->get_one(array(array('REG_url_link' => $REG_url_link)));
396
-    }
397
-
398
-
399
-
400
-    /**
401
-     *        retrieve registration for a specific transaction attendee from db
402
-     *
403
-     * @access        public
404
-     * @param    int $TXN_ID
405
-     * @param    int $ATT_ID
406
-     * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
407
-     *                         attendee number is required
408
-     * @return        mixed        array on success, FALSE on fail
409
-     */
410
-    public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
411
-    {
412
-        return $this->get_one(array(
413
-            array(
414
-                'TXN_ID' => $TXN_ID,
415
-                'ATT_ID' => $ATT_ID,
416
-            ),
417
-            'limit' => array(min(($att_nmbr - 1), 0), 1),
418
-        ));
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     *        get the number of registrations per day  for the Registration Admin page Reports Tab.
425
-     *        (doesn't utilize models because it's a fairly specialized query)
426
-     *
427
-     * @access        public
428
-     * @param $period string which can be passed to php's strtotime function (eg "-1 month")
429
-     * @return stdClass[] with properties regDate and total
430
-     */
431
-    public function get_registrations_per_day_report($period = '-1 month')
432
-    {
433
-        $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
434
-            'Y-m-d H:i:s', 'UTC');
435
-        $where = array(
436
-            'REG_date' => array('>=', $sql_date),
437
-            'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
438
-        );
439
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
440
-            $where['Event.EVT_wp_user'] = get_current_user_id();
441
-        }
442
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
443
-        $results = $this->_get_all_wpdb_results(
444
-            array(
445
-                $where,
446
-                'group_by' => 'regDate',
447
-                'order_by' => array('REG_date' => 'ASC'),
448
-            ),
449
-            OBJECT,
450
-            array(
451
-                'regDate' => array('DATE(' . $query_interval . ')', '%s'),
452
-                'total'   => array('count(REG_ID)', '%d'),
453
-            ));
454
-        return $results;
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * Get the number of registrations per day including the count of registrations for each Registration Status.
461
-     * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
462
-     *
463
-     * @param string $period
464
-     * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
465
-     *                    (i.e. RAP)
466
-     */
467
-    public function get_registrations_per_day_and_per_status_report($period = '-1 month')
468
-    {
469
-        global $wpdb;
470
-        $registration_table = $wpdb->prefix . 'esp_registration';
471
-        $event_table = $wpdb->posts;
472
-        $sql_date = date("Y-m-d H:i:s", strtotime($period));
473
-        //prepare the query interval for displaying offset
474
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
475
-        //inner date query
476
-        $inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
477
-        $inner_where = " WHERE";
478
-        //exclude events not authored by user if permissions in effect
479
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
480
-            $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
481
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
482
-        }
483
-        $inner_where .= " REG_date >= '$sql_date'";
484
-        $inner_date_query .= $inner_where;
485
-        //start main query
486
-        $select = "SELECT DATE($query_interval) as Registration_REG_date, ";
487
-        $join = '';
488
-        $join_parts = array();
489
-        $select_parts = array();
490
-        //loop through registration stati to do parts for each status.
491
-        foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
492
-            if ($STS_ID === EEM_Registration::status_id_incomplete) {
493
-                continue;
494
-            }
495
-            $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
496
-            $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'";
497
-        }
498
-        //setup the selects
499
-        $select .= implode(', ', $select_parts);
500
-        $select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
501
-        //setup the joins
502
-        $join .= implode(" LEFT JOIN ", $join_parts);
503
-        //now let's put it all together
504
-        $query = $select . $join . ' GROUP BY Registration_REG_date';
505
-        //and execute it
506
-        $results = $wpdb->get_results($query, ARRAY_A);
507
-        return $results;
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     *        get the number of registrations per event  for the Registration Admin page Reports Tab
514
-     *
515
-     * @access        public
516
-     * @param $period string which can be passed to php's strtotime function (eg "-1 month")
517
-     * @return stdClass[] each with properties event_name, reg_limit, and total
518
-     */
519
-    public function get_registrations_per_event_report($period = '-1 month')
520
-    {
521
-        $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
522
-            'Y-m-d H:i:s', 'UTC');
523
-        $where = array(
524
-            'REG_date' => array('>=', $date_sql),
525
-            'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
526
-        );
527
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
528
-            $where['Event.EVT_wp_user'] = get_current_user_id();
529
-        }
530
-        $results = $this->_get_all_wpdb_results(array(
531
-            $where,
532
-            'group_by' => 'Event.EVT_name',
533
-            'order_by' => 'Event.EVT_name',
534
-            'limit'    => array(0, 24),
535
-        ),
536
-            OBJECT,
537
-            array(
538
-                'event_name' => array('Event_CPT.post_title', '%s'),
539
-                'total'      => array('COUNT(REG_ID)', '%s'),
540
-            )
541
-        );
542
-        return $results;
543
-    }
544
-
545
-
546
-
547
-    /**
548
-     * Get the number of registrations per event grouped by registration status.
549
-     * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
550
-     *
551
-     * @param string $period
552
-     * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
553
-     *                    (i.e. RAP)
554
-     */
555
-    public function get_registrations_per_event_and_per_status_report($period = '-1 month')
556
-    {
557
-        global $wpdb;
558
-        $registration_table = $wpdb->prefix . 'esp_registration';
559
-        $event_table = $wpdb->posts;
560
-        $sql_date = date("Y-m-d H:i:s", strtotime($period));
561
-        //inner date query
562
-        $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
563
-        $inner_where = " WHERE";
564
-        //exclude events not authored by user if permissions in effect
565
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
566
-            $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
567
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
568
-        }
569
-        $inner_where .= " REG_date >= '$sql_date'";
570
-        $inner_date_query .= $inner_where;
571
-        //build main query
572
-        $select = "SELECT Event.post_title as Registration_Event, ";
573
-        $join = '';
574
-        $join_parts = array();
575
-        $select_parts = array();
576
-        //loop through registration stati to do parts for each status.
577
-        foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
578
-            if ($STS_ID === EEM_Registration::status_id_incomplete) {
579
-                continue;
580
-            }
581
-            $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
582
-            $join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date";
583
-        }
584
-        //setup the selects
585
-        $select .= implode(', ', $select_parts);
586
-        $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
587
-        //setup remaining joins
588
-        $join .= implode(" LEFT JOIN ", $join_parts);
589
-        //now put it all together
590
-        $query = $select . $join . ' GROUP BY Registration_Event';
591
-        //and execute
592
-        $results = $wpdb->get_results($query, ARRAY_A);
593
-        return $results;
594
-    }
595
-
596
-
597
-
598
-    /**
599
-     * Returns the EE_Registration of the primary attendee on the transaction id provided
600
-     *
601
-     * @param int $TXN_ID
602
-     * @return EE_Registration
603
-     */
604
-    public function get_primary_registration_for_transaction_ID($TXN_ID = 0)
605
-    {
606
-        if ( ! $TXN_ID) {
607
-            return false;
608
-        }
609
-        return $this->get_one(array(
610
-            array(
611
-                'TXN_ID'    => $TXN_ID,
612
-                'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT,
613
-            ),
614
-        ));
615
-    }
616
-
617
-
618
-
619
-    /**
620
-     *        get_event_registration_count
621
-     *
622
-     * @access public
623
-     * @param int     $EVT_ID
624
-     * @param boolean $for_incomplete_payments
625
-     * @return int
626
-     */
627
-    public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false)
628
-    {
629
-        // we only count approved registrations towards registration limits
630
-        $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
631
-        if ($for_incomplete_payments) {
632
-            $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
633
-        }
634
-        return $this->count($query_params);
635
-    }
636
-
637
-
638
-
639
-    /**
640
-     * Deletes all registrations with no transactions. Note that this needs to be very efficient
641
-     * and so it uses wpdb directly
642
-     *
643
-     * @global WPDB $wpdb
644
-     * @return int number deleted
645
-     */
646
-    public function delete_registrations_with_no_transaction()
647
-    {
648
-        /** @type WPDB $wpdb */
649
-        global $wpdb;
650
-        return $wpdb->query(
651
-            'DELETE r FROM '
652
-            . $this->table()
653
-            . ' r LEFT JOIN '
654
-            . EEM_Transaction::instance()->table()
655
-            . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL');
656
-    }
657
-
658
-
659
-
660
-    /**
661
-     *  Count registrations checked into (or out of) a datetime
662
-     *
663
-     * @param int     $DTT_ID     datetime ID
664
-     * @param boolean $checked_in whether to count registrations checked IN or OUT
665
-     * @return int
666
-     */
667
-    public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true)
668
-    {
669
-        global $wpdb;
670
-        //subquery to get latest checkin
671
-        $query = $wpdb->prepare(
672
-            'SELECT '
673
-            . 'COUNT( DISTINCT checkins.REG_ID ) '
674
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
675
-            . '( SELECT '
676
-            . 'max( CHK_timestamp ) AS latest_checkin, '
677
-            . 'REG_ID AS REG_ID '
678
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' '
679
-            . 'WHERE DTT_ID=%d '
680
-            . 'GROUP BY REG_ID'
681
-            . ') AS most_recent_checkin_per_reg '
682
-            . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
683
-            . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
684
-            . 'WHERE '
685
-            . 'checkins.CHK_in=%d',
686
-            $DTT_ID,
687
-            $checked_in
688
-        );
689
-        return (int)$wpdb->get_var($query);
690
-    }
691
-
692
-
693
-
694
-    /**
695
-     *  Count registrations checked into (or out of) an event.
696
-     *
697
-     * @param int     $EVT_ID     event ID
698
-     * @param boolean $checked_in whether to count registrations checked IN or OUT
699
-     * @return int
700
-     */
701
-    public function count_registrations_checked_into_event($EVT_ID, $checked_in = true)
702
-    {
703
-        global $wpdb;
704
-        //subquery to get latest checkin
705
-        $query = $wpdb->prepare(
706
-            'SELECT '
707
-            . 'COUNT( DISTINCT checkins.REG_ID ) '
708
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
709
-            . '( SELECT '
710
-            . 'max( CHK_timestamp ) AS latest_checkin, '
711
-            . 'REG_ID AS REG_ID '
712
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c '
713
-            . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d '
714
-            . 'ON c.DTT_ID=d.DTT_ID '
715
-            . 'WHERE d.EVT_ID=%d '
716
-            . 'GROUP BY REG_ID'
717
-            . ') AS most_recent_checkin_per_reg '
718
-            . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
719
-            . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
720
-            . 'WHERE '
721
-            . 'checkins.CHK_in=%d',
722
-            $EVT_ID,
723
-            $checked_in
724
-        );
725
-        return (int)$wpdb->get_var($query);
726
-    }
727
-
728
-
729
-
730
-    /**
731
-     * The purpose of this method is to retrieve an array of
732
-     * EE_Registration objects that represent the latest registration
733
-     * for each ATT_ID given in the function argument.
734
-     *
735
-     * @param array $attendee_ids
736
-     * @return EE_Registration[]
737
-     */
738
-    public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array())
739
-    {
740
-        //first do a native wp_query to get the latest REG_ID's matching these attendees.
741
-        global $wpdb;
742
-        $registration_table = $wpdb->prefix . 'esp_registration';
743
-        $attendee_table = $wpdb->posts;
744
-        $attendee_ids = is_array($attendee_ids)
745
-            ? array_map('absint', $attendee_ids)
746
-            : array((int)$attendee_ids);
747
-        $attendee_ids = implode(',', $attendee_ids);
748
-        //first we do a query to get the registration ids
749
-        // (because a group by before order by causes the order by to be ignored.)
750
-        $registration_id_query = "
20
+	// private instance of the Registration object
21
+	protected static $_instance = null;
22
+
23
+	/**
24
+	 * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values
25
+	 * are status codes (eg, approved, cancelled, etc)
26
+	 *
27
+	 * @var array
28
+	 */
29
+	private static $_reg_status;
30
+
31
+	/**
32
+	 * The value of REG_count for a primary registrant
33
+	 */
34
+	const PRIMARY_REGISTRANT_COUNT = 1;
35
+
36
+	/**
37
+	 * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration.
38
+	 * Initial status for registrations when they are first created
39
+	 * Payments are NOT allowed.
40
+	 * Automatically toggled to whatever the default Event registration status is upon completion of the attendee
41
+	 * information reg step NO space reserved. Registration is NOT active
42
+	 */
43
+	const status_id_incomplete = 'RIC';
44
+
45
+	/**
46
+	 * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration.
47
+	 * Payments are NOT allowed.
48
+	 * Event Admin must manually toggle STS_ID for it to change
49
+	 * No space reserved.
50
+	 * Registration is active
51
+	 */
52
+	const status_id_not_approved = 'RNA';
53
+
54
+	/**
55
+	 * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT .
56
+	 * Payments are allowed.
57
+	 * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
58
+	 * No space reserved.
59
+	 * Registration is active
60
+	 */
61
+	const status_id_pending_payment = 'RPP';
62
+
63
+	/**
64
+	 * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST .
65
+	 * Payments are allowed.
66
+	 * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
67
+	 * No space reserved.
68
+	 * Registration is active
69
+	 */
70
+	const status_id_wait_list = 'RWL';
71
+
72
+	/**
73
+	 * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration.
74
+	 * the TXN may or may not be completed ( paid in full )
75
+	 * Payments are allowed.
76
+	 * A space IS reserved.
77
+	 * Registration is active
78
+	 */
79
+	const status_id_approved = 'RAP';
80
+
81
+	/**
82
+	 * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee.
83
+	 * Payments are NOT allowed.
84
+	 * NO space reserved.
85
+	 * Registration is NOT active
86
+	 */
87
+	const status_id_cancelled = 'RCN';
88
+
89
+	/**
90
+	 * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin
91
+	 * Payments are NOT allowed.
92
+	 * No space reserved.
93
+	 * Registration is NOT active
94
+	 */
95
+	const status_id_declined = 'RDC';
96
+
97
+	/**
98
+	 * @var TableAnalysis $table_analysis
99
+	 */
100
+	protected $_table_analysis;
101
+
102
+
103
+
104
+	/**
105
+	 *    private constructor to prevent direct creation
106
+	 *
107
+	 * @Constructor
108
+	 * @access protected
109
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
110
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
111
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
112
+	 *                         timezone in the 'timezone_string' wp option)
113
+	 */
114
+	protected function __construct($timezone = null)
115
+	{
116
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
117
+		$this->singular_item = __('Registration', 'event_espresso');
118
+		$this->plural_item = __('Registrations', 'event_espresso');
119
+		$this->_tables = array(
120
+			'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'),
121
+		);
122
+		$this->_fields = array(
123
+			'Registration' => array(
124
+				'REG_ID'           => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
125
+				'EVT_ID'           => new EE_Foreign_Key_Int_Field(
126
+					'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'
127
+				),
128
+				'ATT_ID'           => new EE_Foreign_Key_Int_Field(
129
+					'ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'
130
+				),
131
+				'TXN_ID'           => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'),
132
+					false, 0, 'Transaction'
133
+				),
134
+				'TKT_ID'           => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false,
135
+					0, 'Ticket'
136
+				),
137
+				'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
138
+					false, EEM_Registration::status_id_incomplete, 'Status'
139
+				),
140
+				'REG_date'         => new EE_Datetime_Field('REG_date',
141
+					__('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone
142
+				),
143
+				'REG_final_price'  => new EE_Money_Field('REG_final_price',
144
+					__('Registration\'s share of the transaction total', 'event_espresso'), false, 0
145
+				),
146
+				'REG_paid'         => new EE_Money_Field('REG_paid',
147
+					__('Amount paid to date towards registration', 'event_espresso'), false, 0
148
+				),
149
+				'REG_session'      => new EE_Plain_Text_Field('REG_session',
150
+					__('Session ID of registration', 'event_espresso'), false, ''
151
+				),
152
+				'REG_code'         => new EE_Plain_Text_Field('REG_code',
153
+					__('Unique Code for this registration', 'event_espresso'), false, ''
154
+				),
155
+				'REG_url_link'     => new EE_Plain_Text_Field('REG_url_link',
156
+					__('String to be used in URL for identifying registration', 'event_espresso'), false, ''
157
+				),
158
+				'REG_count'        => new EE_Integer_Field('REG_count',
159
+					__('Count of this registration in the group registration ', 'event_espresso'), true, 1
160
+				),
161
+				'REG_group_size'   => new EE_Integer_Field('REG_group_size',
162
+					__('Number of registrations on this group', 'event_espresso'), false, 1
163
+				),
164
+				'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going',
165
+					__('Flag indicating the registrant plans on attending', 'event_espresso'), false, false
166
+				),
167
+				'REG_deleted'      => new EE_Trashed_Flag_Field(
168
+					'REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'),
169
+					false, false
170
+				),
171
+			),
172
+		);
173
+		$this->_model_relations = array(
174
+			'Event'                => new EE_Belongs_To_Relation(),
175
+			'Attendee'             => new EE_Belongs_To_Relation(),
176
+			'Transaction'          => new EE_Belongs_To_Relation(),
177
+			'Ticket'               => new EE_Belongs_To_Relation(),
178
+			'Status'               => new EE_Belongs_To_Relation(),
179
+			'Answer'               => new EE_Has_Many_Relation(),
180
+			'Checkin'              => new EE_Has_Many_Relation(),
181
+			'Registration_Payment' => new EE_Has_Many_Relation(),
182
+			'Payment'              => new EE_HABTM_Relation('Registration_Payment'),
183
+			'Message'              => new EE_Has_Many_Any_Relation(false)
184
+			//allow deletes even if there are messages in the queue related
185
+		);
186
+		$this->_model_chain_to_wp_user = 'Event';
187
+		parent::__construct($timezone);
188
+	}
189
+
190
+
191
+
192
+	/**
193
+	 * reg_statuses_that_allow_payment
194
+	 * a filterable list of registration statuses that allow a registrant to make a payment
195
+	 *
196
+	 * @access public
197
+	 * @return array
198
+	 */
199
+	public static function reg_statuses_that_allow_payment()
200
+	{
201
+		return apply_filters(
202
+			'FHEE__EEM_Registration__reg_statuses_that_allow_payment',
203
+			array(
204
+				EEM_Registration::status_id_approved,
205
+				EEM_Registration::status_id_pending_payment,
206
+				EEM_Registration::status_id_wait_list,
207
+			)
208
+		);
209
+	}
210
+
211
+
212
+
213
+	/**
214
+	 * inactive_reg_statuses
215
+	 * a filterable list of registration statuses that are considered active
216
+	 *
217
+	 * @access public
218
+	 * @return array
219
+	 */
220
+	public static function active_reg_statuses()
221
+	{
222
+		return apply_filters(
223
+			'FHEE__EEM_Registration__reg_statuses_that_allow_payment',
224
+			array(
225
+				EEM_Registration::status_id_approved,
226
+				EEM_Registration::status_id_pending_payment,
227
+				EEM_Registration::status_id_wait_list,
228
+				EEM_Registration::status_id_not_approved,
229
+			)
230
+		);
231
+	}
232
+
233
+
234
+
235
+	/**
236
+	 * inactive_reg_statuses
237
+	 * a filterable list of registration statuses that are not considered active
238
+	 *
239
+	 * @access public
240
+	 * @return array
241
+	 */
242
+	public static function inactive_reg_statuses()
243
+	{
244
+		return apply_filters(
245
+			'FHEE__EEM_Registration__reg_statuses_that_allow_payment',
246
+			array(
247
+				EEM_Registration::status_id_incomplete,
248
+				EEM_Registration::status_id_cancelled,
249
+				EEM_Registration::status_id_declined,
250
+			)
251
+		);
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *    closed_reg_statuses
258
+	 *    a filterable list of registration statuses that are considered "closed"
259
+	 * meaning they should not be considered in any calculations involving monies owing
260
+	 *
261
+	 * @access public
262
+	 * @return array
263
+	 */
264
+	public static function closed_reg_statuses()
265
+	{
266
+		return apply_filters(
267
+			'FHEE__EEM_Registration__closed_reg_statuses',
268
+			array(
269
+				EEM_Registration::status_id_cancelled,
270
+				EEM_Registration::status_id_declined,
271
+			)
272
+		);
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 *        get list of registration statuses
279
+	 *
280
+	 * @access public
281
+	 * @param array $exclude    The status ids to exclude from the returned results
282
+	 * @param bool  $translated If true will return the values as singular localized strings
283
+	 * @return array
284
+	 */
285
+	public static function reg_status_array($exclude = array(), $translated = false)
286
+	{
287
+		EEM_Registration::instance()->_get_registration_status_array($exclude);
288
+		return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence')
289
+			: self::$_reg_status;
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 *    get list of registration statuses
296
+	 *
297
+	 * @access private
298
+	 * @param array $exclude
299
+	 * @return array
300
+	 */
301
+	private function _get_registration_status_array($exclude = array())
302
+	{
303
+		//in the very rare circumstance that we are deleting a model's table's data
304
+		//and the table hasn't actually been created, this could have an error
305
+		/** @type WPDB $wpdb */
306
+		global $wpdb;
307
+		if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
308
+			$results = $wpdb->get_results(
309
+				"SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'"
310
+			);
311
+			self::$_reg_status = array();
312
+			foreach ($results as $status) {
313
+				if ( ! in_array($status->STS_ID, $exclude)) {
314
+					self::$_reg_status[$status->STS_ID] = $status->STS_code;
315
+				}
316
+			}
317
+		}
318
+	}
319
+
320
+
321
+
322
+	/**
323
+	 * Gets the injected table analyzer, or throws an exception
324
+	 *
325
+	 * @return TableAnalysis
326
+	 * @throws \EE_Error
327
+	 */
328
+	protected function _get_table_analysis()
329
+	{
330
+		if ($this->_table_analysis instanceof TableAnalysis) {
331
+			return $this->_table_analysis;
332
+		} else {
333
+			throw new \EE_Error(
334
+				sprintf(
335
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
336
+					get_class($this)
337
+				)
338
+			);
339
+		}
340
+	}
341
+
342
+
343
+
344
+	/**
345
+	 * This returns a wpdb->results array of all registration date month and years matching the incoming query params
346
+	 * and grouped by month and year.
347
+	 *
348
+	 * @param  array $where_params Array of query_params as described in the comments for EEM_Base::get_all()
349
+	 * @return array
350
+	 * @throws \EE_Error
351
+	 */
352
+	public function get_reg_months_and_years($where_params)
353
+	{
354
+		$query_params[0] = $where_params;
355
+		$query_params['group_by'] = array('reg_year', 'reg_month');
356
+		$query_params['order_by'] = array('REG_date' => 'DESC');
357
+		$columns_to_select = array(
358
+			'reg_year'  => array('YEAR(REG_date)', '%s'),
359
+			'reg_month' => array('MONTHNAME(REG_date)', '%s'),
360
+		);
361
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
362
+	}
363
+
364
+
365
+
366
+	/**
367
+	 *        retrieve ALL registrations for a particular Attendee from db
368
+	 *
369
+	 * @access        public
370
+	 * @param        int $ATT_ID
371
+	 * @return    EE_Registration[]
372
+	 */
373
+	public function get_all_registrations_for_attendee($ATT_ID = 0)
374
+	{
375
+		if ( ! $ATT_ID) {
376
+			return false;
377
+		}
378
+		return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
379
+	}
380
+
381
+
382
+
383
+	/**
384
+	 * Gets a registration given their REG_url_link. Yes, this should usually
385
+	 * be passed via a GET parameter.
386
+	 *
387
+	 * @param string $REG_url_link
388
+	 * @return EE_Registration
389
+	 */
390
+	public function get_registration_for_reg_url_link($REG_url_link)
391
+	{
392
+		if ( ! $REG_url_link) {
393
+			return false;
394
+		}
395
+		return $this->get_one(array(array('REG_url_link' => $REG_url_link)));
396
+	}
397
+
398
+
399
+
400
+	/**
401
+	 *        retrieve registration for a specific transaction attendee from db
402
+	 *
403
+	 * @access        public
404
+	 * @param    int $TXN_ID
405
+	 * @param    int $ATT_ID
406
+	 * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
407
+	 *                         attendee number is required
408
+	 * @return        mixed        array on success, FALSE on fail
409
+	 */
410
+	public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
411
+	{
412
+		return $this->get_one(array(
413
+			array(
414
+				'TXN_ID' => $TXN_ID,
415
+				'ATT_ID' => $ATT_ID,
416
+			),
417
+			'limit' => array(min(($att_nmbr - 1), 0), 1),
418
+		));
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 *        get the number of registrations per day  for the Registration Admin page Reports Tab.
425
+	 *        (doesn't utilize models because it's a fairly specialized query)
426
+	 *
427
+	 * @access        public
428
+	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
429
+	 * @return stdClass[] with properties regDate and total
430
+	 */
431
+	public function get_registrations_per_day_report($period = '-1 month')
432
+	{
433
+		$sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
434
+			'Y-m-d H:i:s', 'UTC');
435
+		$where = array(
436
+			'REG_date' => array('>=', $sql_date),
437
+			'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
438
+		);
439
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
440
+			$where['Event.EVT_wp_user'] = get_current_user_id();
441
+		}
442
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
443
+		$results = $this->_get_all_wpdb_results(
444
+			array(
445
+				$where,
446
+				'group_by' => 'regDate',
447
+				'order_by' => array('REG_date' => 'ASC'),
448
+			),
449
+			OBJECT,
450
+			array(
451
+				'regDate' => array('DATE(' . $query_interval . ')', '%s'),
452
+				'total'   => array('count(REG_ID)', '%d'),
453
+			));
454
+		return $results;
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * Get the number of registrations per day including the count of registrations for each Registration Status.
461
+	 * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
462
+	 *
463
+	 * @param string $period
464
+	 * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
465
+	 *                    (i.e. RAP)
466
+	 */
467
+	public function get_registrations_per_day_and_per_status_report($period = '-1 month')
468
+	{
469
+		global $wpdb;
470
+		$registration_table = $wpdb->prefix . 'esp_registration';
471
+		$event_table = $wpdb->posts;
472
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
473
+		//prepare the query interval for displaying offset
474
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
475
+		//inner date query
476
+		$inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
477
+		$inner_where = " WHERE";
478
+		//exclude events not authored by user if permissions in effect
479
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
480
+			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
481
+			$inner_where .= " post_author = " . get_current_user_id() . " AND";
482
+		}
483
+		$inner_where .= " REG_date >= '$sql_date'";
484
+		$inner_date_query .= $inner_where;
485
+		//start main query
486
+		$select = "SELECT DATE($query_interval) as Registration_REG_date, ";
487
+		$join = '';
488
+		$join_parts = array();
489
+		$select_parts = array();
490
+		//loop through registration stati to do parts for each status.
491
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
492
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
493
+				continue;
494
+			}
495
+			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
496
+			$join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'";
497
+		}
498
+		//setup the selects
499
+		$select .= implode(', ', $select_parts);
500
+		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
501
+		//setup the joins
502
+		$join .= implode(" LEFT JOIN ", $join_parts);
503
+		//now let's put it all together
504
+		$query = $select . $join . ' GROUP BY Registration_REG_date';
505
+		//and execute it
506
+		$results = $wpdb->get_results($query, ARRAY_A);
507
+		return $results;
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 *        get the number of registrations per event  for the Registration Admin page Reports Tab
514
+	 *
515
+	 * @access        public
516
+	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
517
+	 * @return stdClass[] each with properties event_name, reg_limit, and total
518
+	 */
519
+	public function get_registrations_per_event_report($period = '-1 month')
520
+	{
521
+		$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
522
+			'Y-m-d H:i:s', 'UTC');
523
+		$where = array(
524
+			'REG_date' => array('>=', $date_sql),
525
+			'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
526
+		);
527
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
528
+			$where['Event.EVT_wp_user'] = get_current_user_id();
529
+		}
530
+		$results = $this->_get_all_wpdb_results(array(
531
+			$where,
532
+			'group_by' => 'Event.EVT_name',
533
+			'order_by' => 'Event.EVT_name',
534
+			'limit'    => array(0, 24),
535
+		),
536
+			OBJECT,
537
+			array(
538
+				'event_name' => array('Event_CPT.post_title', '%s'),
539
+				'total'      => array('COUNT(REG_ID)', '%s'),
540
+			)
541
+		);
542
+		return $results;
543
+	}
544
+
545
+
546
+
547
+	/**
548
+	 * Get the number of registrations per event grouped by registration status.
549
+	 * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
550
+	 *
551
+	 * @param string $period
552
+	 * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
553
+	 *                    (i.e. RAP)
554
+	 */
555
+	public function get_registrations_per_event_and_per_status_report($period = '-1 month')
556
+	{
557
+		global $wpdb;
558
+		$registration_table = $wpdb->prefix . 'esp_registration';
559
+		$event_table = $wpdb->posts;
560
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
561
+		//inner date query
562
+		$inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
563
+		$inner_where = " WHERE";
564
+		//exclude events not authored by user if permissions in effect
565
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
566
+			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
567
+			$inner_where .= " post_author = " . get_current_user_id() . " AND";
568
+		}
569
+		$inner_where .= " REG_date >= '$sql_date'";
570
+		$inner_date_query .= $inner_where;
571
+		//build main query
572
+		$select = "SELECT Event.post_title as Registration_Event, ";
573
+		$join = '';
574
+		$join_parts = array();
575
+		$select_parts = array();
576
+		//loop through registration stati to do parts for each status.
577
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
578
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
579
+				continue;
580
+			}
581
+			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
582
+			$join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date";
583
+		}
584
+		//setup the selects
585
+		$select .= implode(', ', $select_parts);
586
+		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
587
+		//setup remaining joins
588
+		$join .= implode(" LEFT JOIN ", $join_parts);
589
+		//now put it all together
590
+		$query = $select . $join . ' GROUP BY Registration_Event';
591
+		//and execute
592
+		$results = $wpdb->get_results($query, ARRAY_A);
593
+		return $results;
594
+	}
595
+
596
+
597
+
598
+	/**
599
+	 * Returns the EE_Registration of the primary attendee on the transaction id provided
600
+	 *
601
+	 * @param int $TXN_ID
602
+	 * @return EE_Registration
603
+	 */
604
+	public function get_primary_registration_for_transaction_ID($TXN_ID = 0)
605
+	{
606
+		if ( ! $TXN_ID) {
607
+			return false;
608
+		}
609
+		return $this->get_one(array(
610
+			array(
611
+				'TXN_ID'    => $TXN_ID,
612
+				'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT,
613
+			),
614
+		));
615
+	}
616
+
617
+
618
+
619
+	/**
620
+	 *        get_event_registration_count
621
+	 *
622
+	 * @access public
623
+	 * @param int     $EVT_ID
624
+	 * @param boolean $for_incomplete_payments
625
+	 * @return int
626
+	 */
627
+	public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false)
628
+	{
629
+		// we only count approved registrations towards registration limits
630
+		$query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
631
+		if ($for_incomplete_payments) {
632
+			$query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
633
+		}
634
+		return $this->count($query_params);
635
+	}
636
+
637
+
638
+
639
+	/**
640
+	 * Deletes all registrations with no transactions. Note that this needs to be very efficient
641
+	 * and so it uses wpdb directly
642
+	 *
643
+	 * @global WPDB $wpdb
644
+	 * @return int number deleted
645
+	 */
646
+	public function delete_registrations_with_no_transaction()
647
+	{
648
+		/** @type WPDB $wpdb */
649
+		global $wpdb;
650
+		return $wpdb->query(
651
+			'DELETE r FROM '
652
+			. $this->table()
653
+			. ' r LEFT JOIN '
654
+			. EEM_Transaction::instance()->table()
655
+			. ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL');
656
+	}
657
+
658
+
659
+
660
+	/**
661
+	 *  Count registrations checked into (or out of) a datetime
662
+	 *
663
+	 * @param int     $DTT_ID     datetime ID
664
+	 * @param boolean $checked_in whether to count registrations checked IN or OUT
665
+	 * @return int
666
+	 */
667
+	public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true)
668
+	{
669
+		global $wpdb;
670
+		//subquery to get latest checkin
671
+		$query = $wpdb->prepare(
672
+			'SELECT '
673
+			. 'COUNT( DISTINCT checkins.REG_ID ) '
674
+			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
675
+			. '( SELECT '
676
+			. 'max( CHK_timestamp ) AS latest_checkin, '
677
+			. 'REG_ID AS REG_ID '
678
+			. 'FROM ' . EEM_Checkin::instance()->table() . ' '
679
+			. 'WHERE DTT_ID=%d '
680
+			. 'GROUP BY REG_ID'
681
+			. ') AS most_recent_checkin_per_reg '
682
+			. 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
683
+			. 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
684
+			. 'WHERE '
685
+			. 'checkins.CHK_in=%d',
686
+			$DTT_ID,
687
+			$checked_in
688
+		);
689
+		return (int)$wpdb->get_var($query);
690
+	}
691
+
692
+
693
+
694
+	/**
695
+	 *  Count registrations checked into (or out of) an event.
696
+	 *
697
+	 * @param int     $EVT_ID     event ID
698
+	 * @param boolean $checked_in whether to count registrations checked IN or OUT
699
+	 * @return int
700
+	 */
701
+	public function count_registrations_checked_into_event($EVT_ID, $checked_in = true)
702
+	{
703
+		global $wpdb;
704
+		//subquery to get latest checkin
705
+		$query = $wpdb->prepare(
706
+			'SELECT '
707
+			. 'COUNT( DISTINCT checkins.REG_ID ) '
708
+			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
709
+			. '( SELECT '
710
+			. 'max( CHK_timestamp ) AS latest_checkin, '
711
+			. 'REG_ID AS REG_ID '
712
+			. 'FROM ' . EEM_Checkin::instance()->table() . ' AS c '
713
+			. 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d '
714
+			. 'ON c.DTT_ID=d.DTT_ID '
715
+			. 'WHERE d.EVT_ID=%d '
716
+			. 'GROUP BY REG_ID'
717
+			. ') AS most_recent_checkin_per_reg '
718
+			. 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
719
+			. 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
720
+			. 'WHERE '
721
+			. 'checkins.CHK_in=%d',
722
+			$EVT_ID,
723
+			$checked_in
724
+		);
725
+		return (int)$wpdb->get_var($query);
726
+	}
727
+
728
+
729
+
730
+	/**
731
+	 * The purpose of this method is to retrieve an array of
732
+	 * EE_Registration objects that represent the latest registration
733
+	 * for each ATT_ID given in the function argument.
734
+	 *
735
+	 * @param array $attendee_ids
736
+	 * @return EE_Registration[]
737
+	 */
738
+	public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array())
739
+	{
740
+		//first do a native wp_query to get the latest REG_ID's matching these attendees.
741
+		global $wpdb;
742
+		$registration_table = $wpdb->prefix . 'esp_registration';
743
+		$attendee_table = $wpdb->posts;
744
+		$attendee_ids = is_array($attendee_ids)
745
+			? array_map('absint', $attendee_ids)
746
+			: array((int)$attendee_ids);
747
+		$attendee_ids = implode(',', $attendee_ids);
748
+		//first we do a query to get the registration ids
749
+		// (because a group by before order by causes the order by to be ignored.)
750
+		$registration_id_query = "
751 751
 			SELECT registrations.registration_ids as registration_id
752 752
 			FROM (
753 753
 				SELECT
@@ -761,23 +761,23 @@  discard block
 block discarded – undo
761 761
 			  ) AS registrations
762 762
 			  GROUP BY registrations.attendee_ids
763 763
 		";
764
-        $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A);
765
-        if (empty($registration_ids)) {
766
-            return array();
767
-        }
768
-        $ids_for_model_query = array();
769
-        //let's flatten the ids so they can be used in the model query.
770
-        foreach ($registration_ids as $registration_id) {
771
-            if (isset($registration_id['registration_id'])) {
772
-                $ids_for_model_query[] = $registration_id['registration_id'];
773
-            }
774
-        }
775
-        //construct query
776
-        $_where = array(
777
-            'REG_ID' => array('IN', $ids_for_model_query),
778
-        );
779
-        return $this->get_all(array($_where));
780
-    }
764
+		$registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A);
765
+		if (empty($registration_ids)) {
766
+			return array();
767
+		}
768
+		$ids_for_model_query = array();
769
+		//let's flatten the ids so they can be used in the model query.
770
+		foreach ($registration_ids as $registration_id) {
771
+			if (isset($registration_id['registration_id'])) {
772
+				$ids_for_model_query[] = $registration_id['registration_id'];
773
+			}
774
+		}
775
+		//construct query
776
+		$_where = array(
777
+			'REG_ID' => array('IN', $ids_for_model_query),
778
+		);
779
+		return $this->get_all(array($_where));
780
+	}
781 781
 
782 782
 
783 783
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         //and the table hasn't actually been created, this could have an error
305 305
         /** @type WPDB $wpdb */
306 306
         global $wpdb;
307
-        if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
307
+        if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) {
308 308
             $results = $wpdb->get_results(
309 309
                 "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'"
310 310
             );
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             ),
449 449
             OBJECT,
450 450
             array(
451
-                'regDate' => array('DATE(' . $query_interval . ')', '%s'),
451
+                'regDate' => array('DATE('.$query_interval.')', '%s'),
452 452
                 'total'   => array('count(REG_ID)', '%d'),
453 453
             ));
454 454
         return $results;
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     public function get_registrations_per_day_and_per_status_report($period = '-1 month')
468 468
     {
469 469
         global $wpdb;
470
-        $registration_table = $wpdb->prefix . 'esp_registration';
470
+        $registration_table = $wpdb->prefix.'esp_registration';
471 471
         $event_table = $wpdb->posts;
472 472
         $sql_date = date("Y-m-d H:i:s", strtotime($period));
473 473
         //prepare the query interval for displaying offset
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         //exclude events not authored by user if permissions in effect
479 479
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
480 480
             $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
481
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
481
+            $inner_where .= " post_author = ".get_current_user_id()." AND";
482 482
         }
483 483
         $inner_where .= " REG_date >= '$sql_date'";
484 484
         $inner_date_query .= $inner_where;
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
         //setup the joins
502 502
         $join .= implode(" LEFT JOIN ", $join_parts);
503 503
         //now let's put it all together
504
-        $query = $select . $join . ' GROUP BY Registration_REG_date';
504
+        $query = $select.$join.' GROUP BY Registration_REG_date';
505 505
         //and execute it
506 506
         $results = $wpdb->get_results($query, ARRAY_A);
507 507
         return $results;
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
     public function get_registrations_per_event_and_per_status_report($period = '-1 month')
556 556
     {
557 557
         global $wpdb;
558
-        $registration_table = $wpdb->prefix . 'esp_registration';
558
+        $registration_table = $wpdb->prefix.'esp_registration';
559 559
         $event_table = $wpdb->posts;
560 560
         $sql_date = date("Y-m-d H:i:s", strtotime($period));
561 561
         //inner date query
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         //exclude events not authored by user if permissions in effect
565 565
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
566 566
             $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
567
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
567
+            $inner_where .= " post_author = ".get_current_user_id()." AND";
568 568
         }
569 569
         $inner_where .= " REG_date >= '$sql_date'";
570 570
         $inner_date_query .= $inner_where;
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
         //setup remaining joins
588 588
         $join .= implode(" LEFT JOIN ", $join_parts);
589 589
         //now put it all together
590
-        $query = $select . $join . ' GROUP BY Registration_Event';
590
+        $query = $select.$join.' GROUP BY Registration_Event';
591 591
         //and execute
592 592
         $results = $wpdb->get_results($query, ARRAY_A);
593 593
         return $results;
@@ -671,11 +671,11 @@  discard block
 block discarded – undo
671 671
         $query = $wpdb->prepare(
672 672
             'SELECT '
673 673
             . 'COUNT( DISTINCT checkins.REG_ID ) '
674
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
674
+            . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN'
675 675
             . '( SELECT '
676 676
             . 'max( CHK_timestamp ) AS latest_checkin, '
677 677
             . 'REG_ID AS REG_ID '
678
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' '
678
+            . 'FROM '.EEM_Checkin::instance()->table().' '
679 679
             . 'WHERE DTT_ID=%d '
680 680
             . 'GROUP BY REG_ID'
681 681
             . ') AS most_recent_checkin_per_reg '
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
             $DTT_ID,
687 687
             $checked_in
688 688
         );
689
-        return (int)$wpdb->get_var($query);
689
+        return (int) $wpdb->get_var($query);
690 690
     }
691 691
 
692 692
 
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
         $query = $wpdb->prepare(
706 706
             'SELECT '
707 707
             . 'COUNT( DISTINCT checkins.REG_ID ) '
708
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN'
708
+            . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN'
709 709
             . '( SELECT '
710 710
             . 'max( CHK_timestamp ) AS latest_checkin, '
711 711
             . 'REG_ID AS REG_ID '
712
-            . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c '
713
-            . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d '
712
+            . 'FROM '.EEM_Checkin::instance()->table().' AS c '
713
+            . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d '
714 714
             . 'ON c.DTT_ID=d.DTT_ID '
715 715
             . 'WHERE d.EVT_ID=%d '
716 716
             . 'GROUP BY REG_ID'
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
             $EVT_ID,
723 723
             $checked_in
724 724
         );
725
-        return (int)$wpdb->get_var($query);
725
+        return (int) $wpdb->get_var($query);
726 726
     }
727 727
 
728 728
 
@@ -739,11 +739,11 @@  discard block
 block discarded – undo
739 739
     {
740 740
         //first do a native wp_query to get the latest REG_ID's matching these attendees.
741 741
         global $wpdb;
742
-        $registration_table = $wpdb->prefix . 'esp_registration';
742
+        $registration_table = $wpdb->prefix.'esp_registration';
743 743
         $attendee_table = $wpdb->posts;
744 744
         $attendee_ids = is_array($attendee_ids)
745 745
             ? array_map('absint', $attendee_ids)
746
-            : array((int)$attendee_ids);
746
+            : array((int) $attendee_ids);
747 747
         $attendee_ids = implode(',', $attendee_ids);
748 748
         //first we do a query to get the registration ids
749 749
         // (because a group by before order by causes the order by to be ignored.)
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -418,7 +418,7 @@
 block discarded – undo
418 418
      * In this case, we delete the temporary file
419 419
      *
420 420
      * @param JobParameters $job_parameters
421
-     * @return boolean
421
+     * @return JobStepResponse
422 422
      */
423 423
     public function cleanup_job(JobParameters $job_parameters)
424 424
     {
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@
 block discarded – undo
174 174
                 $job_parameters->extra_datum('query_params'));
175 175
             \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
176 176
             $units_processed = count($csv_data);
177
-        }else{
177
+        } else{
178 178
             $units_processed = 0;
179 179
         }
180 180
         $job_parameters->mark_processed($units_processed);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                 array_diff_key(
84 84
                     $query_params,
85 85
                     array_flip(
86
-                        array( 'limit' )
86
+                        array('limit')
87 87
                     )
88 88
                 )
89 89
             )
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
             );
131 131
         }
132 132
         $question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
-        if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
133
+        if (apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134 134
             $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135 135
         }
136
-        $question_query_params['group_by'] = array( 'QST_ID' );
137
-        return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
136
+        $question_query_params['group_by'] = array('QST_ID');
137
+        return array_unique(\EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
138 138
     }
139 139
 
140 140
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154 154
             } else {
155 155
                 //it's a normal where condition
156
-                $question_where_params['Question_Group.Event.Registration.' . $key] = $val;
156
+                $question_where_params['Question_Group.Event.Registration.'.$key] = $val;
157 157
             }
158 158
         }
159 159
         return $question_where_params;
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173 173
     {
174
-        if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
174
+        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
175 175
             $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176 176
                 $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177 177
                 $job_parameters->extra_datum('query_params'));
178 178
             \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179 179
             $units_processed = count($csv_data);
180
-        }else{
180
+        } else {
181 181
             $units_processed = 0;
182 182
         }
183 183
         $job_parameters->mark_processed($units_processed);
Please login to merge, or discard this patch.
Indentation   +414 added lines, -415 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
18 18
 
19 19
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
-    exit('No direct script access allowed');
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -25,443 +25,442 @@  discard block
 block discarded – undo
25 25
 class RegistrationsReport extends JobHandlerFile
26 26
 {
27 27
 
28
-    /**
29
-     * Performs any necessary setup for starting the job. This is also a good
30
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
-     * when continue_job will be called
32
-     *
33
-     * @param JobParameters $job_parameters
34
-     * @throws BatchRequestException
35
-     * @return JobStepResponse
36
-     */
37
-    public function create_job(JobParameters $job_parameters)
38
-    {
39
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
-        if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
-        }
43
-        $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
-            $this->get_filename($event_id));
45
-        $job_parameters->add_extra_data('filepath', $filepath);
46
-        if ($job_parameters->request_datum('use_filters', false)) {
47
-            $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
48
-        } else {
49
-            $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
50
-                array(
51
-                    'OR'                 => array(
52
-                        //don't include registrations from failed or abandoned transactions...
53
-                        'Transaction.STS_ID' => array(
54
-                            'NOT IN',
55
-                            array(
56
-                                \EEM_Transaction::failed_status_code,
57
-                                \EEM_Transaction::abandoned_status_code,
58
-                            ),
59
-                        ),
60
-                        //unless the registration is approved, in which case include it regardless of transaction status
61
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
62
-                    ),
63
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
64
-                ),
65
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
66
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
67
-                'caps'       => \EEM_Base::caps_read_admin,
68
-            ), $event_id);
69
-            if ($event_id) {
70
-                $query_params[0]['EVT_ID'] = $event_id;
71
-            } else {
72
-                $query_params['force_join'][] = 'Event';
73
-            }
74
-        }
75
-        if ( ! isset($query_params['force_join'])) {
76
-            $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
77
-        }
78
-        $job_parameters->add_extra_data('query_params', $query_params);
79
-        $question_labels = $this->_get_question_labels($query_params);
80
-        $job_parameters->add_extra_data('question_labels', $question_labels);
81
-        $job_parameters->set_job_size(
82
-            \EEM_Registration::instance()->count(
83
-                array_diff_key(
84
-                    $query_params,
85
-                    array_flip(
86
-                        array( 'limit' )
87
-                    )
88
-                )
89
-            )
90
-        );
91
-        //we should also set the header columns
92
-        $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'),
93
-            $job_parameters->extra_datum('query_params'));
94
-        \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
95
-        //if we actually processed a row there, record it
96
-        if ($job_parameters->job_size()) {
97
-            $job_parameters->mark_processed(1);
98
-        }
99
-        return new JobStepResponse($job_parameters,
100
-            __('Registrations report started successfully...', 'event_espresso'));
101
-    }
28
+	/**
29
+	 * Performs any necessary setup for starting the job. This is also a good
30
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
+	 * when continue_job will be called
32
+	 *
33
+	 * @param JobParameters $job_parameters
34
+	 * @throws BatchRequestException
35
+	 * @return JobStepResponse
36
+	 */
37
+	public function create_job(JobParameters $job_parameters)
38
+	{
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
+			throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
+		}
43
+		$filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
+			$this->get_filename($event_id));
45
+		$job_parameters->add_extra_data('filepath', $filepath);
46
+		if ($job_parameters->request_datum('use_filters', false)) {
47
+			$query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
48
+		} else {
49
+			$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
50
+				array(
51
+					'OR'                 => array(
52
+						//don't include registrations from failed or abandoned transactions...
53
+						'Transaction.STS_ID' => array(
54
+							'NOT IN',
55
+							array(
56
+								\EEM_Transaction::failed_status_code,
57
+								\EEM_Transaction::abandoned_status_code,
58
+							),
59
+						),
60
+						//unless the registration is approved, in which case include it regardless of transaction status
61
+						'STS_ID'             => \EEM_Registration::status_id_approved,
62
+					),
63
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
64
+				),
65
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
66
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
67
+				'caps'       => \EEM_Base::caps_read_admin,
68
+			), $event_id);
69
+			if ($event_id) {
70
+				$query_params[0]['EVT_ID'] = $event_id;
71
+			} else {
72
+				$query_params['force_join'][] = 'Event';
73
+			}
74
+		}
75
+		if ( ! isset($query_params['force_join'])) {
76
+			$query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
77
+		}
78
+		$job_parameters->add_extra_data('query_params', $query_params);
79
+		$question_labels = $this->_get_question_labels($query_params);
80
+		$job_parameters->add_extra_data('question_labels', $question_labels);
81
+		$job_parameters->set_job_size(
82
+			\EEM_Registration::instance()->count(
83
+				array_diff_key(
84
+					$query_params,
85
+					array_flip(
86
+						array( 'limit' )
87
+					)
88
+				)
89
+			)
90
+		);
91
+		//we should also set the header columns
92
+		$csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'),
93
+			$job_parameters->extra_datum('query_params'));
94
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
95
+		//if we actually processed a row there, record it
96
+		if ($job_parameters->job_size()) {
97
+			$job_parameters->mark_processed(1);
98
+		}
99
+		return new JobStepResponse($job_parameters,
100
+			__('Registrations report started successfully...', 'event_espresso'));
101
+	}
102 102
 
103 103
 
104 104
 
105
-    /**
106
-     * Gets the filename
107
-     * @return string
108
-     */
109
-    protected function get_filename()
110
-    {
111
-        return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
112
-    }
105
+	/**
106
+	 * Gets the filename
107
+	 * @return string
108
+	 */
109
+	protected function get_filename()
110
+	{
111
+		return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
112
+	}
113 113
 
114 114
 
115 115
 
116
-    /**
117
-     * Gets the questions which are to be used for this report, so they
118
-     * can be remembered for later
119
-     *
120
-     * @param array $registration_query_params
121
-     * @return array question admin labels to be used for this report
122
-     */
123
-    protected function _get_question_labels($registration_query_params)
124
-    {
125
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
126
-        $question_query_params = array();
127
-        if ($where !== null) {
128
-            $question_query_params = array(
129
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
130
-            );
131
-        }
132
-        $question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
-        if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135
-        }
136
-        $question_query_params['group_by'] = array( 'QST_ID' );
137
-        return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
138
-    }
116
+	/**
117
+	 * Gets the questions which are to be used for this report, so they
118
+	 * can be remembered for later
119
+	 *
120
+	 * @param array $registration_query_params
121
+	 * @return array question admin labels to be used for this report
122
+	 */
123
+	protected function _get_question_labels($registration_query_params)
124
+	{
125
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
126
+		$question_query_params = array();
127
+		if ($where !== null) {
128
+			$question_query_params = array(
129
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
130
+			);
131
+		}
132
+		$question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
+		if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135
+		}
136
+		$question_query_params['group_by'] = array( 'QST_ID' );
137
+		return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
138
+	}
139 139
 
140 140
 
141 141
 
142
-    /**
143
-     * Takes where params meant for registrations and changes them to work for questions
144
-     *
145
-     * @param array $reg_where_params
146
-     * @return array
147
-     */
148
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
149
-    {
150
-        $question_where_params = array();
151
-        foreach ($reg_where_params as $key => $val) {
152
-            if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
153
-                $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154
-            } else {
155
-                //it's a normal where condition
156
-                $question_where_params['Question_Group.Event.Registration.' . $key] = $val;
157
-            }
158
-        }
159
-        return $question_where_params;
160
-    }
142
+	/**
143
+	 * Takes where params meant for registrations and changes them to work for questions
144
+	 *
145
+	 * @param array $reg_where_params
146
+	 * @return array
147
+	 */
148
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
149
+	{
150
+		$question_where_params = array();
151
+		foreach ($reg_where_params as $key => $val) {
152
+			if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
153
+				$question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154
+			} else {
155
+				//it's a normal where condition
156
+				$question_where_params['Question_Group.Event.Registration.' . $key] = $val;
157
+			}
158
+		}
159
+		return $question_where_params;
160
+	}
161 161
 
162 162
 
163 163
 
164
-    /**
165
-     * Performs another step of the job
166
-     *
167
-     * @param JobParameters $job_parameters
168
-     * @param int           $batch_size
169
-     * @return JobStepResponse
170
-     * @throws \EE_Error
171
-     */
172
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173
-    {
174
-        if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
175
-            $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176
-                $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177
-                $job_parameters->extra_datum('query_params'));
178
-            \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179
-            $units_processed = count($csv_data);
180
-        }else{
181
-            $units_processed = 0;
182
-        }
183
-        $job_parameters->mark_processed($units_processed);
184
-        $extra_response_data = array(
185
-            'file_url' => '',
186
-        );
187
-        if ($units_processed < $batch_size) {
188
-            $job_parameters->set_status(JobParameters::status_complete);
189
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
190
-        }
164
+	/**
165
+	 * Performs another step of the job
166
+	 *
167
+	 * @param JobParameters $job_parameters
168
+	 * @param int           $batch_size
169
+	 * @return JobStepResponse
170
+	 * @throws \EE_Error
171
+	 */
172
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173
+	{
174
+		if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
175
+			$csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176
+				$job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177
+				$job_parameters->extra_datum('query_params'));
178
+			\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179
+			$units_processed = count($csv_data);
180
+		}else{
181
+			$units_processed = 0;
182
+		}
183
+		$job_parameters->mark_processed($units_processed);
184
+		$extra_response_data = array(
185
+			'file_url' => '',
186
+		);
187
+		if ($units_processed < $batch_size) {
188
+			$job_parameters->set_status(JobParameters::status_complete);
189
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
190
+		}
191 191
 
192
-        return new JobStepResponse($job_parameters,
193
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
194
-            $extra_response_data);
195
-    }
192
+		return new JobStepResponse($job_parameters,
193
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
194
+			$extra_response_data);
195
+	}
196 196
 
197 197
 
198 198
 
199
-    /**
200
-     * Gets the csv data for a batch of registrations
201
-
202
-     *
199
+	/**
200
+	 * Gets the csv data for a batch of registrations
201
+	 *
203 202
 *@param int|null    $event_id
204
-     * @param int   $offset
205
-     * @param int   $limit
206
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
207
-     * @param array $query_params    for using where querying the model
208
-     * @return array top-level keys are numeric, next-level keys are column headers
209
-     */
210
-    function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
211
-    {
212
-        $reg_fields_to_include = array(
213
-            'TXN_ID',
214
-            'ATT_ID',
215
-            'REG_ID',
216
-            'REG_date',
217
-            'REG_code',
218
-            'REG_count',
219
-            'REG_final_price',
220
-        );
221
-        $att_fields_to_include = array(
222
-            'ATT_fname',
223
-            'ATT_lname',
224
-            'ATT_email',
225
-            'ATT_address',
226
-            'ATT_address2',
227
-            'ATT_city',
228
-            'STA_ID',
229
-            'CNT_ISO',
230
-            'ATT_zip',
231
-            'ATT_phone',
232
-        );
233
-        $registrations_csv_ready_array = array();
234
-        $reg_model = \EE_Registry::instance()->load_model('Registration');
235
-        $query_params['limit'] = array($offset, $limit);
236
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
237
-        $registration_ids = array();
238
-        foreach ($registration_rows as $reg_row) {
239
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
240
-        }
241
-        foreach ($registration_rows as $reg_row) {
242
-            if (is_array($reg_row)) {
243
-                $reg_csv_array = array();
244
-                if ( ! $event_id) {
245
-                    //get the event's name and Id
246
-                    $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
247
-                        \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
248
-                            $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
249
-                }
250
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
251
-                /*@var $reg_row EE_Registration */
252
-                foreach ($reg_fields_to_include as $field_name) {
253
-                    $field = $reg_model->field_settings_for($field_name);
254
-                    if ($field_name == 'REG_final_price') {
255
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
256
-                            $reg_row['Registration.REG_final_price'], 'localized_float');
257
-                    } elseif ($field_name == 'REG_count') {
258
-                        $value = sprintf(__('%s of %s', 'event_espresso'),
259
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
260
-                                $reg_row['Registration.REG_count']),
261
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
262
-                                $reg_row['Registration.REG_group_size']));
263
-                    } elseif ($field_name == 'REG_date') {
264
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
265
-                            $reg_row['Registration.REG_date'], 'no_html');
266
-                    } else {
267
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
268
-                            $reg_row[$field->get_qualified_column()]);
269
-                    }
270
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
271
-                    if ($field_name == 'REG_final_price') {
272
-                        //add a column named Currency after the final price
273
-                        $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
274
-                    }
275
-                }
276
-                //get pretty status
277
-                $stati = \EEM_Status::instance()->localized_status(array(
278
-                    $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
279
-                    $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
280
-                ), false, 'sentence');
281
-                $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
282
-                //get pretty transaction status
283
-                $reg_csv_array[__("Transaction Status",
284
-                    'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
285
-                $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
286
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
287
-                        $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
288
-                $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
289
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
290
-                        $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
291
-                $payment_methods = array();
292
-                $gateway_txn_ids_etc = array();
293
-                $payment_times = array();
294
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
295
-                    $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
296
-                        array(
297
-                            'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
298
-                            'STS_ID' => \EEM_Payment::status_id_approved,
299
-                        ),
300
-                        'force_join' => array('Payment_Method'),
301
-                    ), ARRAY_A,
302
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
303
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
304
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
305
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
306
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
307
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
308
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
309
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
310
-                    }
311
-                }
312
-                $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
313
-                $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
314
-                $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
315
-                //get whether or not the user has checked in
316
-                $reg_csv_array[__("Check-Ins",
317
-                    "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
318
-                //get ticket of registration and its price
319
-                $ticket_model = \EE_Registry::instance()->load_model('Ticket');
320
-                if ($reg_row['Ticket.TKT_ID']) {
321
-                    $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
322
-                        $reg_row['Ticket.TKT_name']);
323
-                    $datetimes_strings = array();
324
-                    foreach (
325
-                        \EEM_Datetime::instance()->get_all_wpdb_results(array(
326
-                            array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
327
-                            'order_by'                 => array('DTT_EVT_start' => 'ASC'),
328
-                            'default_where_conditions' => 'none',
329
-                        )) as $datetime
330
-                    ) {
331
-                        $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
332
-                            'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
333
-                    }
334
-                } else {
335
-                    $ticket_name = __('Unknown', 'event_espresso');
336
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
337
-                }
338
-                $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
339
-                $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
340
-                //get datetime(s) of registration
341
-                //add attendee columns
342
-                foreach ($att_fields_to_include as $att_field_name) {
343
-                    $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
344
-                    if ($reg_row['Attendee_CPT.ID']) {
345
-                        if ($att_field_name == 'STA_ID') {
346
-                            $value = \EEM_State::instance()
347
-                                               ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
348
-                                                   'STA_name');
349
-                        } elseif ($att_field_name == 'CNT_ISO') {
350
-                            $value = \EEM_Country::instance()
351
-                                                 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
352
-                                                     'CNT_name');
353
-                        } else {
354
-                            $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
355
-                                $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
356
-                        }
357
-                    } else {
358
-                        $value = '';
359
-                    }
360
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
361
-                }
362
-                //make sure each registration has the same questions in the same order
363
-                foreach ($question_labels as $question_label) {
364
-                    if ( ! isset($reg_csv_array[$question_label])) {
365
-                        $reg_csv_array[$question_label] = null;
366
-                    }
367
-                }
368
-                $answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
369
-                    array('REG_ID' => $reg_row['Registration.REG_ID']),
370
-                    'force_join' => array('Question'),
371
-                ));
372
-                //now fill out the questions THEY answered
373
-                foreach ($answers as $answer_row) {
374
-                    if ($answer_row['Question.QST_ID']) {
375
-                        $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
376
-                            'QST_admin_label', $answer_row['Question.QST_admin_label']);
377
-                    } else {
378
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
379
-                    }
380
-                    if (isset($answer_row['Question.QST_type'])
381
-                        && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
382
-                    ) {
383
-                        $reg_csv_array[$question_label] = \EEM_State::instance()
384
-                                                                    ->get_state_name_by_ID($answer_row['Answer.ANS_value']);
385
-                    } else {
386
-                        //this isn't for html, so don't show html entities
387
-                        $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
388
-                            'ANS_value', $answer_row['Answer.ANS_value']));
389
-                    }
390
-                }
391
-                /**
392
-                 * Filter to change the contents of each row of the registrations report CSV file.
393
-                 *
394
-                 * This can be used to add or remote columns from the CSV file, or change their values.                 *
395
-                 * Note: it has this name because originally that's where this filter resided,
396
-                 * and we've left its name as-is for backward compatibility.
397
-                 * Note when using: all rows in the CSV should have the same columns.
398
-                 *
399
-                 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
400
-                 *                             in this row
401
-                 * @param array $reg_row is the row from the database's wp_esp_registration table
402
-                 *
403
-                 */
404
-                $registrations_csv_ready_array[] = apply_filters(
405
-                    'FHEE__EE_Export__report_registrations__reg_csv_array',
406
-                    $reg_csv_array,
407
-                    $reg_row
408
-                );
409
-            }
410
-        }
411
-        //if we couldn't export anything, we want to at least show the column headers
412
-        if (empty($registrations_csv_ready_array)) {
413
-            $reg_csv_array = array();
414
-            $model_and_fields_to_include = array(
415
-                'Registration' => $reg_fields_to_include,
416
-                'Attendee'     => $att_fields_to_include,
417
-            );
418
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
419
-                $model = \EE_Registry::instance()->load_model($model_name);
420
-                foreach ($field_list as $field_name) {
421
-                    $field = $model->field_settings_for($field_name);
422
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
423
-                }
424
-            }
425
-            $registrations_csv_ready_array[] = $reg_csv_array;
426
-        }
427
-        return $registrations_csv_ready_array;
428
-    }
203
+	 * @param int   $offset
204
+	 * @param int   $limit
205
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
206
+	 * @param array $query_params    for using where querying the model
207
+	 * @return array top-level keys are numeric, next-level keys are column headers
208
+	 */
209
+	function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
210
+	{
211
+		$reg_fields_to_include = array(
212
+			'TXN_ID',
213
+			'ATT_ID',
214
+			'REG_ID',
215
+			'REG_date',
216
+			'REG_code',
217
+			'REG_count',
218
+			'REG_final_price',
219
+		);
220
+		$att_fields_to_include = array(
221
+			'ATT_fname',
222
+			'ATT_lname',
223
+			'ATT_email',
224
+			'ATT_address',
225
+			'ATT_address2',
226
+			'ATT_city',
227
+			'STA_ID',
228
+			'CNT_ISO',
229
+			'ATT_zip',
230
+			'ATT_phone',
231
+		);
232
+		$registrations_csv_ready_array = array();
233
+		$reg_model = \EE_Registry::instance()->load_model('Registration');
234
+		$query_params['limit'] = array($offset, $limit);
235
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
236
+		$registration_ids = array();
237
+		foreach ($registration_rows as $reg_row) {
238
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
239
+		}
240
+		foreach ($registration_rows as $reg_row) {
241
+			if (is_array($reg_row)) {
242
+				$reg_csv_array = array();
243
+				if ( ! $event_id) {
244
+					//get the event's name and Id
245
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
246
+						\EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
247
+							$reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
248
+				}
249
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
250
+				/*@var $reg_row EE_Registration */
251
+				foreach ($reg_fields_to_include as $field_name) {
252
+					$field = $reg_model->field_settings_for($field_name);
253
+					if ($field_name == 'REG_final_price') {
254
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
255
+							$reg_row['Registration.REG_final_price'], 'localized_float');
256
+					} elseif ($field_name == 'REG_count') {
257
+						$value = sprintf(__('%s of %s', 'event_espresso'),
258
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
259
+								$reg_row['Registration.REG_count']),
260
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
261
+								$reg_row['Registration.REG_group_size']));
262
+					} elseif ($field_name == 'REG_date') {
263
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
264
+							$reg_row['Registration.REG_date'], 'no_html');
265
+					} else {
266
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
267
+							$reg_row[$field->get_qualified_column()]);
268
+					}
269
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
270
+					if ($field_name == 'REG_final_price') {
271
+						//add a column named Currency after the final price
272
+						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
273
+					}
274
+				}
275
+				//get pretty status
276
+				$stati = \EEM_Status::instance()->localized_status(array(
277
+					$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
278
+					$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
279
+				), false, 'sentence');
280
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
281
+				//get pretty transaction status
282
+				$reg_csv_array[__("Transaction Status",
283
+					'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
284
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
285
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
286
+						$reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
287
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
288
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
289
+						$reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
290
+				$payment_methods = array();
291
+				$gateway_txn_ids_etc = array();
292
+				$payment_times = array();
293
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
294
+					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
295
+						array(
296
+							'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
297
+							'STS_ID' => \EEM_Payment::status_id_approved,
298
+						),
299
+						'force_join' => array('Payment_Method'),
300
+					), ARRAY_A,
301
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
302
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
303
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
304
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
305
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
306
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
307
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
308
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
309
+					}
310
+				}
311
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
312
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
313
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
314
+				//get whether or not the user has checked in
315
+				$reg_csv_array[__("Check-Ins",
316
+					"event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
317
+				//get ticket of registration and its price
318
+				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
319
+				if ($reg_row['Ticket.TKT_ID']) {
320
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
321
+						$reg_row['Ticket.TKT_name']);
322
+					$datetimes_strings = array();
323
+					foreach (
324
+						\EEM_Datetime::instance()->get_all_wpdb_results(array(
325
+							array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
326
+							'order_by'                 => array('DTT_EVT_start' => 'ASC'),
327
+							'default_where_conditions' => 'none',
328
+						)) as $datetime
329
+					) {
330
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
331
+							'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
332
+					}
333
+				} else {
334
+					$ticket_name = __('Unknown', 'event_espresso');
335
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
336
+				}
337
+				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
338
+				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
339
+				//get datetime(s) of registration
340
+				//add attendee columns
341
+				foreach ($att_fields_to_include as $att_field_name) {
342
+					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
343
+					if ($reg_row['Attendee_CPT.ID']) {
344
+						if ($att_field_name == 'STA_ID') {
345
+							$value = \EEM_State::instance()
346
+											   ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
347
+												   'STA_name');
348
+						} elseif ($att_field_name == 'CNT_ISO') {
349
+							$value = \EEM_Country::instance()
350
+												 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
351
+													 'CNT_name');
352
+						} else {
353
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
354
+								$att_field_name, $reg_row[$field_obj->get_qualified_column()]);
355
+						}
356
+					} else {
357
+						$value = '';
358
+					}
359
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
360
+				}
361
+				//make sure each registration has the same questions in the same order
362
+				foreach ($question_labels as $question_label) {
363
+					if ( ! isset($reg_csv_array[$question_label])) {
364
+						$reg_csv_array[$question_label] = null;
365
+					}
366
+				}
367
+				$answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
368
+					array('REG_ID' => $reg_row['Registration.REG_ID']),
369
+					'force_join' => array('Question'),
370
+				));
371
+				//now fill out the questions THEY answered
372
+				foreach ($answers as $answer_row) {
373
+					if ($answer_row['Question.QST_ID']) {
374
+						$question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
375
+							'QST_admin_label', $answer_row['Question.QST_admin_label']);
376
+					} else {
377
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
378
+					}
379
+					if (isset($answer_row['Question.QST_type'])
380
+						&& $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
381
+					) {
382
+						$reg_csv_array[$question_label] = \EEM_State::instance()
383
+																	->get_state_name_by_ID($answer_row['Answer.ANS_value']);
384
+					} else {
385
+						//this isn't for html, so don't show html entities
386
+						$reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
387
+							'ANS_value', $answer_row['Answer.ANS_value']));
388
+					}
389
+				}
390
+				/**
391
+				 * Filter to change the contents of each row of the registrations report CSV file.
392
+				 *
393
+				 * This can be used to add or remote columns from the CSV file, or change their values.                 *
394
+				 * Note: it has this name because originally that's where this filter resided,
395
+				 * and we've left its name as-is for backward compatibility.
396
+				 * Note when using: all rows in the CSV should have the same columns.
397
+				 *
398
+				 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
399
+				 *                             in this row
400
+				 * @param array $reg_row is the row from the database's wp_esp_registration table
401
+				 *
402
+				 */
403
+				$registrations_csv_ready_array[] = apply_filters(
404
+					'FHEE__EE_Export__report_registrations__reg_csv_array',
405
+					$reg_csv_array,
406
+					$reg_row
407
+				);
408
+			}
409
+		}
410
+		//if we couldn't export anything, we want to at least show the column headers
411
+		if (empty($registrations_csv_ready_array)) {
412
+			$reg_csv_array = array();
413
+			$model_and_fields_to_include = array(
414
+				'Registration' => $reg_fields_to_include,
415
+				'Attendee'     => $att_fields_to_include,
416
+			);
417
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
418
+				$model = \EE_Registry::instance()->load_model($model_name);
419
+				foreach ($field_list as $field_name) {
420
+					$field = $model->field_settings_for($field_name);
421
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
422
+				}
423
+			}
424
+			$registrations_csv_ready_array[] = $reg_csv_array;
425
+		}
426
+		return $registrations_csv_ready_array;
427
+	}
429 428
 
430 429
 
431 430
 
432
-    /**
433
-     * Counts total unit to process
434
-     *
435
-     * @deprecated since 4.9.19
436
-     * @param int|array $event_id
437
-     * @return int
438
-     */
439
-    public function count_units_to_process($event_id)
440
-    {
441
-        //use the legacy filter
442
-        if ($event_id) {
443
-            $query_params[0]['EVT_ID'] = $event_id;
444
-        } else {
445
-            $query_params['force_join'][] = 'Event';
446
-        }
447
-        return \EEM_Registration::instance()->count($query_params);
448
-    }
431
+	/**
432
+	 * Counts total unit to process
433
+	 *
434
+	 * @deprecated since 4.9.19
435
+	 * @param int|array $event_id
436
+	 * @return int
437
+	 */
438
+	public function count_units_to_process($event_id)
439
+	{
440
+		//use the legacy filter
441
+		if ($event_id) {
442
+			$query_params[0]['EVT_ID'] = $event_id;
443
+		} else {
444
+			$query_params['force_join'][] = 'Event';
445
+		}
446
+		return \EEM_Registration::instance()->count($query_params);
447
+	}
449 448
 
450 449
 
451 450
 
452
-    /**
453
-     * Performs any clean-up logic when we know the job is completed.
454
-     * In this case, we delete the temporary file
455
-     *
456
-     * @param JobParameters $job_parameters
457
-     * @return boolean
458
-     */
459
-    public function cleanup_job(JobParameters $job_parameters)
460
-    {
461
-        $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
462
-            true, 'd');
463
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
464
-    }
451
+	/**
452
+	 * Performs any clean-up logic when we know the job is completed.
453
+	 * In this case, we delete the temporary file
454
+	 *
455
+	 * @param JobParameters $job_parameters
456
+	 * @return boolean
457
+	 */
458
+	public function cleanup_job(JobParameters $job_parameters)
459
+	{
460
+		$this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
461
+			true, 'd');
462
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
463
+	}
465 464
 }
466 465
 
467 466
 
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
      *    _get_table_filters
228 228
      *
229 229
      * @access protected
230
-     * @return array
230
+     * @return string[]
231 231
      */
232 232
     protected function _get_table_filters()
233 233
     {
Please login to merge, or discard this patch.
Indentation   +840 added lines, -840 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -26,869 +26,869 @@  discard block
 block discarded – undo
26 26
 
27 27
 
28 28
 
29
-    private $_status;
30
-
31
-
32
-
33
-    /**
34
-     * An array of transaction details for the related transaction to the registration being processed.
35
-     * This is set via the _set_related_details method.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_transaction_details = array();
40
-
41
-
42
-
43
-    /**
44
-     * An array of event details for the related event to the registration being processed.
45
-     * This is set via the _set_related_details method.
46
-     *
47
-     * @var array
48
-     */
49
-    protected $_event_details = array();
50
-
51
-
52
-
53
-    /**
54
-     * @param \Registrations_Admin_Page $admin_page
55
-     */
56
-    public function __construct(Registrations_Admin_Page $admin_page)
57
-    {
58
-        if ( ! empty($_GET['event_id'])) {
59
-            $extra_query_args = array();
60
-            foreach ($admin_page->get_views() as $key => $view_details) {
61
-                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
-            }
63
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
-        }
65
-        parent::__construct($admin_page);
66
-        $this->_status = $this->_admin_page->get_registration_status_array();
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     *    _setup_data
73
-     *
74
-     * @access protected
75
-     * @return void
76
-     */
77
-    protected function _setup_data()
78
-    {
79
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     *    _set_properties
87
-     *
88
-     * @access protected
89
-     * @return void
90
-     */
91
-    protected function _set_properties()
92
-    {
93
-        $this->_wp_list_args = array(
94
-            'singular' => __('registration', 'event_espresso'),
95
-            'plural'   => __('registrations', 'event_espresso'),
96
-            'ajax'     => true,
97
-            'screen'   => $this->_admin_page->get_current_screen()->id,
98
-        );
99
-        $ID_column_name = __('ID', 'event_espresso');
100
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
102
-        $ID_column_name .= '</span> ';
103
-        if (isset($_GET['event_id'])) {
104
-            $this->_columns = array(
105
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
-                '_REG_ID'          => $ID_column_name,
107
-                'ATT_fname'        => __('Name', 'event_espresso'),
108
-                'ATT_email'        => __('Email', 'event_espresso'),
109
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
110
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
112
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
113
-                'TXN_paid'         => __('Paid', 'event_espresso'),
114
-                'actions'          => __('Actions', 'event_espresso'),
115
-            );
116
-            $this->_bottom_buttons = array(
117
-                'report' => array(
118
-                    'route'         => 'registrations_report',
119
-                    'extra_request' => array(
120
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
-                    ),
123
-                ),
124
-            );
125
-        } else {
126
-            $this->_columns = array(
127
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
-                '_REG_ID'          => $ID_column_name,
129
-                'ATT_fname'        => __('Name', 'event_espresso'),
130
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
131
-                'event_name'       => __('Event', 'event_espresso'),
132
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
-                '_REG_final_price' => __('Price', 'event_espresso'),
134
-                '_REG_paid'        => __('Paid', 'event_espresso'),
135
-                'actions'          => __('Actions', 'event_espresso'),
136
-            );
137
-            $this->_bottom_buttons = array(
138
-                'report_all' => array(
139
-                    'route'         => 'registrations_report',
140
-                    'extra_request' => array(
141
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
-                    ),
143
-                ),
144
-            );
145
-        }
146
-        $this->_bottom_buttons['report_filtered'] = array(
147
-            'route'         => 'registrations_report',
148
-            'extra_request' => array(
149
-                'use_filters' => true,
150
-                'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
-                            'page',
152
-                            'action',
153
-                            'default_nonce',
154
-                        ))),
155
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
-            ),
157
-        );
158
-        $this->_primary_column = '_REG_ID';
159
-        $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
-            /**
162
-             * Allows users to change the default sort if they wish.
163
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
164
-             */
165
-            'ATT_fname'     => array(
166
-                    'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
167
-                    true,
168
-                    $this
169
-                )
170
-                ? array('ATT_lname' => false)
171
-                : array('ATT_fname' => false),
172
-            'event_name'    => array('event_name' => false),
173
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
174
-            '_REG_ID'       => array('_REG_ID' => false),
175
-        );
176
-        $this->_hidden_columns = array();
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * This simply sets up the row class for the table rows.
183
-     * Allows for easier overriding of child methods for setting up sorting.
184
-     *
185
-     * @param  EE_Registration $item the current item
186
-     * @return string
187
-     */
188
-    protected function _get_row_class($item)
189
-    {
190
-        $class = parent::_get_row_class($item);
191
-        //add status class
192
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
193
-        if ($this->_has_checkbox_column) {
194
-            $class .= ' has-checkbox-column';
195
-        }
196
-        return $class;
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * Set the $_transaction_details property if not set yet.
203
-     *
204
-     * @param EE_Registration $registration
205
-     * @throws \EE_Error
206
-     */
207
-    protected function _set_related_details(EE_Registration $registration)
208
-    {
209
-        $transaction = $registration->get_first_related('Transaction');
210
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
211
-            : EEM_Transaction::failed_status_code;
212
-        $this->_transaction_details = array(
213
-            'transaction' => $transaction,
214
-            'status'      => $status,
215
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
216
-            'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
217
-                EEH_Template::pretty_status($status, false, 'sentence')),
218
-        );
219
-        try {
220
-            $event = $registration->event();
221
-        } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
222
-            $event = null;
223
-        }
224
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
225
-        $this->_event_details = array(
226
-            'event'      => $event,
227
-            'status'     => $status,
228
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
229
-            'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
230
-                EEH_Template::pretty_status($status, false, 'sentence')),
231
-        );
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     *    _get_table_filters
238
-     *
239
-     * @access protected
240
-     * @return array
241
-     */
242
-    protected function _get_table_filters()
243
-    {
244
-        $filters = array();
245
-        //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
246
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
247
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
248
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
249
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
250
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
251
-        $status = array();
252
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
253
-        foreach ($this->_status as $key => $value) {
254
-            $status[] = array('id' => $key, 'text' => $value);
255
-        }
256
-        if ($this->_view !== 'incomplete') {
257
-            $filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
258
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
259
-                    : '');
260
-        }
261
-        if (isset($this->_req_data['event_id'])) {
262
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
263
-        }
264
-        return $filters;
265
-    }
266
-
267
-
268
-
269
-    /**
270
-     *    _add_view_counts
271
-     *
272
-     * @access protected
273
-     * @return void
274
-     * @throws \EE_Error
275
-     */
276
-    protected function _add_view_counts()
277
-    {
278
-        $this->_views['all']['count'] = $this->_total_registrations();
279
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
280
-        $this->_views['today']['count'] = $this->_total_registrations_today();
281
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
282
-            'espresso_registrations_trash_registrations')
283
-        ) {
284
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
285
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
286
-        }
287
-    }
288
-
289
-
290
-
291
-    /**
292
-     * _total_registrations
293
-     *
294
-     * @access protected
295
-     * @param string $view
296
-     * @return int
297
-     * @throws \EE_Error
298
-     */
299
-    protected function _total_registrations($view = '')
300
-    {
301
-        $_where = array();
302
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
303
-        if ($EVT_ID) {
304
-            $_where['EVT_ID'] = $EVT_ID;
305
-        }
306
-        switch ($view) {
307
-            case 'trash' :
308
-                return EEM_Registration::instance()->count_deleted(array($_where));
309
-                break;
310
-            case 'incomplete' :
311
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
312
-                break;
313
-            default :
314
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
315
-        }
316
-        return EEM_Registration::instance()->count(array($_where));
317
-    }
318
-
319
-
320
-
321
-    /**
322
-     * _total_registrations_this_month
323
-     *
324
-     * @access protected
325
-     * @return int
326
-     * @throws \EE_Error
327
-     */
328
-    protected function _total_registrations_this_month()
329
-    {
330
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
331
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
332
-        $this_year_r = date('Y', current_time('timestamp'));
333
-        $time_start = ' 00:00:00';
334
-        $time_end = ' 23:59:59';
335
-        $this_month_r = date('m', current_time('timestamp'));
336
-        $days_this_month = date('t', current_time('timestamp'));
337
-        //setup date query.
338
-        $beginning_string = EEM_Registration::instance()
339
-                                            ->convert_datetime_for_query('REG_date',
340
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
341
-                                                'Y-m-d H:i:s');
342
-        $end_string = EEM_Registration::instance()
343
-                                      ->convert_datetime_for_query('REG_date',
344
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
345
-                                          'Y-m-d H:i:s');
346
-        $_where['REG_date'] = array(
347
-            'BETWEEN',
348
-            array(
349
-                $beginning_string,
350
-                $end_string,
351
-            ),
352
-        );
353
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
354
-        return EEM_Registration::instance()->count(array($_where));
355
-    }
356
-
357
-
358
-
359
-    /**
360
-     * _total_registrations_today
361
-     *
362
-     * @access protected
363
-     * @return int
364
-     * @throws \EE_Error
365
-     */
366
-    protected function _total_registrations_today()
367
-    {
368
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
369
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
370
-        $current_date = date('Y-m-d', current_time('timestamp'));
371
-        $time_start = ' 00:00:00';
372
-        $time_end = ' 23:59:59';
373
-        $_where['REG_date'] = array(
374
-            'BETWEEN',
375
-            array(
376
-                EEM_Registration::instance()
377
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
378
-                EEM_Registration::instance()
379
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
380
-            ),
381
-        );
382
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
383
-        return EEM_Registration::instance()->count(array($_where));
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * column_cb
390
-     *
391
-     * @access public
392
-     * @param \EE_Registration $item
393
-     * @return string
394
-     * @throws \EE_Error
395
-     */
396
-    public function column_cb($item)
397
-    {
398
-        /** checkbox/lock **/
399
-        $transaction = $item->get_first_related('Transaction');
400
-        $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
401
-        return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
402
-                                    . '<span class="ee-lock-icon"></span>'
403
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * column__REG_ID
410
-     *
411
-     * @access public
412
-     * @param \EE_Registration $item
413
-     * @return string
414
-     * @throws \EE_Error
415
-     */
416
-    public function column__REG_ID(EE_Registration $item)
417
-    {
418
-        $attendee = $item->attendee();
419
-        $content = $item->ID();
420
-        $content .= '<div class="show-on-mobile-view-only">';
421
-        $content .= '<br>';
422
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
423
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
425
-        $content .= '</div>';
426
-        return $content;
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * column__REG_date
433
-     *
434
-     * @access public
435
-     * @param \EE_Registration $item
436
-     * @return string
437
-     * @throws \EE_Error
438
-     */
439
-    public function column__REG_date(EE_Registration $item)
440
-    {
441
-        $this->_set_related_details($item);
442
-        //Build row actions
443
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
444
-            'action' => 'view_transaction',
445
-            'TXN_ID' => $this->_transaction_details['id'],
446
-        ), TXN_ADMIN_URL);
447
-        $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
448
-            'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
449
-                                                        . $this->_transaction_details['status']
450
-                                                        . '" href="'
451
-                                                        . $view_lnk_url
452
-                                                        . '" title="'
453
-                                                        . esc_attr($this->_transaction_details['title_attr'])
454
-                                                        . '">'
455
-                                                        . $item->get_i18n_datetime('REG_date')
456
-                                                        . '</a>' : $item->get_i18n_datetime('REG_date');
457
-        $view_link .= '<br><span class="ee-status-text-small">'
458
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
459
-                      . '</span>';
460
-        return $view_link;
461
-    }
462
-
463
-
464
-
465
-    /**
466
-     * column_event_name
467
-     *
468
-     * @access public
469
-     * @param \EE_Registration $item
470
-     * @return string
471
-     * @throws \EE_Error
472
-     */
473
-    public function column_event_name(EE_Registration $item)
474
-    {
475
-        $this->_set_related_details($item);
476
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
477
-        $EVT_ID = $item->event_ID();
478
-        $event_name = $item->event_name();
479
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
480
-        $event_name = wp_trim_words($event_name, 30, '...');
481
-        if ($EVT_ID) {
482
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
483
-                EVENTS_ADMIN_URL);
484
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
485
-                ? '<a class="ee-status-color-'
486
-                  . $this->_event_details['status']
487
-                  . '" href="'
488
-                  . $edit_event_url
489
-                  . '" title="'
490
-                  . esc_attr($this->_event_details['title_attr'])
491
-                  . '">'
492
-                  . $event_name
493
-                  . '</a>' : $event_name;
494
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
495
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
496
-            $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
497
-                'event_espresso'), $event_name);
498
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
499
-        } else {
500
-            $edit_event = $event_name;
501
-            $actions['event_filter'] = '';
502
-        }
503
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
504
-    }
505
-
506
-
507
-
508
-    /**
509
-     * column_DTT_EVT_start
510
-     *
511
-     * @access public
512
-     * @param \EE_Registration $item
513
-     * @return string
514
-     * @throws \EE_Error
515
-     */
516
-    public function column_DTT_EVT_start(EE_Registration $item)
517
-    {
518
-        $datetime_strings = array();
519
-        $ticket = $item->ticket(true);
520
-        if ($ticket instanceof EE_Ticket) {
521
-            $remove_defaults = array('default_where_conditions' => 'none');
522
-            $datetimes = $ticket->datetimes($remove_defaults);
523
-            foreach ($datetimes as $datetime) {
524
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
525
-            }
526
-            return implode("<br />", $datetime_strings);
527
-        } else {
528
-            return __('There is no ticket on this registration', 'event_espresso');
529
-        }
530
-    }
531
-
532
-
533
-
534
-    /**
535
-     * column_ATT_fname
536
-     *
537
-     * @access public
538
-     * @param \EE_Registration $item
539
-     * @return string
540
-     * @throws \EE_Error
541
-     */
542
-    public function column_ATT_fname(EE_Registration $item)
543
-    {
544
-        $attendee = $item->attendee();
545
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
546
-            'action'  => 'view_registration',
547
-            '_REG_ID' => $item->ID(),
548
-        ), REG_ADMIN_URL);
549
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
550
-        $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
551
-            'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
552
-                                                                       . $edit_lnk_url
553
-                                                                       . '" title="'
554
-                                                                       . esc_attr__('View Registration Details',
555
-                'event_espresso')
556
-                                                                       . '">'
557
-                                                                       . $attendee_name
558
-                                                                       . '</a>' : $attendee_name;
559
-        $link .= $item->count() === 1
560
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
561
-        $t = $item->get_first_related('Transaction');
562
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
563
-        //append group count to name
564
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
565
-        //append reg_code
566
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
567
-        //reg status text for accessibility
568
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
569
-                'sentence') . '</span>';
570
-        //trash/restore/delete actions
571
-        $actions = array();
572
-        if ($this->_view !== 'trash'
573
-            && $payment_count === 0
574
-            && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
575
-                'espresso_registrations_trash_registrations', $item->ID())
576
-        ) {
577
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
578
-                'action'  => 'trash_registrations',
579
-                '_REG_ID' => $item->ID(),
580
-            ), REG_ADMIN_URL);
581
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
582
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
583
-        } elseif ($this->_view === 'trash') {
584
-            // restore registration link
585
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586
-                'espresso_registrations_restore_registrations', $item->ID())
587
-            ) {
588
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
589
-                    'action'  => 'restore_registrations',
590
-                    '_REG_ID' => $item->ID(),
591
-                ), REG_ADMIN_URL);
592
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
593
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
594
-            }
595
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
596
-                'espresso_registrations_ee_delete_registrations', $item->ID())
597
-            ) {
598
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
599
-                    'action'  => 'delete_registrations',
600
-                    '_REG_ID' => $item->ID(),
601
-                ), REG_ADMIN_URL);
602
-                $actions['delete'] = '<a href="'
603
-                                     . $delete_lnk_url
604
-                                     . '" title="'
605
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
606
-                                     . '">'
607
-                                     . __('Delete', 'event_espresso')
608
-                                     . '</a>';
609
-            }
610
-        }
611
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
612
-    }
613
-
614
-
615
-
616
-    /**
617
-     * column_ATT_email
618
-     *
619
-     * @access public
620
-     * @param \EE_Registration $item
621
-     * @return string
622
-     * @throws \EE_Error
623
-     */
624
-    public function column_ATT_email(EE_Registration $item)
625
-    {
626
-        $attendee = $item->get_first_related('Attendee');
627
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
628
-            : $attendee->email();
629
-    }
630
-
631
-
632
-
633
-    /**
634
-     * column__REG_count
635
-     *
636
-     * @access public
637
-     * @param \EE_Registration $item
638
-     * @return string
639
-     */
640
-    public function column__REG_count(EE_Registration $item)
641
-    {
642
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
643
-    }
644
-
645
-
646
-
647
-    /**
648
-     * column_PRC_amount
649
-     *
650
-     * @access public
651
-     * @param \EE_Registration $item
652
-     * @return string
653
-     */
654
-    public function column_PRC_amount(EE_Registration $item)
655
-    {
656
-        $ticket = $item->ticket();
657
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
658
-                                                                              . $ticket->name()
659
-                                                                              . '</span><br />' : '';
660
-        if ($item->final_price() > 0) {
661
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
662
-        } else {
663
-            // free event
664
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
665
-                        . __('free', 'event_espresso')
666
-                        . '</span>';
667
-        }
668
-        return $content;
669
-    }
670
-
671
-
672
-
673
-    /**
674
-     * column__REG_final_price
675
-     *
676
-     * @access public
677
-     * @param \EE_Registration $item
678
-     * @return string
679
-     */
680
-    public function column__REG_final_price(EE_Registration $item)
681
-    {
682
-        $ticket = $item->ticket();
683
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
684
-            ? ''
685
-            : '<span class="TKT_name">'
686
-              . $ticket->name()
687
-              . '</span><br />';
688
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
689
-        return $content;
690
-    }
691
-
692
-
693
-
694
-    /**
695
-     * column__REG_paid
696
-     *
697
-     * @access public
698
-     * @param \EE_Registration $item
699
-     * @return string
700
-     */
701
-    public function column__REG_paid(EE_Registration $item)
702
-    {
703
-        $payment_method = $item->payment_method();
704
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
705
-            : __('Unknown', 'event_espresso');
706
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
707
-        if ($item->paid() > 0) {
708
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
709
-                    $payment_method_name) . '</span>';
710
-        }
711
-        return $content;
712
-    }
713
-
714
-
715
-
716
-    /**
717
-     * column_TXN_total
718
-     *
719
-     * @access public
720
-     * @param \EE_Registration $item
721
-     * @return string
722
-     * @throws \EE_Error
723
-     */
724
-    public function column_TXN_total(EE_Registration $item)
725
-    {
726
-        if ($item->transaction()) {
727
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
728
-                'action' => 'view_transaction',
729
-                'TXN_ID' => $item->transaction_ID(),
730
-            ), TXN_ADMIN_URL);
731
-            return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
732
-                'espresso_transactions_view_transaction', $item->transaction_ID())
733
-                ? '<span class="reg-pad-rght"><a class="status-'
734
-                  . $item->transaction()->status_ID()
735
-                  . '" href="'
736
-                  . $view_txn_lnk_url
737
-                  . '"  title="'
738
-                  . esc_attr__('View Transaction', 'event_espresso')
739
-                  . '">'
740
-                  . $item->transaction()->pretty_total()
741
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
742
-        } else {
743
-            return __("None", "event_espresso");
744
-        }
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     * column_TXN_paid
751
-     *
752
-     * @access public
753
-     * @param \EE_Registration $item
754
-     * @return string
755
-     * @throws \EE_Error
756
-     */
757
-    public function column_TXN_paid(EE_Registration $item)
758
-    {
759
-        if ($item->count() === 1) {
760
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
761
-            if ($transaction->paid() >= $transaction->total()) {
762
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
763
-            } else {
764
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
765
-                    'action' => 'view_transaction',
766
-                    'TXN_ID' => $item->transaction_ID(),
767
-                ), TXN_ADMIN_URL);
768
-                return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
769
-                    'espresso_transactions_view_transaction', $item->transaction_ID())
770
-                    ? '<span class="reg-pad-rght"><a class="status-'
771
-                      . $transaction->status_ID()
772
-                      . '" href="'
773
-                      . $view_txn_lnk_url
774
-                      . '"  title="'
775
-                      . esc_attr__('View Transaction', 'event_espresso')
776
-                      . '">'
777
-                      . $item->transaction()->pretty_paid()
778
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
779
-            }
780
-        }
781
-        return '&nbsp;';
782
-    }
783
-
784
-
785
-
786
-    /**
787
-     * column_actions
788
-     *
789
-     * @access public
790
-     * @param \EE_Registration $item
791
-     * @return string
792
-     * @throws \EE_Error
793
-     */
794
-    public function column_actions(EE_Registration $item)
795
-    {
796
-        $actions = array();
797
-        $attendee = $item->attendee();
798
-        $this->_set_related_details($item);
799
-        //Build row actions
800
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
801
-            'action'  => 'view_registration',
802
-            '_REG_ID' => $item->ID(),
803
-        ), REG_ADMIN_URL);
804
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
805
-            'action' => 'edit_attendee',
806
-            'post'   => $item->attendee_ID(),
807
-        ), REG_ADMIN_URL);
808
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
809
-        //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
810
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
811
-            'action'  => 'resend_registration',
812
-            '_REG_ID' => $item->ID(),
813
-        ), REG_ADMIN_URL, true);
814
-        //Build row actions
815
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
816
-            'espresso_registrations_view_registration', $item->ID()) ? '
29
+	private $_status;
30
+
31
+
32
+
33
+	/**
34
+	 * An array of transaction details for the related transaction to the registration being processed.
35
+	 * This is set via the _set_related_details method.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_transaction_details = array();
40
+
41
+
42
+
43
+	/**
44
+	 * An array of event details for the related event to the registration being processed.
45
+	 * This is set via the _set_related_details method.
46
+	 *
47
+	 * @var array
48
+	 */
49
+	protected $_event_details = array();
50
+
51
+
52
+
53
+	/**
54
+	 * @param \Registrations_Admin_Page $admin_page
55
+	 */
56
+	public function __construct(Registrations_Admin_Page $admin_page)
57
+	{
58
+		if ( ! empty($_GET['event_id'])) {
59
+			$extra_query_args = array();
60
+			foreach ($admin_page->get_views() as $key => $view_details) {
61
+				$extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
+			}
63
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
+		}
65
+		parent::__construct($admin_page);
66
+		$this->_status = $this->_admin_page->get_registration_status_array();
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 *    _setup_data
73
+	 *
74
+	 * @access protected
75
+	 * @return void
76
+	 */
77
+	protected function _setup_data()
78
+	{
79
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 *    _set_properties
87
+	 *
88
+	 * @access protected
89
+	 * @return void
90
+	 */
91
+	protected function _set_properties()
92
+	{
93
+		$this->_wp_list_args = array(
94
+			'singular' => __('registration', 'event_espresso'),
95
+			'plural'   => __('registrations', 'event_espresso'),
96
+			'ajax'     => true,
97
+			'screen'   => $this->_admin_page->get_current_screen()->id,
98
+		);
99
+		$ID_column_name = __('ID', 'event_espresso');
100
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
102
+		$ID_column_name .= '</span> ';
103
+		if (isset($_GET['event_id'])) {
104
+			$this->_columns = array(
105
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
+				'_REG_ID'          => $ID_column_name,
107
+				'ATT_fname'        => __('Name', 'event_espresso'),
108
+				'ATT_email'        => __('Email', 'event_espresso'),
109
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
110
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
112
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
113
+				'TXN_paid'         => __('Paid', 'event_espresso'),
114
+				'actions'          => __('Actions', 'event_espresso'),
115
+			);
116
+			$this->_bottom_buttons = array(
117
+				'report' => array(
118
+					'route'         => 'registrations_report',
119
+					'extra_request' => array(
120
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
+					),
123
+				),
124
+			);
125
+		} else {
126
+			$this->_columns = array(
127
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
+				'_REG_ID'          => $ID_column_name,
129
+				'ATT_fname'        => __('Name', 'event_espresso'),
130
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
131
+				'event_name'       => __('Event', 'event_espresso'),
132
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
+				'_REG_final_price' => __('Price', 'event_espresso'),
134
+				'_REG_paid'        => __('Paid', 'event_espresso'),
135
+				'actions'          => __('Actions', 'event_espresso'),
136
+			);
137
+			$this->_bottom_buttons = array(
138
+				'report_all' => array(
139
+					'route'         => 'registrations_report',
140
+					'extra_request' => array(
141
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
+					),
143
+				),
144
+			);
145
+		}
146
+		$this->_bottom_buttons['report_filtered'] = array(
147
+			'route'         => 'registrations_report',
148
+			'extra_request' => array(
149
+				'use_filters' => true,
150
+				'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
+							'page',
152
+							'action',
153
+							'default_nonce',
154
+						))),
155
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
+			),
157
+		);
158
+		$this->_primary_column = '_REG_ID';
159
+		$this->_sortable_columns = array(
160
+			'_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
+			/**
162
+			 * Allows users to change the default sort if they wish.
163
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
164
+			 */
165
+			'ATT_fname'     => array(
166
+					'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
167
+					true,
168
+					$this
169
+				)
170
+				? array('ATT_lname' => false)
171
+				: array('ATT_fname' => false),
172
+			'event_name'    => array('event_name' => false),
173
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
174
+			'_REG_ID'       => array('_REG_ID' => false),
175
+		);
176
+		$this->_hidden_columns = array();
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * This simply sets up the row class for the table rows.
183
+	 * Allows for easier overriding of child methods for setting up sorting.
184
+	 *
185
+	 * @param  EE_Registration $item the current item
186
+	 * @return string
187
+	 */
188
+	protected function _get_row_class($item)
189
+	{
190
+		$class = parent::_get_row_class($item);
191
+		//add status class
192
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
193
+		if ($this->_has_checkbox_column) {
194
+			$class .= ' has-checkbox-column';
195
+		}
196
+		return $class;
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * Set the $_transaction_details property if not set yet.
203
+	 *
204
+	 * @param EE_Registration $registration
205
+	 * @throws \EE_Error
206
+	 */
207
+	protected function _set_related_details(EE_Registration $registration)
208
+	{
209
+		$transaction = $registration->get_first_related('Transaction');
210
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
211
+			: EEM_Transaction::failed_status_code;
212
+		$this->_transaction_details = array(
213
+			'transaction' => $transaction,
214
+			'status'      => $status,
215
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
216
+			'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
217
+				EEH_Template::pretty_status($status, false, 'sentence')),
218
+		);
219
+		try {
220
+			$event = $registration->event();
221
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
222
+			$event = null;
223
+		}
224
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
225
+		$this->_event_details = array(
226
+			'event'      => $event,
227
+			'status'     => $status,
228
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
229
+			'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
230
+				EEH_Template::pretty_status($status, false, 'sentence')),
231
+		);
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 *    _get_table_filters
238
+	 *
239
+	 * @access protected
240
+	 * @return array
241
+	 */
242
+	protected function _get_table_filters()
243
+	{
244
+		$filters = array();
245
+		//todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
246
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
247
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
248
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
249
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
250
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
251
+		$status = array();
252
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
253
+		foreach ($this->_status as $key => $value) {
254
+			$status[] = array('id' => $key, 'text' => $value);
255
+		}
256
+		if ($this->_view !== 'incomplete') {
257
+			$filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
258
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
259
+					: '');
260
+		}
261
+		if (isset($this->_req_data['event_id'])) {
262
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
263
+		}
264
+		return $filters;
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 *    _add_view_counts
271
+	 *
272
+	 * @access protected
273
+	 * @return void
274
+	 * @throws \EE_Error
275
+	 */
276
+	protected function _add_view_counts()
277
+	{
278
+		$this->_views['all']['count'] = $this->_total_registrations();
279
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
280
+		$this->_views['today']['count'] = $this->_total_registrations_today();
281
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
282
+			'espresso_registrations_trash_registrations')
283
+		) {
284
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
285
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
286
+		}
287
+	}
288
+
289
+
290
+
291
+	/**
292
+	 * _total_registrations
293
+	 *
294
+	 * @access protected
295
+	 * @param string $view
296
+	 * @return int
297
+	 * @throws \EE_Error
298
+	 */
299
+	protected function _total_registrations($view = '')
300
+	{
301
+		$_where = array();
302
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
303
+		if ($EVT_ID) {
304
+			$_where['EVT_ID'] = $EVT_ID;
305
+		}
306
+		switch ($view) {
307
+			case 'trash' :
308
+				return EEM_Registration::instance()->count_deleted(array($_where));
309
+				break;
310
+			case 'incomplete' :
311
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
312
+				break;
313
+			default :
314
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
315
+		}
316
+		return EEM_Registration::instance()->count(array($_where));
317
+	}
318
+
319
+
320
+
321
+	/**
322
+	 * _total_registrations_this_month
323
+	 *
324
+	 * @access protected
325
+	 * @return int
326
+	 * @throws \EE_Error
327
+	 */
328
+	protected function _total_registrations_this_month()
329
+	{
330
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
331
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
332
+		$this_year_r = date('Y', current_time('timestamp'));
333
+		$time_start = ' 00:00:00';
334
+		$time_end = ' 23:59:59';
335
+		$this_month_r = date('m', current_time('timestamp'));
336
+		$days_this_month = date('t', current_time('timestamp'));
337
+		//setup date query.
338
+		$beginning_string = EEM_Registration::instance()
339
+											->convert_datetime_for_query('REG_date',
340
+												$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
341
+												'Y-m-d H:i:s');
342
+		$end_string = EEM_Registration::instance()
343
+									  ->convert_datetime_for_query('REG_date',
344
+										  $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
345
+										  'Y-m-d H:i:s');
346
+		$_where['REG_date'] = array(
347
+			'BETWEEN',
348
+			array(
349
+				$beginning_string,
350
+				$end_string,
351
+			),
352
+		);
353
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
354
+		return EEM_Registration::instance()->count(array($_where));
355
+	}
356
+
357
+
358
+
359
+	/**
360
+	 * _total_registrations_today
361
+	 *
362
+	 * @access protected
363
+	 * @return int
364
+	 * @throws \EE_Error
365
+	 */
366
+	protected function _total_registrations_today()
367
+	{
368
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
369
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
370
+		$current_date = date('Y-m-d', current_time('timestamp'));
371
+		$time_start = ' 00:00:00';
372
+		$time_end = ' 23:59:59';
373
+		$_where['REG_date'] = array(
374
+			'BETWEEN',
375
+			array(
376
+				EEM_Registration::instance()
377
+								->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
378
+				EEM_Registration::instance()
379
+								->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
380
+			),
381
+		);
382
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
383
+		return EEM_Registration::instance()->count(array($_where));
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * column_cb
390
+	 *
391
+	 * @access public
392
+	 * @param \EE_Registration $item
393
+	 * @return string
394
+	 * @throws \EE_Error
395
+	 */
396
+	public function column_cb($item)
397
+	{
398
+		/** checkbox/lock **/
399
+		$transaction = $item->get_first_related('Transaction');
400
+		$payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
401
+		return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
402
+									. '<span class="ee-lock-icon"></span>'
403
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * column__REG_ID
410
+	 *
411
+	 * @access public
412
+	 * @param \EE_Registration $item
413
+	 * @return string
414
+	 * @throws \EE_Error
415
+	 */
416
+	public function column__REG_ID(EE_Registration $item)
417
+	{
418
+		$attendee = $item->attendee();
419
+		$content = $item->ID();
420
+		$content .= '<div class="show-on-mobile-view-only">';
421
+		$content .= '<br>';
422
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
423
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
425
+		$content .= '</div>';
426
+		return $content;
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * column__REG_date
433
+	 *
434
+	 * @access public
435
+	 * @param \EE_Registration $item
436
+	 * @return string
437
+	 * @throws \EE_Error
438
+	 */
439
+	public function column__REG_date(EE_Registration $item)
440
+	{
441
+		$this->_set_related_details($item);
442
+		//Build row actions
443
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
444
+			'action' => 'view_transaction',
445
+			'TXN_ID' => $this->_transaction_details['id'],
446
+		), TXN_ADMIN_URL);
447
+		$view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
448
+			'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
449
+														. $this->_transaction_details['status']
450
+														. '" href="'
451
+														. $view_lnk_url
452
+														. '" title="'
453
+														. esc_attr($this->_transaction_details['title_attr'])
454
+														. '">'
455
+														. $item->get_i18n_datetime('REG_date')
456
+														. '</a>' : $item->get_i18n_datetime('REG_date');
457
+		$view_link .= '<br><span class="ee-status-text-small">'
458
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
459
+					  . '</span>';
460
+		return $view_link;
461
+	}
462
+
463
+
464
+
465
+	/**
466
+	 * column_event_name
467
+	 *
468
+	 * @access public
469
+	 * @param \EE_Registration $item
470
+	 * @return string
471
+	 * @throws \EE_Error
472
+	 */
473
+	public function column_event_name(EE_Registration $item)
474
+	{
475
+		$this->_set_related_details($item);
476
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
477
+		$EVT_ID = $item->event_ID();
478
+		$event_name = $item->event_name();
479
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
480
+		$event_name = wp_trim_words($event_name, 30, '...');
481
+		if ($EVT_ID) {
482
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
483
+				EVENTS_ADMIN_URL);
484
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
485
+				? '<a class="ee-status-color-'
486
+				  . $this->_event_details['status']
487
+				  . '" href="'
488
+				  . $edit_event_url
489
+				  . '" title="'
490
+				  . esc_attr($this->_event_details['title_attr'])
491
+				  . '">'
492
+				  . $event_name
493
+				  . '</a>' : $event_name;
494
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
495
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
496
+			$actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
497
+				'event_espresso'), $event_name);
498
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
499
+		} else {
500
+			$edit_event = $event_name;
501
+			$actions['event_filter'] = '';
502
+		}
503
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
504
+	}
505
+
506
+
507
+
508
+	/**
509
+	 * column_DTT_EVT_start
510
+	 *
511
+	 * @access public
512
+	 * @param \EE_Registration $item
513
+	 * @return string
514
+	 * @throws \EE_Error
515
+	 */
516
+	public function column_DTT_EVT_start(EE_Registration $item)
517
+	{
518
+		$datetime_strings = array();
519
+		$ticket = $item->ticket(true);
520
+		if ($ticket instanceof EE_Ticket) {
521
+			$remove_defaults = array('default_where_conditions' => 'none');
522
+			$datetimes = $ticket->datetimes($remove_defaults);
523
+			foreach ($datetimes as $datetime) {
524
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
525
+			}
526
+			return implode("<br />", $datetime_strings);
527
+		} else {
528
+			return __('There is no ticket on this registration', 'event_espresso');
529
+		}
530
+	}
531
+
532
+
533
+
534
+	/**
535
+	 * column_ATT_fname
536
+	 *
537
+	 * @access public
538
+	 * @param \EE_Registration $item
539
+	 * @return string
540
+	 * @throws \EE_Error
541
+	 */
542
+	public function column_ATT_fname(EE_Registration $item)
543
+	{
544
+		$attendee = $item->attendee();
545
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
546
+			'action'  => 'view_registration',
547
+			'_REG_ID' => $item->ID(),
548
+		), REG_ADMIN_URL);
549
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
550
+		$link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
551
+			'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
552
+																	   . $edit_lnk_url
553
+																	   . '" title="'
554
+																	   . esc_attr__('View Registration Details',
555
+				'event_espresso')
556
+																	   . '">'
557
+																	   . $attendee_name
558
+																	   . '</a>' : $attendee_name;
559
+		$link .= $item->count() === 1
560
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
561
+		$t = $item->get_first_related('Transaction');
562
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
563
+		//append group count to name
564
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
565
+		//append reg_code
566
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
567
+		//reg status text for accessibility
568
+		$link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
569
+				'sentence') . '</span>';
570
+		//trash/restore/delete actions
571
+		$actions = array();
572
+		if ($this->_view !== 'trash'
573
+			&& $payment_count === 0
574
+			&& EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
575
+				'espresso_registrations_trash_registrations', $item->ID())
576
+		) {
577
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
578
+				'action'  => 'trash_registrations',
579
+				'_REG_ID' => $item->ID(),
580
+			), REG_ADMIN_URL);
581
+			$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
582
+					'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
583
+		} elseif ($this->_view === 'trash') {
584
+			// restore registration link
585
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586
+				'espresso_registrations_restore_registrations', $item->ID())
587
+			) {
588
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
589
+					'action'  => 'restore_registrations',
590
+					'_REG_ID' => $item->ID(),
591
+				), REG_ADMIN_URL);
592
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
593
+						'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
594
+			}
595
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
596
+				'espresso_registrations_ee_delete_registrations', $item->ID())
597
+			) {
598
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
599
+					'action'  => 'delete_registrations',
600
+					'_REG_ID' => $item->ID(),
601
+				), REG_ADMIN_URL);
602
+				$actions['delete'] = '<a href="'
603
+									 . $delete_lnk_url
604
+									 . '" title="'
605
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
606
+									 . '">'
607
+									 . __('Delete', 'event_espresso')
608
+									 . '</a>';
609
+			}
610
+		}
611
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
612
+	}
613
+
614
+
615
+
616
+	/**
617
+	 * column_ATT_email
618
+	 *
619
+	 * @access public
620
+	 * @param \EE_Registration $item
621
+	 * @return string
622
+	 * @throws \EE_Error
623
+	 */
624
+	public function column_ATT_email(EE_Registration $item)
625
+	{
626
+		$attendee = $item->get_first_related('Attendee');
627
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
628
+			: $attendee->email();
629
+	}
630
+
631
+
632
+
633
+	/**
634
+	 * column__REG_count
635
+	 *
636
+	 * @access public
637
+	 * @param \EE_Registration $item
638
+	 * @return string
639
+	 */
640
+	public function column__REG_count(EE_Registration $item)
641
+	{
642
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
643
+	}
644
+
645
+
646
+
647
+	/**
648
+	 * column_PRC_amount
649
+	 *
650
+	 * @access public
651
+	 * @param \EE_Registration $item
652
+	 * @return string
653
+	 */
654
+	public function column_PRC_amount(EE_Registration $item)
655
+	{
656
+		$ticket = $item->ticket();
657
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
658
+																			  . $ticket->name()
659
+																			  . '</span><br />' : '';
660
+		if ($item->final_price() > 0) {
661
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
662
+		} else {
663
+			// free event
664
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
665
+						. __('free', 'event_espresso')
666
+						. '</span>';
667
+		}
668
+		return $content;
669
+	}
670
+
671
+
672
+
673
+	/**
674
+	 * column__REG_final_price
675
+	 *
676
+	 * @access public
677
+	 * @param \EE_Registration $item
678
+	 * @return string
679
+	 */
680
+	public function column__REG_final_price(EE_Registration $item)
681
+	{
682
+		$ticket = $item->ticket();
683
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
684
+			? ''
685
+			: '<span class="TKT_name">'
686
+			  . $ticket->name()
687
+			  . '</span><br />';
688
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
689
+		return $content;
690
+	}
691
+
692
+
693
+
694
+	/**
695
+	 * column__REG_paid
696
+	 *
697
+	 * @access public
698
+	 * @param \EE_Registration $item
699
+	 * @return string
700
+	 */
701
+	public function column__REG_paid(EE_Registration $item)
702
+	{
703
+		$payment_method = $item->payment_method();
704
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
705
+			: __('Unknown', 'event_espresso');
706
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
707
+		if ($item->paid() > 0) {
708
+			$content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
709
+					$payment_method_name) . '</span>';
710
+		}
711
+		return $content;
712
+	}
713
+
714
+
715
+
716
+	/**
717
+	 * column_TXN_total
718
+	 *
719
+	 * @access public
720
+	 * @param \EE_Registration $item
721
+	 * @return string
722
+	 * @throws \EE_Error
723
+	 */
724
+	public function column_TXN_total(EE_Registration $item)
725
+	{
726
+		if ($item->transaction()) {
727
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
728
+				'action' => 'view_transaction',
729
+				'TXN_ID' => $item->transaction_ID(),
730
+			), TXN_ADMIN_URL);
731
+			return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
732
+				'espresso_transactions_view_transaction', $item->transaction_ID())
733
+				? '<span class="reg-pad-rght"><a class="status-'
734
+				  . $item->transaction()->status_ID()
735
+				  . '" href="'
736
+				  . $view_txn_lnk_url
737
+				  . '"  title="'
738
+				  . esc_attr__('View Transaction', 'event_espresso')
739
+				  . '">'
740
+				  . $item->transaction()->pretty_total()
741
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
742
+		} else {
743
+			return __("None", "event_espresso");
744
+		}
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 * column_TXN_paid
751
+	 *
752
+	 * @access public
753
+	 * @param \EE_Registration $item
754
+	 * @return string
755
+	 * @throws \EE_Error
756
+	 */
757
+	public function column_TXN_paid(EE_Registration $item)
758
+	{
759
+		if ($item->count() === 1) {
760
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
761
+			if ($transaction->paid() >= $transaction->total()) {
762
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
763
+			} else {
764
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
765
+					'action' => 'view_transaction',
766
+					'TXN_ID' => $item->transaction_ID(),
767
+				), TXN_ADMIN_URL);
768
+				return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
769
+					'espresso_transactions_view_transaction', $item->transaction_ID())
770
+					? '<span class="reg-pad-rght"><a class="status-'
771
+					  . $transaction->status_ID()
772
+					  . '" href="'
773
+					  . $view_txn_lnk_url
774
+					  . '"  title="'
775
+					  . esc_attr__('View Transaction', 'event_espresso')
776
+					  . '">'
777
+					  . $item->transaction()->pretty_paid()
778
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
779
+			}
780
+		}
781
+		return '&nbsp;';
782
+	}
783
+
784
+
785
+
786
+	/**
787
+	 * column_actions
788
+	 *
789
+	 * @access public
790
+	 * @param \EE_Registration $item
791
+	 * @return string
792
+	 * @throws \EE_Error
793
+	 */
794
+	public function column_actions(EE_Registration $item)
795
+	{
796
+		$actions = array();
797
+		$attendee = $item->attendee();
798
+		$this->_set_related_details($item);
799
+		//Build row actions
800
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
801
+			'action'  => 'view_registration',
802
+			'_REG_ID' => $item->ID(),
803
+		), REG_ADMIN_URL);
804
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
805
+			'action' => 'edit_attendee',
806
+			'post'   => $item->attendee_ID(),
807
+		), REG_ADMIN_URL);
808
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
809
+		//$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
810
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
811
+			'action'  => 'resend_registration',
812
+			'_REG_ID' => $item->ID(),
813
+		), REG_ADMIN_URL, true);
814
+		//Build row actions
815
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
816
+			'espresso_registrations_view_registration', $item->ID()) ? '
817 817
 			<li>
818 818
 			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
819 819
 				<div class="dashicons dashicons-clipboard"></div>
820 820
 			</a>
821 821
 			</li>' : '';
822
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
823
-            'espresso_registrations_edit_attendee')
824
-                               && $attendee instanceof EE_Attendee ? '
822
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
823
+			'espresso_registrations_edit_attendee')
824
+							   && $attendee instanceof EE_Attendee ? '
825 825
 			<li>
826 826
 			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
827 827
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
828 828
 			</a>
829 829
 			</li>' : '';
830
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
831
-                                     && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
832
-            'espresso_registrations_resend_registration', $item->ID()) ? '
830
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
831
+									 && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
832
+			'espresso_registrations_resend_registration', $item->ID()) ? '
833 833
 			<li>
834 834
 			<a href="'
835
-                                                                         . $resend_reg_lnk_url
836
-                                                                         . '" title="'
837
-                                                                         . esc_attr__('Resend Registration Details',
838
-                'event_espresso')
839
-                                                                         . '" class="tiny-text">
835
+																		 . $resend_reg_lnk_url
836
+																		 . '" title="'
837
+																		 . esc_attr__('Resend Registration Details',
838
+				'event_espresso')
839
+																		 . '" class="tiny-text">
840 840
 				<div class="dashicons dashicons-email-alt"></div>
841 841
 			</a>
842 842
 			</li>' : '';
843
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
844
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
845
-            'action' => 'view_transaction',
846
-            'TXN_ID' => $this->_transaction_details['id'],
847
-        ), TXN_ADMIN_URL);
848
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
849
-            'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
843
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
844
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
845
+			'action' => 'view_transaction',
846
+			'TXN_ID' => $this->_transaction_details['id'],
847
+		), TXN_ADMIN_URL);
848
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
849
+			'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
850 850
 			<li>
851 851
 			<a class="ee-status-color-'
852
-                                                                                           . $this->_transaction_details['status']
853
-                                                                                           . ' tiny-text" href="'
854
-                                                                                           . $view_txn_lnk_url
855
-                                                                                           . '"  title="'
856
-                                                                                           . $this->_transaction_details['title_attr']
857
-                                                                                           . '">
852
+																						   . $this->_transaction_details['status']
853
+																						   . ' tiny-text" href="'
854
+																						   . $view_txn_lnk_url
855
+																						   . '"  title="'
856
+																						   . $this->_transaction_details['title_attr']
857
+																						   . '">
858 858
 				<div class="dashicons dashicons-cart"></div>
859 859
 			</a>
860 860
 			</li>' : '';
861
-        //invoice link
862
-        $actions['dl_invoice_lnk'] = '';
863
-        $dl_invoice_lnk_url = $item->invoice_url();
864
-        //only show invoice link if message type is active.
865
-        if ($attendee instanceof EE_Attendee
866
-            && $item->is_primary_registrant()
867
-            && EEH_MSG_Template::is_mt_active('invoice')
868
-        ) {
869
-            $actions['dl_invoice_lnk'] = '
861
+		//invoice link
862
+		$actions['dl_invoice_lnk'] = '';
863
+		$dl_invoice_lnk_url = $item->invoice_url();
864
+		//only show invoice link if message type is active.
865
+		if ($attendee instanceof EE_Attendee
866
+			&& $item->is_primary_registrant()
867
+			&& EEH_MSG_Template::is_mt_active('invoice')
868
+		) {
869
+			$actions['dl_invoice_lnk'] = '
870 870
 		<li>
871 871
 			<a title="'
872
-                                         . esc_attr__('View Transaction Invoice', 'event_espresso')
873
-                                         . '" target="_blank" href="'
874
-                                         . $dl_invoice_lnk_url
875
-                                         . '" class="tiny-text">
872
+										 . esc_attr__('View Transaction Invoice', 'event_espresso')
873
+										 . '" target="_blank" href="'
874
+										 . $dl_invoice_lnk_url
875
+										 . '" class="tiny-text">
876 876
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
877 877
 			</a>
878 878
 		</li>';
879
-        }
880
-        $actions['filtered_messages_link'] = '';
881
-        //message list table link (filtered by REG_ID
882
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
883
-            $actions['filtered_messages_link'] = '<li>'
884
-                                                 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
885
-                    null, array(
886
-                        '_REG_ID' => $item->ID(),
887
-                    ))
888
-                                                 . '</li>';
889
-        }
890
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
891
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
892
-    }
879
+		}
880
+		$actions['filtered_messages_link'] = '';
881
+		//message list table link (filtered by REG_ID
882
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
883
+			$actions['filtered_messages_link'] = '<li>'
884
+												 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
885
+					null, array(
886
+						'_REG_ID' => $item->ID(),
887
+					))
888
+												 . '</li>';
889
+		}
890
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
891
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
892
+	}
893 893
 
894 894
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         );
158 158
         $this->_primary_column = '_REG_ID';
159 159
         $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
160
+            '_REG_date'     => array('_REG_date' => true), //true means its already sorted
161 161
             /**
162 162
              * Allows users to change the default sort if they wish.
163 163
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     {
190 190
         $class = parent::_get_row_class($item);
191 191
         //add status class
192
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
192
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
193 193
         if ($this->_has_checkbox_column) {
194 194
             $class .= ' has-checkbox-column';
195 195
         }
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
         //setup date query.
338 338
         $beginning_string = EEM_Registration::instance()
339 339
                                             ->convert_datetime_for_query('REG_date',
340
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
340
+                                                $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
341 341
                                                 'Y-m-d H:i:s');
342 342
         $end_string = EEM_Registration::instance()
343 343
                                       ->convert_datetime_for_query('REG_date',
344
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
344
+                                          $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
345 345
                                           'Y-m-d H:i:s');
346 346
         $_where['REG_date'] = array(
347 347
             'BETWEEN',
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
             'BETWEEN',
375 375
             array(
376 376
                 EEM_Registration::instance()
377
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
377
+                                ->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'),
378 378
                 EEM_Registration::instance()
379
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
379
+                                ->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s'),
380 380
             ),
381 381
         );
382 382
         $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
         $content .= '<div class="show-on-mobile-view-only">';
421 421
         $content .= '<br>';
422 422
         $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
423
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
423
+        $content .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
+        $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
425 425
         $content .= '</div>';
426 426
         return $content;
427 427
     }
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
                   . $event_name
493 493
                   . '</a>' : $event_name;
494 494
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
495
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
495
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
496 496
             $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
497 497
                 'event_espresso'), $event_name);
498
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
498
+            $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>';
499 499
         } else {
500 500
             $edit_event = $event_name;
501 501
             $actions['event_filter'] = '';
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
         $t = $item->get_first_related('Transaction');
562 562
         $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
563 563
         //append group count to name
564
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
564
+        $link .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
565 565
         //append reg_code
566
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
566
+        $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
567 567
         //reg status text for accessibility
568
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
569
-                'sentence') . '</span>';
568
+        $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false,
569
+                'sentence').'</span>';
570 570
         //trash/restore/delete actions
571 571
         $actions = array();
572 572
         if ($this->_view !== 'trash'
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
                 'action'  => 'trash_registrations',
579 579
                 '_REG_ID' => $item->ID(),
580 580
             ), REG_ADMIN_URL);
581
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
582
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
581
+            $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration',
582
+                    'event_espresso').'">'.__('Trash', 'event_espresso').'</a>';
583 583
         } elseif ($this->_view === 'trash') {
584 584
             // restore registration link
585 585
             if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
@@ -589,8 +589,8 @@  discard block
 block discarded – undo
589 589
                     'action'  => 'restore_registrations',
590 590
                     '_REG_ID' => $item->ID(),
591 591
                 ), REG_ADMIN_URL);
592
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
593
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
592
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration',
593
+                        'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
594 594
             }
595 595
             if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
596 596
                 'espresso_registrations_ee_delete_registrations', $item->ID())
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                                                                               . $ticket->name()
659 659
                                                                               . '</span><br />' : '';
660 660
         if ($item->final_price() > 0) {
661
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
661
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
662 662
         } else {
663 663
             // free event
664 664
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
             : '<span class="TKT_name">'
686 686
               . $ticket->name()
687 687
               . '</span><br />';
688
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
688
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
689 689
         return $content;
690 690
     }
691 691
 
@@ -703,10 +703,10 @@  discard block
 block discarded – undo
703 703
         $payment_method = $item->payment_method();
704 704
         $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
705 705
             : __('Unknown', 'event_espresso');
706
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
706
+        $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
707 707
         if ($item->paid() > 0) {
708
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
709
-                    $payment_method_name) . '</span>';
708
+            $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'),
709
+                    $payment_method_name).'</span>';
710 710
         }
711 711
         return $content;
712 712
     }
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
                   . esc_attr__('View Transaction', 'event_espresso')
739 739
                   . '">'
740 740
                   . $item->transaction()->pretty_total()
741
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
741
+                  . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
742 742
         } else {
743 743
             return __("None", "event_espresso");
744 744
         }
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
                       . esc_attr__('View Transaction', 'event_espresso')
776 776
                       . '">'
777 777
                       . $item->transaction()->pretty_paid()
778
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
778
+                      . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
779 779
             }
780 780
         }
781 781
         return '&nbsp;';
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
         $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
816 816
             'espresso_registrations_view_registration', $item->ID()) ? '
817 817
 			<li>
818
-			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
818
+			<a href="' . $view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
819 819
 				<div class="dashicons dashicons-clipboard"></div>
820 820
 			</a>
821 821
 			</li>' : '';
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
             'espresso_registrations_edit_attendee')
824 824
                                && $attendee instanceof EE_Attendee ? '
825 825
 			<li>
826
-			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
826
+			<a href="' . $edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text">
827 827
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
828 828
 			</a>
829 829
 			</li>' : '';
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page_Init.core.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -29,91 +29,91 @@  discard block
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    public function __construct()
33
-    {
34
-        //define some page related constants
35
-        define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36
-        define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
-        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
-        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
-        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
-        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
41
-        //check that if we're in maintenance mode that we tell the admin that
42
-        add_action('admin_notices', array($this, 'check_maintenance_mode'));
43
-        parent::__construct();
44
-    }
45
-
46
-
47
-
48
-    protected function _set_init_properties()
49
-    {
50
-        $this->label = EE_MAINTENANCE_LABEL;
51
-    }
52
-
53
-
54
-
55
-    protected function _set_menu_map()
56
-    {
57
-        $menu_map = $this->_menu_map();
58
-        $this->_menu_map = EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
59
-            ? new EE_Admin_Page_Main_Menu($menu_map) : new EE_Admin_Page_Sub_Menu($menu_map);
60
-    }
61
-
62
-
63
-
64
-    protected function _menu_map()
65
-    {
66
-        $map = array(
67
-            'menu_group'              => 'extras',
68
-            'menu_order'              => 30,
69
-            'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
-            'parent_slug'             => 'espresso_events',
71
-            'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
72
-            'menu_label'              => EE_MAINTENANCE_LABEL,
73
-            'capability'              => 'manage_options',
74
-            'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
75
-            'admin_init_page'         => $this,
76
-        );
77
-        if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
78
-            $map['menu_group'] = 'main';
79
-            $map['subtitle'] = EE_MAINTENANCE_LABEL;
80
-            $map['menu_label'] = __('Event Espresso', 'event_espresso');
81
-        }
82
-        return $map;
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
89
-     * maintenance mode
90
-     */
91
-    public function check_maintenance_mode()
92
-    {
93
-        $notice = '';
94
-        $maintenance_page_url = '';
95
-        if (EE_Maintenance_Mode::instance()->level()) {
96
-            $maintenance_page_url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_MAINTENANCE_ADMIN_URL);
97
-            switch (EE_Maintenance_Mode::instance()->level()) {
98
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
99
-                    $notice = '<div class="update-nag">
32
+	public function __construct()
33
+	{
34
+		//define some page related constants
35
+		define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36
+		define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
+		define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
+		define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
+		define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
+		define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
41
+		//check that if we're in maintenance mode that we tell the admin that
42
+		add_action('admin_notices', array($this, 'check_maintenance_mode'));
43
+		parent::__construct();
44
+	}
45
+
46
+
47
+
48
+	protected function _set_init_properties()
49
+	{
50
+		$this->label = EE_MAINTENANCE_LABEL;
51
+	}
52
+
53
+
54
+
55
+	protected function _set_menu_map()
56
+	{
57
+		$menu_map = $this->_menu_map();
58
+		$this->_menu_map = EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
59
+			? new EE_Admin_Page_Main_Menu($menu_map) : new EE_Admin_Page_Sub_Menu($menu_map);
60
+	}
61
+
62
+
63
+
64
+	protected function _menu_map()
65
+	{
66
+		$map = array(
67
+			'menu_group'              => 'extras',
68
+			'menu_order'              => 30,
69
+			'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
+			'parent_slug'             => 'espresso_events',
71
+			'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
72
+			'menu_label'              => EE_MAINTENANCE_LABEL,
73
+			'capability'              => 'manage_options',
74
+			'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
75
+			'admin_init_page'         => $this,
76
+		);
77
+		if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
78
+			$map['menu_group'] = 'main';
79
+			$map['subtitle'] = EE_MAINTENANCE_LABEL;
80
+			$map['menu_label'] = __('Event Espresso', 'event_espresso');
81
+		}
82
+		return $map;
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
89
+	 * maintenance mode
90
+	 */
91
+	public function check_maintenance_mode()
92
+	{
93
+		$notice = '';
94
+		$maintenance_page_url = '';
95
+		if (EE_Maintenance_Mode::instance()->level()) {
96
+			$maintenance_page_url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_MAINTENANCE_ADMIN_URL);
97
+			switch (EE_Maintenance_Mode::instance()->level()) {
98
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
99
+					$notice = '<div class="update-nag">
100 100
 						'
101
-                              . sprintf(__("Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
102
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>")
103
-                              .
104
-                              '</div>';
105
-                    break;
106
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
107
-                    $notice = '<div class="error">
101
+							  . sprintf(__("Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
102
+							"event_espresso"), "<a href='$maintenance_page_url'>", "</a>")
103
+							  .
104
+							  '</div>';
105
+					break;
106
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
107
+					$notice = '<div class="error">
108 108
 						<p>' . sprintf(__("As part of the process for updating Event Espresso, your database also
109 109
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
110
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
111
-                              '</div>';
112
-                    break;
113
-            }
114
-        }
115
-        echo apply_filters('FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice', $notice,
116
-            $maintenance_page_url);
117
-    }
110
+							"event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
111
+							  '</div>';
112
+					break;
113
+			}
114
+		}
115
+		echo apply_filters('FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice', $notice,
116
+			$maintenance_page_url);
117
+	}
118 118
 
119 119
 } //end class Payments_Admin_Page_Init
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
         //define some page related constants
35 35
         define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36 36
         define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
-        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
-        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
-        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
-        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
37
+        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page='.EE_MAINTENANCE_PG_SLUG));
38
+        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES.'maintenance'.DS);
39
+        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN.'templates'.DS);
40
+        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL.'maintenance/assets/');
41 41
         //check that if we're in maintenance mode that we tell the admin that
42 42
         add_action('admin_notices', array($this, 'check_maintenance_mode'));
43 43
         parent::__construct();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     $notice = '<div class="error">
108 108
 						<p>' . sprintf(__("As part of the process for updating Event Espresso, your database also
109 109
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
110
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
110
+                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>").
111 111
                               '</div>';
112 112
                     break;
113 113
             }
Please login to merge, or discard this patch.
modules/invalid_checkout_access/InvalidCheckoutAccess.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 		if (
40 40
 			! ( $checkout->uts || $checkout->reg_url_link )
41 41
 			&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
42
-            && \EE_Config::instance()->registration->track_invalid_checkout_access()
43
-        ) {
42
+			&& \EE_Config::instance()->registration->track_invalid_checkout_access()
43
+		) {
44 44
 			/** @var \EE_Request $request */
45 45
 			$request = \EE_Registry::instance()->load_core( 'EE_Request' );
46 46
 			$ip_address = $request->ip_address();
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 			}
61 61
 			$ee_bot_checkout[ $ip_address ][ $http_referer ]++;
62 62
 			update_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout );
63
-            if (WP_DEBUG) {
64
-                \EE_Error::add_error(
65
-                    esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
66
-                    __FILE__,
67
-                    __FUNCTION__,
68
-                    __LINE__
69
-                );
70
-            }
63
+			if (WP_DEBUG) {
64
+				\EE_Error::add_error(
65
+					esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
66
+					__FILE__,
67
+					__FUNCTION__,
68
+					__LINE__
69
+				);
70
+			}
71 71
 			return true;
72 72
 		}
73 73
 		return false;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\modules\invalid_checkout_access;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 	 * @param \EE_Checkout $checkout
36 36
 	 * @return bool true if access to registration checkout appears to be invalid
37 37
 	 */
38
-	public function checkoutAccessIsInvalid( \EE_Checkout $checkout ) {
38
+	public function checkoutAccessIsInvalid(\EE_Checkout $checkout) {
39 39
 		if (
40
-			! ( $checkout->uts || $checkout->reg_url_link )
41
-			&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
40
+			! ($checkout->uts || $checkout->reg_url_link)
41
+			&& ! (defined('DOING_AJAX') && DOING_AJAX)
42 42
             && \EE_Config::instance()->registration->track_invalid_checkout_access()
43 43
         ) {
44 44
 			/** @var \EE_Request $request */
45
-			$request = \EE_Registry::instance()->load_core( 'EE_Request' );
45
+			$request = \EE_Registry::instance()->load_core('EE_Request');
46 46
 			$ip_address = $request->ip_address();
47
-			$ee_bot_checkout = get_option( InvalidCheckoutAccess::OPTION_KEY );
48
-			if ( $ee_bot_checkout === false ) {
47
+			$ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY);
48
+			if ($ee_bot_checkout === false) {
49 49
 				$ee_bot_checkout = array();
50
-				add_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false );
50
+				add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false);
51 51
 			}
52
-			if ( ! isset( $ee_bot_checkout[ $ip_address ] ) ) {
53
-				$ee_bot_checkout[ $ip_address ] = array();
52
+			if ( ! isset($ee_bot_checkout[$ip_address])) {
53
+				$ee_bot_checkout[$ip_address] = array();
54 54
 			}
55
-			$http_referer = isset( $_SERVER['HTTP_REFERER'] )
56
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
55
+			$http_referer = isset($_SERVER['HTTP_REFERER'])
56
+				? esc_attr($_SERVER['HTTP_REFERER'])
57 57
 				: 0;
58
-			if ( ! isset( $ee_bot_checkout[ $ip_address ][ $http_referer ] ) ) {
59
-				$ee_bot_checkout[ $ip_address ][ $http_referer ] = 0;
58
+			if ( ! isset($ee_bot_checkout[$ip_address][$http_referer])) {
59
+				$ee_bot_checkout[$ip_address][$http_referer] = 0;
60 60
 			}
61
-			$ee_bot_checkout[ $ip_address ][ $http_referer ]++;
62
-			update_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout );
61
+			$ee_bot_checkout[$ip_address][$http_referer]++;
62
+			update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout);
63 63
             if (WP_DEBUG) {
64 64
                 \EE_Error::add_error(
65 65
                     esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'),
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 				'layout_strategy' => new \EE_Admin_Two_Column_Layout(),
89 89
 				'subsections'     => array(
90 90
 					'invalid_checkout_access_hdr'   => new \EE_Form_Section_HTML(
91
-						\EEH_HTML::h2( esc_html__( 'Invalid Checkout Access', 'event_espresso' ) )
91
+						\EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso'))
92 92
 					),
93 93
 					'ee_bot_checkout_data'          => new \EE_Text_Area_Input(
94 94
 						array(
95
-							'html_label_text' => esc_html__( 'Invalid Checkout Data', 'event_espresso' ),
95
+							'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'),
96 96
 							'default'         => var_export(
97
-								get_option( InvalidCheckoutAccess::OPTION_KEY, array() ),
97
+								get_option(InvalidCheckoutAccess::OPTION_KEY, array()),
98 98
 								true
99 99
 							),
100 100
 							'required'        => false,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					),
107 107
 					'track_invalid_checkout_access' => new \EE_Yes_No_Input(
108 108
 						array(
109
-							'html_label_text'         => __( 'Track Invalid Checkout Access?', 'event_espresso' ),
109
+							'html_label_text'         => __('Track Invalid Checkout Access?', 'event_espresso'),
110 110
 							'html_help_text'          => esc_html__(
111 111
 								'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.',
112 112
 								'event_espresso'
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 					),
120 120
 					'delete_invalid_checkout_data'  => new \EE_Yes_No_Input(
121 121
 						array(
122
-							'html_label_text'         => __( 'Reset Invalid Checkout Data', 'event_espresso' ),
122
+							'html_label_text'         => __('Reset Invalid Checkout Data', 'event_espresso'),
123 123
 							'html_help_text'          => esc_html__(
124 124
 								'Setting this to "Yes" will delete all existing invalid checkout access data.',
125 125
 								'event_espresso'
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Registration_Config $EE_Registration_Config
142 142
 	 * @return \EE_Registration_Config
143 143
 	 */
144
-	public function processForm( \EE_Registration_Config $EE_Registration_Config ) {
144
+	public function processForm(\EE_Registration_Config $EE_Registration_Config) {
145 145
 		try {
146 146
 			$invalid_checkout_access_form = $this->getForm();
147 147
 			// if not displaying a form, then check for form submission
148
-			if ( $invalid_checkout_access_form->was_submitted() ) {
148
+			if ($invalid_checkout_access_form->was_submitted()) {
149 149
 				// capture form data
150 150
 				$invalid_checkout_access_form->receive_form_submission();
151 151
 				// validate form data
152
-				if ( $invalid_checkout_access_form->is_valid() ) {
152
+				if ($invalid_checkout_access_form->is_valid()) {
153 153
 					// grab validated data from form
154 154
 					$valid_data = $invalid_checkout_access_form->valid_data();
155 155
 					// ensure form inputs we want are set
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 							$valid_data['track_invalid_checkout_access']
164 164
 						);
165 165
 						// if deleting, then update option with empty array
166
-						if ( filter_var( $valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN ) ) {
167
-							update_option( InvalidCheckoutAccess::OPTION_KEY, array() );
166
+						if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) {
167
+							update_option(InvalidCheckoutAccess::OPTION_KEY, array());
168 168
 						}
169 169
 					} else {
170 170
 						\EE_Error::add_error(
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 						);
179 179
 					}
180 180
 				} else {
181
-					if ( $invalid_checkout_access_form->submission_error_message() !== '' ) {
181
+					if ($invalid_checkout_access_form->submission_error_message() !== '') {
182 182
 						\EE_Error::add_error(
183 183
 							$invalid_checkout_access_form->submission_error_message(),
184 184
 							__FILE__,
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 					}
189 189
 				}
190 190
 			}
191
-		} catch ( \EE_Error $e ) {
191
+		} catch (\EE_Error $e) {
192 192
 			$e->get_error();
193 193
 		}
194 194
 		return $EE_Registration_Config;
Please login to merge, or discard this patch.