@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | * was not a new generated template but just reactivated (which only happens for global templates that |
60 | 60 | * already exist in the database. |
61 | 61 | */ |
62 | - public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) { |
|
62 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
|
63 | 63 | //make sure message_type is an array. |
64 | 64 | $message_types = (array) $message_types; |
65 | 65 | $templates = array(); |
66 | 66 | |
67 | - if ( empty( $messenger ) ) { |
|
68 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
67 | + if (empty($messenger)) { |
|
68 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
72 | - if ( empty( $message_types ) ) { |
|
73 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
72 | + if (empty($message_types)) { |
|
73 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | EEH_MSG_Template::_set_autoloader(); |
77 | - foreach ( $message_types as $message_type ) { |
|
77 | + foreach ($message_types as $message_type) { |
|
78 | 78 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
79 | - if ( $global && empty( $GRP_ID ) ) { |
|
79 | + if ($global && empty($GRP_ID)) { |
|
80 | 80 | $GRP_ID = EEM_Message_Template_Group::instance()->get_one( |
81 | 81 | array( |
82 | 82 | array( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // if this is global template generation. |
92 | 92 | // First let's determine if we already HAVE global templates for this messenger and message_type combination. |
93 | 93 | // If we do then NO generation!! |
94 | - if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) { |
|
94 | + if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) { |
|
95 | 95 | $templates[] = array( |
96 | 96 | 'GRP_ID' => $GRP_ID, |
97 | 97 | 'MTP_context' => '', |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | //we already have generated templates for this so let's go to the next message type. |
100 | 100 | continue; |
101 | 101 | } |
102 | - $new_message_template_group = EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
102 | + $new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
103 | 103 | |
104 | - if ( ! $new_message_template_group ) { |
|
104 | + if ( ! $new_message_template_group) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | $templates[] = $new_message_template_group; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | * @param int $GRP_ID GRP ID ( if a custom template) (if not provided then we're just doing global template check) |
119 | 119 | * @return bool true = generated, false = hasn't been generated. |
120 | 120 | */ |
121 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0 ) { |
|
121 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0) { |
|
122 | 122 | EEH_MSG_Template::_set_autoloader(); |
123 | 123 | //what method we use depends on whether we have an GRP_ID or not |
124 | - $count = empty( $GRP_ID ) |
|
124 | + $count = empty($GRP_ID) |
|
125 | 125 | ? EEM_Message_Template::instance()->count( |
126 | 126 | array( |
127 | 127 | array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ) |
132 | 132 | ) |
133 | 133 | ) |
134 | - : EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
134 | + : EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID))); |
|
135 | 135 | |
136 | 136 | return $count > 0; |
137 | 137 | } |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param array $message_type_names Message type slug |
148 | 148 | * @return int count of updated records. |
149 | 149 | */ |
150 | - public static function update_to_active( $messenger_names, $message_type_names ) { |
|
151 | - $messenger_names = is_array( $messenger_names ) ? $messenger_names : array( $messenger_names ); |
|
152 | - $message_type_names = is_array( $message_type_names ) ? $message_type_names : array( $message_type_names ); |
|
150 | + public static function update_to_active($messenger_names, $message_type_names) { |
|
151 | + $messenger_names = is_array($messenger_names) ? $messenger_names : array($messenger_names); |
|
152 | + $message_type_names = is_array($message_type_names) ? $message_type_names : array($message_type_names); |
|
153 | 153 | return EEM_Message_Template_Group::instance()->update( |
154 | - array( 'MTP_is_active' => 1 ), |
|
154 | + array('MTP_is_active' => 1), |
|
155 | 155 | array( |
156 | 156 | array( |
157 | - 'MTP_messenger' => array( 'IN', $messenger_names ), |
|
158 | - 'MTP_message_type' => array( 'IN', $message_type_names ) |
|
157 | + 'MTP_messenger' => array('IN', $messenger_names), |
|
158 | + 'MTP_message_type' => array('IN', $message_type_names) |
|
159 | 159 | ) |
160 | 160 | ) |
161 | 161 | ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return int count of updated records. |
178 | 178 | */ |
179 | - public static function update_to_inactive( $messenger_names = array(), $message_type_names = array() ) { |
|
179 | + public static function update_to_inactive($messenger_names = array(), $message_type_names = array()) { |
|
180 | 180 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
181 | 181 | $messenger_names, |
182 | 182 | $message_type_names |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $type |
194 | 194 | * @return array array consisting of installed messenger objects and installed message type objects. |
195 | 195 | */ |
196 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
196 | + public static function get_installed_message_objects($type = 'all') { |
|
197 | 197 | self::_set_autoloader(); |
198 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
198 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
199 | 199 | return array( |
200 | 200 | 'messenger' => $message_resource_manager->installed_messengers(), |
201 | 201 | 'message_type' => $message_resource_manager->installed_message_types() |
@@ -231,74 +231,74 @@ discard block |
||
231 | 231 | $context = 'admin', |
232 | 232 | $merged = false |
233 | 233 | ) { |
234 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
235 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
234 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
235 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
236 | 236 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
237 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
237 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
238 | 238 | //convert slug to object |
239 | - $messenger = $message_resource_manager->get_messenger( $messenger ); |
|
239 | + $messenger = $message_resource_manager->get_messenger($messenger); |
|
240 | 240 | |
241 | 241 | //if messenger isn't a EE_messenger resource then bail. |
242 | - if ( ! $messenger instanceof EE_messenger ) { |
|
242 | + if ( ! $messenger instanceof EE_messenger) { |
|
243 | 243 | return array(); |
244 | 244 | } |
245 | 245 | |
246 | 246 | //validate class for getting our list of shortcodes |
247 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
248 | - if ( ! class_exists( $classname ) ) { |
|
249 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso' ); |
|
247 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
248 | + if ( ! class_exists($classname)) { |
|
249 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
250 | 250 | $msg[] = sprintf( |
251 | - __( 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso' ), |
|
251 | + __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), |
|
252 | 252 | $classname |
253 | 253 | ); |
254 | - throw new EE_Error( implode( '||', $msg ) ); |
|
254 | + throw new EE_Error(implode('||', $msg)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** @type EE_Messages_Validator $_VLD */ |
258 | - $_VLD = new $classname( array(), $context ); |
|
258 | + $_VLD = new $classname(array(), $context); |
|
259 | 259 | $valid_shortcodes = $_VLD->get_validators(); |
260 | 260 | |
261 | 261 | //let's make sure we're only getting the shortcode part of the validators |
262 | 262 | $shortcodes = array(); |
263 | - foreach ( $valid_shortcodes as $field => $validators ) { |
|
264 | - $shortcodes[ $field ] = $validators['shortcodes']; |
|
263 | + foreach ($valid_shortcodes as $field => $validators) { |
|
264 | + $shortcodes[$field] = $validators['shortcodes']; |
|
265 | 265 | } |
266 | 266 | $valid_shortcodes = $shortcodes; |
267 | 267 | |
268 | 268 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
269 | - if ( ! empty( $fields ) ) { |
|
269 | + if ( ! empty($fields)) { |
|
270 | 270 | $specified_shortcodes = array(); |
271 | - foreach ( $fields as $field ) { |
|
272 | - if ( isset( $valid_shortcodes[ $field ] ) ) { |
|
273 | - $specified_shortcodes[ $field ] = $valid_shortcodes[ $field ]; |
|
271 | + foreach ($fields as $field) { |
|
272 | + if (isset($valid_shortcodes[$field])) { |
|
273 | + $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | $valid_shortcodes = $specified_shortcodes; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if not merged then let's replace the fields with the localized fields |
280 | - if ( ! $merged ) { |
|
280 | + if ( ! $merged) { |
|
281 | 281 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
282 | 282 | $field_settings = $messenger->get_template_fields(); |
283 | 283 | $localized = array(); |
284 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
284 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
285 | 285 | //get localized field label |
286 | - if ( isset( $field_settings[ $field ] ) ) { |
|
286 | + if (isset($field_settings[$field])) { |
|
287 | 287 | //possible that this is used as a main field. |
288 | - if ( empty( $field_settings[ $field ] ) ) { |
|
289 | - if ( isset( $field_settings['extra'][ $field ] ) ) { |
|
290 | - $_field = $field_settings['extra'][ $field ]['main']['label']; |
|
288 | + if (empty($field_settings[$field])) { |
|
289 | + if (isset($field_settings['extra'][$field])) { |
|
290 | + $_field = $field_settings['extra'][$field]['main']['label']; |
|
291 | 291 | } else { |
292 | 292 | $_field = $field; |
293 | 293 | } |
294 | 294 | } else { |
295 | - $_field = $field_settings[ $field ]['label']; |
|
295 | + $_field = $field_settings[$field]['label']; |
|
296 | 296 | } |
297 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
297 | + } else if (isset($field_settings['extra'])) { |
|
298 | 298 | //loop through extra "main fields" and see if any of their children have our field |
299 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
300 | - if ( isset( $fields[ $field ] ) ) { |
|
301 | - $_field = $fields[ $field ]['label']; |
|
299 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
300 | + if (isset($fields[$field])) { |
|
301 | + $_field = $fields[$field]['label']; |
|
302 | 302 | } else { |
303 | 303 | $_field = $field; |
304 | 304 | } |
@@ -306,22 +306,22 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $_field = $field; |
308 | 308 | } |
309 | - if ( isset( $_field ) ) { |
|
310 | - $localized[ $_field ] = $shortcodes; |
|
309 | + if (isset($_field)) { |
|
310 | + $localized[$_field] = $shortcodes; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | $valid_shortcodes = $localized; |
314 | 314 | } |
315 | 315 | |
316 | 316 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
317 | - if ( $merged ) { |
|
317 | + if ($merged) { |
|
318 | 318 | $merged_codes = array(); |
319 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
320 | - foreach ( $shortcode as $code => $label ) { |
|
321 | - if ( isset( $merged_codes[ $code ] ) ) { |
|
319 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
320 | + foreach ($shortcode as $code => $label) { |
|
321 | + if (isset($merged_codes[$code])) { |
|
322 | 322 | continue; |
323 | 323 | } else { |
324 | - $merged_codes[ $code ] = $label; |
|
324 | + $merged_codes[$code] = $label; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | } |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | * @throws \EE_Error |
342 | 342 | * @return EE_messenger |
343 | 343 | */ |
344 | - public static function messenger_obj( $messenger ) { |
|
344 | + public static function messenger_obj($messenger) { |
|
345 | 345 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
346 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
347 | - return $Message_Resource_Manager->get_messenger( $messenger ); |
|
346 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
347 | + return $Message_Resource_Manager->get_messenger($messenger); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @throws \EE_Error |
358 | 358 | * @return EE_message_type |
359 | 359 | */ |
360 | - public static function message_type_obj( $message_type ) { |
|
360 | + public static function message_type_obj($message_type) { |
|
361 | 361 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
362 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
363 | - return $Message_Resource_Manager->get_message_type( $message_type ); |
|
362 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
363 | + return $Message_Resource_Manager->get_message_type($message_type); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * @param string $message_type message type to check for. |
375 | 375 | * @return boolean |
376 | 376 | */ |
377 | - public static function is_mt_active( $message_type ) { |
|
377 | + public static function is_mt_active($message_type) { |
|
378 | 378 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
379 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
379 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
380 | 380 | $active_mts = $Message_Resource_Manager->list_of_active_message_types(); |
381 | - return in_array( $message_type, $active_mts ); |
|
381 | + return in_array($message_type, $active_mts); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param string $messenger slug for messenger to check. |
392 | 392 | * @return boolean |
393 | 393 | */ |
394 | - public static function is_messenger_active( $messenger ) { |
|
394 | + public static function is_messenger_active($messenger) { |
|
395 | 395 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
396 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
397 | - $active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger ); |
|
396 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
397 | + $active_messenger = $Message_Resource_Manager->get_active_messenger($messenger); |
|
398 | 398 | return $active_messenger instanceof EE_messenger ? true : false; |
399 | 399 | } |
400 | 400 | |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | public static function get_active_messengers_in_db() { |
413 | 413 | EE_Error::doing_it_wrong( |
414 | 414 | __METHOD__, |
415 | - __( 'Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso' ), |
|
415 | + __('Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso'), |
|
416 | 416 | '4.9.0' |
417 | 417 | ); |
418 | 418 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
419 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
419 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
420 | 420 | return $Message_Resource_Manager->get_active_messengers_option(); |
421 | 421 | } |
422 | 422 | |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool FALSE if not updated, TRUE if updated. |
435 | 435 | */ |
436 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
436 | + public static function update_active_messengers_in_db($data_to_save) { |
|
437 | 437 | EE_Error::doing_it_wrong( |
438 | 438 | __METHOD__, |
439 | - __( 'Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso' ), |
|
439 | + __('Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso'), |
|
440 | 440 | '4.9.0' |
441 | 441 | ); |
442 | 442 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
443 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
444 | - return $Message_Resource_Manager->update_active_messengers_option( $data_to_save ); |
|
443 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
444 | + return $Message_Resource_Manager->update_active_messengers_option($data_to_save); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -465,34 +465,34 @@ discard block |
||
465 | 465 | $sending_messenger = '' |
466 | 466 | ) { |
467 | 467 | //first determine if the url can be to the EE_Message object. |
468 | - if ( ! $message_type->always_generate() ) { |
|
469 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
468 | + if ( ! $message_type->always_generate()) { |
|
469 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
473 | - if ( ! $registration instanceof EE_Registration ) { |
|
473 | + if ( ! $registration instanceof EE_Registration) { |
|
474 | 474 | throw new EE_Error( |
475 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
475 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
476 | 476 | ); |
477 | 477 | } |
478 | 478 | |
479 | 479 | //validate given context |
480 | 480 | $contexts = $message_type->get_contexts(); |
481 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
481 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $message->context(), |
486 | - get_class( $message_type ) |
|
486 | + get_class($message_type) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | 491 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
492 | - if ( ! empty( $sending_messenger ) ) { |
|
492 | + if ( ! empty($sending_messenger)) { |
|
493 | 493 | $with_messengers = $message_type->with_messengers(); |
494 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
495 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
494 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
495 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | 498 | __( |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'event_espresso' |
501 | 501 | ), |
502 | 502 | $sending_messenger, |
503 | - get_class( $message_type ) |
|
503 | + get_class($message_type) |
|
504 | 504 | ) |
505 | 505 | ); |
506 | 506 | } |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param EE_Message $message |
524 | 524 | * @return string. |
525 | 525 | */ |
526 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
526 | + public static function generate_browser_trigger(EE_Message $message) { |
|
527 | 527 | $query_args = array( |
528 | 528 | 'ee' => 'msg_browser_trigger', |
529 | 529 | 'token' => $message->MSG_token() |
530 | 530 | ); |
531 | 531 | return apply_filters( |
532 | 532 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
533 | - add_query_arg( $query_args, site_url() ), |
|
533 | + add_query_arg($query_args, site_url()), |
|
534 | 534 | $message |
535 | 535 | ); |
536 | 536 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @param EE_Message $message |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
548 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
549 | 549 | return apply_filters( |
550 | 550 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
551 | 551 | add_query_arg( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | 'GRP_ID' => $message_template_group, |
596 | 596 | 'id' => $data_id |
597 | 597 | ); |
598 | - $url = add_query_arg( $query_args, get_home_url() ); |
|
598 | + $url = add_query_arg($query_args, get_home_url()); |
|
599 | 599 | |
600 | 600 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
601 | 601 | $url = apply_filters( |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @param string $type What action to return. |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public static function get_message_action_icon( $type ) { |
|
626 | + public static function get_message_action_icon($type) { |
|
627 | 627 | $action_icons = self::get_message_action_icons(); |
628 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
628 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -637,34 +637,34 @@ discard block |
||
637 | 637 | * @return array |
638 | 638 | */ |
639 | 639 | public static function get_message_action_icons() { |
640 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
640 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
641 | 641 | array( |
642 | 642 | 'view' => array( |
643 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
643 | + 'label' => __('View Message', 'event_espresso'), |
|
644 | 644 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
645 | 645 | ), |
646 | 646 | 'error' => array( |
647 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
647 | + 'label' => __('View Error Message', 'event_espresso'), |
|
648 | 648 | 'css_class' => 'dashicons dashicons-info', |
649 | 649 | ), |
650 | 650 | 'see_notifications_for' => array( |
651 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
651 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
652 | 652 | 'css_class' => 'dashicons dashicons-megaphone', |
653 | 653 | ), |
654 | 654 | 'generate_now' => array( |
655 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
655 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
656 | 656 | 'css_class' => 'dashicons dashicons-admin-tools', |
657 | 657 | ), |
658 | 658 | 'send_now' => array( |
659 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
659 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
660 | 660 | 'css_class' => 'dashicons dashicons-controls-forward', |
661 | 661 | ), |
662 | 662 | 'queue_for_resending' => array( |
663 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
663 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
664 | 664 | 'css_class' => 'dashicons dashicons-controls-repeat', |
665 | 665 | ), |
666 | 666 | 'view_transaction' => array( |
667 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
667 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
668 | 668 | 'css_class' => 'dashicons dashicons-cart', |
669 | 669 | ) |
670 | 670 | ) |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
687 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
688 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
686 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
687 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
688 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -700,15 +700,15 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return array |
702 | 702 | */ |
703 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
704 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
703 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
704 | + EE_Registry::instance()->load_helper('URL'); |
|
705 | 705 | //if $message is not an instance of EE_Message then let's just do a dummy. |
706 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
707 | - $action_urls = apply_filters( |
|
706 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
707 | + $action_urls = apply_filters( |
|
708 | 708 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
709 | 709 | array( |
710 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
711 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
710 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
711 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
712 | 712 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
713 | 713 | array_merge( |
714 | 714 | array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | ), |
719 | 719 | $query_params |
720 | 720 | ), |
721 | - admin_url( 'admin.php' ) |
|
721 | + admin_url('admin.php') |
|
722 | 722 | ), |
723 | 723 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
724 | 724 | array( |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'action' => 'generate_now', |
727 | 727 | 'MSG_ID' => $message->ID() |
728 | 728 | ), |
729 | - admin_url( 'admin.php' ) |
|
729 | + admin_url('admin.php') |
|
730 | 730 | ), |
731 | 731 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
732 | 732 | array( |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'action' => 'send_now', |
735 | 735 | 'MSG_ID' => $message->ID() |
736 | 736 | ), |
737 | - admin_url( 'admin.php' ) |
|
737 | + admin_url('admin.php') |
|
738 | 738 | ), |
739 | 739 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
740 | 740 | array( |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'action' => 'queue_for_resending', |
743 | 743 | 'MSG_ID' => $message->ID() |
744 | 744 | ), |
745 | - admin_url( 'admin.php' ) |
|
745 | + admin_url('admin.php') |
|
746 | 746 | ), |
747 | 747 | ) |
748 | 748 | ); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | 'action' => 'view_transaction', |
761 | 761 | 'TXN_ID' => $message->TXN_ID() |
762 | 762 | ), |
763 | - admin_url( 'admin.php' ) |
|
763 | + admin_url('admin.php') |
|
764 | 764 | ); |
765 | 765 | } else { |
766 | 766 | $action_urls['view_transaction'] = ''; |
@@ -781,26 +781,26 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
785 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
786 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
787 | - $title = isset( $icon_css['label'] ) ? 'title="' . $icon_css['label'] . '"' : ''; |
|
784 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
785 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
786 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
787 | + $title = isset($icon_css['label']) ? 'title="'.$icon_css['label'].'"' : ''; |
|
788 | 788 | |
789 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
789 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
790 | 790 | return ''; |
791 | 791 | } |
792 | 792 | |
793 | 793 | $icon_css['css_class'] .= esc_attr( |
794 | 794 | apply_filters( |
795 | 795 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
796 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
796 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
797 | 797 | $type, |
798 | 798 | $message, |
799 | 799 | $query_params |
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | |
803 | - return '<a href="' . $url . '"' . $title . '><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
803 | + return '<a href="'.$url.'"'.$title.'><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
804 | 804 | |
805 | 805 | } |
806 | 806 | |
@@ -838,9 +838,9 @@ discard block |
||
838 | 838 | * @param $reg_status |
839 | 839 | * @return string |
840 | 840 | */ |
841 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
841 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
842 | 842 | $reg_status_array = self::reg_status_to_message_type_array(); |
843 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
843 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | |
@@ -874,9 +874,9 @@ discard block |
||
874 | 874 | * @param $payment_status |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
877 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
878 | 878 | $payment_status_array = self::payment_status_to_message_type_array(); |
879 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
879 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -887,32 +887,32 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @return EE_Messages_Template_Pack |
889 | 889 | */ |
890 | - public static function get_template_pack( $template_pack_name ) { |
|
891 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
890 | + public static function get_template_pack($template_pack_name) { |
|
891 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
892 | 892 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
893 | 893 | } |
894 | 894 | |
895 | 895 | //first see if in collection already |
896 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
896 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
897 | 897 | |
898 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
898 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
899 | 899 | return $template_pack; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //nope...let's get it. |
903 | 903 | //not set yet so let's attempt to get it. |
904 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
904 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
905 | 905 | ' ', |
906 | 906 | '_', |
907 | 907 | ucwords( |
908 | - str_replace( '_', ' ', $template_pack_name ) |
|
908 | + str_replace('_', ' ', $template_pack_name) |
|
909 | 909 | ) |
910 | 910 | ); |
911 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
912 | - return self::get_template_pack( 'default' ); |
|
911 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
912 | + return self::get_template_pack('default'); |
|
913 | 913 | } else { |
914 | 914 | $template_pack = new $pack_class_name; |
915 | - self::$_template_pack_collection->add( $template_pack ); |
|
915 | + self::$_template_pack_collection->add($template_pack); |
|
916 | 916 | return $template_pack; |
917 | 917 | } |
918 | 918 | } |
@@ -930,26 +930,26 @@ discard block |
||
930 | 930 | */ |
931 | 931 | public static function get_template_pack_collection() { |
932 | 932 | $new_collection = false; |
933 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
933 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
934 | 934 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
935 | 935 | $new_collection = true; |
936 | 936 | } |
937 | 937 | |
938 | 938 | //glob the defaults directory for messages |
939 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
940 | - foreach( $templates as $template_path ) { |
|
939 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
940 | + foreach ($templates as $template_path) { |
|
941 | 941 | //grab folder name |
942 | - $template = basename( $template_path ); |
|
942 | + $template = basename($template_path); |
|
943 | 943 | |
944 | - if ( ! $new_collection ) { |
|
944 | + if ( ! $new_collection) { |
|
945 | 945 | //already have it? |
946 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
946 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
947 | 947 | continue; |
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
951 | 951 | //setup classname. |
952 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
952 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
953 | 953 | ' ', |
954 | 954 | '_', |
955 | 955 | ucwords( |
@@ -960,20 +960,20 @@ discard block |
||
960 | 960 | ) |
961 | 961 | ) |
962 | 962 | ); |
963 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
963 | + if ( ! class_exists($template_pack_class_name)) { |
|
964 | 964 | continue; |
965 | 965 | } |
966 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
966 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
970 | 970 | * Filter for plugins to add in any additional template packs |
971 | 971 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
972 | 972 | */ |
973 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
974 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
975 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
976 | - self::$_template_pack_collection->add( $template_pack ); |
|
973 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
974 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
975 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
976 | + self::$_template_pack_collection->add($template_pack); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | return self::$_template_pack_collection; |
@@ -991,16 +991,16 @@ discard block |
||
991 | 991 | * @return array |
992 | 992 | * @throws \EE_Error |
993 | 993 | */ |
994 | - public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
994 | + public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
995 | 995 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
996 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
997 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
998 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
999 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
996 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
997 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
998 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
999 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
1000 | 1000 | return array(); |
1001 | 1001 | } |
1002 | 1002 | //whew made it this far! Okay, let's go ahead and create the templates then |
1003 | - return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
1003 | + return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
@@ -1012,15 +1012,15 @@ discard block |
||
1012 | 1012 | * @param $global |
1013 | 1013 | * @return array|mixed |
1014 | 1014 | */ |
1015 | - protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
1015 | + protected static function _create_new_templates(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
1016 | 1016 | //if we're creating a custom template then we don't need to use the defaults class |
1017 | - if ( ! $global ) { |
|
1018 | - return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
1017 | + if ( ! $global) { |
|
1018 | + return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
1019 | 1019 | } |
1020 | 1020 | /** @type EE_Messages_Template_Defaults $Message_Template_Defaults */ |
1021 | 1021 | $Message_Template_Defaults = EE_Registry::factory( |
1022 | 1022 | 'EE_Messages_Template_Defaults', |
1023 | - array( $messenger, $message_type, $GRP_ID ) |
|
1023 | + array($messenger, $message_type, $GRP_ID) |
|
1024 | 1024 | ); |
1025 | 1025 | //generate templates |
1026 | 1026 | $success = $Message_Template_Defaults->create_new_templates(); |
@@ -1028,10 +1028,10 @@ discard block |
||
1028 | 1028 | //if creating the template failed. Then we should deactivate the related message_type for the messenger because |
1029 | 1029 | //its not active if it doesn't have a template. Note this is only happening for GLOBAL template creation |
1030 | 1030 | //attempts. |
1031 | - if ( ! $success ) { |
|
1031 | + if ( ! $success) { |
|
1032 | 1032 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
1033 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1034 | - $message_resource_manager->deactivate_message_type_for_messenger( $message_type->name, $messenger->name ); |
|
1033 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1034 | + $message_resource_manager->deactivate_message_type_for_messenger($message_type->name, $messenger->name); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -1059,11 +1059,11 @@ discard block |
||
1059 | 1059 | * ) |
1060 | 1060 | * @access private |
1061 | 1061 | */ |
1062 | - private static function _create_custom_template_group( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1062 | + private static function _create_custom_template_group(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1063 | 1063 | //defaults |
1064 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1064 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1065 | 1065 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
1066 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1066 | + $Message_Template_Group = empty($GRP_ID) |
|
1067 | 1067 | ? EEM_Message_Template_Group::instance()->get_one( |
1068 | 1068 | array( |
1069 | 1069 | array( |
@@ -1073,9 +1073,9 @@ discard block |
||
1073 | 1073 | ) |
1074 | 1074 | ) |
1075 | 1075 | ) |
1076 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1076 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1077 | 1077 | //if we don't have a mtg at this point then we need to bail. |
1078 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1078 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1079 | 1079 | EE_Error::add_error( |
1080 | 1080 | sprintf( |
1081 | 1081 | __( |
@@ -1094,42 +1094,42 @@ discard block |
||
1094 | 1094 | $message_templates = $Message_Template_Group->message_templates(); |
1095 | 1095 | //now we have what we need to setup the new template |
1096 | 1096 | $new_mtg = clone $Message_Template_Group; |
1097 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1098 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1099 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1100 | - ? $_POST[ 'templateName' ] |
|
1097 | + $new_mtg->set('GRP_ID', 0); |
|
1098 | + $new_mtg->set('MTP_is_global', false); |
|
1099 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1100 | + ? $_POST['templateName'] |
|
1101 | 1101 | : __( |
1102 | 1102 | 'New Custom Template', |
1103 | 1103 | 'event_espresso' |
1104 | 1104 | ); |
1105 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1106 | - ? $_POST[ 'templateDescription' ] |
|
1105 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1106 | + ? $_POST['templateDescription'] |
|
1107 | 1107 | : sprintf( |
1108 | 1108 | __( |
1109 | 1109 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1110 | 1110 | 'event_espresso' |
1111 | 1111 | ), |
1112 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1113 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1112 | + $new_mtg->messenger_obj()->label['singular'], |
|
1113 | + $new_mtg->message_type_obj()->label['singular'] |
|
1114 | 1114 | ); |
1115 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1116 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1115 | + $new_mtg->set('MTP_name', $template_name); |
|
1116 | + $new_mtg->set('MTP_description', $template_description); |
|
1117 | 1117 | //remove ALL relations on this template group so they don't get saved! |
1118 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1118 | + $new_mtg->_remove_relations('Message_Template'); |
|
1119 | 1119 | $new_mtg->save(); |
1120 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1121 | - $success[ 'template_name' ] = $template_name; |
|
1120 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1121 | + $success['template_name'] = $template_name; |
|
1122 | 1122 | //add new message templates and add relation to. |
1123 | - foreach ( $message_templates as $message_template ) { |
|
1124 | - if ( ! $message_template instanceof EE_Message_Template ) { |
|
1123 | + foreach ($message_templates as $message_template) { |
|
1124 | + if ( ! $message_template instanceof EE_Message_Template) { |
|
1125 | 1125 | continue; |
1126 | 1126 | } |
1127 | 1127 | $new_message_template = clone $message_template; |
1128 | - $new_message_template->set( 'MTP_ID', 0 ); |
|
1129 | - $new_message_template->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1128 | + $new_message_template->set('MTP_ID', 0); |
|
1129 | + $new_message_template->set('GRP_ID', $new_mtg->ID()); //relation |
|
1130 | 1130 | $new_message_template->save(); |
1131 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1132 | - $success[ 'MTP_context' ] = $new_message_template->get( 'MTP_context' ); |
|
1131 | + if (empty($success['MTP_context'])) { |
|
1132 | + $success['MTP_context'] = $new_message_template->get('MTP_context'); |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | return $success; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $global = false |
1152 | 1152 | ) { |
1153 | 1153 | //is given message_type valid for given messenger (if this is not a global save) |
1154 | - if ( $global ) { |
|
1154 | + if ($global) { |
|
1155 | 1155 | return true; |
1156 | 1156 | } |
1157 | 1157 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | ) |
1164 | 1164 | ) |
1165 | 1165 | ); |
1166 | - if ( $active_templates > 0 ) { |
|
1166 | + if ($active_templates > 0) { |
|
1167 | 1167 | return true; |
1168 | 1168 | } |
1169 | 1169 | EE_Error::add_error( |
@@ -1192,24 +1192,24 @@ discard block |
||
1192 | 1192 | * @param string $message_type_name name of EE_message_type |
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | - public static function get_fields( $messenger_name, $message_type_name ) { |
|
1195 | + public static function get_fields($messenger_name, $message_type_name) { |
|
1196 | 1196 | $template_fields = array(); |
1197 | 1197 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1198 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1199 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1200 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1201 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1198 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1199 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1200 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1201 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1202 | 1202 | return array(); |
1203 | 1203 | } |
1204 | 1204 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1205 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1206 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1207 | - $template_fields[ $context ][ $field ] = $value; |
|
1205 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1206 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1207 | + $template_fields[$context][$field] = $value; |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | - if ( empty( $template_fields ) ) { |
|
1210 | + if (empty($template_fields)) { |
|
1211 | 1211 | EE_Error::add_error( |
1212 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1212 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1213 | 1213 | __FILE__, |
1214 | 1214 | __FUNCTION__, |
1215 | 1215 | __LINE__ |
@@ -492,7 +492,7 @@ |
||
492 | 492 | if ( ! empty( $sending_messenger ) ) { |
493 | 493 | $with_messengers = $message_type->with_messengers(); |
494 | 494 | if ( ! isset( $with_messengers[$message->messenger()] ) |
495 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
495 | + || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | 498 | __( |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -454,6 +454,7 @@ discard block |
||
454 | 454 | * @param EE_Registration | null $registration The registration object must be included if this |
455 | 455 | * is going to be a registration trigger url. |
456 | 456 | * @param string $sending_messenger The (optional) sending messenger for the url. |
457 | + * @param EE_Registration $registration |
|
457 | 458 | * |
458 | 459 | * @return string |
459 | 460 | * @throws EE_Error |
@@ -1008,8 +1009,8 @@ discard block |
||
1008 | 1009 | /** |
1009 | 1010 | * @param \EE_messenger $messenger |
1010 | 1011 | * @param \EE_message_type $message_type |
1011 | - * @param $GRP_ID |
|
1012 | - * @param $global |
|
1012 | + * @param integer $GRP_ID |
|
1013 | + * @param boolean $global |
|
1013 | 1014 | * @return array|mixed |
1014 | 1015 | */ |
1015 | 1016 | protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
@@ -6,14 +6,14 @@ discard block |
||
6 | 6 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
7 | 7 | <?php |
8 | 8 | if ( $ticket instanceof EE_Ticket ) { |
9 | - do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
10 | - $ticket_description = $ticket->description(); |
|
11 | - $ticket_description .= ! empty( $ticket_description ) |
|
12 | - ? '<br />' . $ticket_status_display |
|
13 | - : $ticket_status_display; |
|
14 | - if ( ! strpos( $ticket_description, '<div' ) ) { |
|
15 | - $ticket_description = "<p>{$ticket_description}</p>"; |
|
16 | - } |
|
9 | + do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
10 | + $ticket_description = $ticket->description(); |
|
11 | + $ticket_description .= ! empty( $ticket_description ) |
|
12 | + ? '<br />' . $ticket_status_display |
|
13 | + : $ticket_status_display; |
|
14 | + if ( ! strpos( $ticket_description, '<div' ) ) { |
|
15 | + $ticket_description = "<p>{$ticket_description}</p>"; |
|
16 | + } |
|
17 | 17 | ?> |
18 | 18 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
19 | 19 | <div class="no-tkt-slctr-ticket-content-dv"> |
@@ -23,6 +23,6 @@ discard block |
||
23 | 23 | <?php } ?> |
24 | 24 | </div> |
25 | 25 | <?php |
26 | - do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
26 | + do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
27 | 27 | } |
28 | 28 | ?> |
@@ -5,24 +5,24 @@ |
||
5 | 5 | <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/> |
6 | 6 | <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/> |
7 | 7 | <?php |
8 | -if ( $ticket instanceof EE_Ticket ) { |
|
9 | - do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); |
|
8 | +if ($ticket instanceof EE_Ticket) { |
|
9 | + do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); |
|
10 | 10 | $ticket_description = $ticket->description(); |
11 | - $ticket_description .= ! empty( $ticket_description ) |
|
12 | - ? '<br />' . $ticket_status_display |
|
11 | + $ticket_description .= ! empty($ticket_description) |
|
12 | + ? '<br />'.$ticket_status_display |
|
13 | 13 | : $ticket_status_display; |
14 | - if ( ! strpos( $ticket_description, '<div' ) ) { |
|
14 | + if ( ! strpos($ticket_description, '<div')) { |
|
15 | 15 | $ticket_description = "<p>{$ticket_description}</p>"; |
16 | 16 | } |
17 | 17 | ?> |
18 | 18 | <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv"> |
19 | 19 | <div class="no-tkt-slctr-ticket-content-dv"> |
20 | 20 | <h5><?php echo $ticket->name(); ?></h5> |
21 | - <?php if ( ! empty( $ticket_description ) ) { ?> |
|
21 | + <?php if ( ! empty($ticket_description)) { ?> |
|
22 | 22 | <?php echo $ticket_description; ?> |
23 | 23 | <?php } ?> |
24 | 24 | </div> |
25 | 25 | <?php |
26 | - do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
26 | + do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
27 | 27 | } |
28 | 28 | ?> |
@@ -588,6 +588,7 @@ discard block |
||
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 |
||
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() ) { |
@@ -1012,7 +1012,7 @@ |
||
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 ] ); |
@@ -1,16 +1,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -41,21 +41,21 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -1,36 +1,36 @@ |
||
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?> |
@@ -105,41 +105,41 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,4 +1,6 @@ |
||
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 | * |
@@ -362,62 +362,62 @@ |
||
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 |
@@ -373,7 +373,7 @@ |
||
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 | { |
@@ -2,7 +2,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -304,7 +304,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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.) |
@@ -418,7 +418,7 @@ |
||
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 | { |
@@ -174,7 +174,7 @@ |
||
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); |
@@ -83,7 +83,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -17,7 +17,7 @@ discard block |
||
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 |
||
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 |
@@ -227,7 +227,7 @@ |
||
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 | { |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 .= ' ' . 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 | - ? ' <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 .= ' ' . 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 ' '; |
|
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®istration_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 .= ' ' . 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 | + ? ' <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 .= ' ' . 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 ' '; |
|
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®istration_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 | } |
@@ -157,7 +157,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 .= ' ' . 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 .= ' '.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 |
||
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 |
||
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 .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
564 | + $link .= ' '.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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 ' '; |
@@ -815,7 +815,7 @@ discard block |
||
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 |
||
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>' : ''; |
@@ -1,6 +1,6 @@ discard block |
||
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 |
||
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 |
@@ -34,10 +34,10 @@ discard block |
||
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 |
||
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 | } |