Completed
Branch FET-8385-datetime-ticket-selec... (cac7e5)
by
unknown
67:23 queued 43:13
created
admin_pages/transactions/Transactions_Admin_Page.core.php 1 patch
Spacing   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $routing
57 57
 	 * @return Transactions_Admin_Page
58 58
 	 */
59
-	public function __construct( $routing = TRUE ) {
60
-		parent::__construct( $routing );
59
+	public function __construct($routing = TRUE) {
60
+		parent::__construct($routing);
61 61
 	}
62 62
 
63 63
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @return void
81 81
 	 */
82 82
 	protected function _ajax_hooks() {
83
-		add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds'));
84
-		add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds'));
85
-		add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment'));
83
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
84
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
85
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
86 86
 	}
87 87
 
88 88
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'buttons' => array(
98 98
 				'add' => esc_html__('Add New Transaction', 'event_espresso'),
99 99
 				'edit' => esc_html__('Edit Transaction', 'event_espresso'),
100
-				'delete' => esc_html__('Delete Transaction','event_espresso'),
100
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
101 101
 			)
102 102
 		);
103 103
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->_set_transaction_status_array();
115 115
 
116
-		$txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0;
116
+		$txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
117 117
 
118 118
 		$this->_page_routes = array(
119 119
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 						'filename' => 'transactions_overview_views_filters_search'
186 186
 					),
187 187
 				),
188
-				'help_tour' => array( 'Transactions_Overview_Help_Tour' ),
188
+				'help_tour' => array('Transactions_Overview_Help_Tour'),
189 189
 				/**
190 190
 				 * commented out because currently we are not displaying tips for transaction list table status but this
191 191
 				 * may change in a later iteration so want to keep the code for then.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'nav' => array(
198 198
 					'label' => esc_html__('View Transaction', 'event_espresso'),
199 199
 					'order' => 5,
200
-					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
200
+					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
201 201
 					'persistent' => FALSE
202 202
 					),
203 203
 				'help_tabs' => array(
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 						'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
219 219
 					),
220 220
 				),
221
-				'qtips' => array( 'Transaction_Details_Tips' ),
222
-				'help_tour' => array( 'Transaction_Details_Help_Tour' ),
221
+				'qtips' => array('Transaction_Details_Tips'),
222
+				'help_tour' => array('Transaction_Details_Help_Tour'),
223 223
 				'metaboxes' => array('_transaction_details_metaboxes'),
224 224
 
225 225
 				'require_nonce' => FALSE
@@ -237,23 +237,23 @@  discard block
 block discarded – undo
237 237
 		// IF a registration was JUST added via the admin...
238 238
 		if (
239 239
 		isset(
240
-			$this->_req_data[ 'redirect_from' ],
241
-			$this->_req_data[ 'EVT_ID' ],
242
-			$this->_req_data[ 'event_name' ]
240
+			$this->_req_data['redirect_from'],
241
+			$this->_req_data['EVT_ID'],
242
+			$this->_req_data['event_name']
243 243
 		)
244 244
 		) {
245 245
 			// then set a cookie so that we can block any attempts to use
246 246
 			// the back button as a way to enter another registration.
247
-			setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' );
247
+			setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/');
248 248
 			// and update the global
249
-			$_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ];
249
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
250 250
 		}
251
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = esc_html__( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
252
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = esc_html__( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
253
-		EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status;
254
-		EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status;
255
-		EE_Registry::$i18n_js_strings[ 'payments_total' ] = esc_html__( 'Payments Total', 'event_espresso' );
256
-		EE_Registry::$i18n_js_strings[ 'transaction_overpaid' ] = esc_html__( 'This transaction has been overpaid ! Payments Total', 'event_espresso' );
251
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
252
+		EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', 'event_espresso');
253
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
254
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
255
+		EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
256
+		EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', 'event_espresso');
257 257
 	}
258 258
 	public function admin_notices() {}
259 259
 	public function admin_footer_scripts() {}
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function load_scripts_styles() {
322 322
 		//enqueue style
323
-		wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION );
323
+		wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION);
324 324
 		wp_enqueue_style('espresso_txn');
325 325
 
326 326
 		//scripts
327 327
 		add_filter('FHEE_load_accounting_js', '__return_true');
328 328
 
329 329
 		//scripts
330
-		wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
330
+		wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
331 331
 		wp_enqueue_script('espresso_txn');
332 332
 
333 333
 	}
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 *	@return void
368 368
 	 */
369 369
 	protected function _set_list_table_views_default() {
370
-		$this->_views = array (
371
-			'all' => array (
370
+		$this->_views = array(
371
+			'all' => array(
372 372
 				'slug' 		=> 'all',
373 373
 				'label' 		=> esc_html__('View All Transactions', 'event_espresso'),
374 374
 				'count' 	=> 0
@@ -396,21 +396,21 @@  discard block
 block discarded – undo
396 396
 	 *	@return void
397 397
 	 */
398 398
 	private function _set_transaction_object() {
399
-		if ( is_object( $this->_transaction) )
399
+		if (is_object($this->_transaction))
400 400
 			return; //get out we've already set the object
401 401
 
402 402
 	    $TXN = EEM_Transaction::instance();
403 403
 
404
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
404
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
405 405
 
406 406
 	    //get transaction object
407 407
 	    $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
408
-	    $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
408
+	    $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL;
409 409
 		$this->_transaction->verify_abandoned_transaction_status();
410 410
 
411
-	 	if ( empty( $this->_transaction ) ) {
412
-	    	$error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  esc_html__(' could not be retrieved.', 'event_espresso');
413
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
411
+	 	if (empty($this->_transaction)) {
412
+	    	$error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso');
413
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
414 414
 	    }
415 415
 	}
416 416
 
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
 	 *	@return array
424 424
 	 */
425 425
 	protected function _transaction_legend_items() {
426
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
426
+		EE_Registry::instance()->load_helper('MSG_Template');
427 427
 		$items = array();
428 428
 
429
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) {
430
-			$related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' );
431
-			if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) {
429
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
430
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
431
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
432 432
 				$items['view_related_messages'] = array(
433 433
 					'class' => $related_for_icon['css_class'],
434 434
 					'desc' => $related_for_icon['label'],
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$items = apply_filters(
440 440
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
441
-			array_merge( $items,
441
+			array_merge($items,
442 442
 				array(
443 443
 					'view_details' => array(
444 444
 						'class' => 'dashicons dashicons-cart',
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 					),
451 451
 					'view_receipt' => array(
452 452
 						'class' => 'dashicons dashicons-media-default',
453
-						'desc' => esc_html__('View Transaction Receipt', 'event_espresso' )
453
+						'desc' => esc_html__('View Transaction Receipt', 'event_espresso')
454 454
 					),
455 455
 					'view_registration' => array(
456 456
 						'class' => 'dashicons dashicons-clipboard',
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 			)
461 461
 		);
462 462
 
463
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
464
-			if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) {
463
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
464
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
465 465
 				$items['send_payment_reminder'] = array(
466 466
 					'class' => 'dashicons dashicons-email-alt',
467 467
 					'desc' => esc_html__('Send Payment Reminder', 'event_espresso')
@@ -482,29 +482,29 @@  discard block
 block discarded – undo
482 482
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
483 483
 			array(
484 484
 				'overpaid'   => array(
485
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
486
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' )
485
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
486
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence')
487 487
 				),
488 488
 				'complete'   => array(
489
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
490
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' )
489
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
490
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence')
491 491
 				),
492 492
 				'incomplete' => array(
493
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
494
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' )
493
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
494
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence')
495 495
 				),
496 496
 				'abandoned'  => array(
497
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
498
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' )
497
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
498
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence')
499 499
 				),
500 500
 				'failed'     => array(
501
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
502
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' )
501
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
502
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence')
503 503
 				)
504 504
 			)
505 505
 		);
506 506
 
507
-		return array_merge( $items, $more_items);
507
+		return array_merge($items, $more_items);
508 508
 	}
509 509
 
510 510
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 	 */
518 518
 	protected function _transactions_overview_list_table() {
519 519
 		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
520
-		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL;
521
-		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : '';
522
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() );
520
+		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL;
521
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : '';
522
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
523 523
 		$this->display_admin_list_table_page_with_no_sidebar();
524 524
 	}
525 525
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	*	@return void
534 534
 	*/
535 535
 	protected function _transaction_details() {
536
-		do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction );
536
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
537 537
 
538 538
 		$this->_set_transaction_status_array();
539 539
 
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
 		$attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
547 547
 
548 548
 		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
549
-		$this->_template_args['txn_nmbr']['label'] = esc_html__( 'Transaction Number', 'event_espresso' );
549
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
550 550
 
551 551
 		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
552
-		$this->_template_args['txn_datetime']['label'] = esc_html__( 'Date', 'event_espresso' );
552
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
553 553
 
554
-		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
555
-		$this->_template_args['txn_status']['label'] = esc_html__( 'Transaction Status', 'event_espresso' );
556
-		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
554
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
555
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
556
+		$this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
557 557
 
558 558
 		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
559 559
 		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 			)
567 567
 		) {
568 568
 			$this->_template_args['send_payment_reminder_button'] =
569
-				EEH_MSG_Template::is_mt_active( 'payment_reminder' )
569
+				EEH_MSG_Template::is_mt_active('payment_reminder')
570 570
 				&& $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
571 571
 				&& $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
572 572
 					? EEH_Template::get_button_or_link(
@@ -588,40 +588,40 @@  discard block
 block discarded – undo
588 588
 		}
589 589
 
590 590
 		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
591
-		$this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE );
592
-		if ( EE_Registry::instance()->CFG->currency->sign_b4 ) {
593
-			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
591
+		$this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
592
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
593
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due'];
594 594
 		} else {
595
-			$this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
595
+			$this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign;
596 596
 		}
597
-		$this->_template_args['amount_due_class'] =  '';
597
+		$this->_template_args['amount_due_class'] = '';
598 598
 
599
-		if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) {
599
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
600 600
 			// paid in full
601
-			$this->_template_args['amount_due'] =  FALSE;
602
-		} elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) {
601
+			$this->_template_args['amount_due'] = FALSE;
602
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
603 603
 			// overpaid
604
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
605
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) {
604
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
605
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
606 606
 			// monies owing
607
-			$this->_template_args['amount_due_class'] =  'txn-overview-part-payment-spn';
608
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) {
607
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
608
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
609 609
 			// no payments made yet
610
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
611
-		} elseif ( $this->_transaction->get('TXN_total') == 0 ) {
610
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
611
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
612 612
 			// free event
613
-			$this->_template_args['amount_due'] =  FALSE;
613
+			$this->_template_args['amount_due'] = FALSE;
614 614
 		}
615 615
 
616 616
 		$payment_method = $this->_transaction->payment_method();
617 617
 
618 618
 		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
619 619
 			? $payment_method->admin_name()
620
-			: esc_html__( 'Unknown', 'event_espresso' );
620
+			: esc_html__('Unknown', 'event_espresso');
621 621
 
622 622
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
623 623
 		// link back to overview
624
-		$this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] )
624
+		$this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER'])
625 625
 			? $_SERVER['HTTP_REFERER']
626 626
 			: TXN_ADMIN_URL;
627 627
 
@@ -629,13 +629,13 @@  discard block
 block discarded – undo
629 629
 		// next link
630 630
 		$next_txn = $this->_transaction->next(
631 631
 			null,
632
-			array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ),
632
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
633 633
 			'TXN_ID'
634 634
 		);
635 635
 		$this->_template_args['next_transaction'] = $next_txn
636 636
 			? $this->_next_link(
637 637
 				EE_Admin_Page::add_query_args_and_nonce(
638
-					array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ),
638
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
639 639
 					TXN_ADMIN_URL
640 640
 				),
641 641
 				'dashicons dashicons-arrow-right ee-icon-size-22'
@@ -644,13 +644,13 @@  discard block
 block discarded – undo
644 644
 		// previous link
645 645
 		$previous_txn = $this->_transaction->previous(
646 646
 			null,
647
-			array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ),
647
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
648 648
 			'TXN_ID'
649 649
 		);
650 650
 		$this->_template_args['previous_transaction'] = $previous_txn
651 651
 			? $this->_previous_link(
652 652
 				EE_Admin_Page::add_query_args_and_nonce(
653
-					array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ),
653
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
654 654
 					TXN_ADMIN_URL
655 655
 				),
656 656
 				'dashicons dashicons-arrow-left ee-icon-size-22'
@@ -660,16 +660,16 @@  discard block
 block discarded – undo
660 660
 		// were we just redirected here after adding a new registration ???
661 661
 		if (
662 662
 			isset(
663
-				$this->_req_data[ 'redirect_from' ],
664
-				$this->_req_data[ 'EVT_ID' ],
665
-				$this->_req_data[ 'event_name' ]
663
+				$this->_req_data['redirect_from'],
664
+				$this->_req_data['EVT_ID'],
665
+				$this->_req_data['event_name']
666 666
 			)
667 667
 		) {
668 668
 			if (
669 669
 				EE_Registry::instance()->CAP->current_user_can(
670 670
 					'ee_edit_registrations',
671 671
 					'espresso_registrations_new_registration',
672
-					$this->_req_data[ 'EVT_ID' ]
672
+					$this->_req_data['EVT_ID']
673 673
 				)
674 674
 			) {
675 675
 				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
@@ -679,25 +679,25 @@  discard block
 block discarded – undo
679 679
 						'action'   => 'new_registration',
680 680
 						'return'   => 'default',
681 681
 						'TXN_ID'   => $this->_transaction->ID(),
682
-						'event_id' => $this->_req_data[ 'EVT_ID' ],
682
+						'event_id' => $this->_req_data['EVT_ID'],
683 683
 					),
684 684
 					REG_ADMIN_URL
685 685
 				);
686 686
 				$this->_admin_page_title .= '">';
687 687
 
688 688
 				$this->_admin_page_title .= sprintf(
689
-					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso' ),
690
-					htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' )
689
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
690
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
691 691
 				);
692 692
 				$this->_admin_page_title .= '</a>';
693 693
 			}
694
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
694
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
695 695
 		}
696 696
 		// grab messages at the last second
697 697
 		$this->_template_args['notices'] = EE_Error::get_notices();
698 698
 		// path to template
699
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
700
-		$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
699
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
700
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
701 701
 
702 702
 		// the details template wrapper
703 703
 		$this->display_admin_page_with_sidebar();
@@ -716,18 +716,18 @@  discard block
 block discarded – undo
716 716
 
717 717
 		$this->_set_transaction_object();
718 718
 
719
-		add_meta_box( 'edit-txn-details-mbox', esc_html__( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' );
719
+		add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
720 720
 		add_meta_box(
721 721
 			'edit-txn-attendees-mbox',
722
-			esc_html__( 'Attendees Registered in this Transaction', 'event_espresso' ),
723
-			array( $this, 'txn_attendees_meta_box' ),
722
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
723
+			array($this, 'txn_attendees_meta_box'),
724 724
 			$this->_wp_page_slug,
725 725
 			'normal',
726 726
 			'high',
727
-			array( 'TXN_ID' => $this->_transaction->ID() )
727
+			array('TXN_ID' => $this->_transaction->ID())
728 728
 		);
729
-		add_meta_box( 'edit-txn-registrant-mbox', esc_html__( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
730
-		add_meta_box( 'edit-txn-billing-info-mbox', esc_html__( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
729
+		add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
730
+		add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
731 731
 
732 732
 	}
733 733
 
@@ -748,15 +748,15 @@  discard block
 block discarded – undo
748 748
 
749 749
 		//get line table
750 750
 		EEH_Autoloader::register_line_item_display_autoloaders();
751
-		$Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' );
752
-		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() );
751
+		$Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
752
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
753 753
 		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
754 754
 
755 755
 		// process taxes
756
-		$taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax )));
757
-		$this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE;
756
+		$taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
757
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE;
758 758
 
759
-		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE );
759
+		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
760 760
 		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
761 761
 		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
762 762
 
@@ -764,63 +764,63 @@  discard block
 block discarded – undo
764 764
 
765 765
 		// process payment details
766 766
 		$payments = $this->_transaction->get_many_related('Payment');
767
-		if( ! empty(  $payments ) ) {
768
-			$this->_template_args[ 'payments' ] = $payments;
769
-			$this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments );
767
+		if ( ! empty($payments)) {
768
+			$this->_template_args['payments'] = $payments;
769
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
770 770
 		} else {
771
-			$this->_template_args[ 'payments' ] = false;
772
-			$this->_template_args[ 'existing_reg_payments' ] = array();
771
+			$this->_template_args['payments'] = false;
772
+			$this->_template_args['existing_reg_payments'] = array();
773 773
 		}
774 774
 
775
-		$this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment'  ), TXN_ADMIN_URL );
776
-		$this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL );
775
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
776
+		$this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
777 777
 
778
-		if ( isset( $txn_details['invoice_number'] )) {
778
+		if (isset($txn_details['invoice_number'])) {
779 779
 			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
780
-			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( 'Invoice Number', 'event_espresso' );
780
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', 'event_espresso');
781 781
 		}
782 782
 
783 783
 		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
784
-		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__( 'Registration Session', 'event_espresso' );
784
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', 'event_espresso');
785 785
 
786
-		$this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '';
787
-		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__( 'Transaction placed from IP', 'event_espresso' );
786
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
787
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', 'event_espresso');
788 788
 
789
-		$this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '';
790
-		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__( 'Registrant User Agent', 'event_espresso' );
789
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
790
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', 'event_espresso');
791 791
 
792 792
 		$reg_steps = '<ul>';
793
-		foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) {
794
-			if ( $reg_step_status === true ) {
795
-				$reg_steps .= '<li style="color:#70cc50">' . sprintf( esc_html__( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
796
-			} else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) {
797
-					$reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
798
-							esc_html__( '%1$s : Initiated %2$s', 'event_espresso' ),
799
-							ucwords( str_replace( '_', ' ', $reg_step ) ),
800
-							date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) )
801
-						) . '</li>';
793
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
794
+			if ($reg_step_status === true) {
795
+				$reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
796
+			} else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
797
+					$reg_steps .= '<li style="color:#2EA2CC">'.sprintf(
798
+							esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
799
+							ucwords(str_replace('_', ' ', $reg_step)),
800
+							date(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
801
+						).'</li>';
802 802
 				} else {
803
-				$reg_steps .= '<li style="color:#E76700">' . sprintf( esc_html__( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
803
+				$reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
804 804
 			}
805 805
 		}
806 806
 		$reg_steps .= '</ul>';
807 807
 		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
808
-		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( 'Registration Step Progress', 'event_espresso' );
808
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', 'event_espresso');
809 809
 
810 810
 
811 811
 		$this->_get_registrations_to_apply_payment_to();
812
-		$this->_get_payment_methods( $payments );
812
+		$this->_get_payment_methods($payments);
813 813
 		$this->_get_payment_status_array();
814 814
 		$this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
815 815
 
816
-		$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction'  ), TXN_ADMIN_URL );
817
-		$this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL );
818
-		$this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL );
816
+		$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
817
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
818
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
819 819
 
820 820
 		// 'espresso_delete_payment_nonce'
821 821
 
822
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
823
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
822
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
823
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
824 824
 
825 825
 	}
826 826
 
@@ -835,27 +835,27 @@  discard block
 block discarded – undo
835 835
 	 * @param EE_Payment[] $payments
836 836
 	 * @return array
837 837
 	 */
838
-	protected function _get_registration_payment_IDs( $payments = array() ) {
838
+	protected function _get_registration_payment_IDs($payments = array()) {
839 839
 		$existing_reg_payments = array();
840 840
 		// get all reg payments for these payments
841
-		$reg_payments = EEM_Registration_Payment::instance()->get_all( array(
841
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(array(
842 842
 			array(
843 843
 				'PAY_ID' => array(
844 844
 					'IN',
845
-					array_keys( $payments )
845
+					array_keys($payments)
846 846
 				)
847 847
 			)
848
-		) );
849
-		if ( ! empty( $reg_payments ) ) {
850
-			foreach ( $payments as $payment ) {
851
-				if ( ! $payment instanceof EE_Payment ) {
848
+		));
849
+		if ( ! empty($reg_payments)) {
850
+			foreach ($payments as $payment) {
851
+				if ( ! $payment instanceof EE_Payment) {
852 852
 					continue;
853
-				} else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) {
854
-					$existing_reg_payments[ $payment->ID() ] = array();
853
+				} else if ( ! isset($existing_reg_payments[$payment->ID()])) {
854
+					$existing_reg_payments[$payment->ID()] = array();
855 855
 				}
856
-				foreach ( $reg_payments as $reg_payment ) {
857
-					if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) {
858
-						$existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID();
856
+				foreach ($reg_payments as $reg_payment) {
857
+					if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
858
+						$existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
859 859
 					}
860 860
 				}
861 861
 			}
@@ -888,54 +888,54 @@  discard block
 block discarded – undo
888 888
 				)
889 889
 			)
890 890
 		);
891
-		$registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
891
+		$registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div(
892 892
 			'', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;'
893 893
 		);
894
-		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div( '', '', 'admin-primary-mbox-tbl-wrap' );
895
-		$registrations_to_apply_payment_to .= EEH_HTML::table( '', '', 'admin-primary-mbox-tbl' );
894
+		$registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
895
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
896 896
 		$registrations_to_apply_payment_to .= EEH_HTML::thead(
897 897
 			EEH_HTML::tr(
898
-				EEH_HTML::th( esc_html__( 'ID', 'event_espresso' ) ) .
899
-				EEH_HTML::th( esc_html__( 'Registrant', 'event_espresso' ) ) .
900
-				EEH_HTML::th( esc_html__( 'Ticket', 'event_espresso' ) ) .
901
-				EEH_HTML::th( esc_html__( 'Event', 'event_espresso' ) ) .
902
-				EEH_HTML::th( esc_html__( 'Paid', 'event_espresso' ), '', 'txn-admin-payment-paid-td jst-cntr' ) .
903
-				EEH_HTML::th( esc_html__( 'Owing', 'event_espresso' ), '', 'txn-admin-payment-owing-td jst-cntr' ) .
904
-				EEH_HTML::th( esc_html__( 'Apply', 'event_espresso' ), '', 'jst-cntr' )
898
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')).
899
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
900
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
901
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')).
902
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
903
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
904
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
905 905
 			)
906 906
 		);
907 907
 		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
908 908
 		// get registrations for TXN
909
-		$registrations = $this->_transaction->registrations( $query_params );
910
-		foreach ( $registrations as $registration ) {
911
-			if ( $registration instanceof EE_Registration ) {
909
+		$registrations = $this->_transaction->registrations($query_params);
910
+		foreach ($registrations as $registration) {
911
+			if ($registration instanceof EE_Registration) {
912 912
 				$attendee_name = $registration->attendee() instanceof EE_Attendee
913 913
 					? $registration->attendee()->full_name()
914
-					: esc_html__( 'Unknown Attendee', 'event_espresso' );
914
+					: esc_html__('Unknown Attendee', 'event_espresso');
915 915
 				$owing = $registration->final_price() - $registration->paid();
916 916
 				$taxable = $registration->ticket()->taxable()
917
-					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__( '+ tax', 'event_espresso' ) . '</span>'
917
+					? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
918 918
 					: '';
919
-				$checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments )
919
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
920 920
 					? ' checked="checked"'
921 921
 					: '';
922 922
 				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
923 923
 				$registrations_to_apply_payment_to .= EEH_HTML::tr(
924
-					EEH_HTML::td( $registration->ID() ) .
925
-					EEH_HTML::td( $attendee_name ) .
924
+					EEH_HTML::td($registration->ID()).
925
+					EEH_HTML::td($attendee_name).
926 926
 					EEH_HTML::td(
927
-						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
928
-					) .
929
-					EEH_HTML::td( $registration->event_name() ) .
930
-					EEH_HTML::td( $registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr' ) .
931
-					EEH_HTML::td( EEH_Template::format_currency( $owing ), '', 'txn-admin-payment-owing-td jst-cntr' ) .
927
+						$registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
928
+					).
929
+					EEH_HTML::td($registration->event_name()).
930
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
931
+					EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr').
932 932
 					EEH_HTML::td(
933
-						'<input type="checkbox" value="' . $registration->ID()
933
+						'<input type="checkbox" value="'.$registration->ID()
934 934
 						. '" name="txn_admin_payment[registrations]"'
935
-						. $checked . $disabled . '>',
935
+						. $checked.$disabled.'>',
936 936
 						'', 'jst-cntr'
937 937
 					),
938
-					'apply-payment-registration-row-' . $registration->ID()
938
+					'apply-payment-registration-row-'.$registration->ID()
939 939
 				);
940 940
 			}
941 941
 		}
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 			'', 'clear description'
951 951
 		);
952 952
 		$registrations_to_apply_payment_to .= EEH_HTML::divx();
953
-		$this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to;
953
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
954 954
 	}
955 955
 
956 956
 
@@ -967,9 +967,9 @@  discard block
 block discarded – undo
967 967
 		$statuses = EEM_Registration::reg_status_array(array(), TRUE);
968 968
 		//let's add a "don't change" option.
969 969
 		$status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
970
-		$status_array = array_merge( $status_array, $statuses );
971
-		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' );
972
-		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' );
970
+		$status_array = array_merge($status_array, $statuses);
971
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
972
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
973 973
 
974 974
 	}
975 975
 
@@ -984,21 +984,21 @@  discard block
 block discarded – undo
984 984
 	 * @param EE_Payment[] to show on this page
985 985
 	 *	@return void
986 986
 	 */
987
-	private function _get_payment_methods( $payments = array() ) {
987
+	private function _get_payment_methods($payments = array()) {
988 988
 		$payment_methods_of_payments = array();
989
-		foreach( $payments as $payment ){
990
-			if( $payment instanceof EE_Payment ){
991
-				$payment_methods_of_payments[] = $payment->get( 'PMD_ID' );
989
+		foreach ($payments as $payment) {
990
+			if ($payment instanceof EE_Payment) {
991
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
992 992
 			}
993 993
 		}
994
-		if( $payment_methods_of_payments ){
995
-			$query_args = array( array( 'OR*payment_method_for_payment' => array(
996
-					'PMD_ID' => array( 'IN', $payment_methods_of_payments ),
997
-					'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) );
998
-		}else{
999
-			$query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) );
994
+		if ($payment_methods_of_payments) {
995
+			$query_args = array(array('OR*payment_method_for_payment' => array(
996
+					'PMD_ID' => array('IN', $payment_methods_of_payments),
997
+					'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') )));
998
+		} else {
999
+			$query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
1000 1000
 		}
1001
-		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args );
1001
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1002 1002
 	}
1003 1003
 
1004 1004
 
@@ -1012,17 +1012,17 @@  discard block
 block discarded – undo
1012 1012
 	 * @param array $metabox
1013 1013
 	 * @return void
1014 1014
 	 */
1015
-	public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) {
1015
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array())) {
1016 1016
 
1017
-		extract( $metabox['args'] );
1017
+		extract($metabox['args']);
1018 1018
 		$this->_template_args['post'] = $post;
1019 1019
 		$this->_template_args['event_attendees'] = array();
1020 1020
 		// process items in cart
1021
-		$line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) );
1022
-		if ( ! empty( $line_items )) {
1023
-			foreach ( $line_items as $item ) {
1024
-				if ( $item instanceof EE_Line_Item ) {
1025
-					switch( $item->OBJ_type() ) {
1021
+		$line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
1022
+		if ( ! empty($line_items)) {
1023
+			foreach ($line_items as $item) {
1024
+				if ($item instanceof EE_Line_Item) {
1025
+					switch ($item->OBJ_type()) {
1026 1026
 
1027 1027
 						case 'Event' :
1028 1028
 							break;
@@ -1030,39 +1030,39 @@  discard block
 block discarded – undo
1030 1030
 						case 'Ticket' :
1031 1031
 							$ticket = $item->ticket();
1032 1032
 							//right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
1033
-							if ( ! $ticket instanceof EE_Ticket ) {
1033
+							if ( ! $ticket instanceof EE_Ticket) {
1034 1034
 								continue;
1035 1035
 							}
1036 1036
 							try {
1037 1037
 								$event_name = $ticket->get_event_name();
1038
-							} catch ( Exception $e ) {
1039
-								EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1040
-								$event_name = esc_html__( 'Unknown Event', 'event_espresso' );
1038
+							} catch (Exception $e) {
1039
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1040
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1041 1041
 							}
1042
-							$event_name .= ' - ' . $item->get( 'LIN_name' );
1043
-							$ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ) );
1042
+							$event_name .= ' - '.$item->get('LIN_name');
1043
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1044 1044
 							// now get all of the registrations for this transaction that use this ticket
1045
-							$registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() )));
1046
-							foreach( $registrations as $registration ) {
1047
-								if ( ! $registration instanceof EE_Registration ) {
1045
+							$registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
1046
+							foreach ($registrations as $registration) {
1047
+								if ( ! $registration instanceof EE_Registration) {
1048 1048
 									continue;
1049 1049
 								}
1050
-								$this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] 			= $registration->status_ID();
1051
-								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] 			= $registration->count();
1052
-								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] 	= $event_name;
1053
-								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] 		= $ticket_price;
1050
+								$this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID();
1051
+								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count();
1052
+								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
1053
+								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price;
1054 1054
 								// attendee info
1055 1055
 								$attendee = $registration->get_first_related('Attendee');
1056
-								if ( $attendee instanceof EE_Attendee ) {
1057
-									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 	= $attendee->ID();
1058
-									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= $attendee->full_name();
1059
-									$this->_template_args['event_attendees'][$registration->ID()]['email']		= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>';
1060
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 	= EEH_Address::format( $attendee, 'inline', false, false );
1056
+								if ($attendee instanceof EE_Attendee) {
1057
+									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID();
1058
+									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
1059
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', 'event_espresso').'">'.$attendee->email().'</a>';
1060
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, 'inline', false, false);
1061 1061
 								} else {
1062 1062
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 	= '';
1063
-									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= '';
1063
+									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1064 1064
 									$this->_template_args['event_attendees'][$registration->ID()]['email'] 		= '';
1065
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 	= '';
1065
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] = '';
1066 1066
 								}
1067 1067
 							}
1068 1068
 							break;
@@ -1071,12 +1071,12 @@  discard block
 block discarded – undo
1071 1071
 				}
1072 1072
 			}
1073 1073
 
1074
-			$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees'  ), TXN_ADMIN_URL );
1075
-			echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE );
1074
+			$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
1075
+			echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE);
1076 1076
 
1077 1077
 		} else {
1078 1078
 			echo sprintf(
1079
-				esc_html__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ),
1079
+				esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'),
1080 1080
 				'<p class="important-notice">',
1081 1081
 				'</p>'
1082 1082
 			);
@@ -1095,19 +1095,19 @@  discard block
 block discarded – undo
1095 1095
 	 */
1096 1096
 	public function txn_registrant_side_meta_box() {
1097 1097
 		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
1098
-		if ( ! $primary_att instanceof EE_Attendee ) {
1098
+		if ( ! $primary_att instanceof EE_Attendee) {
1099 1099
 			$this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.', 'event_espresso');
1100 1100
 			$primary_att = EEM_Attendee::instance()->create_default_object();
1101 1101
 		}
1102
-		$this->_template_args['ATT_ID'] 						= $primary_att->ID();
1102
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1103 1103
 		$this->_template_args['prime_reg_fname']		= $primary_att->fname();
1104 1104
 		$this->_template_args['prime_reg_lname']		= $primary_att->lname();
1105
-		$this->_template_args['prime_reg_email'] 		= $primary_att->email();
1105
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1106 1106
 		$this->_template_args['prime_reg_phone'] 	= $primary_att->phone();
1107
-		$this->_template_args['edit_attendee_url'] 	= EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID()  ), REG_ADMIN_URL );
1107
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL);
1108 1108
 		// get formatted address for registrant
1109
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att );
1110
-		echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE );
1109
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1110
+		echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE);
1111 1111
 	}
1112 1112
 
1113 1113
 
@@ -1123,12 +1123,12 @@  discard block
 block discarded – undo
1123 1123
 
1124 1124
 		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1125 1125
 		$this->_template_args['billing_form_url'] = add_query_arg(
1126
-			array( 'action' => 'edit_transaction', 'process' => 'billing'  ),
1126
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1127 1127
 			TXN_ADMIN_URL
1128 1128
 		);
1129 1129
 
1130
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1131
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/
1130
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1131
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/
1132 1132
 	}
1133 1133
 
1134 1134
 
@@ -1141,42 +1141,42 @@  discard block
 block discarded – undo
1141 1141
 	*	@return void
1142 1142
 	*/
1143 1143
 	public function apply_payments_or_refunds() {
1144
-		$json_response_data = array( 'return_data' => FALSE );
1144
+		$json_response_data = array('return_data' => FALSE);
1145 1145
 		$valid_data = $this->_validate_payment_request_data();
1146
-		if ( ! empty( $valid_data ) ) {
1147
-			$PAY_ID = $valid_data[ 'PAY_ID' ];
1146
+		if ( ! empty($valid_data)) {
1147
+			$PAY_ID = $valid_data['PAY_ID'];
1148 1148
 			//save  the new payment
1149
-			$payment = $this->_create_payment_from_request_data( $valid_data );
1149
+			$payment = $this->_create_payment_from_request_data($valid_data);
1150 1150
 			// get the TXN for this payment
1151 1151
 			$transaction = $payment->transaction();
1152 1152
 			// verify transaction
1153
-			if ( $transaction instanceof EE_Transaction ) {
1153
+			if ($transaction instanceof EE_Transaction) {
1154 1154
 				// calculate_total_payments_and_update_status
1155
-				$this->_process_transaction_payments( $transaction );
1156
-				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment );
1157
-				$this->_remove_existing_registration_payments( $payment, $PAY_ID );
1155
+				$this->_process_transaction_payments($transaction);
1156
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1157
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1158 1158
 				// apply payment to registrations (if applicable)
1159
-				if ( ! empty( $REG_IDs ) ) {
1160
-					$this->_update_registration_payments( $transaction, $payment, $REG_IDs );
1159
+				if ( ! empty($REG_IDs)) {
1160
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1161 1161
 					$this->_maybe_send_notifications();
1162 1162
 					// now process status changes for the same registrations
1163
-					$this->_process_registration_status_change( $transaction, $REG_IDs );
1163
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1164 1164
 				}
1165
-				$this->_maybe_send_notifications( $payment );
1165
+				$this->_maybe_send_notifications($payment);
1166 1166
 				//prepare to render page
1167
-				$json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs );
1168
-				do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment );
1167
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1168
+				do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment);
1169 1169
 			} else {
1170 1170
 				EE_Error::add_error(
1171
-					esc_html__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ),
1171
+					esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1172 1172
 					__FILE__, __FUNCTION__, __LINE__
1173 1173
 				);
1174 1174
 			}
1175 1175
 		} else {
1176
-			EE_Error::add_error( esc_html__( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1176
+			EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1177 1177
 		}
1178 1178
 
1179
-		$notices = EE_Error::get_notices( false, false, false );
1179
+		$notices = EE_Error::get_notices(false, false, false);
1180 1180
 		$this->_template_args = array(
1181 1181
 			'data' => $json_response_data,
1182 1182
 			'error' => $notices['errors'],
@@ -1193,30 +1193,30 @@  discard block
 block discarded – undo
1193 1193
 	 * @return array
1194 1194
 	 */
1195 1195
 	protected function _validate_payment_request_data() {
1196
-		if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) {
1196
+		if ( ! isset($this->_req_data['txn_admin_payment'])) {
1197 1197
 			return false;
1198 1198
 		}
1199 1199
 		$payment_form = $this->_generate_payment_form_section();
1200 1200
 		try {
1201
-			if ( $payment_form->was_submitted() ) {
1201
+			if ($payment_form->was_submitted()) {
1202 1202
 				$payment_form->receive_form_submission();
1203
-				if ( ! $payment_form->is_valid() ) {
1203
+				if ( ! $payment_form->is_valid()) {
1204 1204
 					$submission_error_messages = array();
1205
-					foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) {
1206
-						if ( $validation_error instanceof EE_Validation_Error ) {
1205
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1206
+						if ($validation_error instanceof EE_Validation_Error) {
1207 1207
 							$submission_error_messages[] = sprintf(
1208
-								_x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ),
1208
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1209 1209
 								$validation_error->get_form_section()->html_label_text(),
1210 1210
 								$validation_error->getMessage()
1211 1211
 							);
1212 1212
 						}
1213 1213
 					}
1214
-					EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1214
+					EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1215 1215
 					return array();
1216 1216
 				}
1217 1217
 			}
1218
-		} catch ( EE_Error $e ) {
1219
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1218
+		} catch (EE_Error $e) {
1219
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1220 1220
 			return array();
1221 1221
 		}
1222 1222
 		return $payment_form->valid_data();
@@ -1238,63 +1238,63 @@  discard block
 block discarded – undo
1238 1238
 						array(
1239 1239
 							'default' => 0,
1240 1240
 							'required' => false,
1241
-							'html_label_text' => esc_html__( 'Payment ID', 'event_espresso' ),
1242
-							'validation_strategies' => array( new EE_Int_Normalization() )
1241
+							'html_label_text' => esc_html__('Payment ID', 'event_espresso'),
1242
+							'validation_strategies' => array(new EE_Int_Normalization())
1243 1243
 						)
1244 1244
 					),
1245 1245
 					'TXN_ID' => new EE_Text_Input(
1246 1246
 						array(
1247 1247
 							'default' => 0,
1248 1248
 							'required' => true,
1249
-							'html_label_text' => esc_html__( 'Transaction ID', 'event_espresso' ),
1250
-							'validation_strategies' => array( new EE_Int_Normalization() )
1249
+							'html_label_text' => esc_html__('Transaction ID', 'event_espresso'),
1250
+							'validation_strategies' => array(new EE_Int_Normalization())
1251 1251
 						)
1252 1252
 					),
1253 1253
 					'type' => new EE_Text_Input(
1254 1254
 						array(
1255 1255
 							'default' => 1,
1256 1256
 							'required' => true,
1257
-							'html_label_text' => esc_html__( 'Payment or Refund', 'event_espresso' ),
1258
-							'validation_strategies' => array( new EE_Int_Normalization() )
1257
+							'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'),
1258
+							'validation_strategies' => array(new EE_Int_Normalization())
1259 1259
 						)
1260 1260
 					),
1261 1261
 					'amount' => new EE_Text_Input(
1262 1262
 						array(
1263 1263
 							'default' => 0,
1264 1264
 							'required' => true,
1265
-							'html_label_text' => esc_html__( 'Payment amount', 'event_espresso' ),
1266
-							'validation_strategies' => array( new EE_Float_Normalization() )
1265
+							'html_label_text' => esc_html__('Payment amount', 'event_espresso'),
1266
+							'validation_strategies' => array(new EE_Float_Normalization())
1267 1267
 						)
1268 1268
 					),
1269 1269
 					'status' => new EE_Text_Input(
1270 1270
 						array(
1271 1271
 							'default' => EEM_Payment::status_id_approved,
1272 1272
 							'required' => true,
1273
-							'html_label_text' => esc_html__( 'Payment status', 'event_espresso' ),
1273
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1274 1274
 						)
1275 1275
 					),
1276 1276
 					'PMD_ID' => new EE_Text_Input(
1277 1277
 						array(
1278 1278
 							'default' => 2,
1279 1279
 							'required' => true,
1280
-							'html_label_text' => esc_html__( 'Payment Method', 'event_espresso' ),
1281
-							'validation_strategies' => array( new EE_Int_Normalization() )
1280
+							'html_label_text' => esc_html__('Payment Method', 'event_espresso'),
1281
+							'validation_strategies' => array(new EE_Int_Normalization())
1282 1282
 						)
1283 1283
 					),
1284 1284
 					'date' => new EE_Text_Input(
1285 1285
 						array(
1286 1286
 							'default' => time(),
1287 1287
 							'required' => true,
1288
-							'html_label_text' => esc_html__( 'Payment date', 'event_espresso' ),
1288
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1289 1289
 						)
1290 1290
 					),
1291 1291
 					'txn_id_chq_nmbr' => new EE_Text_Input(
1292 1292
 						array(
1293 1293
 							'default' => '',
1294 1294
 							'required' => false,
1295
-							'html_label_text' => esc_html__( 'Transaction or Cheque Number', 'event_espresso' ),
1295
+							'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1296 1296
                                                         'validation_strategies' => array(
1297
-                                                            new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ),
1297
+                                                            new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100),
1298 1298
                                                         )
1299 1299
 						)
1300 1300
 					),
@@ -1302,9 +1302,9 @@  discard block
 block discarded – undo
1302 1302
 						array(
1303 1303
 							'default' => '',
1304 1304
 							'required' => false,
1305
-							'html_label_text' => esc_html__( 'Purchase Order Number', 'event_espresso' ),
1305
+							'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'),
1306 1306
                                                         'validation_strategies' => array(
1307
-                                                            new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ),
1307
+                                                            new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100),
1308 1308
                                                         )
1309 1309
 						)
1310 1310
 					),
@@ -1312,9 +1312,9 @@  discard block
 block discarded – undo
1312 1312
 						array(
1313 1313
 							'default' => '',
1314 1314
 							'required' => false,
1315
-							'html_label_text' => esc_html__( 'Extra Field for Accounting', 'event_espresso' ),
1315
+							'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'),
1316 1316
                                                         'validation_strategies' => array(
1317
-                                                            new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ),
1317
+                                                            new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100),
1318 1318
                                                         )
1319 1319
 						)
1320 1320
 					),
@@ -1331,37 +1331,37 @@  discard block
 block discarded – undo
1331 1331
 	 * @param array $valid_data
1332 1332
 	 * @return EE_Payment
1333 1333
 	 */
1334
-	protected function _create_payment_from_request_data( $valid_data ) {
1335
-		$PAY_ID = $valid_data[ 'PAY_ID' ];
1334
+	protected function _create_payment_from_request_data($valid_data) {
1335
+		$PAY_ID = $valid_data['PAY_ID'];
1336 1336
 		// get payment amount
1337
-		$amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0;
1337
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1338 1338
 		// payments have a type value of 1 and refunds have a type value of -1
1339 1339
 		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1340
-		$amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount;
1340
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1341 1341
 		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1342
-		$date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) );
1342
+		$date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp'));
1343 1343
 		$payment = EE_Payment::new_instance(
1344 1344
 			array(
1345
-				'TXN_ID' 								=> $valid_data[ 'TXN_ID' ],
1346
-				'STS_ID' 								=> $valid_data[ 'status' ],
1345
+				'TXN_ID' 								=> $valid_data['TXN_ID'],
1346
+				'STS_ID' 								=> $valid_data['status'],
1347 1347
 				'PAY_timestamp' 				=> $date,
1348 1348
 				'PAY_source'           			=> EEM_Payment_Method::scope_admin,
1349
-				'PMD_ID'               				=> $valid_data[ 'PMD_ID' ],
1349
+				'PMD_ID'               				=> $valid_data['PMD_ID'],
1350 1350
 				'PAY_amount'           			=> $amount,
1351
-				'PAY_txn_id_chq_nmbr'  	=> $valid_data[ 'txn_id_chq_nmbr' ],
1352
-				'PAY_po_number'        		=> $valid_data[ 'po_number' ],
1353
-				'PAY_extra_accntng'    		=> $valid_data[ 'accounting' ],
1351
+				'PAY_txn_id_chq_nmbr'  	=> $valid_data['txn_id_chq_nmbr'],
1352
+				'PAY_po_number'        		=> $valid_data['po_number'],
1353
+				'PAY_extra_accntng'    		=> $valid_data['accounting'],
1354 1354
 				'PAY_details'          				=> $valid_data,
1355 1355
 				'PAY_ID'               				=> $PAY_ID
1356 1356
 			),
1357 1357
 			'',
1358
-			array( 'Y-m-d', 'g:i a' )
1358
+			array('Y-m-d', 'g:i a')
1359 1359
 		);
1360 1360
 
1361
-		if ( ! $payment->save() ) {
1361
+		if ( ! $payment->save()) {
1362 1362
 			EE_Error::add_error(
1363 1363
 				sprintf(
1364
-					esc_html__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ),
1364
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1365 1365
 					$payment->ID()
1366 1366
 				),
1367 1367
 				__FILE__, __FUNCTION__, __LINE__
@@ -1378,15 +1378,15 @@  discard block
 block discarded – undo
1378 1378
 	 * @param \EE_Transaction $transaction
1379 1379
 	 * @return array
1380 1380
 	 */
1381
-	protected function _process_transaction_payments( EE_Transaction $transaction ) {
1381
+	protected function _process_transaction_payments(EE_Transaction $transaction) {
1382 1382
 		/** @type EE_Transaction_Payments $transaction_payments */
1383
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1383
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1384 1384
 		//update the transaction with this payment
1385
-		if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) {
1386
-			EE_Error::add_success( esc_html__( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1385
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1386
+			EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1387 1387
 		} else {
1388 1388
 			EE_Error::add_error(
1389
-				esc_html__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' )
1389
+				esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso')
1390 1390
 				, __FILE__, __FUNCTION__, __LINE__
1391 1391
 			);
1392 1392
 		}
@@ -1402,19 +1402,19 @@  discard block
 block discarded – undo
1402 1402
 	 * @param \EE_Payment $payment
1403 1403
 	 * @return array
1404 1404
 	 */
1405
-	protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) {
1405
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) {
1406 1406
 		$REG_IDs = array();
1407 1407
 		// grab array of IDs for specific registrations to apply changes to
1408
-		if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) {
1409
-			$REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ];
1408
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1409
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1410 1410
 		}
1411 1411
 		//nothing specified ? then get all reg IDs
1412
-		if ( empty( $REG_IDs ) ) {
1412
+		if (empty($REG_IDs)) {
1413 1413
 			$registrations = $payment->transaction()->registrations();
1414
-			$REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment );
1414
+			$REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1415 1415
 		}
1416 1416
 		// ensure that REG_IDs are integers and NOT strings
1417
-		return array_map( 'intval', $REG_IDs );
1417
+		return array_map('intval', $REG_IDs);
1418 1418
 	}
1419 1419
 
1420 1420
 
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 	/**
1432 1432
 	 * @param array $existing_reg_payment_REG_IDs
1433 1433
 	 */
1434
-	public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) {
1434
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) {
1435 1435
 		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1436 1436
 	}
1437 1437
 
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
 	 * @param \EE_Payment $payment
1447 1447
 	 * @return array
1448 1448
 	 */
1449
-	protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) {
1450
-		if ( $this->existing_reg_payment_REG_IDs() === null ) {
1449
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) {
1450
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1451 1451
 			// let's get any existing reg payment records for this payment
1452
-			$existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' );
1452
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1453 1453
 			// but we only want the REG IDs, so grab the array keys
1454
-			$existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array();
1455
-			$this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs );
1454
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1455
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1456 1456
 		}
1457 1457
 		return $this->existing_reg_payment_REG_IDs();
1458 1458
 	}
@@ -1471,23 +1471,23 @@  discard block
 block discarded – undo
1471 1471
 	 * @param int         $PAY_ID
1472 1472
 	 * @return bool;
1473 1473
 	 */
1474
-	protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) {
1474
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) {
1475 1475
 		// newly created payments will have nothing recorded for $PAY_ID
1476
-		if ( $PAY_ID == 0 ) {
1476
+		if ($PAY_ID == 0) {
1477 1477
 			return false;
1478 1478
 		}
1479
-		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1480
-		if ( empty( $existing_reg_payment_REG_IDs )) {
1479
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1480
+		if (empty($existing_reg_payment_REG_IDs)) {
1481 1481
 			return false;
1482 1482
 		}
1483 1483
 		/** @type EE_Transaction_Payments $transaction_payments */
1484
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1484
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1485 1485
 		return $transaction_payments->delete_registration_payments_and_update_registrations(
1486 1486
 			$payment,
1487 1487
 			array(
1488 1488
 				array(
1489 1489
 					'PAY_ID' => $payment->ID(),
1490
-					'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ),
1490
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1491 1491
 				)
1492 1492
 			)
1493 1493
 		);
@@ -1506,25 +1506,25 @@  discard block
 block discarded – undo
1506 1506
 	 * @param array $REG_IDs
1507 1507
 	 * @return bool
1508 1508
 	 */
1509
-	protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) {
1509
+	protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) {
1510 1510
 		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1511 1511
 		// so let's do that using our set of REG_IDs from the form
1512 1512
 		$registration_query_where_params = array(
1513
-			'REG_ID' => array( 'IN', $REG_IDs )
1513
+			'REG_ID' => array('IN', $REG_IDs)
1514 1514
 		);
1515 1515
 		// but add in some conditions regarding payment,
1516 1516
 		// so that we don't apply payments to registrations that are free or have already been paid for
1517 1517
 		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1518
-		if ( ! $payment->is_a_refund() ) {
1519
-			$registration_query_where_params[ 'REG_final_price' ]  = array( '!=', 0 );
1520
-			$registration_query_where_params[ 'REG_final_price*' ]  = array( '!=', 'REG_paid', true );
1518
+		if ( ! $payment->is_a_refund()) {
1519
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
1520
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1521 1521
 		}
1522 1522
 		//EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1523
-		$registrations = $transaction->registrations( array( $registration_query_where_params ) );
1524
-		if ( ! empty( $registrations ) ) {
1523
+		$registrations = $transaction->registrations(array($registration_query_where_params));
1524
+		if ( ! empty($registrations)) {
1525 1525
 			/** @type EE_Payment_Processor $payment_processor */
1526
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1527
-			$payment_processor->process_registration_payments( $transaction, $payment, $registrations );
1526
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1527
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
1528 1528
 		}
1529 1529
 	}
1530 1530
 
@@ -1540,22 +1540,22 @@  discard block
 block discarded – undo
1540 1540
 	 * @param array $REG_IDs
1541 1541
 	 * @return bool
1542 1542
 	 */
1543
-	protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) {
1543
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) {
1544 1544
 		// first if there is no change in status then we get out.
1545 1545
 		if (
1546
-			! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] )
1546
+			! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1547 1547
 			|| $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1548 1548
 		) {
1549 1549
 			//no error message, no change requested, just nothing to do man.
1550 1550
 			return FALSE;
1551 1551
 		}
1552 1552
 		/** @type EE_Transaction_Processor $transaction_processor */
1553
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1553
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1554 1554
 		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1555 1555
 		return $transaction_processor->manually_update_registration_statuses(
1556 1556
 			$transaction,
1557
-			sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ),
1558
-			array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) )
1557
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1558
+			array(array('REG_ID' => array('IN', $REG_IDs)))
1559 1559
 		);
1560 1560
 	}
1561 1561
 
@@ -1570,16 +1570,16 @@  discard block
 block discarded – undo
1570 1570
 	 * @param bool | null        $delete_txn_reg_status_change
1571 1571
 	 * @return array
1572 1572
 	 */
1573
-	protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) {
1573
+	protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) {
1574 1574
 		// was the payment deleted ?
1575
-		if ( is_bool( $delete_txn_reg_status_change )) {
1575
+		if (is_bool($delete_txn_reg_status_change)) {
1576 1576
 			return array(
1577 1577
 				'PAY_ID' 				=> $payment->ID(),
1578 1578
 				'amount' 			=> $payment->amount(),
1579 1579
 				'total_paid' 			=> $payment->transaction()->paid(),
1580 1580
 				'txn_status' 			=> $payment->transaction()->status_ID(),
1581 1581
 				'pay_status' 		=> $payment->STS_ID(),
1582
-				'registrations' 	=> $this->_registration_payment_data_array( $REG_IDs ),
1582
+				'registrations' 	=> $this->_registration_payment_data_array($REG_IDs),
1583 1583
 				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1584 1584
 			);
1585 1585
 		} else {
@@ -1591,16 +1591,16 @@  discard block
 block discarded – undo
1591 1591
 				'pay_status' 	=> $payment->STS_ID(),
1592 1592
 				'PAY_ID'           => $payment->ID(),
1593 1593
 				'STS_ID' 			=> $payment->STS_ID(),
1594
-				'status' 			=> self::$_pay_status[ $payment->STS_ID() ],
1595
-				'date' 				=> $payment->timestamp( 'Y-m-d', 'h:i a' ),
1596
-				'method' 		=> strtoupper( $payment->source() ),
1594
+				'status' 			=> self::$_pay_status[$payment->STS_ID()],
1595
+				'date' 				=> $payment->timestamp('Y-m-d', 'h:i a'),
1596
+				'method' 		=> strtoupper($payment->source()),
1597 1597
 				'PM_ID' 			=> $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1598
-				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__( "Unknown", 'event_espresso' ),
1598
+				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", 'event_espresso'),
1599 1599
 				'gateway_response' 	=> $payment->gateway_response(),
1600 1600
 				'txn_id_chq_nmbr'  	=> $payment->txn_id_chq_nmbr(),
1601 1601
 				'po_number'        		=> $payment->po_number(),
1602 1602
 				'extra_accntng'    		=> $payment->extra_accntng(),
1603
-				'registrations'    			=> $this->_registration_payment_data_array( $REG_IDs ),
1603
+				'registrations'    			=> $this->_registration_payment_data_array($REG_IDs),
1604 1604
 			);
1605 1605
 		}
1606 1606
 	}
@@ -1615,39 +1615,39 @@  discard block
 block discarded – undo
1615 1615
 	*	@return void
1616 1616
 	*/
1617 1617
 	public function delete_payment() {
1618
-		$json_response_data = array( 'return_data' => FALSE );
1619
-		$PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0;
1620
-		if ( $PAY_ID ) {
1621
-			$delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false;
1622
-			$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
1623
-			if ( $payment instanceof EE_Payment ) {
1624
-				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1618
+		$json_response_data = array('return_data' => FALSE);
1619
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1620
+		if ($PAY_ID) {
1621
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1622
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1623
+			if ($payment instanceof EE_Payment) {
1624
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1625 1625
 				/** @type EE_Transaction_Payments $transaction_payments */
1626
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1627
-				if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) {
1628
-					$json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change );
1629
-					if ( $delete_txn_reg_status_change ) {
1626
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1627
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1628
+					$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change);
1629
+					if ($delete_txn_reg_status_change) {
1630 1630
 						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1631 1631
 						//MAKE sure we also add the delete_txn_req_status_change to the
1632 1632
 						//$_REQUEST global because that's how messages will be looking for it.
1633 1633
 						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1634 1634
 						$this->_maybe_send_notifications();
1635
-						$this->_process_registration_status_change( $payment->transaction(), $REG_IDs );
1635
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1636 1636
 					}
1637 1637
 				}
1638 1638
 			} else {
1639 1639
 				EE_Error::add_error(
1640
-					esc_html__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ),
1640
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1641 1641
 					__FILE__, __FUNCTION__, __LINE__
1642 1642
 				);
1643 1643
 			}
1644 1644
 		} else {
1645 1645
 			EE_Error::add_error(
1646
-				esc_html__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ),
1646
+				esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'),
1647 1647
 				__FILE__, __FUNCTION__, __LINE__
1648 1648
 			);
1649 1649
 		}
1650
-		$notices = EE_Error::get_notices( false, false, false);
1650
+		$notices = EE_Error::get_notices(false, false, false);
1651 1651
 		$this->_template_args = array(
1652 1652
 			'data' => $json_response_data,
1653 1653
 			'success' => $notices['success'],
@@ -1667,16 +1667,16 @@  discard block
 block discarded – undo
1667 1667
 	 * @param array $REG_IDs
1668 1668
 	 * @return array
1669 1669
 	 */
1670
-	protected function _registration_payment_data_array( $REG_IDs ) {
1670
+	protected function _registration_payment_data_array($REG_IDs) {
1671 1671
 		$registration_payment_data = array();
1672 1672
 		//if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1673
-		if ( ! empty( $REG_IDs ) ) {
1674
-			$registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) );
1675
-			foreach ( $registrations as $registration ) {
1676
-				if ( $registration instanceof EE_Registration ) {
1677
-					$registration_payment_data[ $registration->ID() ] = array(
1673
+		if ( ! empty($REG_IDs)) {
1674
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1675
+			foreach ($registrations as $registration) {
1676
+				if ($registration instanceof EE_Registration) {
1677
+					$registration_payment_data[$registration->ID()] = array(
1678 1678
 						'paid' => $registration->pretty_paid(),
1679
-						'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ),
1679
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1680 1680
 					);
1681 1681
 				}
1682 1682
 			}
@@ -1696,30 +1696,30 @@  discard block
 block discarded – undo
1696 1696
 	 * @access protected
1697 1697
 	 * @param \EE_Payment | null $payment
1698 1698
 	 */
1699
-	protected function _maybe_send_notifications( $payment = null ) {
1700
-		switch ( $payment instanceof EE_Payment ) {
1699
+	protected function _maybe_send_notifications($payment = null) {
1700
+		switch ($payment instanceof EE_Payment) {
1701 1701
 			// payment notifications
1702 1702
 			case true :
1703 1703
 				if (
1704 1704
 					isset(
1705
-						$this->_req_data[ 'txn_payments' ],
1706
-						$this->_req_data[ 'txn_payments' ][ 'send_notifications' ]
1705
+						$this->_req_data['txn_payments'],
1706
+						$this->_req_data['txn_payments']['send_notifications']
1707 1707
 					) &&
1708
-					filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1708
+					filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1709 1709
 				) {
1710
-					$this->_process_payment_notification( $payment );
1710
+					$this->_process_payment_notification($payment);
1711 1711
 				}
1712 1712
 				break;
1713 1713
 			// registration notifications
1714 1714
 			case false :
1715 1715
 				if (
1716 1716
 					isset(
1717
-						$this->_req_data[ 'txn_reg_status_change' ],
1718
-						$this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ]
1717
+						$this->_req_data['txn_reg_status_change'],
1718
+						$this->_req_data['txn_reg_status_change']['send_notifications']
1719 1719
 					) &&
1720
-					filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1720
+					filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1721 1721
 				) {
1722
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
1722
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1723 1723
 				}
1724 1724
 				break;
1725 1725
 		}
@@ -1735,11 +1735,11 @@  discard block
 block discarded – undo
1735 1735
 	*	@return void
1736 1736
 	*/
1737 1737
 	protected function _send_payment_reminder() {
1738
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1739
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1740
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array();
1741
-		do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction );
1742
-		$this->_redirect_after_action( FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE );
1738
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
1739
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1740
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array();
1741
+		do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction);
1742
+		$this->_redirect_after_action(FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE);
1743 1743
 	}
1744 1744
 
1745 1745
 
@@ -1753,36 +1753,36 @@  discard block
 block discarded – undo
1753 1753
 	 * @param string   $view
1754 1754
 	 * @return mixed int = count || array of transaction objects
1755 1755
 	 */
1756
-	public function get_transactions( $perpage, $count = FALSE, $view = '' ) {
1756
+	public function get_transactions($perpage, $count = FALSE, $view = '') {
1757 1757
 
1758 1758
 		$TXN = EEM_Transaction::instance();
1759 1759
 
1760
-	    $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1761
-	    $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1760
+	    $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year'));
1761
+	    $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1762 1762
 
1763 1763
 	    //make sure our timestamps start and end right at the boundaries for each day
1764
-	    $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1765
-	    $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1764
+	    $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1765
+	    $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1766 1766
 
1767 1767
 
1768 1768
 	    //convert to timestamps
1769
-	    $start_date = strtotime( $start_date );
1770
-	    $end_date = strtotime( $end_date );
1769
+	    $start_date = strtotime($start_date);
1770
+	    $end_date = strtotime($end_date);
1771 1771
 
1772 1772
 	    //makes sure start date is the lowest value and vice versa
1773
-	    $start_date = min( $start_date, $end_date );
1774
-	    $end_date = max( $start_date, $end_date );
1773
+	    $start_date = min($start_date, $end_date);
1774
+	    $end_date = max($start_date, $end_date);
1775 1775
 
1776 1776
 	    //convert to correct format for query
1777
-	$start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
1778
-	$end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
1777
+	$start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1778
+	$end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1779 1779
 
1780 1780
 
1781 1781
 
1782 1782
 	    //set orderby
1783 1783
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1784 1784
 
1785
-		switch ( $this->_req_data['orderby'] ) {
1785
+		switch ($this->_req_data['orderby']) {
1786 1786
 			case 'TXN_ID':
1787 1787
 				$orderby = 'TXN_ID';
1788 1788
 				break;
@@ -1796,66 +1796,66 @@  discard block
 block discarded – undo
1796 1796
 				$orderby = 'TXN_timestamp';
1797 1797
 		}
1798 1798
 
1799
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
1800
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1801
-		$per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10;
1802
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1799
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1800
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1801
+		$per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1802
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1803 1803
 
1804
-		$offset = ($current_page-1)*$per_page;
1805
-		$limit = array( $offset, $per_page );
1804
+		$offset = ($current_page - 1) * $per_page;
1805
+		$limit = array($offset, $per_page);
1806 1806
 
1807 1807
 		$_where = array(
1808
-			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ),
1808
+			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)),
1809 1809
 			'Registration.REG_count' => 1
1810 1810
 		);
1811 1811
 
1812
-		if ( isset( $this->_req_data['EVT_ID'] ) ) {
1812
+		if (isset($this->_req_data['EVT_ID'])) {
1813 1813
 			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1814 1814
 		}
1815 1815
 
1816
-		if ( isset( $this->_req_data['s'] ) ) {
1817
-			$search_string = '%' . $this->_req_data['s'] . '%';
1816
+		if (isset($this->_req_data['s'])) {
1817
+			$search_string = '%'.$this->_req_data['s'].'%';
1818 1818
 			$_where['OR'] = array(
1819
-				'Registration.Event.EVT_name' => array( 'LIKE', $search_string ),
1820
-				'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ),
1821
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ),
1822
-				'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ),
1823
-				'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ),
1824
-				'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ),
1825
-				'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ),
1826
-				'Registration.Attendee.ATT_email' => array('LIKE', $search_string ),
1827
-				'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ),
1828
-				'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ),
1829
-				'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ),
1830
-				'Registration.REG_final_price' => array( 'LIKE', $search_string ),
1831
-				'Registration.REG_code' => array( 'LIKE', $search_string ),
1832
-				'Registration.REG_count' => array( 'LIKE' , $search_string ),
1833
-				'Registration.REG_group_size' => array( 'LIKE' , $search_string ),
1834
-				'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ),
1835
-				'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ),
1836
-				'Payment.PAY_source' => array('LIKE', $search_string ),
1837
-				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ),
1838
-				'TXN_session_data' => array( 'LIKE', $search_string ),
1839
-				'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string )
1819
+				'Registration.Event.EVT_name' => array('LIKE', $search_string),
1820
+				'Registration.Event.EVT_desc' => array('LIKE', $search_string),
1821
+				'Registration.Event.EVT_short_desc' => array('LIKE', $search_string),
1822
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1823
+				'Registration.Attendee.ATT_fname' => array('LIKE', $search_string),
1824
+				'Registration.Attendee.ATT_lname' => array('LIKE', $search_string),
1825
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1826
+				'Registration.Attendee.ATT_email' => array('LIKE', $search_string),
1827
+				'Registration.Attendee.ATT_address' => array('LIKE', $search_string),
1828
+				'Registration.Attendee.ATT_address2' => array('LIKE', $search_string),
1829
+				'Registration.Attendee.ATT_city' => array('LIKE', $search_string),
1830
+				'Registration.REG_final_price' => array('LIKE', $search_string),
1831
+				'Registration.REG_code' => array('LIKE', $search_string),
1832
+				'Registration.REG_count' => array('LIKE', $search_string),
1833
+				'Registration.REG_group_size' => array('LIKE', $search_string),
1834
+				'Registration.Ticket.TKT_name' => array('LIKE', $search_string),
1835
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1836
+				'Payment.PAY_source' => array('LIKE', $search_string),
1837
+				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string),
1838
+				'TXN_session_data' => array('LIKE', $search_string),
1839
+				'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string)
1840 1840
 				);
1841 1841
 		}
1842 1842
 
1843 1843
 		//failed transactions
1844
-		$failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE;
1845
-		$abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE;
1844
+		$failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE;
1845
+		$abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE;
1846 1846
 
1847
-		if ( $failed ) {
1848
-			$_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code;
1849
-		} else if ( $abandoned ) {
1847
+		if ($failed) {
1848
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
1849
+		} else if ($abandoned) {
1850 1850
 				$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1851 1851
 		} else {
1852
-				$_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code );
1853
-				$_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code );
1852
+				$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
1853
+				$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1854 1854
 		}
1855 1855
 
1856
-		$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit );
1856
+		$query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1857 1857
 
1858
-		$transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params);
1858
+		$transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params);
1859 1859
 
1860 1860
 
1861 1861
 		return $transactions;
Please login to merge, or discard this patch.
core/db_models/EEM_Line_Item.model.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -105,41 +105,41 @@  discard block
 block discarded – undo
105 105
 	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
106 106
 	 * @return \EEM_Line_Item
107 107
 	 */
108
-	protected function __construct( $timezone ) {
109
-		$this->singular_item = __('Line Item','event_espresso');
110
-		$this->plural_item = __('Line Items','event_espresso');
108
+	protected function __construct($timezone) {
109
+		$this->singular_item = __('Line Item', 'event_espresso');
110
+		$this->plural_item = __('Line Items', 'event_espresso');
111 111
 
112 112
 		$this->_tables = array(
113
-			'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID')
113
+			'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID')
114 114
 		);
115
-		$line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) );
115
+		$line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event'));
116 116
 		$this->_fields = array(
117 117
 			'Line_Item' => array(
118
-				'LIN_ID' 				=> new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ),
119
-				'LIN_code' 			=> new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ),
120
-				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ),
121
-				'LIN_name' 			=> new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ),
122
-				'LIN_desc' 			=> new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ),
123
-				'LIN_unit_price' 	=> new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ),
124
-				'LIN_percent' 		=> new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ),
125
-				'LIN_is_taxable' 	=> new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ),
126
-				'LIN_order' 			=> new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ),
127
-				'LIN_total' 			=> new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ),
128
-				'LIN_quantity' 	=> new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ),
129
-				'LIN_parent' 		=> new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ),
130
-				'LIN_type' 			=> new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array(
118
+				'LIN_ID' 				=> new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")),
119
+				'LIN_code' 			=> new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE),
120
+				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'),
121
+				'LIN_name' 			=> new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''),
122
+				'LIN_desc' 			=> new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE),
123
+				'LIN_unit_price' 	=> new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0),
124
+				'LIN_percent' 		=> new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0),
125
+				'LIN_is_taxable' 	=> new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE),
126
+				'LIN_order' 			=> new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1),
127
+				'LIN_total' 			=> new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0),
128
+				'LIN_quantity' 	=> new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1),
129
+				'LIN_parent' 		=> new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL),
130
+				'LIN_type' 			=> new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array(
131 131
 						self::type_line_item		=>  __("Line Item", "event_espresso"),
132 132
 						self::type_sub_line_item	=>  __("Sub-Item", "event_espresso"),
133 133
 						self::type_sub_total		=>  __("Subtotal", "event_espresso"),
134 134
 						self::type_tax_sub_total 	=> __("Tax Subtotal", "event_espresso"),
135 135
 						self::type_tax					=>  __("Tax", "event_espresso"),
136 136
 						self::type_total				=>  __("Total", "event_espresso"),
137
-						self::type_cancellation	=> __( 'Cancellation', 'event_espresso' )
137
+						self::type_cancellation	=> __('Cancellation', 'event_espresso')
138 138
 					)
139 139
 				),
140
-				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ),
141
-				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ),
142
-				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
140
+				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for),
141
+				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for),
142
+				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
143 143
 			)
144 144
 		);
145 145
 		$this->_model_relations = array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		);
151 151
 		$this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
152 152
 		$this->_caps_slug = 'transactions';
153
-		parent::__construct( $timezone );
153
+		parent::__construct($timezone);
154 154
 	}
155 155
 
156 156
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 * @param EE_Transaction|int $transaction
162 162
 	 * @return EE_Line_Item[]
163 163
 	 */
164
-	public function get_all_of_type_for_transaction( $line_item_type, $transaction ){
165
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
166
-		return $this->get_all( array( array(
164
+	public function get_all_of_type_for_transaction($line_item_type, $transaction) {
165
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
166
+		return $this->get_all(array(array(
167 167
 			'LIN_type' => $line_item_type,
168 168
 			'TXN_ID' => $transaction
169 169
 		)));
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 	 * @param EE_Transaction|int $transaction
178 178
 	 * @return EE_Line_Item[]
179 179
 	 */
180
-	public function get_all_non_ticket_line_items_for_transaction( $transaction ) {
181
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
182
-		return $this->get_all( array( array(
180
+	public function get_all_non_ticket_line_items_for_transaction($transaction) {
181
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
182
+		return $this->get_all(array(array(
183 183
 			'LIN_type' => self::type_line_item,
184 184
 			'TXN_ID' => $transaction,
185 185
 			'OR' => array(
186
-				'OBJ_type*notticket' => array( '!=', 'Ticket'),
187
-				'OBJ_type*null' => array( 'IS_NULL' ))
186
+				'OBJ_type*notticket' => array('!=', 'Ticket'),
187
+				'OBJ_type*null' => array('IS_NULL'))
188 188
 		)));
189 189
 	}
190 190
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * because if there are spam bots afoot there will be LOTS of line items
195 195
 	 * @return int count of how many deleted
196 196
 	 */
197
-	public function delete_line_items_with_no_transaction(){
197
+	public function delete_line_items_with_no_transaction() {
198 198
 		/** @type WPDB $wpdb */
199 199
 		global $wpdb;
200 200
 		$time_to_leave_alone = apply_filters(
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 		);
203 203
 		$query = $wpdb->prepare(
204 204
 				'DELETE li
205
-				FROM ' . $this->table() . ' li
206
-				LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID
205
+				FROM ' . $this->table().' li
206
+				LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID
207 207
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
208 208
 				// use GMT time because that's what TXN_timestamps are in
209
-				date(  'Y-m-d H:i:s', time() - $time_to_leave_alone )
209
+				date('Y-m-d H:i:s', time() - $time_to_leave_alone)
210 210
 				);
211
-		return $wpdb->query( $query );
211
+		return $wpdb->query($query);
212 212
 	}
213 213
 
214 214
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 * @param \EE_Base_Class $object
222 222
 	 * @return EE_Line_Item[]
223 223
 	 */
224
-	public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){
225
-		return $this->get_all( array( array(
224
+	public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) {
225
+		return $this->get_all(array(array(
226 226
 			'TXN_ID' 		=> $TXN_ID,
227
-			'OBJ_type' 	=> str_replace( 'EE_', '', get_class( $object )),
227
+			'OBJ_type' 	=> str_replace('EE_', '', get_class($object)),
228 228
 			'OBJ_ID' 		=> $object->ID()
229 229
 		)));
230 230
 	}
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 * @param array $OBJ_IDs
241 241
 	 * @return EE_Line_Item[]
242 242
 	 */
243
-	public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){
243
+	public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) {
244 244
 		$query_params = array(
245 245
 			'OBJ_type' 	=> $OBJ_type,
246 246
 			// if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
247
-			'OBJ_ID' 		=> is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs
247
+			'OBJ_ID' 		=> is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs
248 248
 		);
249
-		if ( $TXN_ID ) {
249
+		if ($TXN_ID) {
250 250
 			$query_params['TXN_ID'] = $TXN_ID;
251 251
 		}
252
-		return $this->get_all( array( $query_params ));
252
+		return $this->get_all(array($query_params));
253 253
 	}
254 254
 
255 255
 
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	 * @param EE_Transaction $transaction
261 261
 	 * @return EE_Line_Item[]
262 262
 	 */
263
-	public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) {
264
-		return $this->get_all( array(
263
+	public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) {
264
+		return $this->get_all(array(
265 265
 		   array(
266 266
 			   'TXN_ID'   => $transaction->ID(),
267 267
 			   'OBJ_type' => 'Ticket',
268 268
 		   )
269
-	   ) );
269
+	   ));
270 270
 	}
271 271
 
272 272
 
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
 	 * @param int $TKT_ID
279 279
 	 * @return \EE_Line_Item
280 280
 	 */
281
-	public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) {
282
-		return $this->get_one( array(
281
+	public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) {
282
+		return $this->get_one(array(
283 283
 		   array(
284
-			   'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ),
284
+			   'TXN_ID'   => EEM_Transaction::instance()->ensure_is_ID($TXN_ID),
285 285
 			   'OBJ_ID'   => $TKT_ID,
286 286
 			   'OBJ_type' => 'Ticket',
287 287
 		   )
288
-	   ) );
288
+	   ));
289 289
 	}
290 290
 
291 291
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @param EE_Promotion $promotion
301 301
 	 * @return EE_Line_Item
302 302
 	 */
303
-	public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) {
304
-		return $this->get_one( array(
303
+	public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) {
304
+		return $this->get_one(array(
305 305
 			array(
306 306
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
307 307
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 	 * @param EE_Line_Item $parent_line_item
323 323
 	 * @return EE_Line_Item[]
324 324
 	 */
325
-	public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) {
326
-		return $this->get_all( array(
325
+	public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) {
326
+		return $this->get_all(array(
327 327
 			array(
328 328
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
329 329
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 * @param EE_Registration $registration
341 341
 	 * @return EE_Line_ITem
342 342
 	 */
343
-	public function get_line_item_for_registration( EE_Registration $registration ) {
344
-		return $this->get_one( $this->line_item_for_registration_query_params( $registration ));
343
+	public function get_line_item_for_registration(EE_Registration $registration) {
344
+		return $this->get_one($this->line_item_for_registration_query_params($registration));
345 345
 	}
346 346
 
347 347
 	/**
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 	 * @param array $original_query_params any extra query params you'd like to be merged with
351 351
 	 * @return array like EEM_Base::get_all()'s $query_params
352 352
 	 */
353
-	public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) {
354
-		return array_replace_recursive( $original_query_params, array(
353
+	public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) {
354
+		return array_replace_recursive($original_query_params, array(
355 355
 			array(
356 356
 				'OBJ_ID' => $registration->ticket_ID(),
357 357
 				'OBJ_type' => 'Ticket',
358 358
 				'TXN_ID' => $registration->transaction_ID()
359 359
 			)
360
-		) );
360
+		));
361 361
 	}
362 362
 
363 363
 
Please login to merge, or discard this patch.
core/helpers/EEH_Event_Query.helper.php 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function add_query_filters() {
87 87
 		//add query filters
88
-		add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 );
88
+		add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1);
89 89
 	}
90 90
 
91 91
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param \WP_Query $WP_Query
98 98
 	 * @return bool
99 99
 	 */
100
-	public static function apply_query_filters( WP_Query $WP_Query ) {
101
-		return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) ||  apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false;
100
+	public static function apply_query_filters(WP_Query $WP_Query) {
101
+		return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false;
102 102
 	}
103 103
 
104 104
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 * @access    public
109 109
 	 * @param \WP_Query $WP_Query
110 110
 	 */
111
-	public static function filter_query_parts( WP_Query $WP_Query ) {
111
+	public static function filter_query_parts(WP_Query $WP_Query) {
112 112
 		//ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in.
113
-		if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) {
113
+		if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) {
114 114
 			// build event list query
115
-			add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 );
116
-			add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 );
117
-			add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 );
118
-			add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 );
119
-			add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 );
115
+			add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2);
116
+			add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2);
117
+			add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2);
118
+			add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2);
119
+			add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2);
120 120
 		}
121 121
 	}
122 122
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 	 * @param string $orderby
132 132
 	 * @param string $sort
133 133
 	 */
134
-	public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) {
134
+	public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') {
135 135
 		self::$_query_params = array();
136
-		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month );
137
-		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category );
138
-		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired );
139
-		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby );
140
-		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort );
136
+		EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month);
137
+		EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category);
138
+		EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired);
139
+		EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby);
140
+		EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort);
141 141
 	}
142 142
 
143 143
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param string $month
150 150
 	 * @return    string
151 151
 	 */
152
-	private static function _display_month( $month = '' ) {
153
-		return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month;
152
+	private static function _display_month($month = '') {
153
+		return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month;
154 154
 	}
155 155
 
156 156
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @param string $category
163 163
 	 * @return    string
164 164
 	 */
165
-	private static function _event_category_slug( $category = '' ) {
166
-		return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category;
165
+	private static function _event_category_slug($category = '') {
166
+		return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category;
167 167
 	}
168 168
 
169 169
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @param bool $show_expired
176 176
 	 * @return    boolean
177 177
 	 */
178
-	private static function _show_expired( $show_expired = FALSE ) {
178
+	private static function _show_expired($show_expired = FALSE) {
179 179
 		// override default expired option if set via filter
180
-		$_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired;
181
-		return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN );
180
+		$_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired;
181
+		return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN);
182 182
 	}
183 183
 
184 184
 
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 	 * @param    string $orderby
191 191
 	 * @return    array
192 192
 	 */
193
-	private static function _orderby( $orderby = 'start_date' ) {
194
-		$event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby;
195
-		$event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby );
196
-		$event_query_orderby = array_map( 'trim', $event_query_orderby );
193
+	private static function _orderby($orderby = 'start_date') {
194
+		$event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby;
195
+		$event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby);
196
+		$event_query_orderby = array_map('trim', $event_query_orderby);
197 197
 		return $event_query_orderby;
198 198
 	}
199 199
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @param string $sort
207 207
 	 * @return    array
208 208
 	 */
209
-	private static function _sort( $sort = 'ASC' ) {
210
-		$sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort;
211
-		return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC';
209
+	private static function _sort($sort = 'ASC') {
210
+		$sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort;
211
+		return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC';
212 212
 	}
213 213
 
214 214
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return array   array of clauses
223 223
 	 */
224
-	public static function posts_clauses( $clauses, WP_Query $wp_query ) {
225
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
224
+	public static function posts_clauses($clauses, WP_Query $wp_query) {
225
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
226 226
 			global $wpdb;
227
-			$clauses['groupby'] = $wpdb->posts . '.ID ';
227
+			$clauses['groupby'] = $wpdb->posts.'.ID ';
228 228
 		}
229 229
 		return $clauses;
230 230
 	}
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	 * @param WP_Query $wp_query
240 240
 	 * @return    string
241 241
 	 */
242
-	public static function posts_fields( $SQL, WP_Query $wp_query ) {
243
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
242
+	public static function posts_fields($SQL, WP_Query $wp_query) {
243
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
244 244
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
245
-			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby );
245
+			$SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby);
246 246
 		}
247 247
 		return $SQL;
248 248
 	}
@@ -257,29 +257,29 @@  discard block
 block discarded – undo
257 257
 	 * @internal  param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
258 258
 	 * @return    string
259 259
 	 */
260
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
261
-		$SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
262
-		foreach( (array)$orderby_params as $orderby ) {
263
-			switch ( $orderby ) {
260
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
261
+		$SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
262
+		foreach ((array) $orderby_params as $orderby) {
263
+			switch ($orderby) {
264 264
 
265 265
 				case 'ticket_start' :
266
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ;
266
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date';
267 267
 					break;
268 268
 
269 269
 				case 'ticket_end' :
270
-					$SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ;
270
+					$SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date';
271 271
 					break;
272 272
 
273 273
 				case 'venue_title' :
274
-					$SQL .= ', Venue.post_title AS venue_title' ;
274
+					$SQL .= ', Venue.post_title AS venue_title';
275 275
 					break;
276 276
 
277 277
 				case 'city' :
278
-					$SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ;
278
+					$SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city';
279 279
 					break;
280 280
 
281 281
 				case 'state' :
282
-					$SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ;
282
+					$SQL .= ', '.EEM_State::instance()->table().'.STA_name';
283 283
 					break;
284 284
 
285 285
 			}
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	 * @param WP_Query $wp_query
298 298
 	 * @return    string
299 299
 	 */
300
-	public static function posts_join( $SQL = '', WP_Query $wp_query ) {
301
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
300
+	public static function posts_join($SQL = '', WP_Query $wp_query) {
301
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
302 302
 			// Category
303
-			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired );
304
-			$SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category );
305
-			$SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby );
303
+			$SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired);
304
+			$SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category);
305
+			$SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby);
306 306
 		}
307 307
 		return $SQL;
308 308
 	}
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
 	 * @param    boolean $show_expired if TRUE, then displayed past events
318 318
 	 * @return string
319 319
 	 */
320
-	public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) {
321
-		if ( ! $show_expired ) {
322
-			$join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
323
-			if ( strpos( $SQL, $join ) === FALSE ) {
324
-				$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) ';
320
+	public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) {
321
+		if ( ! $show_expired) {
322
+			$join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
323
+			if (strpos($SQL, $join) === FALSE) {
324
+				$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) ';
325 325
 			}
326 326
 		}
327 327
 		return $SQL;
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	 * @param 	string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
338 338
 	 * @return 	string
339 339
 	 */
340
-	public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) {
341
-		if ( ! empty( $join_terms ) ) {
340
+	public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') {
341
+		if ( ! empty($join_terms)) {
342 342
 			global $wpdb;
343 343
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
344 344
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 	 * @param 	array $orderby_params
359 359
 	 * @return 	string
360 360
 	 */
361
-	public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) {
362
-		foreach ( (array)$orderby_params as $orderby ) {
363
-			switch ( $orderby ) {
361
+	public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) {
362
+		foreach ((array) $orderby_params as $orderby) {
363
+			switch ($orderby) {
364 364
 				case 'ticket_start' :
365 365
 				case 'ticket_end' :
366
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() );
367
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )';
366
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name());
367
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )';
368 368
 					break;
369 369
 				case 'venue_title' :
370 370
 				case 'city' :
371
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
371
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
372 372
 					break;
373 373
 				case 'state' :
374
-					$SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL );
375
-					$SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL );
374
+					$SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
375
+					$SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL);
376 376
 					break;
377 377
 				case 'start_date' :
378 378
 				default :
379
-					$SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' );
379
+					$SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID');
380 380
 					break;
381 381
 
382 382
 			}
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 	 * @param string $join
395 395
 	 * @return string
396 396
 	 */
397
-	protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) {
398
-		if ( ! empty( $join )) {
399
-			$join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name();
400
-			if ( strpos( $SQL, $join ) === FALSE ) {
401
-				return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )';
397
+	protected static function _posts_join_for_datetime($SQL = '', $join = '') {
398
+		if ( ! empty($join)) {
399
+			$join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name();
400
+			if (strpos($SQL, $join) === FALSE) {
401
+				return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )';
402 402
 			}
403 403
 		}
404 404
 		return '';
@@ -413,13 +413,13 @@  discard block
 block discarded – undo
413 413
 	 * @param string $SQL
414 414
 	 * @return string
415 415
 	 */
416
-	protected static function _posts_join_for_event_venue( $SQL = '' ) {
416
+	protected static function _posts_join_for_event_venue($SQL = '') {
417 417
 		// Event Venue table name
418 418
 		$event_venue_table = EEM_Event_Venue::instance()->table();
419 419
 		// generate conditions for:  Event <=> Event Venue  JOIN clause
420
-		$event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name();
420
+		$event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name();
421 421
 		// don't add joins if they have already been added
422
-		if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) {
422
+		if (strpos($SQL, $event_to_event_venue_join) === FALSE) {
423 423
 			// Venue table name
424 424
 			$venue_table = EEM_Venue::instance()->table();
425 425
 			// Venue table pk
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			$venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )";
433 433
 			// generate JOIN clause for: Venue <=> Venue Meta
434 434
 			$venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )";
435
-			unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table );
435
+			unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table);
436 436
 			return $venue_SQL;
437 437
 		}
438
-		unset( $event_venue_table, $event_to_event_venue_join );
438
+		unset($event_venue_table, $event_to_event_venue_join);
439 439
 		return '';
440 440
 	}
441 441
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 * @param string $SQL
449 449
 	 * @return string
450 450
 	 */
451
-	protected static function _posts_join_for_venue_state( $SQL = '' ) {
451
+	protected static function _posts_join_for_venue_state($SQL = '') {
452 452
 		// Venue Meta table name
453 453
 		$venue_meta_table = EEM_Venue::instance()->second_table();
454 454
 		// State table name
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
 		// State table pk
457 457
 		$state_table_pk = EEM_State::instance()->primary_key_name();
458 458
 		// verify vars
459
-		if ( $venue_meta_table && $state_table && $state_table_pk ) {
459
+		if ($venue_meta_table && $state_table && $state_table_pk) {
460 460
 			// like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID
461 461
 			$join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk";
462 462
 			// don't add join if it has already been added
463
-			if ( strpos( $SQL, $join ) === FALSE ) {
464
-				unset( $state_table_pk, $venue_meta_table, $venue_table_pk );
463
+			if (strpos($SQL, $join) === FALSE) {
464
+				unset($state_table_pk, $venue_meta_table, $venue_table_pk);
465 465
 				return " LEFT JOIN $state_table ON ( $join )";
466 466
 			}
467 467
 		}
468
-		unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk );
468
+		unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk);
469 469
 		return '';
470 470
 	}
471 471
 
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 	 * @param WP_Query $wp_query
480 480
 	 * @return    string
481 481
 	 */
482
-	public static function posts_where( $SQL = '', WP_Query $wp_query ) {
483
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
482
+	public static function posts_where($SQL = '', WP_Query $wp_query) {
483
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
484 484
 			// Show Expired ?
485
-			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired  );
485
+			$SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired);
486 486
 			// Category
487
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category  );
487
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category);
488 488
 			// Start Date
489
-			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month );
489
+			$SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month);
490 490
 		}
491 491
 		return $SQL;
492 492
 	}
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param    boolean $show_expired if TRUE, then displayed past events
501 501
 	 * @return    string
502 502
 	 */
503
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
504
-		return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', TRUE ) . '" ' : '';
503
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
504
+		return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', TRUE).'" ' : '';
505 505
 	}
506 506
 
507 507
 
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 	 * @param    boolean $event_category_slug
514 514
 	 * @return    string
515 515
 	 */
516
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
516
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
517 517
 		global $wpdb;
518
-		return ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
518
+		return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : '';
519 519
 	}
520 520
 
521 521
 
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 	 * @param    boolean $month
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
530
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
531 531
 		$SQL = '';
532
-		if ( ! empty( $month ) ) {
532
+		if ( ! empty($month)) {
533 533
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
534
-			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . date( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"';
534
+			$SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.date('Y-m-t 23:59:59', strtotime($month)).'"';
535 535
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
536
-			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . date( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" ';
536
+			$SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.date('Y-m-01 0:0:00', strtotime($month)).'" ';
537 537
 		}
538 538
 		return $SQL;
539 539
 	}
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
 	 * @param WP_Query $wp_query
549 549
 	 * @return    string
550 550
 	 */
551
-	public static function posts_orderby( $SQL = '', WP_Query $wp_query ) {
552
-		if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) {
553
-			$SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort );
551
+	public static function posts_orderby($SQL = '', WP_Query $wp_query) {
552
+		if (EEH_Event_Query::apply_query_filters($wp_query)) {
553
+			$SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort);
554 554
 		}
555 555
 		return $SQL;
556 556
 	}
@@ -581,63 +581,63 @@  discard block
 block discarded – undo
581 581
 	 * @param string     $sort
582 582
 	 * @return string
583 583
 	 */
584
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
584
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
585 585
 		global $wpdb;
586 586
 		$SQL = '';
587 587
 		$counter = 0;
588 588
 		//make sure 'orderby' is set in query params
589
-		if ( ! isset( self::$_query_params['orderby'] )) {
589
+		if ( ! isset(self::$_query_params['orderby'])) {
590 590
 			self::$_query_params['orderby'] = array();
591 591
 		}
592 592
 		// loop thru $orderby_params (type cast as array)
593
-		foreach ( (array)$orderby_params as $orderby ) {
593
+		foreach ((array) $orderby_params as $orderby) {
594 594
 			// check if we have already added this param
595
-			if ( isset( self::$_query_params['orderby'][ $orderby ] )) {
595
+			if (isset(self::$_query_params['orderby'][$orderby])) {
596 596
 				// if so then remove from the $orderby_params so that the count() method below is accurate
597
-				unset( $orderby_params[ $orderby ] );
597
+				unset($orderby_params[$orderby]);
598 598
 				// then bump ahead to the next param
599 599
 				continue;
600 600
 			}
601 601
 			// this will ad a comma depending on whether this is the first or last param
602
-			$glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', ';
602
+			$glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', ';
603 603
 			// ok what's we dealing with?
604
-			switch ( $orderby ) {
604
+			switch ($orderby) {
605 605
 				case 'id' :
606 606
 				case 'ID' :
607
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
607
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
608 608
 					break;
609 609
 				case 'end_date' :
610
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
610
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
611 611
 					break;
612 612
 				case 'event_name' :
613
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
613
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
614 614
 					break;
615 615
 				case 'category_slug' :
616
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
616
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
617 617
 					break;
618 618
 				case 'ticket_start' :
619
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
619
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
620 620
 					break;
621 621
 				case 'ticket_end' :
622
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
622
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
623 623
 					break;
624 624
 				case 'venue_title' :
625
-					$SQL .= $glue . 'venue_title ' . $sort;
625
+					$SQL .= $glue.'venue_title '.$sort;
626 626
 					break;
627 627
 				case 'city' :
628
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
628
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
629 629
 					break;
630 630
 				case 'state' :
631
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
631
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
632 632
 					break;
633 633
 				case 'start_date' :
634 634
 				default :
635
-					$SQL .= $glue . ' event_start_date ' . $sort;
635
+					$SQL .= $glue.' event_start_date '.$sort;
636 636
 					break;
637 637
 			}
638 638
 			// add to array of orderby params that have been added
639
-			self::$_query_params['orderby'][ $orderby ] = TRUE;
640
-			$counter ++;
639
+			self::$_query_params['orderby'][$orderby] = TRUE;
640
+			$counter++;
641 641
 		}
642 642
 		return $SQL;
643 643
 	}
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 1 patch
Spacing   +142 added lines, -143 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 /**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 * @return string
54 54
 	 * @throws \EE_Error
55 55
 	 */
56
-	public static function get_valid_timezone_string( $timezone_string = '' ) {
56
+	public static function get_valid_timezone_string($timezone_string = '') {
57 57
 		// if passed a value, then use that, else get WP option
58
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' );
58
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
59 59
 		// value from above exists, use that, else get timezone string from gmt_offset
60
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
61
-		EEH_DTT_Helper::validate_timezone( $timezone_string );
60
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
61
+		EEH_DTT_Helper::validate_timezone($timezone_string);
62 62
 		return $timezone_string;
63 63
 	}
64 64
 
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 	 * @return bool
75 75
 	 * @throws \EE_Error
76 76
 	 */
77
-	public static function validate_timezone( $timezone_string, $throw_error = true ) {
77
+	public static function validate_timezone($timezone_string, $throw_error = true) {
78 78
 		// easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
79 79
 		try {
80
-			new DateTimeZone( $timezone_string );
81
-		} catch ( Exception $e ) {
80
+			new DateTimeZone($timezone_string);
81
+		} catch (Exception $e) {
82 82
 			// sometimes we take exception to exceptions
83
-			if ( ! $throw_error ) {
83
+			if ( ! $throw_error) {
84 84
 				return false;
85 85
 			}
86 86
 			throw new EE_Error(
87 87
 				sprintf(
88
-					__( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ),
88
+					__('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'),
89 89
 					$timezone_string,
90 90
 					'<a href="http://www.php.net/manual/en/timezones.php">',
91 91
 					'</a>'
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 * @param string $gmt_offset
105 105
 	 * @return string
106 106
 	 */
107
-	public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) {
107
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '') {
108 108
 		$timezone_string = 'UTC';
109
-		$gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' );
110
-		if ( $gmt_offset !== '' ) {
109
+		$gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
110
+		if ($gmt_offset !== '') {
111 111
 			// convert GMT offset to seconds
112 112
 			$gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
113 113
 			// account for WP offsets that aren't valid UTC
114
-			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset );
114
+			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
115 115
 			// although we don't know the TZ abbreviation, we know the UTC offset
116
-			$timezone_string = timezone_name_from_abbr( null, $gmt_offset );
116
+			$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
117 117
 		}
118 118
 		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
119
-		$timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset );
119
+		$timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
120 120
 		return $timezone_string;
121 121
 	}
122 122
 	
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 	 * @return int seconds offset
128 128
 	 */
129 129
 	public static function get_site_timezone_gmt_offset() {
130
-		$timezone_string = get_option( 'timezone_string' );
131
-		if ( $timezone_string ) {
130
+		$timezone_string = get_option('timezone_string');
131
+		if ($timezone_string) {
132 132
 			try {
133
-				$timezone = new DateTimeZone( $timezone_string );
134
-				return $timezone->getOffset( new DateTime() ); //in WordPress DateTime defaults to UTC
135
-			} catch( Exception $e ){}
133
+				$timezone = new DateTimeZone($timezone_string);
134
+				return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
135
+			} catch (Exception $e) {}
136 136
 		}
137
-		$offset = get_option( 'gmt_offset' );
138
-		return (int) ( $offset * HOUR_IN_SECONDS );
137
+		$offset = get_option('gmt_offset');
138
+		return (int) ($offset * HOUR_IN_SECONDS);
139 139
 	}
140 140
 
141 141
 
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 * @param int $gmt_offset
148 148
 	 * @return int
149 149
 	 */
150
-	public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) {
150
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0) {
151 151
 		//make sure $gmt_offset is int
152 152
 		$gmt_offset = (int) $gmt_offset;
153
-		switch ( $gmt_offset ) {
153
+		switch ($gmt_offset) {
154 154
 
155 155
 			//			case -30600 :
156 156
 			//				$gmt_offset = -28800;
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 	 * @return string
203 203
 	 * @throws \EE_Error
204 204
 	 */
205
-	public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) {
205
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) {
206 206
 		$abbreviations = timezone_abbreviations_list();
207
-		foreach ( $abbreviations as $abbreviation ) {
208
-			foreach ( $abbreviation as $city ) {
209
-				if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) {
207
+		foreach ($abbreviations as $abbreviation) {
208
+			foreach ($abbreviation as $city) {
209
+				if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) {
210 210
 					// check if the timezone is valid but don't throw any errors if it isn't
211
-					if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) {
211
+					if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
212 212
 						return $city['timezone_id'];
213 213
 					}
214 214
 				}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 		throw new EE_Error(
218 218
 			sprintf(
219
-				__( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ),
219
+				__('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'),
220 220
 				$gmt_offset,
221 221
 				'<a href="http://www.php.net/manual/en/timezones.php">',
222 222
 				'</a>'
@@ -230,23 +230,23 @@  discard block
 block discarded – undo
230 230
 	 * @access public
231 231
 	 * @param string $timezone_string
232 232
 	 */
233
-	public static function timezone_select_input( $timezone_string = '' ) {
233
+	public static function timezone_select_input($timezone_string = '') {
234 234
 		// get WP date time format
235
-		$datetime_format = get_option('date_format') . ' '  . get_option('time_format');
235
+		$datetime_format = get_option('date_format').' '.get_option('time_format');
236 236
 		// if passed a value, then use that, else get WP option
237
-		$timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' );
237
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
238 238
 		// check if the timezone is valid but don't throw any errors if it isn't
239
-		$timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false );
239
+		$timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
240 240
 		$gmt_offset = get_option('gmt_offset');
241 241
 
242 242
 		$check_zone_info = true;
243
-		if ( empty( $timezone_string )) {
243
+		if (empty($timezone_string)) {
244 244
 			// Create a UTC+- zone if no timezone string exists
245 245
 			$check_zone_info = false;
246
-			if ( $gmt_offset > 0 ) {
247
-				$timezone_string = 'UTC+' . $gmt_offset;
248
-			} elseif ( $gmt_offset < 0 ) {
249
-				$timezone_string = 'UTC' . $gmt_offset;
246
+			if ($gmt_offset > 0) {
247
+				$timezone_string = 'UTC+'.$gmt_offset;
248
+			} elseif ($gmt_offset < 0) {
249
+				$timezone_string = 'UTC'.$gmt_offset;
250 250
 			} else {
251 251
 				$timezone_string = 'UTC';
252 252
 			}
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 					__('%1$sUTC%2$s time is %3$s'),
269 269
 					'<abbr title="Coordinated Universal Time">',
270 270
 					'</abbr>',
271
-					'<code>' . date_i18n( $datetime_format , false, true ) . '</code>'
271
+					'<code>'.date_i18n($datetime_format, false, true).'</code>'
272 272
 				);
273 273
 				?></span>
274
-			<?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?>
275
-				<br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span>
274
+			<?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?>
275
+				<br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span>
276 276
 		<?php endif; ?>
277 277
 
278 278
 				<?php if ($check_zone_info && $timezone_string) : ?>
@@ -304,10 +304,9 @@  discard block
 block discarded – undo
304 304
 
305 305
 						if ($found) {
306 306
 							$message = $tr['isdst'] ?
307
-											__(' Daylight saving time begins on: %s.' ) :
308
-											__(' Standard time begins  on: %s.');
307
+											__(' Daylight saving time begins on: %s.') : __(' Standard time begins  on: %s.');
309 308
 							// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
310
-							printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' );
309
+							printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >');
311 310
 						} else {
312 311
 							_e('This timezone does not observe daylight saving time.');
313 312
 						}
@@ -337,14 +336,14 @@  discard block
 block discarded – undo
337 336
 	 *
338 337
 	 * @return int      $unix_timestamp with the offset applied for the given timezone.
339 338
 	 */
340
-	public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) {
339
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') {
341 340
 		$unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp;
342
-		$timezone_string = self::get_valid_timezone_string( $timezone_string );
343
-		$TimeZone = new DateTimeZone( $timezone_string );
341
+		$timezone_string = self::get_valid_timezone_string($timezone_string);
342
+		$TimeZone = new DateTimeZone($timezone_string);
344 343
 
345
-		$DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone );
346
-		$offset = timezone_offset_get( $TimeZone, $DateTime );
347
-		return (int)$DateTime->format( 'U' ) + (int)$offset;
344
+		$DateTime = new DateTime('@'.$unix_timestamp, $TimeZone);
345
+		$offset = timezone_offset_get($TimeZone, $DateTime);
346
+		return (int) $DateTime->format('U') + (int) $offset;
348 347
 	}
349 348
 
350 349
 
@@ -359,17 +358,17 @@  discard block
 block discarded – undo
359 358
 	 * @param  string					$datetime_field_name 	the datetime fieldname to be manipulated
360 359
 	 * @return 	EE_Base_Class
361 360
 	 */
362
-	protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) {
361
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) {
363 362
 		// grab current datetime format
364 363
 		$current_format = $obj->get_format();
365 364
 		// set new full timestamp format
366
-		$obj->set_date_format( EE_Datetime_Field::mysql_date_format );
367
-		$obj->set_time_format( EE_Datetime_Field::mysql_time_format );
365
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
366
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
368 367
 		// set the new date value using a full timestamp format so that no data is lost
369
-		$obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) );
368
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
370 369
 		// reset datetime formats
371
-		$obj->set_date_format( $current_format[0] );
372
-		$obj->set_time_format( $current_format[1] );
370
+		$obj->set_date_format($current_format[0]);
371
+		$obj->set_time_format($current_format[1]);
373 372
 		return $obj;
374 373
 	}
375 374
 
@@ -386,11 +385,11 @@  discard block
 block discarded – undo
386 385
 	 * @param  integer 	$value    what you want to increment the time by
387 386
 	 * @return EE_Base_Class		   return the EE_Base_Class object so right away you can do something with it (chaining)
388 387
 	 */
389
-	public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) {
388
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) {
390 389
 		//get the raw UTC date.
391
-		$DateTime = $obj->get_DateTime_object( $datetime_field_name );
392
-		$DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value );
393
-		return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name );
390
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
391
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
392
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
394 393
 	}
395 394
 
396 395
 
@@ -405,11 +404,11 @@  discard block
 block discarded – undo
405 404
 	 * @param int            $value
406 405
 	 * @return \EE_Base_Class
407 406
 	 */
408
-	public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) {
407
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) {
409 408
 		//get the raw UTC date
410
-		$DateTime = $obj->get_DateTime_object( $datetime_field_name );
411
-		$DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' );
412
-		return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name );
409
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
410
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
411
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
413 412
 	}
414 413
 
415 414
 
@@ -422,44 +421,44 @@  discard block
 block discarded – undo
422 421
 	 * @return \DateTime return whatever type came in.
423 422
 	 * @throws \EE_Error
424 423
 	 */
425
-	protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) {
426
-		if ( ! $DateTime instanceof DateTime ) {
424
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') {
425
+		if ( ! $DateTime instanceof DateTime) {
427 426
 			throw new EE_Error(
428 427
 				sprintf(
429
-					__( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ),
430
-					print_r( $DateTime, true )
428
+					__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
429
+					print_r($DateTime, true)
431 430
 				)
432 431
 			);
433 432
 		}
434
-		switch ( $period ) {
433
+		switch ($period) {
435 434
 			case 'years' :
436
-				$value = 'P' . $value . 'Y';
435
+				$value = 'P'.$value.'Y';
437 436
 				break;
438 437
 			case 'months' :
439
-				$value = 'P' . $value . 'M';
438
+				$value = 'P'.$value.'M';
440 439
 				break;
441 440
 			case 'weeks' :
442
-				$value = 'P' . $value . 'W';
441
+				$value = 'P'.$value.'W';
443 442
 				break;
444 443
 			case 'days' :
445
-				$value = 'P' . $value . 'D';
444
+				$value = 'P'.$value.'D';
446 445
 				break;
447 446
 			case 'hours' :
448
-				$value = 'PT' . $value . 'H';
447
+				$value = 'PT'.$value.'H';
449 448
 				break;
450 449
 			case 'minutes' :
451
-				$value = 'PT' . $value . 'M';
450
+				$value = 'PT'.$value.'M';
452 451
 				break;
453 452
 			case 'seconds' :
454
-				$value = 'PT' . $value . 'S';
453
+				$value = 'PT'.$value.'S';
455 454
 				break;
456 455
 		}
457
-		switch ( $operand ) {
456
+		switch ($operand) {
458 457
 			case '+':
459
-				$DateTime->add( new DateInterval( $value ) );
458
+				$DateTime->add(new DateInterval($value));
460 459
 				break;
461 460
 			case '-':
462
-				$DateTime->sub( new DateInterval( $value ) );
461
+				$DateTime->sub(new DateInterval($value));
463 462
 				break;
464 463
 		}
465 464
 		return $DateTime;
@@ -475,16 +474,16 @@  discard block
 block discarded – undo
475 474
 	 * @return \DateTime return whatever type came in.
476 475
 	 * @throws \EE_Error
477 476
 	 */
478
-	protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) {
479
-		if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) {
477
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') {
478
+		if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
480 479
 			throw new EE_Error(
481 480
 				sprintf(
482
-					__( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ),
483
-					print_r( $timestamp, true )
481
+					__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
482
+					print_r($timestamp, true)
484 483
 				)
485 484
 			);
486 485
 		}
487
-		switch ( $period ) {
486
+		switch ($period) {
488 487
 			case 'years' :
489 488
 				$value = YEAR_IN_SECONDS * $value;
490 489
 				break;
@@ -504,9 +503,9 @@  discard block
 block discarded – undo
504 503
 				$value = MINUTE_IN_SECONDS * $value;
505 504
 				break;
506 505
 		}
507
-		switch ( $operand ) {
506
+		switch ($operand) {
508 507
 			case '+':
509
-				$timestamp  += $value;
508
+				$timestamp += $value;
510 509
 				break;
511 510
 			case '-':
512 511
 				$timestamp -= $value;
@@ -526,11 +525,11 @@  discard block
 block discarded – undo
526 525
 	 * @param  string  $operand What operand you wish to use for the calculation
527 526
 	 * @return mixed string|DateTime          return whatever type came in.
528 527
 	 */
529
-	public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) {
530
-		if ( $DateTime_or_timestamp instanceof DateTime ) {
531
-			return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand );
532
-		} else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) {
533
-			return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand );
528
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') {
529
+		if ($DateTime_or_timestamp instanceof DateTime) {
530
+			return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
531
+		} else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
532
+			return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
534 533
 		} else {
535 534
 			//error
536 535
 			return $DateTime_or_timestamp;
@@ -560,24 +559,24 @@  discard block
 block discarded – undo
560 559
 	 * 			'moment' => //date and time format.
561 560
 	 * 		)
562 561
 	 */
563
-	public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) {
564
-		if ( $date_format_string === null ) {
565
-			$date_format_string = get_option( 'date_format' );
562
+	public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) {
563
+		if ($date_format_string === null) {
564
+			$date_format_string = get_option('date_format');
566 565
 		}
567 566
 
568
-		if ( $time_format_string === null ) {
569
-			$time_format_string = get_option( 'time_format' );
567
+		if ($time_format_string === null) {
568
+			$time_format_string = get_option('time_format');
570 569
 		}
571 570
 
572
-		$date_format = self::_php_to_js_moment_converter( $date_format_string );
573
-		$time_format = self::_php_to_js_moment_converter( $time_format_string );
571
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
572
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
574 573
 
575 574
 		return array(
576 575
 			'js' => array(
577 576
 				'date' => $date_format['js'],
578 577
 				'time' => $time_format['js']
579 578
 				),
580
-			'moment' => $date_format['moment'] . ' ' . $time_format['moment' ]
579
+			'moment' => $date_format['moment'].' '.$time_format['moment']
581 580
 			);
582 581
 	}
583 582
 
@@ -591,7 +590,7 @@  discard block
 block discarded – undo
591 590
 	 *
592 591
 	 * @return array js and moment formats.
593 592
 	 */
594
-	protected static function _php_to_js_moment_converter( $format_string ) {
593
+	protected static function _php_to_js_moment_converter($format_string) {
595 594
 		/**
596 595
 		 * This is a map of symbols for formats.
597 596
 		 * The index is the php symbol, the equivalent values are in the array.
@@ -748,15 +747,15 @@  discard block
 block discarded – undo
748 747
 		$jquery_ui_format = "";
749 748
 		$moment_format = "";
750 749
 		$escaping = false;
751
-		for ( $i = 0; $i < strlen($format_string); $i++ ) {
750
+		for ($i = 0; $i < strlen($format_string); $i++) {
752 751
 			$char = $format_string[$i];
753
-			if ( $char === '\\' )  { // PHP date format escaping character
752
+			if ($char === '\\') { // PHP date format escaping character
754 753
 				$i++;
755
-				if ( $escaping ) {
754
+				if ($escaping) {
756 755
 					$jquery_ui_format .= $format_string[$i];
757 756
 					$moment_format .= $format_string[$i];
758 757
 				} else {
759
-					$jquery_ui_format .= '\'' . $format_string[$i];
758
+					$jquery_ui_format .= '\''.$format_string[$i];
760 759
 					$moment_format .= $format_string[$i];
761 760
 				}
762 761
 				$escaping = true;
@@ -775,7 +774,7 @@  discard block
 block discarded – undo
775 774
 				}
776 775
 			}
777 776
 		}
778
-		return array( 'js' => $jquery_ui_format, 'moment' => $moment_format );
777
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
779 778
 	}
780 779
 
781 780
 
@@ -790,25 +789,25 @@  discard block
 block discarded – undo
790 789
 	 *                           		errors is returned.  So for client code calling, check for is_array() to
791 790
 	 *                           		indicate failed validations.
792 791
 	 */
793
-	public static function validate_format_string( $format_string ) {
792
+	public static function validate_format_string($format_string) {
794 793
 		$error_msg = array();
795 794
 		//time format checks
796
-		switch ( true ) {
797
-			case   strpos( $format_string, 'h' )  !== false  :
798
-			case   strpos( $format_string, 'g' ) !== false :
795
+		switch (true) {
796
+			case   strpos($format_string, 'h') !== false  :
797
+			case   strpos($format_string, 'g') !== false :
799 798
 				/**
800 799
 				 * if the time string has a lowercase 'h' which == 12 hour time format and there
801 800
 				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
802 801
 				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
803 802
 				 */
804
-				if ( strpos( strtoupper( $format_string ), 'A' )  === false ) {
805
-					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' );
803
+				if (strpos(strtoupper($format_string), 'A') === false) {
804
+					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso');
806 805
 				}
807 806
 				break;
808 807
 
809 808
 		}
810 809
 
811
-		return empty( $error_msg ) ? true : $error_msg;
810
+		return empty($error_msg) ? true : $error_msg;
812 811
 	}
813 812
 
814 813
 
@@ -830,11 +829,11 @@  discard block
 block discarded – undo
830 829
 	 * @param mixed $date_2
831 830
 	 * @return bool
832 831
 	 */
833
-	public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) {
832
+	public static function dates_represent_one_24_hour_date($date_1, $date_2) {
834 833
 
835 834
 		if (
836
-			( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) ||
837
-			( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' )
835
+			( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
836
+			($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
838 837
 		) {
839 838
 			return false;
840 839
 		}
@@ -851,11 +850,11 @@  discard block
 block discarded – undo
851 850
 	 * @param string $field_for_interval  The Database field that is the interval is applied to in the query.
852 851
 	 * @return string
853 852
 	 */
854
-	public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) {
853
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) {
855 854
 		try {
856 855
 			/** need to account for timezone offset on the selects */
857
-			$DateTimeZone = new DateTimeZone( $timezone_string );
858
-		} catch ( Exception $e ) {
856
+			$DateTimeZone = new DateTimeZone($timezone_string);
857
+		} catch (Exception $e) {
859 858
 			$DateTimeZone = null;
860 859
 		}
861 860
 
@@ -863,10 +862,10 @@  discard block
 block discarded – undo
863 862
 		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
864 863
 		 * Hence we do the calc for DateTimeZone::getOffset.
865 864
 		 */
866
-		$offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' );
865
+		$offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
867 866
 		$query_interval = $offset < 0
868
-			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)'
869
-			: 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)';
867
+			? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
868
+			: 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
870 869
 		return $query_interval;
871 870
 	}
872 871
 	
@@ -878,47 +877,47 @@  discard block
 block discarded – undo
878 877
 	 * @return string
879 878
 	 */
880 879
 	public static function get_timezone_string_for_display() {
881
-		$pretty_timezone = apply_filters( 'FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '' );
882
-		if( ! empty( $pretty_timezone ) ) {
883
-			return esc_html( $pretty_timezone );
880
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
881
+		if ( ! empty($pretty_timezone)) {
882
+			return esc_html($pretty_timezone);
884 883
 		}
885
-		$timezone_string = get_option( 'timezone_string' );
886
-		if( $timezone_string ) {
884
+		$timezone_string = get_option('timezone_string');
885
+		if ($timezone_string) {
887 886
 			static $mo_loaded = false;
888 887
 			// Load translations for continents and cities just like wp_timezone_choice does
889
-			if ( ! $mo_loaded ) {
888
+			if ( ! $mo_loaded) {
890 889
 				$locale = get_locale();
891
-				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
892
-				load_textdomain( 'continents-cities', $mofile );
890
+				$mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
891
+				load_textdomain('continents-cities', $mofile);
893 892
 				$mo_loaded = true;
894 893
 			}
895 894
 			//well that was easy. 
896
-			$parts = explode('/', $timezone_string );
895
+			$parts = explode('/', $timezone_string);
897 896
 			//remove the continent
898
-			unset( $parts[0] );
897
+			unset($parts[0]);
899 898
 			$t_parts = array();
900
-			foreach( $parts as $part ) {
901
-				$t_parts[] = translate( str_replace( '_', ' ', $part ), 'continents-cities' );
899
+			foreach ($parts as $part) {
900
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
902 901
 			}
903
-			return implode( ' - ', $t_parts );
902
+			return implode(' - ', $t_parts);
904 903
 		}
905 904
 		//they haven't set the timezone string, so let's return a string like "UTC+1"
906
-		$gmt_offset = get_option( 'gmt_offset' );
907
-		if( intval( $gmt_offset ) >= 0 ) {
905
+		$gmt_offset = get_option('gmt_offset');
906
+		if (intval($gmt_offset) >= 0) {
908 907
 			$prefix = '+';
909 908
 		} else {
910 909
 			$prefix = '';
911 910
 		}
912
-		$parts = explode( '.', (string) $gmt_offset );
913
-		if( count( $parts ) === 1 ) {
911
+		$parts = explode('.', (string) $gmt_offset);
912
+		if (count($parts) === 1) {
914 913
 			$parts[1] = '00';
915 914
 		} else {
916 915
 			//convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
917 916
 			//to minutes, eg 30 or 15, respectively
918
-			$hour_fraction = (float)( '0.' . $parts[1] );
919
-			$parts[1] = (string)$hour_fraction * 60;
917
+			$hour_fraction = (float) ('0.'.$parts[1]);
918
+			$parts[1] = (string) $hour_fraction * 60;
920 919
 		}
921
-		return sprintf( __( 'UTC%1$s', 'event_espresso' ), $prefix . implode( ':', $parts ) );
920
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
922 921
 	}
923 922
 
924 923
 
Please login to merge, or discard this patch.
core/db_models/EEM_Registration.model.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -373,7 +373,7 @@
 block discarded – undo
373 373
      * @param    int $ATT_ID
374 374
      * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
375 375
      *                         attendee number is required
376
-     * @return        mixed        array on success, FALSE on fail
376
+     * @return        null|EE_Base_Class        array on success, FALSE on fail
377 377
      */
378 378
     public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
379 379
     {
Please login to merge, or discard this patch.
Indentation   +711 added lines, -711 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\services\database\TableAnalysis;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -18,699 +18,699 @@  discard block
 block discarded – undo
18 18
 class EEM_Registration extends EEM_Soft_Delete_Base
19 19
 {
20 20
 
21
-    // private instance of the Registration object
22
-    protected static $_instance = null;
23
-
24
-    /**
25
-     * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values
26
-     * are status codes (eg, approved, cancelled, etc)
27
-     *
28
-     * @var array
29
-     */
30
-    private static $_reg_status;
31
-
32
-    /**
33
-     * The value of REG_count for a primary registrant
34
-     */
35
-    const PRIMARY_REGISTRANT_COUNT = 1;
36
-
37
-    /**
38
-     * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration.
39
-     * Initial status for registrations when they are first created
40
-     * Payments are NOT allowed.
41
-     * Automatically toggled to whatever the default Event registration status is upon completion of the attendee
42
-     * information reg step NO space reserved. Registration is NOT active
43
-     */
44
-    const status_id_incomplete = 'RIC';
45
-
46
-    /**
47
-     * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration.
48
-     * Payments are NOT allowed.
49
-     * Event Admin must manually toggle STS_ID for it to change
50
-     * No space reserved.
51
-     * Registration is active
52
-     */
53
-    const status_id_not_approved = 'RNA';
54
-
55
-    /**
56
-     * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT .
57
-     * Payments are allowed.
58
-     * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
59
-     * No space reserved.
60
-     * Registration is active
61
-     */
62
-    const status_id_pending_payment = 'RPP';
63
-
64
-    /**
65
-     * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST .
66
-     * Payments are allowed.
67
-     * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
68
-     * No space reserved.
69
-     * Registration is active
70
-     */
71
-    const status_id_wait_list = 'RWL';
72
-
73
-    /**
74
-     * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration.
75
-     * the TXN may or may not be completed ( paid in full )
76
-     * Payments are allowed.
77
-     * A space IS reserved.
78
-     * Registration is active
79
-     */
80
-    const status_id_approved = 'RAP';
81
-
82
-    /**
83
-     * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee.
84
-     * Payments are NOT allowed.
85
-     * NO space reserved.
86
-     * Registration is NOT active
87
-     */
88
-    const status_id_cancelled = 'RCN';
89
-
90
-    /**
91
-     * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin
92
-     * Payments are NOT allowed.
93
-     * No space reserved.
94
-     * Registration is NOT active
95
-     */
96
-    const status_id_declined = 'RDC';
97
-
98
-    /**
99
-     * @var TableAnalysis $table_analysis
100
-     */
101
-    protected $_table_analysis;
102
-
103
-
104
-
105
-    /**
106
-     *    private constructor to prevent direct creation
107
-     *
108
-     * @Constructor
109
-     * @access protected
110
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
111
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
112
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
113
-     *                         timezone in the 'timezone_string' wp option)
114
-     */
115
-    protected function __construct($timezone = null)
116
-    {
117
-        $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
118
-        $this->singular_item = __('Registration', 'event_espresso');
119
-        $this->plural_item = __('Registrations', 'event_espresso');
120
-        $this->_tables = array(
121
-            'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'),
122
-        );
123
-        $this->_fields = array(
124
-            'Registration' => array(
125
-                'REG_ID'           => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
126
-                'EVT_ID'           => new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0,
127
-                    'Event'),
128
-                'ATT_ID'           => new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false,
129
-                    0, 'Attendee'),
130
-                'TXN_ID'           => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'),
131
-                    false, 0, 'Transaction'),
132
-                'TKT_ID'           => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false,
133
-                    0, 'Ticket'),
134
-                'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
135
-                    false, EEM_Registration::status_id_incomplete, 'Status'),
136
-                'REG_date'         => new EE_Datetime_Field('REG_date',
137
-                    __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
138
-                'REG_final_price'  => new EE_Money_Field('REG_final_price',
139
-                    __('Registration\'s share of the transaction total', 'event_espresso'), false, 0),
140
-                'REG_paid'         => new EE_Money_Field('REG_paid',
141
-                    __('Amount paid to date towards registration', 'event_espresso'), false, 0),
142
-                'REG_session'      => new EE_Plain_Text_Field('REG_session',
143
-                    __('Session ID of registration', 'event_espresso'), false, ''),
144
-                'REG_code'         => new EE_Plain_Text_Field('REG_code',
145
-                    __('Unique Code for this registration', 'event_espresso'), false, ''),
146
-                'REG_url_link'     => new EE_Plain_Text_Field('REG_url_link',
147
-                    __('String to be used in URL for identifying registration', 'event_espresso'), false, ''),
148
-                'REG_count'        => new EE_Integer_Field('REG_count',
149
-                    __('Count of this registration in the group registration ', 'event_espresso'), true, 1),
150
-                'REG_group_size'   => new EE_Integer_Field('REG_group_size',
151
-                    __('Number of registrations on this group', 'event_espresso'), false, 1),
152
-                'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going',
153
-                    __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false),
154
-                'REG_deleted'      => new EE_Trashed_Flag_Field('REG_deleted',
155
-                    __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false),
156
-            ),
157
-        );
158
-        $this->_model_relations = array(
159
-            'Event'                => new EE_Belongs_To_Relation(),
160
-            'Attendee'             => new EE_Belongs_To_Relation(),
161
-            'Transaction'          => new EE_Belongs_To_Relation(),
162
-            'Ticket'               => new EE_Belongs_To_Relation(),
163
-            'Status'               => new EE_Belongs_To_Relation(),
164
-            'Answer'               => new EE_Has_Many_Relation(),
165
-            'Checkin'              => new EE_Has_Many_Relation(),
166
-            'Registration_Payment' => new EE_Has_Many_Relation(),
167
-            'Payment'              => new EE_HABTM_Relation('Registration_Payment'),
168
-            'Message'              => new EE_Has_Many_Any_Relation(false)
169
-            //allow deletes even if there are messages in the queue related
170
-        );
171
-        $this->_model_chain_to_wp_user = 'Event';
172
-        parent::__construct($timezone);
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * reg_statuses_that_allow_payment
179
-     * a filterable list of registration statuses that allow a registrant to make a payment
180
-     *
181
-     * @access public
182
-     * @return array
183
-     */
184
-    public static function reg_statuses_that_allow_payment()
185
-    {
186
-        return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
187
-            EEM_Registration::status_id_approved,
188
-            EEM_Registration::status_id_pending_payment,
189
-            EEM_Registration::status_id_wait_list,
190
-        ));
191
-    }
192
-
193
-
194
-
195
-    /**
196
-     * inactive_reg_statuses
197
-     * a filterable list of registration statuses that are considered active
198
-     *
199
-     * @access public
200
-     * @return array
201
-     */
202
-    public static function active_reg_statuses()
203
-    {
204
-        return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
205
-            EEM_Registration::status_id_approved,
206
-            EEM_Registration::status_id_pending_payment,
207
-            EEM_Registration::status_id_wait_list,
208
-            EEM_Registration::status_id_not_approved,
209
-        ));
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     * inactive_reg_statuses
216
-     * a filterable list of registration statuses that are not considered active
217
-     *
218
-     * @access public
219
-     * @return array
220
-     */
221
-    public static function inactive_reg_statuses()
222
-    {
223
-        return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
224
-            EEM_Registration::status_id_incomplete,
225
-            EEM_Registration::status_id_cancelled,
226
-            EEM_Registration::status_id_declined,
227
-        ));
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     *    closed_reg_statuses
234
-     *    a filterable list of registration statuses that are considered "closed"
235
-     * meaning they should not be considered in any calculations involving monies owing
236
-     *
237
-     * @access public
238
-     * @return array
239
-     */
240
-    public static function closed_reg_statuses()
241
-    {
242
-        return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array(
243
-            EEM_Registration::status_id_cancelled,
244
-            EEM_Registration::status_id_declined,
245
-        ));
246
-    }
247
-
248
-
249
-
250
-    /**
251
-     *        get list of registration statuses
252
-     *
253
-     * @access public
254
-     * @param array $exclude    The status ids to exclude from the returned results
255
-     * @param bool  $translated If true will return the values as singular localized strings
256
-     * @return array
257
-     */
258
-    public static function reg_status_array($exclude = array(), $translated = false)
259
-    {
260
-        EEM_Registration::instance()->_get_registration_status_array($exclude);
261
-        return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence')
262
-            : self::$_reg_status;
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     *    get list of registration statuses
269
-     *
270
-     * @access private
271
-     * @param array $exclude
272
-     * @return array
273
-     */
274
-    private function _get_registration_status_array($exclude = array())
275
-    {
276
-        //in the very rare circumstance that we are deleting a model's table's data
277
-        //and the table hasn't actually been created, this could have an error
278
-        /** @type WPDB $wpdb */
279
-        global $wpdb;
280
-        if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
281
-            $SQL = 'SELECT STS_ID, STS_code FROM ' . $wpdb->prefix . 'esp_status WHERE STS_type = "registration"';
282
-            $results = $wpdb->get_results($SQL);
283
-            self::$_reg_status = array();
284
-            foreach ($results as $status) {
285
-                if ( ! in_array($status->STS_ID, $exclude)) {
286
-                    self::$_reg_status[$status->STS_ID] = $status->STS_code;
287
-                }
288
-            }
289
-        }
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     * Gets the injected table analyzer, or throws an exception
296
-     *
297
-     * @return TableAnalysis
298
-     * @throws \EE_Error
299
-     */
300
-    protected function _get_table_analysis()
301
-    {
302
-        if ($this->_table_analysis instanceof TableAnalysis) {
303
-            return $this->_table_analysis;
304
-        } else {
305
-            throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
306
-                get_class($this)));
307
-        }
308
-    }
309
-
310
-
311
-
312
-    /**
313
-     * This returns a wpdb->results array of all registration date month and years matching the incoming query params
314
-     * and grouped by month and year.
315
-     *
316
-     * @param  array $where_params Array of query_params as described in the comments for EEM_Base::get_all()
317
-     * @return array
318
-     * @throws \EE_Error
319
-     */
320
-    public function get_reg_months_and_years($where_params)
321
-    {
322
-        $query_params[0] = $where_params;
323
-        $query_params['group_by'] = array('reg_year', 'reg_month');
324
-        $query_params['order_by'] = array('REG_date' => 'DESC');
325
-        $columns_to_select = array(
326
-            'reg_year'  => array('YEAR(REG_date)', '%s'),
327
-            'reg_month' => array('MONTHNAME(REG_date)', '%s'),
328
-        );
329
-        return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
330
-    }
331
-
332
-
333
-
334
-    /**
335
-     *        retrieve ALL registrations for a particular Attendee from db
336
-     *
337
-     * @access        public
338
-     * @param        int $ATT_ID
339
-     * @return    EE_Registration[]
340
-     */
341
-    public function get_all_registrations_for_attendee($ATT_ID = 0)
342
-    {
343
-        if ( ! $ATT_ID) {
344
-            return false;
345
-        }
346
-        return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * Gets a registration given their REG_url_link. Yes, this should usually
353
-     * be passed via a GET parameter.
354
-     *
355
-     * @param string $REG_url_link
356
-     * @return EE_Registration
357
-     */
358
-    public function get_registration_for_reg_url_link($REG_url_link)
359
-    {
360
-        if ( ! $REG_url_link) {
361
-            return false;
362
-        }
363
-        return $this->get_one(array(array('REG_url_link' => $REG_url_link)));
364
-    }
365
-
366
-
367
-
368
-    /**
369
-     *        retrieve registration for a specific transaction attendee from db
370
-     *
371
-     * @access        public
372
-     * @param    int $TXN_ID
373
-     * @param    int $ATT_ID
374
-     * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
375
-     *                         attendee number is required
376
-     * @return        mixed        array on success, FALSE on fail
377
-     */
378
-    public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
379
-    {
380
-        return $this->get_one(array(
381
-            array(
382
-                'TXN_ID' => $TXN_ID,
383
-                'ATT_ID' => $ATT_ID,
384
-            ),
385
-            'limit' => array(min(($att_nmbr - 1), 0), 1),
386
-        ));
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     *        get the number of registrations per day  for the Registration Admin page Reports Tab.
393
-     *        (doesn't utilize models because it's a fairly specialized query)
394
-     *
395
-     * @access        public
396
-     * @param $period string which can be passed to php's strtotime function (eg "-1 month")
397
-     * @return stdClass[] with properties regDate and total
398
-     */
399
-    public function get_registrations_per_day_report($period = '-1 month')
400
-    {
401
-        $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
402
-            'Y-m-d H:i:s', 'UTC');
403
-        $where = array(
404
-            'REG_date' => array('>=', $sql_date),
405
-            'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
406
-        );
407
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
408
-            $where['Event.EVT_wp_user'] = get_current_user_id();
409
-        }
410
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
411
-        $results = $this->_get_all_wpdb_results(array(
412
-            $where,
413
-            'group_by' => 'regDate',
414
-            'order_by' => array('REG_date' => 'ASC'),
415
-        ), OBJECT, array(
416
-            'regDate' => array('DATE(' . $query_interval . ')', '%s'),
417
-            'total'   => array('count(REG_ID)', '%d'),
418
-        ));
419
-        return $results;
420
-    }
421
-
422
-
423
-
424
-    /**
425
-     * Get the number of registrations per day including the count of registrations for each Registration Status.
426
-     * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
427
-     *
428
-     * @param string $period
429
-     * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
430
-     *                    (i.e. RAP)
431
-     */
432
-    public function get_registrations_per_day_and_per_status_report($period = '-1 month')
433
-    {
434
-        global $wpdb;
435
-        $registration_table = $wpdb->prefix . 'esp_registration';
436
-        $event_table = $wpdb->posts;
437
-        $sql_date = date("Y-m-d H:i:s", strtotime($period));
438
-        //prepare the query interval for displaying offset
439
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
440
-        //inner date query
441
-        $inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
442
-        $inner_where = " WHERE";
443
-        //exclude events not authored by user if permissions in effect
444
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
445
-            $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
446
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
447
-        }
448
-        $inner_where .= " REG_date >= '$sql_date'";
449
-        $inner_date_query .= $inner_where;
450
-        //start main query
451
-        $select = "SELECT DATE($query_interval) as Registration_REG_date, ";
452
-        $join = '';
453
-        $join_parts = array();
454
-        $select_parts = array();
455
-        //loop through registration stati to do parts for each status.
456
-        foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
457
-            if ($STS_ID === EEM_Registration::status_id_incomplete) {
458
-                continue;
459
-            }
460
-            $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
461
-            $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'";
462
-        }
463
-        //setup the selects
464
-        $select .= implode(', ', $select_parts);
465
-        $select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
466
-        //setup the joins
467
-        $join .= implode(" LEFT JOIN ", $join_parts);
468
-        //now let's put it all together
469
-        $query = $select . $join . ' GROUP BY Registration_REG_date';
470
-        //and execute it
471
-        $results = $wpdb->get_results($query, ARRAY_A);
472
-        return $results;
473
-    }
474
-
475
-
476
-
477
-    /**
478
-     *        get the number of registrations per event  for the Registration Admin page Reports Tab
479
-     *
480
-     * @access        public
481
-     * @param $period string which can be passed to php's strtotime function (eg "-1 month")
482
-     * @return stdClass[] each with properties event_name, reg_limit, and total
483
-     */
484
-    public function get_registrations_per_event_report($period = '-1 month')
485
-    {
486
-        $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
487
-            'Y-m-d H:i:s', 'UTC');
488
-        $where = array(
489
-            'REG_date' => array('>=', $date_sql),
490
-            'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
491
-        );
492
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
493
-            $where['Event.EVT_wp_user'] = get_current_user_id();
494
-        }
495
-        $results = $this->_get_all_wpdb_results(array(
496
-            $where,
497
-            'group_by' => 'Event.EVT_name',
498
-            'order_by' => 'Event.EVT_name',
499
-            'limit'    => array(0, 24),
500
-        ), OBJECT, array(
501
-            'event_name' => array('Event_CPT.post_title', '%s'),
502
-            'total'      => array('COUNT(REG_ID)', '%s'),
503
-        ));
504
-        return $results;
505
-    }
506
-
507
-
508
-
509
-    /**
510
-     * Get the number of registrations per event grouped by registration status.
511
-     * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
512
-     *
513
-     * @param string $period
514
-     * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
515
-     *                    (i.e. RAP)
516
-     */
517
-    public function get_registrations_per_event_and_per_status_report($period = '-1 month')
518
-    {
519
-        global $wpdb;
520
-        $registration_table = $wpdb->prefix . 'esp_registration';
521
-        $event_table = $wpdb->posts;
522
-        $sql_date = date("Y-m-d H:i:s", strtotime($period));
523
-        //inner date query
524
-        $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
525
-        $inner_where = " WHERE";
526
-        //exclude events not authored by user if permissions in effect
527
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
528
-            $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
529
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
530
-        }
531
-        $inner_where .= " REG_date >= '$sql_date'";
532
-        $inner_date_query .= $inner_where;
533
-        //build main query
534
-        $select = "SELECT Event.post_title as Registration_Event, ";
535
-        $join = '';
536
-        $join_parts = array();
537
-        $select_parts = array();
538
-        //loop through registration stati to do parts for each status.
539
-        foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
540
-            if ($STS_ID === EEM_Registration::status_id_incomplete) {
541
-                continue;
542
-            }
543
-            $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
544
-            $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";
545
-        }
546
-        //setup the selects
547
-        $select .= implode(', ', $select_parts);
548
-        $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
549
-        //setup remaining joins
550
-        $join .= implode(" LEFT JOIN ", $join_parts);
551
-        //now put it all together
552
-        $query = $select . $join . ' GROUP BY Registration_Event';
553
-        //and execute
554
-        $results = $wpdb->get_results($query, ARRAY_A);
555
-        return $results;
556
-    }
557
-
558
-
559
-
560
-    /**
561
-     * Returns the EE_Registration of the primary attendee on the transaction id provided
562
-     *
563
-     * @param int $TXN_ID
564
-     * @return EE_Registration
565
-     */
566
-    public function get_primary_registration_for_transaction_ID($TXN_ID = 0)
567
-    {
568
-        if ( ! $TXN_ID) {
569
-            return false;
570
-        }
571
-        return $this->get_one(array(
572
-            array(
573
-                'TXN_ID'    => $TXN_ID,
574
-                'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT,
575
-            ),
576
-        ));
577
-    }
578
-
579
-
580
-
581
-    /**
582
-     *        get_event_registration_count
583
-     *
584
-     * @access public
585
-     * @param int     $EVT_ID
586
-     * @param boolean $for_incomplete_payments
587
-     * @return int
588
-     */
589
-    public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false)
590
-    {
591
-        // we only count approved registrations towards registration limits
592
-        $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
593
-        if ($for_incomplete_payments) {
594
-            $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
595
-        }
596
-        return $this->count($query_params);
597
-    }
598
-
599
-
600
-
601
-    /**
602
-     * Deletes all registrations with no transactions. Note that this needs to be very efficient
603
-     * and so it uses wpdb directly
604
-     *
605
-     * @global WPDB $wpdb
606
-     * @return int number deleted
607
-     */
608
-    public function delete_registrations_with_no_transaction()
609
-    {
610
-        /** @type WPDB $wpdb */
611
-        global $wpdb;
612
-        return $wpdb->query('DELETE r FROM '
613
-                            . $this->table()
614
-                            . ' r LEFT JOIN '
615
-                            . EEM_Transaction::instance()->table()
616
-                            . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL');
617
-    }
618
-
619
-
620
-
621
-    /**
622
-     *  Count registrations checked into (or out of) a datetime
623
-     *
624
-     * @param int     $DTT_ID     datetime ID
625
-     * @param boolean $checked_in whether to count registrations checked IN or OUT
626
-     * @return int
627
-     */
628
-    public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true)
629
-    {
630
-        global $wpdb;
631
-        //subquery to get latest checkin
632
-        $query = $wpdb->prepare('SELECT '
633
-                                . 'COUNT( DISTINCT checkins.REG_ID ) '
634
-                                . 'FROM '
635
-                                . EEM_Checkin::instance()
636
-                                             ->table()
637
-                                . ' AS checkins INNER JOIN'
638
-                                . '( SELECT '
639
-                                . 'max( CHK_timestamp ) AS latest_checkin, '
640
-                                . 'REG_ID AS REG_ID '
641
-                                . 'FROM '
642
-                                . EEM_Checkin::instance()->table()
643
-                                . ' '
644
-                                . 'WHERE DTT_ID=%d '
645
-                                . 'GROUP BY REG_ID'
646
-                                . ') AS most_recent_checkin_per_reg '
647
-                                . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
648
-                                . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
649
-                                . 'WHERE '
650
-                                . 'checkins.CHK_in=%d', $DTT_ID, $checked_in);
651
-        return (int)$wpdb->get_var($query);
652
-    }
653
-
654
-
655
-
656
-    /**
657
-     *  Count registrations checked into (or out of) an event.
658
-     *
659
-     * @param int     $EVT_ID     event ID
660
-     * @param boolean $checked_in whether to count registrations checked IN or OUT
661
-     * @return int
662
-     */
663
-    public function count_registrations_checked_into_event($EVT_ID, $checked_in = true)
664
-    {
665
-        global $wpdb;
666
-        //subquery to get latest checkin
667
-        $query = $wpdb->prepare('SELECT '
668
-                                . 'COUNT( DISTINCT checkins.REG_ID ) '
669
-                                . 'FROM '
670
-                                . EEM_Checkin::instance()
671
-                                             ->table()
672
-                                . ' AS checkins INNER JOIN'
673
-                                . '( SELECT '
674
-                                . 'max( CHK_timestamp ) AS latest_checkin, '
675
-                                . 'REG_ID AS REG_ID '
676
-                                . 'FROM '
677
-                                . EEM_Checkin::instance()->table()
678
-                                . ' AS c '
679
-                                . 'INNER JOIN '
680
-                                . EEM_Datetime::instance()->table()
681
-                                . ' AS d '
682
-                                . 'ON c.DTT_ID=d.DTT_ID '
683
-                                . 'WHERE d.EVT_ID=%d '
684
-                                . 'GROUP BY REG_ID'
685
-                                . ') AS most_recent_checkin_per_reg '
686
-                                . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
687
-                                . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
688
-                                . 'WHERE '
689
-                                . 'checkins.CHK_in=%d', $EVT_ID, $checked_in);
690
-        return (int)$wpdb->get_var($query);
691
-    }
692
-
693
-
694
-
695
-    /**
696
-     * The purpose of this method is to retrieve an array of
697
-     * EE_Registration objects that represent the latest registration
698
-     * for each ATT_ID given in the function argument.
699
-     *
700
-     * @param array $attendee_ids
701
-     * @return EE_Registration[]
702
-     */
703
-    public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array())
704
-    {
705
-        //first do a native wp_query to get the latest REG_ID's matching these attendees.
706
-        global $wpdb;
707
-        $registration_table = $wpdb->prefix . 'esp_registration';
708
-        $attendee_table = $wpdb->posts;
709
-        $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids);
710
-        $attendee_ids = implode(',', $attendee_ids);
711
-        //first we do a query to get the registration ids
712
-        // (because a group by before order by causes the order by to be ignored.)
713
-        $registration_id_query = "
21
+	// private instance of the Registration object
22
+	protected static $_instance = null;
23
+
24
+	/**
25
+	 * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values
26
+	 * are status codes (eg, approved, cancelled, etc)
27
+	 *
28
+	 * @var array
29
+	 */
30
+	private static $_reg_status;
31
+
32
+	/**
33
+	 * The value of REG_count for a primary registrant
34
+	 */
35
+	const PRIMARY_REGISTRANT_COUNT = 1;
36
+
37
+	/**
38
+	 * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration.
39
+	 * Initial status for registrations when they are first created
40
+	 * Payments are NOT allowed.
41
+	 * Automatically toggled to whatever the default Event registration status is upon completion of the attendee
42
+	 * information reg step NO space reserved. Registration is NOT active
43
+	 */
44
+	const status_id_incomplete = 'RIC';
45
+
46
+	/**
47
+	 * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration.
48
+	 * Payments are NOT allowed.
49
+	 * Event Admin must manually toggle STS_ID for it to change
50
+	 * No space reserved.
51
+	 * Registration is active
52
+	 */
53
+	const status_id_not_approved = 'RNA';
54
+
55
+	/**
56
+	 * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT .
57
+	 * Payments are allowed.
58
+	 * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
59
+	 * No space reserved.
60
+	 * Registration is active
61
+	 */
62
+	const status_id_pending_payment = 'RPP';
63
+
64
+	/**
65
+	 * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST .
66
+	 * Payments are allowed.
67
+	 * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee
68
+	 * No space reserved.
69
+	 * Registration is active
70
+	 */
71
+	const status_id_wait_list = 'RWL';
72
+
73
+	/**
74
+	 * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration.
75
+	 * the TXN may or may not be completed ( paid in full )
76
+	 * Payments are allowed.
77
+	 * A space IS reserved.
78
+	 * Registration is active
79
+	 */
80
+	const status_id_approved = 'RAP';
81
+
82
+	/**
83
+	 * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee.
84
+	 * Payments are NOT allowed.
85
+	 * NO space reserved.
86
+	 * Registration is NOT active
87
+	 */
88
+	const status_id_cancelled = 'RCN';
89
+
90
+	/**
91
+	 * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin
92
+	 * Payments are NOT allowed.
93
+	 * No space reserved.
94
+	 * Registration is NOT active
95
+	 */
96
+	const status_id_declined = 'RDC';
97
+
98
+	/**
99
+	 * @var TableAnalysis $table_analysis
100
+	 */
101
+	protected $_table_analysis;
102
+
103
+
104
+
105
+	/**
106
+	 *    private constructor to prevent direct creation
107
+	 *
108
+	 * @Constructor
109
+	 * @access protected
110
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
111
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
112
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
113
+	 *                         timezone in the 'timezone_string' wp option)
114
+	 */
115
+	protected function __construct($timezone = null)
116
+	{
117
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
118
+		$this->singular_item = __('Registration', 'event_espresso');
119
+		$this->plural_item = __('Registrations', 'event_espresso');
120
+		$this->_tables = array(
121
+			'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'),
122
+		);
123
+		$this->_fields = array(
124
+			'Registration' => array(
125
+				'REG_ID'           => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
126
+				'EVT_ID'           => new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0,
127
+					'Event'),
128
+				'ATT_ID'           => new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false,
129
+					0, 'Attendee'),
130
+				'TXN_ID'           => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'),
131
+					false, 0, 'Transaction'),
132
+				'TKT_ID'           => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false,
133
+					0, 'Ticket'),
134
+				'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
135
+					false, EEM_Registration::status_id_incomplete, 'Status'),
136
+				'REG_date'         => new EE_Datetime_Field('REG_date',
137
+					__('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
138
+				'REG_final_price'  => new EE_Money_Field('REG_final_price',
139
+					__('Registration\'s share of the transaction total', 'event_espresso'), false, 0),
140
+				'REG_paid'         => new EE_Money_Field('REG_paid',
141
+					__('Amount paid to date towards registration', 'event_espresso'), false, 0),
142
+				'REG_session'      => new EE_Plain_Text_Field('REG_session',
143
+					__('Session ID of registration', 'event_espresso'), false, ''),
144
+				'REG_code'         => new EE_Plain_Text_Field('REG_code',
145
+					__('Unique Code for this registration', 'event_espresso'), false, ''),
146
+				'REG_url_link'     => new EE_Plain_Text_Field('REG_url_link',
147
+					__('String to be used in URL for identifying registration', 'event_espresso'), false, ''),
148
+				'REG_count'        => new EE_Integer_Field('REG_count',
149
+					__('Count of this registration in the group registration ', 'event_espresso'), true, 1),
150
+				'REG_group_size'   => new EE_Integer_Field('REG_group_size',
151
+					__('Number of registrations on this group', 'event_espresso'), false, 1),
152
+				'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going',
153
+					__('Flag indicating the registrant plans on attending', 'event_espresso'), false, false),
154
+				'REG_deleted'      => new EE_Trashed_Flag_Field('REG_deleted',
155
+					__('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false),
156
+			),
157
+		);
158
+		$this->_model_relations = array(
159
+			'Event'                => new EE_Belongs_To_Relation(),
160
+			'Attendee'             => new EE_Belongs_To_Relation(),
161
+			'Transaction'          => new EE_Belongs_To_Relation(),
162
+			'Ticket'               => new EE_Belongs_To_Relation(),
163
+			'Status'               => new EE_Belongs_To_Relation(),
164
+			'Answer'               => new EE_Has_Many_Relation(),
165
+			'Checkin'              => new EE_Has_Many_Relation(),
166
+			'Registration_Payment' => new EE_Has_Many_Relation(),
167
+			'Payment'              => new EE_HABTM_Relation('Registration_Payment'),
168
+			'Message'              => new EE_Has_Many_Any_Relation(false)
169
+			//allow deletes even if there are messages in the queue related
170
+		);
171
+		$this->_model_chain_to_wp_user = 'Event';
172
+		parent::__construct($timezone);
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * reg_statuses_that_allow_payment
179
+	 * a filterable list of registration statuses that allow a registrant to make a payment
180
+	 *
181
+	 * @access public
182
+	 * @return array
183
+	 */
184
+	public static function reg_statuses_that_allow_payment()
185
+	{
186
+		return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
187
+			EEM_Registration::status_id_approved,
188
+			EEM_Registration::status_id_pending_payment,
189
+			EEM_Registration::status_id_wait_list,
190
+		));
191
+	}
192
+
193
+
194
+
195
+	/**
196
+	 * inactive_reg_statuses
197
+	 * a filterable list of registration statuses that are considered active
198
+	 *
199
+	 * @access public
200
+	 * @return array
201
+	 */
202
+	public static function active_reg_statuses()
203
+	{
204
+		return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
205
+			EEM_Registration::status_id_approved,
206
+			EEM_Registration::status_id_pending_payment,
207
+			EEM_Registration::status_id_wait_list,
208
+			EEM_Registration::status_id_not_approved,
209
+		));
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 * inactive_reg_statuses
216
+	 * a filterable list of registration statuses that are not considered active
217
+	 *
218
+	 * @access public
219
+	 * @return array
220
+	 */
221
+	public static function inactive_reg_statuses()
222
+	{
223
+		return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array(
224
+			EEM_Registration::status_id_incomplete,
225
+			EEM_Registration::status_id_cancelled,
226
+			EEM_Registration::status_id_declined,
227
+		));
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 *    closed_reg_statuses
234
+	 *    a filterable list of registration statuses that are considered "closed"
235
+	 * meaning they should not be considered in any calculations involving monies owing
236
+	 *
237
+	 * @access public
238
+	 * @return array
239
+	 */
240
+	public static function closed_reg_statuses()
241
+	{
242
+		return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array(
243
+			EEM_Registration::status_id_cancelled,
244
+			EEM_Registration::status_id_declined,
245
+		));
246
+	}
247
+
248
+
249
+
250
+	/**
251
+	 *        get list of registration statuses
252
+	 *
253
+	 * @access public
254
+	 * @param array $exclude    The status ids to exclude from the returned results
255
+	 * @param bool  $translated If true will return the values as singular localized strings
256
+	 * @return array
257
+	 */
258
+	public static function reg_status_array($exclude = array(), $translated = false)
259
+	{
260
+		EEM_Registration::instance()->_get_registration_status_array($exclude);
261
+		return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence')
262
+			: self::$_reg_status;
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 *    get list of registration statuses
269
+	 *
270
+	 * @access private
271
+	 * @param array $exclude
272
+	 * @return array
273
+	 */
274
+	private function _get_registration_status_array($exclude = array())
275
+	{
276
+		//in the very rare circumstance that we are deleting a model's table's data
277
+		//and the table hasn't actually been created, this could have an error
278
+		/** @type WPDB $wpdb */
279
+		global $wpdb;
280
+		if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
281
+			$SQL = 'SELECT STS_ID, STS_code FROM ' . $wpdb->prefix . 'esp_status WHERE STS_type = "registration"';
282
+			$results = $wpdb->get_results($SQL);
283
+			self::$_reg_status = array();
284
+			foreach ($results as $status) {
285
+				if ( ! in_array($status->STS_ID, $exclude)) {
286
+					self::$_reg_status[$status->STS_ID] = $status->STS_code;
287
+				}
288
+			}
289
+		}
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 * Gets the injected table analyzer, or throws an exception
296
+	 *
297
+	 * @return TableAnalysis
298
+	 * @throws \EE_Error
299
+	 */
300
+	protected function _get_table_analysis()
301
+	{
302
+		if ($this->_table_analysis instanceof TableAnalysis) {
303
+			return $this->_table_analysis;
304
+		} else {
305
+			throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
306
+				get_class($this)));
307
+		}
308
+	}
309
+
310
+
311
+
312
+	/**
313
+	 * This returns a wpdb->results array of all registration date month and years matching the incoming query params
314
+	 * and grouped by month and year.
315
+	 *
316
+	 * @param  array $where_params Array of query_params as described in the comments for EEM_Base::get_all()
317
+	 * @return array
318
+	 * @throws \EE_Error
319
+	 */
320
+	public function get_reg_months_and_years($where_params)
321
+	{
322
+		$query_params[0] = $where_params;
323
+		$query_params['group_by'] = array('reg_year', 'reg_month');
324
+		$query_params['order_by'] = array('REG_date' => 'DESC');
325
+		$columns_to_select = array(
326
+			'reg_year'  => array('YEAR(REG_date)', '%s'),
327
+			'reg_month' => array('MONTHNAME(REG_date)', '%s'),
328
+		);
329
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
330
+	}
331
+
332
+
333
+
334
+	/**
335
+	 *        retrieve ALL registrations for a particular Attendee from db
336
+	 *
337
+	 * @access        public
338
+	 * @param        int $ATT_ID
339
+	 * @return    EE_Registration[]
340
+	 */
341
+	public function get_all_registrations_for_attendee($ATT_ID = 0)
342
+	{
343
+		if ( ! $ATT_ID) {
344
+			return false;
345
+		}
346
+		return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * Gets a registration given their REG_url_link. Yes, this should usually
353
+	 * be passed via a GET parameter.
354
+	 *
355
+	 * @param string $REG_url_link
356
+	 * @return EE_Registration
357
+	 */
358
+	public function get_registration_for_reg_url_link($REG_url_link)
359
+	{
360
+		if ( ! $REG_url_link) {
361
+			return false;
362
+		}
363
+		return $this->get_one(array(array('REG_url_link' => $REG_url_link)));
364
+	}
365
+
366
+
367
+
368
+	/**
369
+	 *        retrieve registration for a specific transaction attendee from db
370
+	 *
371
+	 * @access        public
372
+	 * @param    int $TXN_ID
373
+	 * @param    int $ATT_ID
374
+	 * @param    int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the
375
+	 *                         attendee number is required
376
+	 * @return        mixed        array on success, FALSE on fail
377
+	 */
378
+	public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0)
379
+	{
380
+		return $this->get_one(array(
381
+			array(
382
+				'TXN_ID' => $TXN_ID,
383
+				'ATT_ID' => $ATT_ID,
384
+			),
385
+			'limit' => array(min(($att_nmbr - 1), 0), 1),
386
+		));
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 *        get the number of registrations per day  for the Registration Admin page Reports Tab.
393
+	 *        (doesn't utilize models because it's a fairly specialized query)
394
+	 *
395
+	 * @access        public
396
+	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
397
+	 * @return stdClass[] with properties regDate and total
398
+	 */
399
+	public function get_registrations_per_day_report($period = '-1 month')
400
+	{
401
+		$sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
402
+			'Y-m-d H:i:s', 'UTC');
403
+		$where = array(
404
+			'REG_date' => array('>=', $sql_date),
405
+			'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
406
+		);
407
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
408
+			$where['Event.EVT_wp_user'] = get_current_user_id();
409
+		}
410
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date');
411
+		$results = $this->_get_all_wpdb_results(array(
412
+			$where,
413
+			'group_by' => 'regDate',
414
+			'order_by' => array('REG_date' => 'ASC'),
415
+		), OBJECT, array(
416
+			'regDate' => array('DATE(' . $query_interval . ')', '%s'),
417
+			'total'   => array('count(REG_ID)', '%d'),
418
+		));
419
+		return $results;
420
+	}
421
+
422
+
423
+
424
+	/**
425
+	 * Get the number of registrations per day including the count of registrations for each Registration Status.
426
+	 * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
427
+	 *
428
+	 * @param string $period
429
+	 * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID
430
+	 *                    (i.e. RAP)
431
+	 */
432
+	public function get_registrations_per_day_and_per_status_report($period = '-1 month')
433
+	{
434
+		global $wpdb;
435
+		$registration_table = $wpdb->prefix . 'esp_registration';
436
+		$event_table = $wpdb->posts;
437
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
438
+		//prepare the query interval for displaying offset
439
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date');
440
+		//inner date query
441
+		$inner_date_query = "SELECT DISTINCT REG_date from $registration_table ";
442
+		$inner_where = " WHERE";
443
+		//exclude events not authored by user if permissions in effect
444
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
445
+			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
446
+			$inner_where .= " post_author = " . get_current_user_id() . " AND";
447
+		}
448
+		$inner_where .= " REG_date >= '$sql_date'";
449
+		$inner_date_query .= $inner_where;
450
+		//start main query
451
+		$select = "SELECT DATE($query_interval) as Registration_REG_date, ";
452
+		$join = '';
453
+		$join_parts = array();
454
+		$select_parts = array();
455
+		//loop through registration stati to do parts for each status.
456
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
457
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
458
+				continue;
459
+			}
460
+			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
461
+			$join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'";
462
+		}
463
+		//setup the selects
464
+		$select .= implode(', ', $select_parts);
465
+		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN ";
466
+		//setup the joins
467
+		$join .= implode(" LEFT JOIN ", $join_parts);
468
+		//now let's put it all together
469
+		$query = $select . $join . ' GROUP BY Registration_REG_date';
470
+		//and execute it
471
+		$results = $wpdb->get_results($query, ARRAY_A);
472
+		return $results;
473
+	}
474
+
475
+
476
+
477
+	/**
478
+	 *        get the number of registrations per event  for the Registration Admin page Reports Tab
479
+	 *
480
+	 * @access        public
481
+	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
482
+	 * @return stdClass[] each with properties event_name, reg_limit, and total
483
+	 */
484
+	public function get_registrations_per_event_report($period = '-1 month')
485
+	{
486
+		$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)),
487
+			'Y-m-d H:i:s', 'UTC');
488
+		$where = array(
489
+			'REG_date' => array('>=', $date_sql),
490
+			'STS_ID'   => array('!=', EEM_Registration::status_id_incomplete),
491
+		);
492
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
493
+			$where['Event.EVT_wp_user'] = get_current_user_id();
494
+		}
495
+		$results = $this->_get_all_wpdb_results(array(
496
+			$where,
497
+			'group_by' => 'Event.EVT_name',
498
+			'order_by' => 'Event.EVT_name',
499
+			'limit'    => array(0, 24),
500
+		), OBJECT, array(
501
+			'event_name' => array('Event_CPT.post_title', '%s'),
502
+			'total'      => array('COUNT(REG_ID)', '%s'),
503
+		));
504
+		return $results;
505
+	}
506
+
507
+
508
+
509
+	/**
510
+	 * Get the number of registrations per event grouped by registration status.
511
+	 * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results.
512
+	 *
513
+	 * @param string $period
514
+	 * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID
515
+	 *                    (i.e. RAP)
516
+	 */
517
+	public function get_registrations_per_event_and_per_status_report($period = '-1 month')
518
+	{
519
+		global $wpdb;
520
+		$registration_table = $wpdb->prefix . 'esp_registration';
521
+		$event_table = $wpdb->posts;
522
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
523
+		//inner date query
524
+		$inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table ";
525
+		$inner_where = " WHERE";
526
+		//exclude events not authored by user if permissions in effect
527
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
528
+			$inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
529
+			$inner_where .= " post_author = " . get_current_user_id() . " AND";
530
+		}
531
+		$inner_where .= " REG_date >= '$sql_date'";
532
+		$inner_date_query .= $inner_where;
533
+		//build main query
534
+		$select = "SELECT Event.post_title as Registration_Event, ";
535
+		$join = '';
536
+		$join_parts = array();
537
+		$select_parts = array();
538
+		//loop through registration stati to do parts for each status.
539
+		foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) {
540
+			if ($STS_ID === EEM_Registration::status_id_incomplete) {
541
+				continue;
542
+			}
543
+			$select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID";
544
+			$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";
545
+		}
546
+		//setup the selects
547
+		$select .= implode(', ', $select_parts);
548
+		$select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN ";
549
+		//setup remaining joins
550
+		$join .= implode(" LEFT JOIN ", $join_parts);
551
+		//now put it all together
552
+		$query = $select . $join . ' GROUP BY Registration_Event';
553
+		//and execute
554
+		$results = $wpdb->get_results($query, ARRAY_A);
555
+		return $results;
556
+	}
557
+
558
+
559
+
560
+	/**
561
+	 * Returns the EE_Registration of the primary attendee on the transaction id provided
562
+	 *
563
+	 * @param int $TXN_ID
564
+	 * @return EE_Registration
565
+	 */
566
+	public function get_primary_registration_for_transaction_ID($TXN_ID = 0)
567
+	{
568
+		if ( ! $TXN_ID) {
569
+			return false;
570
+		}
571
+		return $this->get_one(array(
572
+			array(
573
+				'TXN_ID'    => $TXN_ID,
574
+				'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT,
575
+			),
576
+		));
577
+	}
578
+
579
+
580
+
581
+	/**
582
+	 *        get_event_registration_count
583
+	 *
584
+	 * @access public
585
+	 * @param int     $EVT_ID
586
+	 * @param boolean $for_incomplete_payments
587
+	 * @return int
588
+	 */
589
+	public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false)
590
+	{
591
+		// we only count approved registrations towards registration limits
592
+		$query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
593
+		if ($for_incomplete_payments) {
594
+			$query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
595
+		}
596
+		return $this->count($query_params);
597
+	}
598
+
599
+
600
+
601
+	/**
602
+	 * Deletes all registrations with no transactions. Note that this needs to be very efficient
603
+	 * and so it uses wpdb directly
604
+	 *
605
+	 * @global WPDB $wpdb
606
+	 * @return int number deleted
607
+	 */
608
+	public function delete_registrations_with_no_transaction()
609
+	{
610
+		/** @type WPDB $wpdb */
611
+		global $wpdb;
612
+		return $wpdb->query('DELETE r FROM '
613
+							. $this->table()
614
+							. ' r LEFT JOIN '
615
+							. EEM_Transaction::instance()->table()
616
+							. ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL');
617
+	}
618
+
619
+
620
+
621
+	/**
622
+	 *  Count registrations checked into (or out of) a datetime
623
+	 *
624
+	 * @param int     $DTT_ID     datetime ID
625
+	 * @param boolean $checked_in whether to count registrations checked IN or OUT
626
+	 * @return int
627
+	 */
628
+	public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true)
629
+	{
630
+		global $wpdb;
631
+		//subquery to get latest checkin
632
+		$query = $wpdb->prepare('SELECT '
633
+								. 'COUNT( DISTINCT checkins.REG_ID ) '
634
+								. 'FROM '
635
+								. EEM_Checkin::instance()
636
+											 ->table()
637
+								. ' AS checkins INNER JOIN'
638
+								. '( SELECT '
639
+								. 'max( CHK_timestamp ) AS latest_checkin, '
640
+								. 'REG_ID AS REG_ID '
641
+								. 'FROM '
642
+								. EEM_Checkin::instance()->table()
643
+								. ' '
644
+								. 'WHERE DTT_ID=%d '
645
+								. 'GROUP BY REG_ID'
646
+								. ') AS most_recent_checkin_per_reg '
647
+								. 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
648
+								. 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
649
+								. 'WHERE '
650
+								. 'checkins.CHK_in=%d', $DTT_ID, $checked_in);
651
+		return (int)$wpdb->get_var($query);
652
+	}
653
+
654
+
655
+
656
+	/**
657
+	 *  Count registrations checked into (or out of) an event.
658
+	 *
659
+	 * @param int     $EVT_ID     event ID
660
+	 * @param boolean $checked_in whether to count registrations checked IN or OUT
661
+	 * @return int
662
+	 */
663
+	public function count_registrations_checked_into_event($EVT_ID, $checked_in = true)
664
+	{
665
+		global $wpdb;
666
+		//subquery to get latest checkin
667
+		$query = $wpdb->prepare('SELECT '
668
+								. 'COUNT( DISTINCT checkins.REG_ID ) '
669
+								. 'FROM '
670
+								. EEM_Checkin::instance()
671
+											 ->table()
672
+								. ' AS checkins INNER JOIN'
673
+								. '( SELECT '
674
+								. 'max( CHK_timestamp ) AS latest_checkin, '
675
+								. 'REG_ID AS REG_ID '
676
+								. 'FROM '
677
+								. EEM_Checkin::instance()->table()
678
+								. ' AS c '
679
+								. 'INNER JOIN '
680
+								. EEM_Datetime::instance()->table()
681
+								. ' AS d '
682
+								. 'ON c.DTT_ID=d.DTT_ID '
683
+								. 'WHERE d.EVT_ID=%d '
684
+								. 'GROUP BY REG_ID'
685
+								. ') AS most_recent_checkin_per_reg '
686
+								. 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID '
687
+								. 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
688
+								. 'WHERE '
689
+								. 'checkins.CHK_in=%d', $EVT_ID, $checked_in);
690
+		return (int)$wpdb->get_var($query);
691
+	}
692
+
693
+
694
+
695
+	/**
696
+	 * The purpose of this method is to retrieve an array of
697
+	 * EE_Registration objects that represent the latest registration
698
+	 * for each ATT_ID given in the function argument.
699
+	 *
700
+	 * @param array $attendee_ids
701
+	 * @return EE_Registration[]
702
+	 */
703
+	public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array())
704
+	{
705
+		//first do a native wp_query to get the latest REG_ID's matching these attendees.
706
+		global $wpdb;
707
+		$registration_table = $wpdb->prefix . 'esp_registration';
708
+		$attendee_table = $wpdb->posts;
709
+		$attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids);
710
+		$attendee_ids = implode(',', $attendee_ids);
711
+		//first we do a query to get the registration ids
712
+		// (because a group by before order by causes the order by to be ignored.)
713
+		$registration_id_query = "
714 714
 			SELECT registrations.registration_ids as registration_id
715 715
 			FROM (
716 716
 				SELECT
@@ -724,23 +724,23 @@  discard block
 block discarded – undo
724 724
 			  ) AS registrations
725 725
 			  GROUP BY registrations.attendee_ids
726 726
 		";
727
-        $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A);
728
-        if (empty($registration_ids)) {
729
-            return array();
730
-        }
731
-        $ids_for_model_query = array();
732
-        //let's flatten the ids so they can be used in the model query.
733
-        foreach ($registration_ids as $registration_id) {
734
-            if (isset($registration_id['registration_id'])) {
735
-                $ids_for_model_query[] = $registration_id['registration_id'];
736
-            }
737
-        }
738
-        //construct query
739
-        $_where = array(
740
-            'REG_ID' => array('IN', $ids_for_model_query),
741
-        );
742
-        return $this->get_all(array($_where));
743
-    }
727
+		$registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A);
728
+		if (empty($registration_ids)) {
729
+			return array();
730
+		}
731
+		$ids_for_model_query = array();
732
+		//let's flatten the ids so they can be used in the model query.
733
+		foreach ($registration_ids as $registration_id) {
734
+			if (isset($registration_id['registration_id'])) {
735
+				$ids_for_model_query[] = $registration_id['registration_id'];
736
+			}
737
+		}
738
+		//construct query
739
+		$_where = array(
740
+			'REG_ID' => array('IN', $ids_for_model_query),
741
+		);
742
+		return $this->get_all(array($_where));
743
+	}
744 744
 
745 745
 
746 746
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
         //and the table hasn't actually been created, this could have an error
278 278
         /** @type WPDB $wpdb */
279 279
         global $wpdb;
280
-        if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) {
281
-            $SQL = 'SELECT STS_ID, STS_code FROM ' . $wpdb->prefix . 'esp_status WHERE STS_type = "registration"';
280
+        if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) {
281
+            $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"';
282 282
             $results = $wpdb->get_results($SQL);
283 283
             self::$_reg_status = array();
284 284
             foreach ($results as $status) {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
             'group_by' => 'regDate',
414 414
             'order_by' => array('REG_date' => 'ASC'),
415 415
         ), OBJECT, array(
416
-            'regDate' => array('DATE(' . $query_interval . ')', '%s'),
416
+            'regDate' => array('DATE('.$query_interval.')', '%s'),
417 417
             'total'   => array('count(REG_ID)', '%d'),
418 418
         ));
419 419
         return $results;
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     public function get_registrations_per_day_and_per_status_report($period = '-1 month')
433 433
     {
434 434
         global $wpdb;
435
-        $registration_table = $wpdb->prefix . 'esp_registration';
435
+        $registration_table = $wpdb->prefix.'esp_registration';
436 436
         $event_table = $wpdb->posts;
437 437
         $sql_date = date("Y-m-d H:i:s", strtotime($period));
438 438
         //prepare the query interval for displaying offset
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         //exclude events not authored by user if permissions in effect
444 444
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
445 445
             $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
446
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
446
+            $inner_where .= " post_author = ".get_current_user_id()." AND";
447 447
         }
448 448
         $inner_where .= " REG_date >= '$sql_date'";
449 449
         $inner_date_query .= $inner_where;
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         //setup the joins
467 467
         $join .= implode(" LEFT JOIN ", $join_parts);
468 468
         //now let's put it all together
469
-        $query = $select . $join . ' GROUP BY Registration_REG_date';
469
+        $query = $select.$join.' GROUP BY Registration_REG_date';
470 470
         //and execute it
471 471
         $results = $wpdb->get_results($query, ARRAY_A);
472 472
         return $results;
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
     public function get_registrations_per_event_and_per_status_report($period = '-1 month')
518 518
     {
519 519
         global $wpdb;
520
-        $registration_table = $wpdb->prefix . 'esp_registration';
520
+        $registration_table = $wpdb->prefix.'esp_registration';
521 521
         $event_table = $wpdb->posts;
522 522
         $sql_date = date("Y-m-d H:i:s", strtotime($period));
523 523
         //inner date query
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         //exclude events not authored by user if permissions in effect
527 527
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
528 528
             $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID";
529
-            $inner_where .= " post_author = " . get_current_user_id() . " AND";
529
+            $inner_where .= " post_author = ".get_current_user_id()." AND";
530 530
         }
531 531
         $inner_where .= " REG_date >= '$sql_date'";
532 532
         $inner_date_query .= $inner_where;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
         //setup remaining joins
550 550
         $join .= implode(" LEFT JOIN ", $join_parts);
551 551
         //now put it all together
552
-        $query = $select . $join . ' GROUP BY Registration_Event';
552
+        $query = $select.$join.' GROUP BY Registration_Event';
553 553
         //and execute
554 554
         $results = $wpdb->get_results($query, ARRAY_A);
555 555
         return $results;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
                                 . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
649 649
                                 . 'WHERE '
650 650
                                 . 'checkins.CHK_in=%d', $DTT_ID, $checked_in);
651
-        return (int)$wpdb->get_var($query);
651
+        return (int) $wpdb->get_var($query);
652 652
     }
653 653
 
654 654
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
                                 . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin '
688 688
                                 . 'WHERE '
689 689
                                 . 'checkins.CHK_in=%d', $EVT_ID, $checked_in);
690
-        return (int)$wpdb->get_var($query);
690
+        return (int) $wpdb->get_var($query);
691 691
     }
692 692
 
693 693
 
@@ -704,9 +704,9 @@  discard block
 block discarded – undo
704 704
     {
705 705
         //first do a native wp_query to get the latest REG_ID's matching these attendees.
706 706
         global $wpdb;
707
-        $registration_table = $wpdb->prefix . 'esp_registration';
707
+        $registration_table = $wpdb->prefix.'esp_registration';
708 708
         $attendee_table = $wpdb->posts;
709
-        $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids);
709
+        $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int) $attendee_ids);
710 710
         $attendee_ids = implode(',', $attendee_ids);
711 711
         //first we do a query to get the registration ids
712 712
         // (because a group by before order by causes the order by to be ignored.)
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -418,7 +418,7 @@
 block discarded – undo
418 418
      * In this case, we delete the temporary file
419 419
      *
420 420
      * @param JobParameters $job_parameters
421
-     * @return boolean
421
+     * @return JobStepResponse
422 422
      */
423 423
     public function cleanup_job(JobParameters $job_parameters)
424 424
     {
Please login to merge, or discard this patch.
Indentation   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
18 18
 
19 19
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
-    exit('No direct script access allowed');
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -25,407 +25,407 @@  discard block
 block discarded – undo
25 25
 class RegistrationsReport extends JobHandlerFile
26 26
 {
27 27
 
28
-    /**
29
-     * Performs any necessary setup for starting the job. This is also a good
30
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
-     * when continue_job will be called
32
-     *
33
-     * @param JobParameters $job_parameters
34
-     * @throws BatchRequestException
35
-     * @return JobStepResponse
36
-     */
37
-    public function create_job(JobParameters $job_parameters)
38
-    {
39
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
-        if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
-        }
43
-        $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
-            $this->get_filename_from_event($event_id));
45
-        $job_parameters->add_extra_data('filepath', $filepath);
46
-        $question_data_for_columns = $this->_get_questions_for_report($event_id);
47
-        $job_parameters->add_extra_data('questions_data', $question_data_for_columns);
48
-        $job_parameters->set_job_size($this->count_units_to_process($event_id));
49
-        //we should also set the header columns
50
-        $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('questions_data'));
51
-        \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
52
-        //if we actually processed a row there, record it
53
-        if ($job_parameters->job_size()) {
54
-            $job_parameters->mark_processed(1);
55
-        }
56
-        return new JobStepResponse($job_parameters,
57
-            __('Registrations report started successfully...', 'event_espresso'));
58
-    }
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_from_event($event_id));
45
+		$job_parameters->add_extra_data('filepath', $filepath);
46
+		$question_data_for_columns = $this->_get_questions_for_report($event_id);
47
+		$job_parameters->add_extra_data('questions_data', $question_data_for_columns);
48
+		$job_parameters->set_job_size($this->count_units_to_process($event_id));
49
+		//we should also set the header columns
50
+		$csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('questions_data'));
51
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
52
+		//if we actually processed a row there, record it
53
+		if ($job_parameters->job_size()) {
54
+			$job_parameters->mark_processed(1);
55
+		}
56
+		return new JobStepResponse($job_parameters,
57
+			__('Registrations report started successfully...', 'event_espresso'));
58
+	}
59 59
 
60 60
 
61 61
 
62
-    /**
63
-     * Creates teh filename form the event id (or lack thereof)
64
-     *
65
-     * @param int $event_id
66
-     * @return string
67
-     */
68
-    protected function get_filename_from_event($event_id)
69
-    {
70
-        if ($event_id) {
71
-            $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
72
-            if ( ! $event_slug) {
73
-                $event_slug = __('unknown', 'event_espresso');
74
-            }
75
-        } else {
76
-            $event_slug = __('all', 'event_espresso');
77
-        }
78
-        return sprintf("registrations-for-%s.csv", $event_slug);
79
-    }
62
+	/**
63
+	 * Creates teh filename form the event id (or lack thereof)
64
+	 *
65
+	 * @param int $event_id
66
+	 * @return string
67
+	 */
68
+	protected function get_filename_from_event($event_id)
69
+	{
70
+		if ($event_id) {
71
+			$event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
72
+			if ( ! $event_slug) {
73
+				$event_slug = __('unknown', 'event_espresso');
74
+			}
75
+		} else {
76
+			$event_slug = __('all', 'event_espresso');
77
+		}
78
+		return sprintf("registrations-for-%s.csv", $event_slug);
79
+	}
80 80
 
81 81
 
82 82
 
83
-    /**
84
-     * Gets the questions which are to be used for this report, so they
85
-     * can be remembered for later
86
-     *
87
-     * @param int|null $event_id
88
-     * @return array of wpdb results for questions which are to be used for this report
89
-     */
90
-    protected function _get_questions_for_report($event_id)
91
-    {
92
-        $question_query_params = array(
93
-            array(
94
-                'Answer.ANS_ID' => array('IS_NOT_NULL'),
95
-            ),
96
-            'group_by' => array('QST_ID'),
97
-        );
98
-        if ($event_id) {
99
-            $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id;
100
-        }
101
-        return \EEM_Question::instance()->get_all_wpdb_results($question_query_params);
102
-    }
83
+	/**
84
+	 * Gets the questions which are to be used for this report, so they
85
+	 * can be remembered for later
86
+	 *
87
+	 * @param int|null $event_id
88
+	 * @return array of wpdb results for questions which are to be used for this report
89
+	 */
90
+	protected function _get_questions_for_report($event_id)
91
+	{
92
+		$question_query_params = array(
93
+			array(
94
+				'Answer.ANS_ID' => array('IS_NOT_NULL'),
95
+			),
96
+			'group_by' => array('QST_ID'),
97
+		);
98
+		if ($event_id) {
99
+			$question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id;
100
+		}
101
+		return \EEM_Question::instance()->get_all_wpdb_results($question_query_params);
102
+	}
103 103
 
104 104
 
105 105
 
106
-    /**
107
-     * Performs another step of the job
108
-     *
109
-     * @param JobParameters $job_parameters
110
-     * @param int           $batch_size
111
-     * @return JobStepResponse
112
-     * @throws \EE_Error
113
-     */
114
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
115
-    {
116
-        $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
117
-            $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('questions_data'));
118
-        \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
119
-        $units_processed = count($csv_data);
120
-        $job_parameters->mark_processed($units_processed);
121
-        $extra_response_data = array(
122
-            'file_url' => '',
123
-        );
124
-        if ($units_processed < $batch_size) {
125
-            $job_parameters->set_status(JobParameters::status_complete);
126
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
127
-        }
128
-        return new JobStepResponse($job_parameters,
129
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
130
-            $extra_response_data);
131
-    }
106
+	/**
107
+	 * Performs another step of the job
108
+	 *
109
+	 * @param JobParameters $job_parameters
110
+	 * @param int           $batch_size
111
+	 * @return JobStepResponse
112
+	 * @throws \EE_Error
113
+	 */
114
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
115
+	{
116
+		$csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
117
+			$job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('questions_data'));
118
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
119
+		$units_processed = count($csv_data);
120
+		$job_parameters->mark_processed($units_processed);
121
+		$extra_response_data = array(
122
+			'file_url' => '',
123
+		);
124
+		if ($units_processed < $batch_size) {
125
+			$job_parameters->set_status(JobParameters::status_complete);
126
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
127
+		}
128
+		return new JobStepResponse($job_parameters,
129
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
130
+			$extra_response_data);
131
+	}
132 132
 
133 133
 
134 134
 
135
-    /**
136
-     * Gets the csv data for a batch of registrations
137
-     *
138
-     * @param int|null $event_id
139
-     * @param int      $offset
140
-     * @param int      $limit
141
-     * @param array    $questions_for_these_regs_rows results of $wpdb->get_results( $something, ARRAY_A) when querying
142
-     *                                                for questions
143
-     * @return array top-level keys are numeric, next-level keys are column headers
144
-     */
145
-    function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows)
146
-    {
147
-        $reg_fields_to_include = array(
148
-            'TXN_ID',
149
-            'ATT_ID',
150
-            'REG_ID',
151
-            'REG_date',
152
-            'REG_code',
153
-            'REG_count',
154
-            'REG_final_price',
155
-        );
156
-        $att_fields_to_include = array(
157
-            'ATT_fname',
158
-            'ATT_lname',
159
-            'ATT_email',
160
-            'ATT_address',
161
-            'ATT_address2',
162
-            'ATT_city',
163
-            'STA_ID',
164
-            'CNT_ISO',
165
-            'ATT_zip',
166
-            'ATT_phone',
167
-        );
168
-        $registrations_csv_ready_array = array();
169
-        $reg_model = \EE_Registry::instance()->load_model('Registration');
170
-        $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
171
-                array(
172
-                    'OR'                 => array(
173
-                        //don't include registrations from failed or abandoned transactions...
174
-                        'Transaction.STS_ID' => array(
175
-                            'NOT IN',
176
-                            array(
177
-                                \EEM_Transaction::failed_status_code,
178
-                                \EEM_Transaction::abandoned_status_code,
179
-                            ),
180
-                        ),
181
-                        //unless the registration is approved, in which case include it regardless of transaction status
182
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
183
-                    ),
184
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
185
-                ),
186
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
187
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
188
-                'limit'      => array($offset, $limit),
189
-                'caps'       => \EEM_Base::caps_read_admin,
190
-            ), $event_id);
191
-        if ($event_id) {
192
-            $query_params[0]['EVT_ID'] = $event_id;
193
-        } else {
194
-            $query_params['force_join'][] = 'Event';
195
-        }
196
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
197
-        //get all questions which relate to someone in this group
198
-        $registration_ids = array();
199
-        foreach ($registration_rows as $reg_row) {
200
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
201
-        }
202
-        foreach ($registration_rows as $reg_row) {
203
-            if (is_array($reg_row)) {
204
-                $reg_csv_array = array();
205
-                if ( ! $event_id) {
206
-                    //get the event's name and Id
207
-                    $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
208
-                        \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
209
-                            $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
210
-                }
211
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
212
-                /*@var $reg_row EE_Registration */
213
-                foreach ($reg_fields_to_include as $field_name) {
214
-                    $field = $reg_model->field_settings_for($field_name);
215
-                    if ($field_name == 'REG_final_price') {
216
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
217
-                            $reg_row['Registration.REG_final_price'], 'localized_float');
218
-                    } elseif ($field_name == 'REG_count') {
219
-                        $value = sprintf(__('%s of %s', 'event_espresso'),
220
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
221
-                                $reg_row['Registration.REG_count']),
222
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
223
-                                $reg_row['Registration.REG_group_size']));
224
-                    } elseif ($field_name == 'REG_date') {
225
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
226
-                            $reg_row['Registration.REG_date'], 'no_html');
227
-                    } else {
228
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
229
-                            $reg_row[$field->get_qualified_column()]);
230
-                    }
231
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
232
-                    if ($field_name == 'REG_final_price') {
233
-                        //add a column named Currency after the final price
234
-                        $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
235
-                    }
236
-                }
237
-                //get pretty status
238
-                $stati = \EEM_Status::instance()->localized_status(array(
239
-                    $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
240
-                    $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
241
-                ), false, 'sentence');
242
-                $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
243
-                //get pretty transaction status
244
-                $reg_csv_array[__("Transaction Status",
245
-                    'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
246
-                $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
247
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
248
-                        $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
249
-                $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
250
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
251
-                        $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
252
-                $payment_methods = array();
253
-                $gateway_txn_ids_etc = array();
254
-                $payment_times = array();
255
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
256
-                    $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
257
-                        array(
258
-                            'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
259
-                            'STS_ID' => \EEM_Payment::status_id_approved,
260
-                        ),
261
-                        'force_join' => array('Payment_Method'),
262
-                    ), ARRAY_A,
263
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
264
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
265
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
266
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
267
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
268
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
269
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
270
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
271
-                    }
272
-                }
273
-                $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
274
-                $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
275
-                $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
276
-                //get whether or not the user has checked in
277
-                $reg_csv_array[__("Check-Ins",
278
-                    "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
279
-                //get ticket of registration and its price
280
-                $ticket_model = \EE_Registry::instance()->load_model('Ticket');
281
-                if ($reg_row['Ticket.TKT_ID']) {
282
-                    $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
283
-                        $reg_row['Ticket.TKT_name']);
284
-                    $datetimes_strings = array();
285
-                    foreach (
286
-                        \EEM_Datetime::instance()
287
-                                     ->get_all_wpdb_results(array(
288
-                                         array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
289
-                                         'order_by'                 => array('DTT_EVT_start' => 'ASC'),
290
-                                         'default_where_conditions' => 'none',
291
-                                     )) as $datetime
292
-                    ) {
293
-                        $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
294
-                            'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
295
-                    }
296
-                } else {
297
-                    $ticket_name = __('Unknown', 'event_espresso');
298
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
299
-                }
300
-                $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
301
-                $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
302
-                //get datetime(s) of registration
303
-                //add attendee columns
304
-                foreach ($att_fields_to_include as $att_field_name) {
305
-                    $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
306
-                    if ($reg_row['Attendee_CPT.ID']) {
307
-                        if ($att_field_name == 'STA_ID') {
308
-                            $value = \EEM_State::instance()
309
-                                               ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
310
-                                                   'STA_name');
311
-                        } elseif ($att_field_name == 'CNT_ISO') {
312
-                            $value = \EEM_Country::instance()
313
-                                                 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
314
-                                                     'CNT_name');
315
-                        } else {
316
-                            $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
317
-                                $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
318
-                        }
319
-                    } else {
320
-                        $value = '';
321
-                    }
322
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
323
-                }
324
-                //make sure each registration has the same questions in the same order
325
-                foreach ($questions_for_these_regs_rows as $question_row) {
326
-                    if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
327
-                        $reg_csv_array[$question_row['Question.QST_admin_label']] = null;
328
-                    }
329
-                }
330
-                $answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
331
-                        array('REG_ID' => $reg_row['Registration.REG_ID']),
332
-                        'force_join' => array('Question'),
333
-                    ));
334
-                //now fill out the questions THEY answered
335
-                foreach ($answers as $answer_row) {
336
-                    if ($answer_row['Question.QST_ID']) {
337
-                        $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
338
-                            'QST_admin_label', $answer_row['Question.QST_admin_label']);
339
-                    } else {
340
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
341
-                    }
342
-                    if (isset($answer_row['Question.QST_type'])
343
-                        && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
344
-                    ) {
345
-                        $reg_csv_array[$question_label] = \EEM_State::instance()
346
-                                                                    ->get_state_name_by_ID($answer_row['Answer.ANS_value']);
347
-                    } else {
348
-                        $reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
349
-                            'ANS_value', $answer_row['Answer.ANS_value']);
350
-                    }
351
-                }
352
-                $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array',
353
-                    $reg_csv_array, $reg_row);
354
-            }
355
-        }
356
-        //if we couldn't export anything, we want to at least show the column headers
357
-        if (empty($registrations_csv_ready_array)) {
358
-            $reg_csv_array = array();
359
-            $model_and_fields_to_include = array(
360
-                'Registration' => $reg_fields_to_include,
361
-                'Attendee'     => $att_fields_to_include,
362
-            );
363
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
364
-                $model = \EE_Registry::instance()->load_model($model_name);
365
-                foreach ($field_list as $field_name) {
366
-                    $field = $model->field_settings_for($field_name);
367
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
368
-                }
369
-            }
370
-            $registrations_csv_ready_array[] = $reg_csv_array;
371
-        }
372
-        return $registrations_csv_ready_array;
373
-    }
135
+	/**
136
+	 * Gets the csv data for a batch of registrations
137
+	 *
138
+	 * @param int|null $event_id
139
+	 * @param int      $offset
140
+	 * @param int      $limit
141
+	 * @param array    $questions_for_these_regs_rows results of $wpdb->get_results( $something, ARRAY_A) when querying
142
+	 *                                                for questions
143
+	 * @return array top-level keys are numeric, next-level keys are column headers
144
+	 */
145
+	function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows)
146
+	{
147
+		$reg_fields_to_include = array(
148
+			'TXN_ID',
149
+			'ATT_ID',
150
+			'REG_ID',
151
+			'REG_date',
152
+			'REG_code',
153
+			'REG_count',
154
+			'REG_final_price',
155
+		);
156
+		$att_fields_to_include = array(
157
+			'ATT_fname',
158
+			'ATT_lname',
159
+			'ATT_email',
160
+			'ATT_address',
161
+			'ATT_address2',
162
+			'ATT_city',
163
+			'STA_ID',
164
+			'CNT_ISO',
165
+			'ATT_zip',
166
+			'ATT_phone',
167
+		);
168
+		$registrations_csv_ready_array = array();
169
+		$reg_model = \EE_Registry::instance()->load_model('Registration');
170
+		$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
171
+				array(
172
+					'OR'                 => array(
173
+						//don't include registrations from failed or abandoned transactions...
174
+						'Transaction.STS_ID' => array(
175
+							'NOT IN',
176
+							array(
177
+								\EEM_Transaction::failed_status_code,
178
+								\EEM_Transaction::abandoned_status_code,
179
+							),
180
+						),
181
+						//unless the registration is approved, in which case include it regardless of transaction status
182
+						'STS_ID'             => \EEM_Registration::status_id_approved,
183
+					),
184
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
185
+				),
186
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
187
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
188
+				'limit'      => array($offset, $limit),
189
+				'caps'       => \EEM_Base::caps_read_admin,
190
+			), $event_id);
191
+		if ($event_id) {
192
+			$query_params[0]['EVT_ID'] = $event_id;
193
+		} else {
194
+			$query_params['force_join'][] = 'Event';
195
+		}
196
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
197
+		//get all questions which relate to someone in this group
198
+		$registration_ids = array();
199
+		foreach ($registration_rows as $reg_row) {
200
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
201
+		}
202
+		foreach ($registration_rows as $reg_row) {
203
+			if (is_array($reg_row)) {
204
+				$reg_csv_array = array();
205
+				if ( ! $event_id) {
206
+					//get the event's name and Id
207
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
208
+						\EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
209
+							$reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
210
+				}
211
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
212
+				/*@var $reg_row EE_Registration */
213
+				foreach ($reg_fields_to_include as $field_name) {
214
+					$field = $reg_model->field_settings_for($field_name);
215
+					if ($field_name == 'REG_final_price') {
216
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
217
+							$reg_row['Registration.REG_final_price'], 'localized_float');
218
+					} elseif ($field_name == 'REG_count') {
219
+						$value = sprintf(__('%s of %s', 'event_espresso'),
220
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
221
+								$reg_row['Registration.REG_count']),
222
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
223
+								$reg_row['Registration.REG_group_size']));
224
+					} elseif ($field_name == 'REG_date') {
225
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
226
+							$reg_row['Registration.REG_date'], 'no_html');
227
+					} else {
228
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
229
+							$reg_row[$field->get_qualified_column()]);
230
+					}
231
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
232
+					if ($field_name == 'REG_final_price') {
233
+						//add a column named Currency after the final price
234
+						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
235
+					}
236
+				}
237
+				//get pretty status
238
+				$stati = \EEM_Status::instance()->localized_status(array(
239
+					$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
240
+					$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
241
+				), false, 'sentence');
242
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
243
+				//get pretty transaction status
244
+				$reg_csv_array[__("Transaction Status",
245
+					'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
246
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
247
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
248
+						$reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
249
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
250
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
251
+						$reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
252
+				$payment_methods = array();
253
+				$gateway_txn_ids_etc = array();
254
+				$payment_times = array();
255
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
256
+					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
257
+						array(
258
+							'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
259
+							'STS_ID' => \EEM_Payment::status_id_approved,
260
+						),
261
+						'force_join' => array('Payment_Method'),
262
+					), ARRAY_A,
263
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
264
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
265
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
266
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
267
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
268
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
269
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
270
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
271
+					}
272
+				}
273
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
274
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
275
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
276
+				//get whether or not the user has checked in
277
+				$reg_csv_array[__("Check-Ins",
278
+					"event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
279
+				//get ticket of registration and its price
280
+				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
281
+				if ($reg_row['Ticket.TKT_ID']) {
282
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
283
+						$reg_row['Ticket.TKT_name']);
284
+					$datetimes_strings = array();
285
+					foreach (
286
+						\EEM_Datetime::instance()
287
+									 ->get_all_wpdb_results(array(
288
+										 array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
289
+										 'order_by'                 => array('DTT_EVT_start' => 'ASC'),
290
+										 'default_where_conditions' => 'none',
291
+									 )) as $datetime
292
+					) {
293
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
294
+							'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
295
+					}
296
+				} else {
297
+					$ticket_name = __('Unknown', 'event_espresso');
298
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
299
+				}
300
+				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
301
+				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
302
+				//get datetime(s) of registration
303
+				//add attendee columns
304
+				foreach ($att_fields_to_include as $att_field_name) {
305
+					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
306
+					if ($reg_row['Attendee_CPT.ID']) {
307
+						if ($att_field_name == 'STA_ID') {
308
+							$value = \EEM_State::instance()
309
+											   ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
310
+												   'STA_name');
311
+						} elseif ($att_field_name == 'CNT_ISO') {
312
+							$value = \EEM_Country::instance()
313
+												 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
314
+													 'CNT_name');
315
+						} else {
316
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
317
+								$att_field_name, $reg_row[$field_obj->get_qualified_column()]);
318
+						}
319
+					} else {
320
+						$value = '';
321
+					}
322
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
323
+				}
324
+				//make sure each registration has the same questions in the same order
325
+				foreach ($questions_for_these_regs_rows as $question_row) {
326
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
327
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
328
+					}
329
+				}
330
+				$answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
331
+						array('REG_ID' => $reg_row['Registration.REG_ID']),
332
+						'force_join' => array('Question'),
333
+					));
334
+				//now fill out the questions THEY answered
335
+				foreach ($answers as $answer_row) {
336
+					if ($answer_row['Question.QST_ID']) {
337
+						$question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
338
+							'QST_admin_label', $answer_row['Question.QST_admin_label']);
339
+					} else {
340
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
341
+					}
342
+					if (isset($answer_row['Question.QST_type'])
343
+						&& $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
344
+					) {
345
+						$reg_csv_array[$question_label] = \EEM_State::instance()
346
+																	->get_state_name_by_ID($answer_row['Answer.ANS_value']);
347
+					} else {
348
+						$reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
349
+							'ANS_value', $answer_row['Answer.ANS_value']);
350
+					}
351
+				}
352
+				$registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array',
353
+					$reg_csv_array, $reg_row);
354
+			}
355
+		}
356
+		//if we couldn't export anything, we want to at least show the column headers
357
+		if (empty($registrations_csv_ready_array)) {
358
+			$reg_csv_array = array();
359
+			$model_and_fields_to_include = array(
360
+				'Registration' => $reg_fields_to_include,
361
+				'Attendee'     => $att_fields_to_include,
362
+			);
363
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
364
+				$model = \EE_Registry::instance()->load_model($model_name);
365
+				foreach ($field_list as $field_name) {
366
+					$field = $model->field_settings_for($field_name);
367
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
368
+				}
369
+			}
370
+			$registrations_csv_ready_array[] = $reg_csv_array;
371
+		}
372
+		return $registrations_csv_ready_array;
373
+	}
374 374
 
375 375
 
376 376
 
377
-    /**
378
-     * Counts total unit to process
379
-     *
380
-     * @param int $event_id
381
-     * @return int
382
-     */
383
-    public function count_units_to_process($event_id)
384
-    {
385
-        //use the legacy filter
386
-        $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
387
-                array(
388
-                    'OR'                 => array(
389
-                        //don't include registrations from failed or abandoned transactions...
390
-                        'Transaction.STS_ID' => array(
391
-                            'NOT IN',
392
-                            array(
393
-                                \EEM_Transaction::failed_status_code,
394
-                                \EEM_Transaction::abandoned_status_code,
395
-                            ),
396
-                        ),
397
-                        //unless the registration is approved, in which case include it regardless of transaction status
398
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
399
-                    ),
400
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
401
-                ),
402
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
403
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
404
-                'caps'       => \EEM_Base::caps_read_admin,
405
-            ), $event_id);
406
-        if ($event_id) {
407
-            $query_params[0]['EVT_ID'] = $event_id;
408
-        } else {
409
-            $query_params['force_join'][] = 'Event';
410
-        }
411
-        return \EEM_Registration::instance()->count($query_params);
412
-    }
377
+	/**
378
+	 * Counts total unit to process
379
+	 *
380
+	 * @param int $event_id
381
+	 * @return int
382
+	 */
383
+	public function count_units_to_process($event_id)
384
+	{
385
+		//use the legacy filter
386
+		$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
387
+				array(
388
+					'OR'                 => array(
389
+						//don't include registrations from failed or abandoned transactions...
390
+						'Transaction.STS_ID' => array(
391
+							'NOT IN',
392
+							array(
393
+								\EEM_Transaction::failed_status_code,
394
+								\EEM_Transaction::abandoned_status_code,
395
+							),
396
+						),
397
+						//unless the registration is approved, in which case include it regardless of transaction status
398
+						'STS_ID'             => \EEM_Registration::status_id_approved,
399
+					),
400
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
401
+				),
402
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
403
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
404
+				'caps'       => \EEM_Base::caps_read_admin,
405
+			), $event_id);
406
+		if ($event_id) {
407
+			$query_params[0]['EVT_ID'] = $event_id;
408
+		} else {
409
+			$query_params['force_join'][] = 'Event';
410
+		}
411
+		return \EEM_Registration::instance()->count($query_params);
412
+	}
413 413
 
414 414
 
415 415
 
416
-    /**
417
-     * Performs any clean-up logic when we know the job is completed.
418
-     * In this case, we delete the temporary file
419
-     *
420
-     * @param JobParameters $job_parameters
421
-     * @return boolean
422
-     */
423
-    public function cleanup_job(JobParameters $job_parameters)
424
-    {
425
-        $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
426
-            true, 'd');
427
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
428
-    }
416
+	/**
417
+	 * Performs any clean-up logic when we know the job is completed.
418
+	 * In this case, we delete the temporary file
419
+	 *
420
+	 * @param JobParameters $job_parameters
421
+	 * @return boolean
422
+	 */
423
+	public function cleanup_job(JobParameters $job_parameters)
424
+	{
425
+		$this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
426
+			true, 'd');
427
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
428
+	}
429 429
 }
430 430
 
431 431
 
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @link             {@link http://www.eventespresso.com}
40 40
  * @since            4.0
41 41
  */
42
-if ( function_exists( 'espresso_version' ) ) {
42
+if (function_exists('espresso_version')) {
43 43
 
44 44
 	/**
45 45
 	 *    espresso_duplicate_plugin_error
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 			</p>
57 57
 		</div>
58 58
 		<?php
59
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60 60
 	}
61
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 
63 63
 } else {
64 64
 
65
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
66 66
 
67
-	if ( ! version_compare( PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=' ) ) {
67
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
68 68
 
69 69
 		/**
70 70
 		 * espresso_minimum_php_version_error
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 				</p>
91 91
 			</div>
92 92
 			<?php
93
-			espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
93
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
94 94
 		}
95
-		add_action( 'admin_notices', 'espresso_minimum_php_version_error', 1 );
95
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96 96
 
97 97
 	} else {
98 98
 
@@ -103,99 +103,99 @@  discard block
 block discarded – undo
103 103
 		 * @return string
104 104
 		 */
105 105
 		function espresso_version() {
106
-			return apply_filters( 'FHEE__espresso__espresso_version', '4.9.19.rc.001' );
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.19.rc.001');
107 107
 		}
108 108
 
109 109
 		// define versions
110
-		define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
111
-		define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
112
-		define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
113
-		define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
114
-		define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
110
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
111
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
112
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
113
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
114
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
115 115
 
116 116
 		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
117
-		if ( ! defined( 'DS' ) ) {
118
-			define( 'DS', '/' );
117
+		if ( ! defined('DS')) {
118
+			define('DS', '/');
119 119
 		}
120
-		if ( ! defined( 'PS' ) ) {
121
-			define( 'PS', PATH_SEPARATOR );
120
+		if ( ! defined('PS')) {
121
+			define('PS', PATH_SEPARATOR);
122 122
 		}
123
-		if ( ! defined( 'SP' ) ) {
124
-			define( 'SP', ' ' );
123
+		if ( ! defined('SP')) {
124
+			define('SP', ' ');
125 125
 		}
126
-		if ( ! defined( 'EENL' ) ) {
127
-			define( 'EENL', "\n" );
126
+		if ( ! defined('EENL')) {
127
+			define('EENL', "\n");
128 128
 		}
129
-		define( 'EE_SUPPORT_EMAIL', '[email protected]' );
129
+		define('EE_SUPPORT_EMAIL', '[email protected]');
130 130
 		// define the plugin directory and URL
131
-		define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
132
-		define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
133
-		define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
131
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
132
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
133
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
134 134
 		// main root folder paths
135
-		define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
136
-		define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
137
-		define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
138
-		define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
139
-		define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
140
-		define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
141
-		define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
142
-		define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
135
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
136
+		define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
137
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
138
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
139
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
140
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
141
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
142
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
143 143
 		// core system paths
144
-		define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
145
-		define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
146
-		define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
147
-		define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
148
-		define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
149
-		define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
150
-		define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
151
-		define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
152
-		define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
153
-		define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
154
-		define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
155
-		define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
144
+		define('EE_ADMIN', EE_CORE.'admin'.DS);
145
+		define('EE_CPTS', EE_CORE.'CPTs'.DS);
146
+		define('EE_CLASSES', EE_CORE.'db_classes'.DS);
147
+		define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
148
+		define('EE_BUSINESS', EE_CORE.'business'.DS);
149
+		define('EE_MODELS', EE_CORE.'db_models'.DS);
150
+		define('EE_HELPERS', EE_CORE.'helpers'.DS);
151
+		define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
152
+		define('EE_TEMPLATES', EE_CORE.'templates'.DS);
153
+		define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
154
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
155
+		define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
156 156
 		// gateways
157
-		define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
158
-		define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
157
+		define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
158
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
159 159
 		// asset URL paths
160
-		define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
161
-		define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
162
-		define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
163
-		define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
164
-		define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
165
-		define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
160
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
161
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
162
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
163
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
164
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
165
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
166 166
 		// define upload paths
167 167
 		$uploads = wp_upload_dir();
168 168
 		// define the uploads directory and URL
169
-		define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS );
170
-		define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS );
169
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
170
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
171 171
 		// define the templates directory and URL
172
-		define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS );
173
-		define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS );
172
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
173
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
174 174
 		// define the gateway directory and URL
175
-		define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS );
176
-		define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS );
175
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
176
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
177 177
 		// languages folder/path
178
-		define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
179
-		define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
178
+		define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
179
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
180 180
 		//check for dompdf fonts in uploads
181
-		if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
182
-			define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
181
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
182
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
183 183
 		}
184 184
 		//ajax constants
185 185
 		define(
186 186
 			'EE_FRONT_AJAX',
187
-			isset( $_REQUEST['ee_front_ajax'] ) || isset( $_REQUEST['data']['ee_front_ajax'] ) ? true : false
187
+			isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
188 188
 		);
189 189
 		define(
190 190
 			'EE_ADMIN_AJAX',
191
-			isset( $_REQUEST['ee_admin_ajax'] ) || isset( $_REQUEST['data']['ee_admin_ajax'] ) ? true : false
191
+			isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
192 192
 		);
193 193
 		//just a handy constant occasionally needed for finding values representing infinity in the DB
194 194
 		//you're better to use this than its straight value (currently -1) in case you ever
195 195
 		//want to change its default value! or find when -1 means infinity
196
-		define( 'EE_INF_IN_DB', -1 );
197
-		define( 'EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX );
198
-		define( 'EE_DEBUG', false );
196
+		define('EE_INF_IN_DB', -1);
197
+		define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
198
+		define('EE_DEBUG', false);
199 199
 
200 200
 
201 201
 		/**
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
204 204
 		 */
205 205
 		function espresso_plugin_activation() {
206
-			update_option( 'ee_espresso_activation', true );
206
+			update_option('ee_espresso_activation', true);
207 207
 		}
208
-		register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
208
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
209 209
 
210 210
 
211 211
 
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 		 */
216 216
 		function espresso_load_error_handling() {
217 217
 			// load debugging tools
218
-			if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
219
-				require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
218
+			if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
219
+				require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
220 220
 				EEH_Debug_Tools::instance();
221 221
 			}
222 222
 			// load error handling
223
-			if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
224
-				require_once( EE_CORE . 'EE_Error.core.php' );
223
+			if (is_readable(EE_CORE.'EE_Error.core.php')) {
224
+				require_once(EE_CORE.'EE_Error.core.php');
225 225
 			} else {
226
-				wp_die( esc_html__( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
226
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
227 227
 			}
228 228
 		}
229 229
 
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
 		 * @param    string $full_path_to_file
238 238
 		 * @throws    EE_Error
239 239
 		 */
240
-		function espresso_load_required( $classname, $full_path_to_file ) {
240
+		function espresso_load_required($classname, $full_path_to_file) {
241 241
 			static $error_handling_loaded = false;
242
-			if ( ! $error_handling_loaded ) {
242
+			if ( ! $error_handling_loaded) {
243 243
 				espresso_load_error_handling();
244 244
 				$error_handling_loaded = true;
245 245
 			}
246
-			if ( is_readable( $full_path_to_file ) ) {
247
-				require_once( $full_path_to_file );
246
+			if (is_readable($full_path_to_file)) {
247
+				require_once($full_path_to_file);
248 248
 			} else {
249
-				throw new EE_Error (
249
+				throw new EE_Error(
250 250
 					sprintf(
251 251
 						esc_html__(
252 252
 							'The %s class file could not be located or is not readable due to file permissions.',
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			}
259 259
 		}
260 260
 
261
-		espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
262
-		espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
263
-		espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
261
+		espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
262
+		espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
263
+		espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
264 264
 		new EE_Bootstrap();
265 265
 
266 266
 	}
267 267
 }
268 268
 
269
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
269
+if ( ! function_exists('espresso_deactivate_plugin')) {
270 270
 
271 271
 	/**
272 272
 	 *    deactivate_plugin
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
277 277
 	 * @return    void
278 278
 	 */
279
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
280
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
281
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
279
+	function espresso_deactivate_plugin($plugin_basename = '') {
280
+		if ( ! function_exists('deactivate_plugins')) {
281
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
282 282
 		}
283
-		unset( $_GET['activate'], $_REQUEST['activate'] );
284
-		deactivate_plugins( $plugin_basename );
283
+		unset($_GET['activate'], $_REQUEST['activate']);
284
+		deactivate_plugins($plugin_basename);
285 285
 	}
286 286
 
287 287
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +2878 added lines, -2878 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -24,1772 +24,1772 @@  discard block
 block discarded – undo
24 24
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
25 25
 {
26 26
 
27
-    /**
28
-     * @var EE_Registration
29
-     */
30
-    private $_registration;
31
-
32
-    /**
33
-     * @var EE_Event
34
-     */
35
-    private $_reg_event;
36
-
37
-    /**
38
-     * @var EE_Session
39
-     */
40
-    private        $_session;
41
-
42
-    private static $_reg_status;
43
-
44
-    /**
45
-     * Form for displaying the custom questions for this registration.
46
-     * This gets used a few times throughout the request so its best to cache it
47
-     *
48
-     * @var EE_Registration_Custom_Questions_Form
49
-     */
50
-    protected $_reg_custom_questions_form = null;
51
-
52
-
53
-
54
-    /**
55
-     *        constructor
56
-     *
57
-     * @Constructor
58
-     * @access public
59
-     * @param bool $routing
60
-     * @return Registrations_Admin_Page
61
-     */
62
-    public function __construct($routing = true)
63
-    {
64
-        parent::__construct($routing);
65
-        add_action('wp_loaded', array($this, 'wp_loaded'));
66
-    }
67
-
68
-
69
-
70
-    public function wp_loaded()
71
-    {
72
-        // when adding a new registration...
73
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') {
74
-            EE_System::do_not_cache();
75
-            if ( ! isset($this->_req_data['processing_registration'])
76
-                 || absint($this->_req_data['processing_registration']) !== 1
77
-            ) {
78
-                // and it's NOT the attendee information reg step
79
-                // force cookie expiration by setting time to last week
80
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
81
-                // and update the global
82
-                $_COOKIE['ee_registration_added'] = 0;
83
-            }
84
-        }
85
-    }
86
-
87
-
88
-
89
-    protected function _init_page_props()
90
-    {
91
-        $this->page_slug = REG_PG_SLUG;
92
-        $this->_admin_base_url = REG_ADMIN_URL;
93
-        $this->_admin_base_path = REG_ADMIN;
94
-        $this->page_label = __('Registrations', 'event_espresso');
95
-        $this->_cpt_routes = array(
96
-            'add_new_attendee' => 'espresso_attendees',
97
-            'edit_attendee'    => 'espresso_attendees',
98
-            'insert_attendee'  => 'espresso_attendees',
99
-            'update_attendee'  => 'espresso_attendees',
100
-        );
101
-        $this->_cpt_model_names = array(
102
-            'add_new_attendee' => 'EEM_Attendee',
103
-            'edit_attendee'    => 'EEM_Attendee',
104
-        );
105
-        $this->_cpt_edit_routes = array(
106
-            'espresso_attendees' => 'edit_attendee',
107
-        );
108
-        $this->_pagenow_map = array(
109
-            'add_new_attendee' => 'post-new.php',
110
-            'edit_attendee'    => 'post.php',
111
-            'trash'            => 'post.php',
112
-        );
113
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
114
-        //add filters so that the comment urls don't take users to a confusing 404 page
115
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
116
-    }
117
-
118
-
119
-
120
-    public function clear_comment_link($link, $comment, $args)
121
-    {
122
-        //gotta make sure this only happens on this route
123
-        $post_type = get_post_type($comment->comment_post_ID);
124
-        if ($post_type == 'espresso_attendees') {
125
-            return '#commentsdiv';
126
-        }
127
-        return $link;
128
-    }
129
-
130
-
131
-
132
-    protected function _ajax_hooks()
133
-    {
134
-        //todo: all hooks for registrations ajax goes in here
135
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
136
-    }
137
-
138
-
139
-
140
-    protected function _define_page_props()
141
-    {
142
-        $this->_admin_page_title = $this->page_label;
143
-        $this->_labels = array(
144
-            'buttons'                      => array(
145
-                'add-registrant'      => __('Add New Registration', 'event_espresso'),
146
-                'add-attendee'        => __('Add Contact', 'event_espresso'),
147
-                'edit'                => __('Edit Contact', 'event_espresso'),
148
-                'report'              => __("Event Registrations CSV Report", "event_espresso"),
149
-                'report_all'          => __('All Registrations CSV Report', 'event_espresso'),
150
-                'contact_list_report' => __('Contact List Report', 'event_espresso'),
151
-                'contact_list_export' => __("Export Data", "event_espresso"),
152
-            ),
153
-            'publishbox'                   => array(
154
-                'add_new_attendee' => __("Add Contact Record", 'event_espresso'),
155
-                'edit_attendee'    => __("Update Contact Record", 'event_espresso'),
156
-            ),
157
-            'hide_add_button_on_cpt_route' => array(
158
-                'edit_attendee' => true,
159
-            ),
160
-        );
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     *        grab url requests and route them
167
-     *
168
-     * @access private
169
-     * @return void
170
-     */
171
-    public function _set_page_routes()
172
-    {
173
-        $this->_get_registration_status_array();
174
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175
-            ? $this->_req_data['_REG_ID'] : 0;
176
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
177
-            ? $this->_req_data['ATT_ID'] : 0;
178
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post']
179
-            : $att_id;
180
-        $this->_page_routes = array(
181
-            'default' => array(
182
-                'func'       => '_registrations_overview_list_table',
183
-                'capability' => 'ee_read_registrations',
184
-            ),
185
-            'view_registration' => array(
186
-                'func'       => '_registration_details',
187
-                'capability' => 'ee_read_registration',
188
-                'obj_id'     => $reg_id,
189
-            ),
190
-            'edit_registration' => array(
191
-                'func'               => '_update_attendee_registration_form',
192
-                'noheader'           => true,
193
-                'headers_sent_route' => 'view_registration',
194
-                'capability'         => 'ee_edit_registration',
195
-                'obj_id'             => $reg_id,
196
-                '_REG_ID'            => $reg_id,
197
-            ),
198
-            'trash_registrations' => array(
199
-                'func'       => '_trash_or_restore_registrations',
200
-                'args'       => array('trash' => true),
201
-                'noheader'   => true,
202
-                'capability' => 'ee_delete_registrations',
203
-            ),
204
-            'restore_registrations' => array(
205
-                'func'       => '_trash_or_restore_registrations',
206
-                'args'       => array('trash' => false),
207
-                'noheader'   => true,
208
-                'capability' => 'ee_delete_registrations',
209
-            ),
210
-            'delete_registrations' => array(
211
-                'func'       => '_delete_registrations',
212
-                'noheader'   => true,
213
-                'capability' => 'ee_delete_registrations',
214
-            ),
215
-            'new_registration' => array(
216
-                'func'       => 'new_registration',
217
-                'capability' => 'ee_edit_registrations',
218
-            ),
219
-            'process_reg_step' => array(
220
-                'func'       => 'process_reg_step',
221
-                'noheader'   => true,
222
-                'capability' => 'ee_edit_registrations',
223
-            ),
224
-            'redirect_to_txn' => array(
225
-                'func'       => 'redirect_to_txn',
226
-                'noheader'   => true,
227
-                'capability' => 'ee_edit_registrations',
228
-            ),
229
-            'change_reg_status' => array(
230
-                'func'       => '_change_reg_status',
231
-                'noheader'   => true,
232
-                'capability' => 'ee_edit_registration',
233
-                'obj_id'     => $reg_id,
234
-            ),
235
-            'approve_registration' => array(
236
-                'func'       => 'approve_registration',
237
-                'noheader'   => true,
238
-                'capability' => 'ee_edit_registration',
239
-                'obj_id'     => $reg_id,
240
-            ),
241
-            'approve_and_notify_registration' => array(
242
-                'func'       => 'approve_registration',
243
-                'noheader'   => true,
244
-                'args'       => array(true),
245
-                'capability' => 'ee_edit_registration',
246
-                'obj_id'     => $reg_id,
247
-            ),
248
-            'decline_registration' => array(
249
-                'func'       => 'decline_registration',
250
-                'noheader'   => true,
251
-                'capability' => 'ee_edit_registration',
252
-                'obj_id'     => $reg_id,
253
-            ),
254
-            'decline_and_notify_registration' => array(
255
-                'func'       => 'decline_registration',
256
-                'noheader'   => true,
257
-                'args'       => array(true),
258
-                'capability' => 'ee_edit_registration',
259
-                'obj_id'     => $reg_id,
260
-            ),
261
-            'pending_registration' => array(
262
-                'func'       => 'pending_registration',
263
-                'noheader'   => true,
264
-                'capability' => 'ee_edit_registration',
265
-                'obj_id'     => $reg_id,
266
-            ),
267
-            'pending_and_notify_registration' => array(
268
-                'func'       => 'pending_registration',
269
-                'noheader'   => true,
270
-                'args'       => array(true),
271
-                'capability' => 'ee_edit_registration',
272
-                'obj_id'     => $reg_id,
273
-            ),
274
-            'no_approve_registration' => array(
275
-                'func'       => 'not_approve_registration',
276
-                'noheader'   => true,
277
-                'capability' => 'ee_edit_registration',
278
-                'obj_id'     => $reg_id,
279
-            ),
280
-            'no_approve_and_notify_registration' => array(
281
-                'func'       => 'not_approve_registration',
282
-                'noheader'   => true,
283
-                'args'       => array(true),
284
-                'capability' => 'ee_edit_registration',
285
-                'obj_id'     => $reg_id,
286
-            ),
287
-            'cancel_registration' => array(
288
-                'func'       => 'cancel_registration',
289
-                'noheader'   => true,
290
-                'capability' => 'ee_edit_registration',
291
-                'obj_id'     => $reg_id,
292
-            ),
293
-            'cancel_and_notify_registration' => array(
294
-                'func'       => 'cancel_registration',
295
-                'noheader'   => true,
296
-                'args'       => array(true),
297
-                'capability' => 'ee_edit_registration',
298
-                'obj_id'     => $reg_id,
299
-            ),
300
-            'contact_list' => array(
301
-                'func'       => '_attendee_contact_list_table',
302
-                'capability' => 'ee_read_contacts',
303
-            ),
304
-            'add_new_attendee' => array(
305
-                'func' => '_create_new_cpt_item',
306
-                'args' => array(
307
-                    'new_attendee' => true,
308
-                    'capability'   => 'ee_edit_contacts',
309
-                ),
310
-            ),
311
-            'edit_attendee' => array(
312
-                'func'       => '_edit_cpt_item',
313
-                'capability' => 'ee_edit_contacts',
314
-                'obj_id'     => $att_id,
315
-            ),
316
-            'duplicate_attendee' => array(
317
-                'func'       => '_duplicate_attendee',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_contacts',
320
-                'obj_id'     => $att_id,
321
-            ),
322
-            'insert_attendee' => array(
323
-                'func'       => '_insert_or_update_attendee',
324
-                'args'       => array(
325
-                    'new_attendee' => true,
326
-                ),
327
-                'noheader'   => true,
328
-                'capability' => 'ee_edit_contacts',
329
-            ),
330
-            'update_attendee' => array(
331
-                'func'       => '_insert_or_update_attendee',
332
-                'args'       => array(
333
-                    'new_attendee' => false,
334
-                ),
335
-                'noheader'   => true,
336
-                'capability' => 'ee_edit_contacts',
337
-                'obj_id'     => $att_id,
338
-            ),
339
-            'trash_attendees' => array(
340
-                'func'       => '_trash_or_restore_attendees',
341
-                'args'       => array(
342
-                    'trash' => true,
343
-                ),
344
-                'noheader'   => true,
345
-                'capability' => 'ee_delete_contacts',
346
-                'obj_id'     => $att_id,
347
-            ),
348
-            'restore_attendees'    => array(
349
-                'func'       => '_trash_or_restore_attendees',
350
-                'args'       => array(
351
-                    'trash' => false,
352
-                ),
353
-                'noheader'   => true,
354
-                'capability' => 'ee_delete_contacts',
355
-                'obj_id'     => $att_id,
356
-            ),
357
-            'resend_registration'  => array(
358
-                'func'       => '_resend_registration',
359
-                'noheader'   => true,
360
-                'capability' => 'ee_send_message',
361
-            ),
362
-            'registrations_report' => array(
363
-                'func'       => '_registrations_report',
364
-                'noheader'   => true,
365
-                'capability' => 'ee_read_registrations',
366
-            ),
367
-            'contact_list_export'  => array(
368
-                'func'       => '_contact_list_export',
369
-                'noheader'   => true,
370
-                'capability' => 'export',
371
-            ),
372
-            'contact_list_report'  => array(
373
-                'func'       => '_contact_list_report',
374
-                'noheader'   => true,
375
-                'capability' => 'ee_read_contacts',
376
-            ),
377
-        );
378
-    }
379
-
380
-
381
-
382
-    protected function _set_page_config()
383
-    {
384
-        $this->_page_config = array(
385
-            'default' => array(
386
-                'nav'           => array(
387
-                    'label' => __('Overview', 'event_espresso'),
388
-                    'order' => 5,
389
-                ),
390
-                'help_tabs'     => array(
391
-                    'registrations_overview_help_tab'                       => array(
392
-                        'title'    => __('Registrations Overview', 'event_espresso'),
393
-                        'filename' => 'registrations_overview',
394
-                    ),
395
-                    'registrations_overview_table_column_headings_help_tab' => array(
396
-                        'title'    => __('Registrations Table Column Headings', 'event_espresso'),
397
-                        'filename' => 'registrations_overview_table_column_headings',
398
-                    ),
399
-                    'registrations_overview_filters_help_tab'               => array(
400
-                        'title'    => __('Registration Filters', 'event_espresso'),
401
-                        'filename' => 'registrations_overview_filters',
402
-                    ),
403
-                    'registrations_overview_views_help_tab'                 => array(
404
-                        'title'    => __('Registration Views', 'event_espresso'),
405
-                        'filename' => 'registrations_overview_views',
406
-                    ),
407
-                    'registrations_regoverview_other_help_tab'              => array(
408
-                        'title'    => __('Registrations Other', 'event_espresso'),
409
-                        'filename' => 'registrations_overview_other',
410
-                    ),
411
-                ),
412
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
413
-                'qtips'         => array('Registration_List_Table_Tips'),
414
-                'list_table'    => 'EE_Registrations_List_Table',
415
-                'require_nonce' => false,
416
-            ),
417
-            'view_registration' => array(
418
-                'nav'           => array(
419
-                    'label'      => __('REG Details', 'event_espresso'),
420
-                    'order'      => 15,
421
-                    'url'        => isset($this->_req_data['_REG_ID'])
422
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
423
-                        : $this->_admin_base_url,
424
-                    'persistent' => false,
425
-                ),
426
-                'help_tabs'     => array(
427
-                    'registrations_details_help_tab'                    => array(
428
-                        'title'    => __('Registration Details', 'event_espresso'),
429
-                        'filename' => 'registrations_details',
430
-                    ),
431
-                    'registrations_details_table_help_tab'              => array(
432
-                        'title'    => __('Registration Details Table', 'event_espresso'),
433
-                        'filename' => 'registrations_details_table',
434
-                    ),
435
-                    'registrations_details_form_answers_help_tab'       => array(
436
-                        'title'    => __('Registration Form Answers', 'event_espresso'),
437
-                        'filename' => 'registrations_details_form_answers',
438
-                    ),
439
-                    'registrations_details_registrant_details_help_tab' => array(
440
-                        'title'    => __('Contact Details', 'event_espresso'),
441
-                        'filename' => 'registrations_details_registrant_details',
442
-                    ),
443
-                ),
444
-                'help_tour'     => array('Registration_Details_Help_Tour'),
445
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
446
-                    array('_registration_details_metaboxes')),
447
-                'require_nonce' => false,
448
-            ),
449
-            'new_registration' => array(
450
-                'nav'           => array(
451
-                    'label'      => __('Add New Registration', 'event_espresso'),
452
-                    'url'        => '#',
453
-                    'order'      => 15,
454
-                    'persistent' => false,
455
-                ),
456
-                'metaboxes'     => $this->_default_espresso_metaboxes,
457
-                'labels'        => array(
458
-                    'publishbox' => __('Save Registration', 'event_espresso'),
459
-                ),
460
-                'require_nonce' => false,
461
-            ),
462
-            'add_new_attendee' => array(
463
-                'nav'           => array(
464
-                    'label'      => __('Add Contact', 'event_espresso'),
465
-                    'order'      => 15,
466
-                    'persistent' => false,
467
-                ),
468
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
469
-                    array('_publish_post_box', 'attendee_editor_metaboxes')),
470
-                'require_nonce' => false,
471
-            ),
472
-            'edit_attendee' => array(
473
-                'nav'           => array(
474
-                    'label'      => __('Edit Contact', 'event_espresso'),
475
-                    'order'      => 15,
476
-                    'persistent' => false,
477
-                    'url'        => isset($this->_req_data['ATT_ID'])
478
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
479
-                        : $this->_admin_base_url,
480
-                ),
481
-                'metaboxes'     => array('attendee_editor_metaboxes'),
482
-                'require_nonce' => false,
483
-            ),
484
-            'contact_list' => array(
485
-                'nav'           => array(
486
-                    'label' => __('Contact List', 'event_espresso'),
487
-                    'order' => 20,
488
-                ),
489
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
490
-                'help_tabs'     => array(
491
-                    'registrations_contact_list_help_tab'                       => array(
492
-                        'title'    => __('Registrations Contact List', 'event_espresso'),
493
-                        'filename' => 'registrations_contact_list',
494
-                    ),
495
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
496
-                        'title'    => __('Contact List Table Column Headings', 'event_espresso'),
497
-                        'filename' => 'registrations_contact_list_table_column_headings',
498
-                    ),
499
-                    'registrations_contact_list_views_help_tab'                 => array(
500
-                        'title'    => __('Contact List Views', 'event_espresso'),
501
-                        'filename' => 'registrations_contact_list_views',
502
-                    ),
503
-                    'registrations_contact_list_other_help_tab'                 => array(
504
-                        'title'    => __('Contact List Other', 'event_espresso'),
505
-                        'filename' => 'registrations_contact_list_other',
506
-                    ),
507
-                ),
508
-                'help_tour'     => array('Contact_List_Help_Tour'),
509
-                'metaboxes'     => array(),
510
-                'require_nonce' => false,
511
-            ),
512
-            //override default cpt routes
513
-            'create_new'   => '',
514
-            'edit'         => '',
515
-        );
516
-    }
517
-
518
-
519
-
520
-    /**
521
-     * The below methods aren't used by this class currently
522
-     */
523
-    protected function _add_screen_options()
524
-    {
525
-    }
526
-
527
-
528
-
529
-    protected function _add_feature_pointers()
530
-    {
531
-    }
532
-
533
-
534
-
535
-    public function admin_init()
536
-    {
537
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes',
538
-            'event_espresso');
539
-    }
540
-
541
-
542
-
543
-    public function admin_notices()
544
-    {
545
-    }
546
-
547
-
548
-
549
-    public function admin_footer_scripts()
550
-    {
551
-    }
552
-
553
-
554
-
555
-    /**
556
-     *        get list of registration statuses
557
-     *
558
-     * @access private
559
-     * @return void
560
-     */
561
-    private function _get_registration_status_array()
562
-    {
563
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
564
-    }
565
-
566
-
567
-
568
-    protected function _add_screen_options_default()
569
-    {
570
-        $this->_per_page_screen_option();
571
-    }
572
-
573
-
574
-
575
-    protected function _add_screen_options_contact_list()
576
-    {
577
-        $page_title = $this->_admin_page_title;
578
-        $this->_admin_page_title = __("Contacts", 'event_espresso');
579
-        $this->_per_page_screen_option();
580
-        $this->_admin_page_title = $page_title;
581
-    }
582
-
583
-
584
-
585
-    public function load_scripts_styles()
586
-    {
587
-        //style
588
-        //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
589
-        wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'),
590
-            EVENT_ESPRESSO_VERSION);
591
-        wp_enqueue_style('espresso_reg');
592
-        //script
593
-        wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js',
594
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
595
-        wp_enqueue_script('espresso_reg');
596
-    }
597
-
598
-
599
-
600
-    public function load_scripts_styles_edit_attendee()
601
-    {
602
-        //stuff to only show up on our attendee edit details page.
603
-        $attendee_details_translations = array(
604
-            'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'),
605
-                $this->_cpt_model_obj->get_datetime('ATT_created')),
606
-        );
607
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
608
-        wp_enqueue_script('jquery-validate');
609
-    }
610
-
611
-
612
-
613
-    public function load_scripts_styles_view_registration()
614
-    {
615
-        //styles
616
-        wp_enqueue_style('espresso-ui-theme');
617
-        //scripts
618
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
619
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
620
-    }
621
-
622
-
623
-
624
-    public function load_scripts_styles_contact_list()
625
-    {
626
-        wp_deregister_style('espresso_reg');
627
-        wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'),
628
-            EVENT_ESPRESSO_VERSION);
629
-        wp_enqueue_style('espresso_att');
630
-    }
631
-
632
-
633
-
634
-    public function load_scripts_styles_new_registration()
635
-    {
636
-        wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'),
637
-            EVENT_ESPRESSO_VERSION, true);
638
-        wp_enqueue_script('ee-spco-for-admin');
639
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
640
-        EE_Form_Section_Proper::wp_enqueue_scripts();
641
-        EED_Ticket_Selector::load_tckt_slctr_assets();
642
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
643
-    }
644
-
645
-
646
-
647
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
648
-    {
649
-        add_filter('FHEE_load_EE_messages', '__return_true');
650
-    }
651
-
652
-
653
-
654
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
655
-    {
656
-        add_filter('FHEE_load_EE_messages', '__return_true');
657
-    }
658
-
659
-
660
-
661
-    protected function _set_list_table_views_default()
662
-    {
663
-        //for notification related bulk actions we need to make sure only active messengers have an option.
664
-        EED_Messages::set_autoloaders();
665
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
666
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
667
-        $active_mts = $message_resource_manager->list_of_active_message_types();
668
-        //key= bulk_action_slug, value= message type.
669
-        $match_array = array(
670
-            'approve_registration'    => 'registration',
671
-            'decline_registration'    => 'declined_registration',
672
-            'pending_registration'    => 'pending_approval',
673
-            'no_approve_registration' => 'not_approved_registration',
674
-            'cancel_registration'     => 'cancelled_registration',
675
-        );
676
-        /** setup reg status bulk actions **/
677
-        $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
678
-        if (in_array($match_array['approve_registration'], $active_mts)
679
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
680
-        ) {
681
-            $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations',
682
-                'event_espresso');
683
-        }
684
-        $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
685
-        if (in_array($match_array['decline_registration'], $active_mts)
686
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
687
-        ) {
688
-            $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations',
689
-                'event_espresso');
690
-        }
691
-        $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
692
-        if (in_array($match_array['pending_registration'], $active_mts)
693
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
694
-        ) {
695
-            $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify',
696
-                'event_espresso');
697
-        }
698
-        $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
699
-        if (in_array($match_array['no_approve_registration'], $active_mts)
700
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
701
-        ) {
702
-            $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify',
703
-                'event_espresso');
704
-        }
705
-        $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
706
-        if (in_array($match_array['cancel_registration'], $active_mts)
707
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
708
-        ) {
709
-            $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify',
710
-                'event_espresso');
711
-        }
712
-        $this->_views = array(
713
-            'all'   => array(
714
-                'slug'        => 'all',
715
-                'label'       => __('View All Registrations', 'event_espresso'),
716
-                'count'       => 0,
717
-                'bulk_action' => array_merge($def_reg_status_actions, array(
718
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
719
-                )),
720
-            ),
721
-            'month' => array(
722
-                'slug'        => 'month',
723
-                'label'       => __('This Month', 'event_espresso'),
724
-                'count'       => 0,
725
-                'bulk_action' => array_merge($def_reg_status_actions, array(
726
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
727
-                )),
728
-            ),
729
-            'today' => array(
730
-                'slug'        => 'today',
731
-                'label'       => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
732
-                'count'       => 0,
733
-                'bulk_action' => array_merge($def_reg_status_actions, array(
734
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
735
-                )),
736
-            ),
737
-        );
738
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
739
-            'espresso_registrations_delete_registration')
740
-        ) {
741
-            $this->_views['incomplete'] = array(
742
-                'slug'        => 'incomplete',
743
-                'label'       => __('Incomplete', 'event_espresso'),
744
-                'count'       => 0,
745
-                'bulk_action' => array(
746
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
747
-                ),
748
-            );
749
-            $this->_views['trash'] = array(
750
-                'slug'        => 'trash',
751
-                'label'       => __('Trash', 'event_espresso'),
752
-                'count'       => 0,
753
-                'bulk_action' => array(
754
-                    'restore_registrations' => __('Restore Registrations', 'event_espresso'),
755
-                    'delete_registrations'  => __('Delete Registrations Permanently', 'event_espresso'),
756
-                ),
757
-            );
758
-        }
759
-    }
760
-
761
-
762
-
763
-    protected function _set_list_table_views_contact_list()
764
-    {
765
-        $this->_views = array(
766
-            'in_use' => array(
767
-                'slug'        => 'in_use',
768
-                'label'       => __('In Use', 'event_espresso'),
769
-                'count'       => 0,
770
-                'bulk_action' => array(
771
-                    'trash_attendees' => __('Move to Trash', 'event_espresso'),
772
-                ),
773
-            ),
774
-        );
775
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts',
776
-            'espresso_registrations_trash_attendees')
777
-        ) {
778
-            $this->_views['trash'] = array(
779
-                'slug'        => 'trash',
780
-                'label'       => __('Trash', 'event_espresso'),
781
-                'count'       => 0,
782
-                'bulk_action' => array(
783
-                    'restore_attendees' => __('Restore from Trash', 'event_espresso'),
784
-                ),
785
-            );
786
-        }
787
-    }
788
-
789
-
790
-
791
-    protected function _registration_legend_items()
792
-    {
793
-        $fc_items = array(
794
-            'star-icon'        => array(
795
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
796
-                'desc'  => __('This is the Primary Registrant', 'event_espresso'),
797
-            ),
798
-            'view_details'     => array(
799
-                'class' => 'dashicons dashicons-clipboard',
800
-                'desc'  => __('View Registration Details', 'event_espresso'),
801
-            ),
802
-            'edit_attendee'    => array(
803
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
804
-                'desc'  => __('Edit Contact Details', 'event_espresso'),
805
-            ),
806
-            'view_transaction' => array(
807
-                'class' => 'dashicons dashicons-cart',
808
-                'desc'  => __('View Transaction Details', 'event_espresso'),
809
-            ),
810
-            'view_invoice'     => array(
811
-                'class' => 'dashicons dashicons-media-spreadsheet',
812
-                'desc'  => __('View Transaction Invoice', 'event_espresso'),
813
-            ),
814
-        );
815
-        if (EE_Registry::instance()->CAP->current_user_can('ee_send_message',
816
-            'espresso_registrations_resend_registration')
817
-        ) {
818
-            $fc_items['resend_registration'] = array(
819
-                'class' => 'dashicons dashicons-email-alt',
820
-                'desc'  => __('Resend Registration Details', 'event_espresso'),
821
-            );
822
-        } else {
823
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
824
-        }
825
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
826
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
827
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
828
-                $fc_items['view_related_messages'] = array(
829
-                    'class' => $related_for_icon['css_class'],
830
-                    'desc'  => $related_for_icon['label'],
831
-                );
832
-            }
833
-        }
834
-        $sc_items = array(
835
-            'approved_status'   => array(
836
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
837
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
838
-            ),
839
-            'pending_status'    => array(
840
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
841
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
842
-            ),
843
-            'wait_list'         => array(
844
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
845
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
846
-            ),
847
-            'incomplete_status' => array(
848
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
849
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'),
850
-            ),
851
-            'not_approved'      => array(
852
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
853
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
854
-            ),
855
-            'declined_status'   => array(
856
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
857
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
858
-            ),
859
-            'cancelled_status'  => array(
860
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
861
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
862
-            ),
863
-        );
864
-        return array_merge($fc_items, $sc_items);
865
-    }
866
-
867
-
868
-
869
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
870
-    /**
871
-     * @throws \EE_Error
872
-     */
873
-    protected function _registrations_overview_list_table()
874
-    {
875
-        $this->_template_args['admin_page_header'] = '';
876
-        $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
877
-        if ($EVT_ID) {
878
-            if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations',
879
-                'espresso_registrations_new_registration', $EVT_ID)
880
-            ) {
881
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant',
882
-                        array('event_id' => $EVT_ID), 'add-new-h2');
883
-            }
884
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
885
-            if ($event instanceof EE_Event) {
886
-                $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s',
887
-                    'event_espresso'), '<h3 style="line-height:1.5em;">',
888
-                    '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array(
889
-                        'action' => 'edit',
890
-                        'post'   => $event->ID(),
891
-                    ), EVENTS_ADMIN_URL) . '">&nbsp;' . $event->get('EVT_name') . '&nbsp;</a>&nbsp;', '</h3>');
892
-            }
893
-            $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
894
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
895
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
896
-                $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5);
897
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
898
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
899
-                $this->_template_args['admin_page_header'] .= $datetime->name();
900
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
901
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
902
-            }
903
-        }
904
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
905
-        $this->display_admin_list_table_page_with_no_sidebar();
906
-    }
907
-
908
-
909
-
910
-    /**
911
-     * This sets the _registration property for the registration details screen
912
-     *
913
-     * @access private
914
-     * @return bool
915
-     */
916
-    private function _set_registration_object()
917
-    {
918
-        //get out if we've already set the object
919
-        if (is_object($this->_registration)) {
920
-            return true;
921
-        }
922
-        $REG = EEM_Registration::instance();
923
-        $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
924
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
925
-            return true;
926
-        } else {
927
-            $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.',
928
-                'event_espresso'), $REG_ID);
929
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
930
-            $this->_registration = null;
931
-            return false;
932
-        }
933
-    }
934
-
935
-
936
-
937
-    /**
938
-     * get registrations for given parameters (used by list table)
939
-     *
940
-     * @param  int     $per_page   how many registrations displayed per page
941
-     * @param  boolean $count      return the count or objects
942
-     * @param  boolean $this_month whether to return for just this month
943
-     * @param  boolean $today      whether to return results for just today
944
-     * @throws \EE_Error
945
-     * @return mixed (int|array)  int = count || array of registration objects
946
-     */
947
-    public function get_registrations($per_page = 10, $count = false, $this_month = false, $today = false)
948
-    {
949
-        $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0
950
-            ? absint($this->_req_data['event_id']) : false;
951
-        $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0
952
-            ? absint($this->_req_data['EVT_CAT']) : false;
953
-        $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null;
954
-        $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status'])
955
-            : false;
956
-        $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range'])
957
-            : false;//should be like 2013-april
958
-        $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false;
959
-        $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false;
960
-        $start_date = false;
961
-        $end_date = false;
962
-        $_where = array();
963
-        $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? true : false;
964
-        $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? true : false;
965
-        //set orderby
966
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
967
-        switch ($this->_req_data['orderby']) {
968
-            case '_REG_ID':
969
-                $orderby = 'REG_ID';
970
-                break;
971
-            case '_Reg_status':
972
-                $orderby = 'STS_ID';
973
-                break;
974
-            case 'ATT_fname':
975
-                $orderby = 'Attendee.ATT_lname';
976
-                break;
977
-            case 'event_name':
978
-                $orderby = 'Event.EVT_name';
979
-                break;
980
-            case 'DTT_EVT_start':
981
-                $orderby = 'Event.Datetime.DTT_EVT_start';
982
-                break;
983
-            default: //'REG_date'
984
-                $orderby = 'REG_date';
985
-        }
986
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
987
-            : 'DESC';
988
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
989
-            ? $this->_req_data['paged'] : 1;
990
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
991
-            ? $this->_req_data['perpage'] : $per_page;
992
-        $offset = ($current_page - 1) * $per_page;
993
-        $limit = $count ? null : array($offset, $per_page);
994
-        if ($EVT_ID) {
995
-            $_where['EVT_ID'] = $EVT_ID;
996
-        }
997
-        if ($CAT_ID) {
998
-            $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
999
-        }
1000
-        //if DTT is included we filter by that datetime.
1001
-        if ($DTT_ID) {
1002
-            $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID;
1003
-        }
1004
-        if ($incomplete) {
1005
-            $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
1006
-        } else if ( ! $trash) {
1007
-            $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1008
-        }
1009
-        if ($reg_status) {
1010
-            $_where['STS_ID'] = $reg_status;
1011
-        }
1012
-        $this_year_r = date('Y', current_time('timestamp'));
1013
-        $time_start = ' 00:00:00';
1014
-        $time_end = ' 23:59:59';
1015
-        if ($today_a || $today) {
1016
-            $curdate = date('Y-m-d', current_time('timestamp'));
1017
-            $_where['REG_date'] = array(
1018
-                'BETWEEN',
1019
-                array(
1020
-                    EEM_Registration::instance()
1021
-                                    ->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'),
1022
-                    EEM_Registration::instance()
1023
-                                    ->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'),
1024
-                ),
1025
-            );
1026
-        } elseif ($this_month_a || $this_month) {
1027
-            $this_month_r = date('m', current_time('timestamp'));
1028
-            $days_this_month = date('t', current_time('timestamp'));
1029
-            $_where['REG_date'] = array(
1030
-                'BETWEEN',
1031
-                array(
1032
-                    EEM_Registration::instance()
1033
-                                    ->convert_datetime_for_query('REG_date',
1034
-                                        $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'),
1035
-                    EEM_Registration::instance()
1036
-                                    ->convert_datetime_for_query('REG_date',
1037
-                                        $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
1038
-                                        'Y-m-d H:i:s'),
1039
-                ),
1040
-            );
1041
-        } elseif ($month_range) {
1042
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1043
-            $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : '';
1044
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1045
-            $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01'));
1046
-            $_where['REG_date'] = array(
1047
-                'BETWEEN',
1048
-                array(
1049
-                    EEM_Registration::instance()
1050
-                                    ->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00',
1051
-                                        'Y-m-d H:i:s'),
1052
-                    EEM_Registration::instance()
1053
-                                    ->convert_datetime_for_query('REG_date',
1054
-                                        $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'),
1055
-                ),
1056
-            );
1057
-        } elseif ($start_date && $end_date) {
1058
-            throw new EE_Error("not yet supported");
1059
-        } elseif ($start_date) {
1060
-            throw new EE_Error("not yet supported");
1061
-        } elseif ($end_date) {
1062
-            throw new EE_Error("not yet supported");
1063
-        }
1064
-        if ( ! empty($this->_req_data['s'])) {
1065
-            $sstr = '%' . $this->_req_data['s'] . '%';
1066
-            $_where['OR'] = array(
1067
-                'Event.EVT_name'                          => array('LIKE', $sstr),
1068
-                'Event.EVT_desc'                          => array('LIKE', $sstr),
1069
-                'Event.EVT_short_desc'                    => array('LIKE', $sstr),
1070
-                'Attendee.ATT_full_name'                  => array('LIKE', $sstr),
1071
-                'Attendee.ATT_fname'                      => array('LIKE', $sstr),
1072
-                'Attendee.ATT_lname'                      => array('LIKE', $sstr),
1073
-                'Attendee.ATT_short_bio'                  => array('LIKE', $sstr),
1074
-                'Attendee.ATT_email'                      => array('LIKE', $sstr),
1075
-                'Attendee.ATT_address'                    => array('LIKE', $sstr),
1076
-                'Attendee.ATT_address2'                   => array('LIKE', $sstr),
1077
-                'Attendee.ATT_city'                       => array('LIKE', $sstr),
1078
-                'REG_final_price'                         => array('LIKE', $sstr),
1079
-                'REG_code'                                => array('LIKE', $sstr),
1080
-                'REG_count'                               => array('LIKE', $sstr),
1081
-                'REG_group_size'                          => array('LIKE', $sstr),
1082
-                'Ticket.TKT_name'                         => array('LIKE', $sstr),
1083
-                'Ticket.TKT_description'                  => array('LIKE', $sstr),
1084
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr),
1085
-            );
1086
-        }
1087
-        //capability checks
1088
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
1089
-            $_where['AND'] = array(
1090
-                'Event.EVT_wp_user' => get_current_user_id(),
1091
-            );
1092
-        }
1093
-        if ($count) {
1094
-            if ($trash) {
1095
-                return EEM_Registration::instance()->count_deleted(array($_where));
1096
-            } else if ($incomplete) {
1097
-                return EEM_Registration::instance()->count(array($_where));
1098
-            } else {
1099
-                return EEM_Registration::instance()->count(array(
1100
-                    $_where,
1101
-                    'default_where_conditions' => 'this_model_only',
1102
-                ));
1103
-            }
1104
-        } else {
1105
-            //make sure we remove default where conditions cause all registrations matching query are returned
1106
-            $query_params = array(
1107
-                $_where,
1108
-                'order_by'                 => array($orderby => $sort),
1109
-                'default_where_conditions' => 'this_model_only',
1110
-            );
1111
-            if ($per_page !== -1) {
1112
-                $query_params['limit'] = $limit;
1113
-            }
1114
-            $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params)
1115
-                : EEM_Registration::instance()->get_all($query_params);
1116
-            if ($EVT_ID
1117
-                && isset($registrations[0])
1118
-                && $registrations[0] instanceof EE_Registration
1119
-                && $registrations[0]->event_obj()
1120
-            ) {
1121
-                $first_registration = $registrations[0];
1122
-                //EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1123
-                $event_name = $first_registration->event_obj()->name();
1124
-                $event_date = $first_registration->date_obj()
1125
-                                                 ->start_date_and_time('l F j, Y,',
1126
-                                                     'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1127
-                // edit event link
1128
-                if ($event_name != '') {
1129
-                    $edit_event_url = self::add_query_args_and_nonce(array(
1130
-                        'action' => 'edit_event',
1131
-                        'EVT_ID' => $EVT_ID,
1132
-                    ), EVENTS_ADMIN_URL);
1133
-                    $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ',
1134
-                            'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>';
1135
-                    $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>';
1136
-                }
1137
-                $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL);
1138
-                $back_2_reg_lnk = '<a href="'
1139
-                                  . $back_2_reg_url
1140
-                                  . '" title="'
1141
-                                  . esc_attr__('click to return to viewing all registrations ', 'event_espresso')
1142
-                                  . '">&laquo; '
1143
-                                  . __('Back to All Registrations', 'event_espresso')
1144
-                                  . '</a>';
1145
-                $this->_template_args['before_admin_page_content'] = '
27
+	/**
28
+	 * @var EE_Registration
29
+	 */
30
+	private $_registration;
31
+
32
+	/**
33
+	 * @var EE_Event
34
+	 */
35
+	private $_reg_event;
36
+
37
+	/**
38
+	 * @var EE_Session
39
+	 */
40
+	private        $_session;
41
+
42
+	private static $_reg_status;
43
+
44
+	/**
45
+	 * Form for displaying the custom questions for this registration.
46
+	 * This gets used a few times throughout the request so its best to cache it
47
+	 *
48
+	 * @var EE_Registration_Custom_Questions_Form
49
+	 */
50
+	protected $_reg_custom_questions_form = null;
51
+
52
+
53
+
54
+	/**
55
+	 *        constructor
56
+	 *
57
+	 * @Constructor
58
+	 * @access public
59
+	 * @param bool $routing
60
+	 * @return Registrations_Admin_Page
61
+	 */
62
+	public function __construct($routing = true)
63
+	{
64
+		parent::__construct($routing);
65
+		add_action('wp_loaded', array($this, 'wp_loaded'));
66
+	}
67
+
68
+
69
+
70
+	public function wp_loaded()
71
+	{
72
+		// when adding a new registration...
73
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') {
74
+			EE_System::do_not_cache();
75
+			if ( ! isset($this->_req_data['processing_registration'])
76
+				 || absint($this->_req_data['processing_registration']) !== 1
77
+			) {
78
+				// and it's NOT the attendee information reg step
79
+				// force cookie expiration by setting time to last week
80
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
81
+				// and update the global
82
+				$_COOKIE['ee_registration_added'] = 0;
83
+			}
84
+		}
85
+	}
86
+
87
+
88
+
89
+	protected function _init_page_props()
90
+	{
91
+		$this->page_slug = REG_PG_SLUG;
92
+		$this->_admin_base_url = REG_ADMIN_URL;
93
+		$this->_admin_base_path = REG_ADMIN;
94
+		$this->page_label = __('Registrations', 'event_espresso');
95
+		$this->_cpt_routes = array(
96
+			'add_new_attendee' => 'espresso_attendees',
97
+			'edit_attendee'    => 'espresso_attendees',
98
+			'insert_attendee'  => 'espresso_attendees',
99
+			'update_attendee'  => 'espresso_attendees',
100
+		);
101
+		$this->_cpt_model_names = array(
102
+			'add_new_attendee' => 'EEM_Attendee',
103
+			'edit_attendee'    => 'EEM_Attendee',
104
+		);
105
+		$this->_cpt_edit_routes = array(
106
+			'espresso_attendees' => 'edit_attendee',
107
+		);
108
+		$this->_pagenow_map = array(
109
+			'add_new_attendee' => 'post-new.php',
110
+			'edit_attendee'    => 'post.php',
111
+			'trash'            => 'post.php',
112
+		);
113
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
114
+		//add filters so that the comment urls don't take users to a confusing 404 page
115
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
116
+	}
117
+
118
+
119
+
120
+	public function clear_comment_link($link, $comment, $args)
121
+	{
122
+		//gotta make sure this only happens on this route
123
+		$post_type = get_post_type($comment->comment_post_ID);
124
+		if ($post_type == 'espresso_attendees') {
125
+			return '#commentsdiv';
126
+		}
127
+		return $link;
128
+	}
129
+
130
+
131
+
132
+	protected function _ajax_hooks()
133
+	{
134
+		//todo: all hooks for registrations ajax goes in here
135
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
136
+	}
137
+
138
+
139
+
140
+	protected function _define_page_props()
141
+	{
142
+		$this->_admin_page_title = $this->page_label;
143
+		$this->_labels = array(
144
+			'buttons'                      => array(
145
+				'add-registrant'      => __('Add New Registration', 'event_espresso'),
146
+				'add-attendee'        => __('Add Contact', 'event_espresso'),
147
+				'edit'                => __('Edit Contact', 'event_espresso'),
148
+				'report'              => __("Event Registrations CSV Report", "event_espresso"),
149
+				'report_all'          => __('All Registrations CSV Report', 'event_espresso'),
150
+				'contact_list_report' => __('Contact List Report', 'event_espresso'),
151
+				'contact_list_export' => __("Export Data", "event_espresso"),
152
+			),
153
+			'publishbox'                   => array(
154
+				'add_new_attendee' => __("Add Contact Record", 'event_espresso'),
155
+				'edit_attendee'    => __("Update Contact Record", 'event_espresso'),
156
+			),
157
+			'hide_add_button_on_cpt_route' => array(
158
+				'edit_attendee' => true,
159
+			),
160
+		);
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 *        grab url requests and route them
167
+	 *
168
+	 * @access private
169
+	 * @return void
170
+	 */
171
+	public function _set_page_routes()
172
+	{
173
+		$this->_get_registration_status_array();
174
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175
+			? $this->_req_data['_REG_ID'] : 0;
176
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
177
+			? $this->_req_data['ATT_ID'] : 0;
178
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post']
179
+			: $att_id;
180
+		$this->_page_routes = array(
181
+			'default' => array(
182
+				'func'       => '_registrations_overview_list_table',
183
+				'capability' => 'ee_read_registrations',
184
+			),
185
+			'view_registration' => array(
186
+				'func'       => '_registration_details',
187
+				'capability' => 'ee_read_registration',
188
+				'obj_id'     => $reg_id,
189
+			),
190
+			'edit_registration' => array(
191
+				'func'               => '_update_attendee_registration_form',
192
+				'noheader'           => true,
193
+				'headers_sent_route' => 'view_registration',
194
+				'capability'         => 'ee_edit_registration',
195
+				'obj_id'             => $reg_id,
196
+				'_REG_ID'            => $reg_id,
197
+			),
198
+			'trash_registrations' => array(
199
+				'func'       => '_trash_or_restore_registrations',
200
+				'args'       => array('trash' => true),
201
+				'noheader'   => true,
202
+				'capability' => 'ee_delete_registrations',
203
+			),
204
+			'restore_registrations' => array(
205
+				'func'       => '_trash_or_restore_registrations',
206
+				'args'       => array('trash' => false),
207
+				'noheader'   => true,
208
+				'capability' => 'ee_delete_registrations',
209
+			),
210
+			'delete_registrations' => array(
211
+				'func'       => '_delete_registrations',
212
+				'noheader'   => true,
213
+				'capability' => 'ee_delete_registrations',
214
+			),
215
+			'new_registration' => array(
216
+				'func'       => 'new_registration',
217
+				'capability' => 'ee_edit_registrations',
218
+			),
219
+			'process_reg_step' => array(
220
+				'func'       => 'process_reg_step',
221
+				'noheader'   => true,
222
+				'capability' => 'ee_edit_registrations',
223
+			),
224
+			'redirect_to_txn' => array(
225
+				'func'       => 'redirect_to_txn',
226
+				'noheader'   => true,
227
+				'capability' => 'ee_edit_registrations',
228
+			),
229
+			'change_reg_status' => array(
230
+				'func'       => '_change_reg_status',
231
+				'noheader'   => true,
232
+				'capability' => 'ee_edit_registration',
233
+				'obj_id'     => $reg_id,
234
+			),
235
+			'approve_registration' => array(
236
+				'func'       => 'approve_registration',
237
+				'noheader'   => true,
238
+				'capability' => 'ee_edit_registration',
239
+				'obj_id'     => $reg_id,
240
+			),
241
+			'approve_and_notify_registration' => array(
242
+				'func'       => 'approve_registration',
243
+				'noheader'   => true,
244
+				'args'       => array(true),
245
+				'capability' => 'ee_edit_registration',
246
+				'obj_id'     => $reg_id,
247
+			),
248
+			'decline_registration' => array(
249
+				'func'       => 'decline_registration',
250
+				'noheader'   => true,
251
+				'capability' => 'ee_edit_registration',
252
+				'obj_id'     => $reg_id,
253
+			),
254
+			'decline_and_notify_registration' => array(
255
+				'func'       => 'decline_registration',
256
+				'noheader'   => true,
257
+				'args'       => array(true),
258
+				'capability' => 'ee_edit_registration',
259
+				'obj_id'     => $reg_id,
260
+			),
261
+			'pending_registration' => array(
262
+				'func'       => 'pending_registration',
263
+				'noheader'   => true,
264
+				'capability' => 'ee_edit_registration',
265
+				'obj_id'     => $reg_id,
266
+			),
267
+			'pending_and_notify_registration' => array(
268
+				'func'       => 'pending_registration',
269
+				'noheader'   => true,
270
+				'args'       => array(true),
271
+				'capability' => 'ee_edit_registration',
272
+				'obj_id'     => $reg_id,
273
+			),
274
+			'no_approve_registration' => array(
275
+				'func'       => 'not_approve_registration',
276
+				'noheader'   => true,
277
+				'capability' => 'ee_edit_registration',
278
+				'obj_id'     => $reg_id,
279
+			),
280
+			'no_approve_and_notify_registration' => array(
281
+				'func'       => 'not_approve_registration',
282
+				'noheader'   => true,
283
+				'args'       => array(true),
284
+				'capability' => 'ee_edit_registration',
285
+				'obj_id'     => $reg_id,
286
+			),
287
+			'cancel_registration' => array(
288
+				'func'       => 'cancel_registration',
289
+				'noheader'   => true,
290
+				'capability' => 'ee_edit_registration',
291
+				'obj_id'     => $reg_id,
292
+			),
293
+			'cancel_and_notify_registration' => array(
294
+				'func'       => 'cancel_registration',
295
+				'noheader'   => true,
296
+				'args'       => array(true),
297
+				'capability' => 'ee_edit_registration',
298
+				'obj_id'     => $reg_id,
299
+			),
300
+			'contact_list' => array(
301
+				'func'       => '_attendee_contact_list_table',
302
+				'capability' => 'ee_read_contacts',
303
+			),
304
+			'add_new_attendee' => array(
305
+				'func' => '_create_new_cpt_item',
306
+				'args' => array(
307
+					'new_attendee' => true,
308
+					'capability'   => 'ee_edit_contacts',
309
+				),
310
+			),
311
+			'edit_attendee' => array(
312
+				'func'       => '_edit_cpt_item',
313
+				'capability' => 'ee_edit_contacts',
314
+				'obj_id'     => $att_id,
315
+			),
316
+			'duplicate_attendee' => array(
317
+				'func'       => '_duplicate_attendee',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_contacts',
320
+				'obj_id'     => $att_id,
321
+			),
322
+			'insert_attendee' => array(
323
+				'func'       => '_insert_or_update_attendee',
324
+				'args'       => array(
325
+					'new_attendee' => true,
326
+				),
327
+				'noheader'   => true,
328
+				'capability' => 'ee_edit_contacts',
329
+			),
330
+			'update_attendee' => array(
331
+				'func'       => '_insert_or_update_attendee',
332
+				'args'       => array(
333
+					'new_attendee' => false,
334
+				),
335
+				'noheader'   => true,
336
+				'capability' => 'ee_edit_contacts',
337
+				'obj_id'     => $att_id,
338
+			),
339
+			'trash_attendees' => array(
340
+				'func'       => '_trash_or_restore_attendees',
341
+				'args'       => array(
342
+					'trash' => true,
343
+				),
344
+				'noheader'   => true,
345
+				'capability' => 'ee_delete_contacts',
346
+				'obj_id'     => $att_id,
347
+			),
348
+			'restore_attendees'    => array(
349
+				'func'       => '_trash_or_restore_attendees',
350
+				'args'       => array(
351
+					'trash' => false,
352
+				),
353
+				'noheader'   => true,
354
+				'capability' => 'ee_delete_contacts',
355
+				'obj_id'     => $att_id,
356
+			),
357
+			'resend_registration'  => array(
358
+				'func'       => '_resend_registration',
359
+				'noheader'   => true,
360
+				'capability' => 'ee_send_message',
361
+			),
362
+			'registrations_report' => array(
363
+				'func'       => '_registrations_report',
364
+				'noheader'   => true,
365
+				'capability' => 'ee_read_registrations',
366
+			),
367
+			'contact_list_export'  => array(
368
+				'func'       => '_contact_list_export',
369
+				'noheader'   => true,
370
+				'capability' => 'export',
371
+			),
372
+			'contact_list_report'  => array(
373
+				'func'       => '_contact_list_report',
374
+				'noheader'   => true,
375
+				'capability' => 'ee_read_contacts',
376
+			),
377
+		);
378
+	}
379
+
380
+
381
+
382
+	protected function _set_page_config()
383
+	{
384
+		$this->_page_config = array(
385
+			'default' => array(
386
+				'nav'           => array(
387
+					'label' => __('Overview', 'event_espresso'),
388
+					'order' => 5,
389
+				),
390
+				'help_tabs'     => array(
391
+					'registrations_overview_help_tab'                       => array(
392
+						'title'    => __('Registrations Overview', 'event_espresso'),
393
+						'filename' => 'registrations_overview',
394
+					),
395
+					'registrations_overview_table_column_headings_help_tab' => array(
396
+						'title'    => __('Registrations Table Column Headings', 'event_espresso'),
397
+						'filename' => 'registrations_overview_table_column_headings',
398
+					),
399
+					'registrations_overview_filters_help_tab'               => array(
400
+						'title'    => __('Registration Filters', 'event_espresso'),
401
+						'filename' => 'registrations_overview_filters',
402
+					),
403
+					'registrations_overview_views_help_tab'                 => array(
404
+						'title'    => __('Registration Views', 'event_espresso'),
405
+						'filename' => 'registrations_overview_views',
406
+					),
407
+					'registrations_regoverview_other_help_tab'              => array(
408
+						'title'    => __('Registrations Other', 'event_espresso'),
409
+						'filename' => 'registrations_overview_other',
410
+					),
411
+				),
412
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
413
+				'qtips'         => array('Registration_List_Table_Tips'),
414
+				'list_table'    => 'EE_Registrations_List_Table',
415
+				'require_nonce' => false,
416
+			),
417
+			'view_registration' => array(
418
+				'nav'           => array(
419
+					'label'      => __('REG Details', 'event_espresso'),
420
+					'order'      => 15,
421
+					'url'        => isset($this->_req_data['_REG_ID'])
422
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
423
+						: $this->_admin_base_url,
424
+					'persistent' => false,
425
+				),
426
+				'help_tabs'     => array(
427
+					'registrations_details_help_tab'                    => array(
428
+						'title'    => __('Registration Details', 'event_espresso'),
429
+						'filename' => 'registrations_details',
430
+					),
431
+					'registrations_details_table_help_tab'              => array(
432
+						'title'    => __('Registration Details Table', 'event_espresso'),
433
+						'filename' => 'registrations_details_table',
434
+					),
435
+					'registrations_details_form_answers_help_tab'       => array(
436
+						'title'    => __('Registration Form Answers', 'event_espresso'),
437
+						'filename' => 'registrations_details_form_answers',
438
+					),
439
+					'registrations_details_registrant_details_help_tab' => array(
440
+						'title'    => __('Contact Details', 'event_espresso'),
441
+						'filename' => 'registrations_details_registrant_details',
442
+					),
443
+				),
444
+				'help_tour'     => array('Registration_Details_Help_Tour'),
445
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
446
+					array('_registration_details_metaboxes')),
447
+				'require_nonce' => false,
448
+			),
449
+			'new_registration' => array(
450
+				'nav'           => array(
451
+					'label'      => __('Add New Registration', 'event_espresso'),
452
+					'url'        => '#',
453
+					'order'      => 15,
454
+					'persistent' => false,
455
+				),
456
+				'metaboxes'     => $this->_default_espresso_metaboxes,
457
+				'labels'        => array(
458
+					'publishbox' => __('Save Registration', 'event_espresso'),
459
+				),
460
+				'require_nonce' => false,
461
+			),
462
+			'add_new_attendee' => array(
463
+				'nav'           => array(
464
+					'label'      => __('Add Contact', 'event_espresso'),
465
+					'order'      => 15,
466
+					'persistent' => false,
467
+				),
468
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
469
+					array('_publish_post_box', 'attendee_editor_metaboxes')),
470
+				'require_nonce' => false,
471
+			),
472
+			'edit_attendee' => array(
473
+				'nav'           => array(
474
+					'label'      => __('Edit Contact', 'event_espresso'),
475
+					'order'      => 15,
476
+					'persistent' => false,
477
+					'url'        => isset($this->_req_data['ATT_ID'])
478
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
479
+						: $this->_admin_base_url,
480
+				),
481
+				'metaboxes'     => array('attendee_editor_metaboxes'),
482
+				'require_nonce' => false,
483
+			),
484
+			'contact_list' => array(
485
+				'nav'           => array(
486
+					'label' => __('Contact List', 'event_espresso'),
487
+					'order' => 20,
488
+				),
489
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
490
+				'help_tabs'     => array(
491
+					'registrations_contact_list_help_tab'                       => array(
492
+						'title'    => __('Registrations Contact List', 'event_espresso'),
493
+						'filename' => 'registrations_contact_list',
494
+					),
495
+					'registrations_contact-list_table_column_headings_help_tab' => array(
496
+						'title'    => __('Contact List Table Column Headings', 'event_espresso'),
497
+						'filename' => 'registrations_contact_list_table_column_headings',
498
+					),
499
+					'registrations_contact_list_views_help_tab'                 => array(
500
+						'title'    => __('Contact List Views', 'event_espresso'),
501
+						'filename' => 'registrations_contact_list_views',
502
+					),
503
+					'registrations_contact_list_other_help_tab'                 => array(
504
+						'title'    => __('Contact List Other', 'event_espresso'),
505
+						'filename' => 'registrations_contact_list_other',
506
+					),
507
+				),
508
+				'help_tour'     => array('Contact_List_Help_Tour'),
509
+				'metaboxes'     => array(),
510
+				'require_nonce' => false,
511
+			),
512
+			//override default cpt routes
513
+			'create_new'   => '',
514
+			'edit'         => '',
515
+		);
516
+	}
517
+
518
+
519
+
520
+	/**
521
+	 * The below methods aren't used by this class currently
522
+	 */
523
+	protected function _add_screen_options()
524
+	{
525
+	}
526
+
527
+
528
+
529
+	protected function _add_feature_pointers()
530
+	{
531
+	}
532
+
533
+
534
+
535
+	public function admin_init()
536
+	{
537
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes',
538
+			'event_espresso');
539
+	}
540
+
541
+
542
+
543
+	public function admin_notices()
544
+	{
545
+	}
546
+
547
+
548
+
549
+	public function admin_footer_scripts()
550
+	{
551
+	}
552
+
553
+
554
+
555
+	/**
556
+	 *        get list of registration statuses
557
+	 *
558
+	 * @access private
559
+	 * @return void
560
+	 */
561
+	private function _get_registration_status_array()
562
+	{
563
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
564
+	}
565
+
566
+
567
+
568
+	protected function _add_screen_options_default()
569
+	{
570
+		$this->_per_page_screen_option();
571
+	}
572
+
573
+
574
+
575
+	protected function _add_screen_options_contact_list()
576
+	{
577
+		$page_title = $this->_admin_page_title;
578
+		$this->_admin_page_title = __("Contacts", 'event_espresso');
579
+		$this->_per_page_screen_option();
580
+		$this->_admin_page_title = $page_title;
581
+	}
582
+
583
+
584
+
585
+	public function load_scripts_styles()
586
+	{
587
+		//style
588
+		//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
589
+		wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'),
590
+			EVENT_ESPRESSO_VERSION);
591
+		wp_enqueue_style('espresso_reg');
592
+		//script
593
+		wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js',
594
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
595
+		wp_enqueue_script('espresso_reg');
596
+	}
597
+
598
+
599
+
600
+	public function load_scripts_styles_edit_attendee()
601
+	{
602
+		//stuff to only show up on our attendee edit details page.
603
+		$attendee_details_translations = array(
604
+			'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'),
605
+				$this->_cpt_model_obj->get_datetime('ATT_created')),
606
+		);
607
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
608
+		wp_enqueue_script('jquery-validate');
609
+	}
610
+
611
+
612
+
613
+	public function load_scripts_styles_view_registration()
614
+	{
615
+		//styles
616
+		wp_enqueue_style('espresso-ui-theme');
617
+		//scripts
618
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
619
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
620
+	}
621
+
622
+
623
+
624
+	public function load_scripts_styles_contact_list()
625
+	{
626
+		wp_deregister_style('espresso_reg');
627
+		wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'),
628
+			EVENT_ESPRESSO_VERSION);
629
+		wp_enqueue_style('espresso_att');
630
+	}
631
+
632
+
633
+
634
+	public function load_scripts_styles_new_registration()
635
+	{
636
+		wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'),
637
+			EVENT_ESPRESSO_VERSION, true);
638
+		wp_enqueue_script('ee-spco-for-admin');
639
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
640
+		EE_Form_Section_Proper::wp_enqueue_scripts();
641
+		EED_Ticket_Selector::load_tckt_slctr_assets();
642
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
643
+	}
644
+
645
+
646
+
647
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
648
+	{
649
+		add_filter('FHEE_load_EE_messages', '__return_true');
650
+	}
651
+
652
+
653
+
654
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
655
+	{
656
+		add_filter('FHEE_load_EE_messages', '__return_true');
657
+	}
658
+
659
+
660
+
661
+	protected function _set_list_table_views_default()
662
+	{
663
+		//for notification related bulk actions we need to make sure only active messengers have an option.
664
+		EED_Messages::set_autoloaders();
665
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
666
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
667
+		$active_mts = $message_resource_manager->list_of_active_message_types();
668
+		//key= bulk_action_slug, value= message type.
669
+		$match_array = array(
670
+			'approve_registration'    => 'registration',
671
+			'decline_registration'    => 'declined_registration',
672
+			'pending_registration'    => 'pending_approval',
673
+			'no_approve_registration' => 'not_approved_registration',
674
+			'cancel_registration'     => 'cancelled_registration',
675
+		);
676
+		/** setup reg status bulk actions **/
677
+		$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
678
+		if (in_array($match_array['approve_registration'], $active_mts)
679
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
680
+		) {
681
+			$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations',
682
+				'event_espresso');
683
+		}
684
+		$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
685
+		if (in_array($match_array['decline_registration'], $active_mts)
686
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
687
+		) {
688
+			$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations',
689
+				'event_espresso');
690
+		}
691
+		$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
692
+		if (in_array($match_array['pending_registration'], $active_mts)
693
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
694
+		) {
695
+			$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify',
696
+				'event_espresso');
697
+		}
698
+		$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
699
+		if (in_array($match_array['no_approve_registration'], $active_mts)
700
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
701
+		) {
702
+			$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify',
703
+				'event_espresso');
704
+		}
705
+		$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
706
+		if (in_array($match_array['cancel_registration'], $active_mts)
707
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
708
+		) {
709
+			$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify',
710
+				'event_espresso');
711
+		}
712
+		$this->_views = array(
713
+			'all'   => array(
714
+				'slug'        => 'all',
715
+				'label'       => __('View All Registrations', 'event_espresso'),
716
+				'count'       => 0,
717
+				'bulk_action' => array_merge($def_reg_status_actions, array(
718
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
719
+				)),
720
+			),
721
+			'month' => array(
722
+				'slug'        => 'month',
723
+				'label'       => __('This Month', 'event_espresso'),
724
+				'count'       => 0,
725
+				'bulk_action' => array_merge($def_reg_status_actions, array(
726
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
727
+				)),
728
+			),
729
+			'today' => array(
730
+				'slug'        => 'today',
731
+				'label'       => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
732
+				'count'       => 0,
733
+				'bulk_action' => array_merge($def_reg_status_actions, array(
734
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
735
+				)),
736
+			),
737
+		);
738
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
739
+			'espresso_registrations_delete_registration')
740
+		) {
741
+			$this->_views['incomplete'] = array(
742
+				'slug'        => 'incomplete',
743
+				'label'       => __('Incomplete', 'event_espresso'),
744
+				'count'       => 0,
745
+				'bulk_action' => array(
746
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
747
+				),
748
+			);
749
+			$this->_views['trash'] = array(
750
+				'slug'        => 'trash',
751
+				'label'       => __('Trash', 'event_espresso'),
752
+				'count'       => 0,
753
+				'bulk_action' => array(
754
+					'restore_registrations' => __('Restore Registrations', 'event_espresso'),
755
+					'delete_registrations'  => __('Delete Registrations Permanently', 'event_espresso'),
756
+				),
757
+			);
758
+		}
759
+	}
760
+
761
+
762
+
763
+	protected function _set_list_table_views_contact_list()
764
+	{
765
+		$this->_views = array(
766
+			'in_use' => array(
767
+				'slug'        => 'in_use',
768
+				'label'       => __('In Use', 'event_espresso'),
769
+				'count'       => 0,
770
+				'bulk_action' => array(
771
+					'trash_attendees' => __('Move to Trash', 'event_espresso'),
772
+				),
773
+			),
774
+		);
775
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts',
776
+			'espresso_registrations_trash_attendees')
777
+		) {
778
+			$this->_views['trash'] = array(
779
+				'slug'        => 'trash',
780
+				'label'       => __('Trash', 'event_espresso'),
781
+				'count'       => 0,
782
+				'bulk_action' => array(
783
+					'restore_attendees' => __('Restore from Trash', 'event_espresso'),
784
+				),
785
+			);
786
+		}
787
+	}
788
+
789
+
790
+
791
+	protected function _registration_legend_items()
792
+	{
793
+		$fc_items = array(
794
+			'star-icon'        => array(
795
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
796
+				'desc'  => __('This is the Primary Registrant', 'event_espresso'),
797
+			),
798
+			'view_details'     => array(
799
+				'class' => 'dashicons dashicons-clipboard',
800
+				'desc'  => __('View Registration Details', 'event_espresso'),
801
+			),
802
+			'edit_attendee'    => array(
803
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
804
+				'desc'  => __('Edit Contact Details', 'event_espresso'),
805
+			),
806
+			'view_transaction' => array(
807
+				'class' => 'dashicons dashicons-cart',
808
+				'desc'  => __('View Transaction Details', 'event_espresso'),
809
+			),
810
+			'view_invoice'     => array(
811
+				'class' => 'dashicons dashicons-media-spreadsheet',
812
+				'desc'  => __('View Transaction Invoice', 'event_espresso'),
813
+			),
814
+		);
815
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message',
816
+			'espresso_registrations_resend_registration')
817
+		) {
818
+			$fc_items['resend_registration'] = array(
819
+				'class' => 'dashicons dashicons-email-alt',
820
+				'desc'  => __('Resend Registration Details', 'event_espresso'),
821
+			);
822
+		} else {
823
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
824
+		}
825
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
826
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
827
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
828
+				$fc_items['view_related_messages'] = array(
829
+					'class' => $related_for_icon['css_class'],
830
+					'desc'  => $related_for_icon['label'],
831
+				);
832
+			}
833
+		}
834
+		$sc_items = array(
835
+			'approved_status'   => array(
836
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
837
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
838
+			),
839
+			'pending_status'    => array(
840
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
841
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
842
+			),
843
+			'wait_list'         => array(
844
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
845
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
846
+			),
847
+			'incomplete_status' => array(
848
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
849
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'),
850
+			),
851
+			'not_approved'      => array(
852
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
853
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
854
+			),
855
+			'declined_status'   => array(
856
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
857
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
858
+			),
859
+			'cancelled_status'  => array(
860
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
861
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
862
+			),
863
+		);
864
+		return array_merge($fc_items, $sc_items);
865
+	}
866
+
867
+
868
+
869
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
870
+	/**
871
+	 * @throws \EE_Error
872
+	 */
873
+	protected function _registrations_overview_list_table()
874
+	{
875
+		$this->_template_args['admin_page_header'] = '';
876
+		$EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
877
+		if ($EVT_ID) {
878
+			if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations',
879
+				'espresso_registrations_new_registration', $EVT_ID)
880
+			) {
881
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant',
882
+						array('event_id' => $EVT_ID), 'add-new-h2');
883
+			}
884
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
885
+			if ($event instanceof EE_Event) {
886
+				$this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s',
887
+					'event_espresso'), '<h3 style="line-height:1.5em;">',
888
+					'<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array(
889
+						'action' => 'edit',
890
+						'post'   => $event->ID(),
891
+					), EVENTS_ADMIN_URL) . '">&nbsp;' . $event->get('EVT_name') . '&nbsp;</a>&nbsp;', '</h3>');
892
+			}
893
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
894
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
895
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
896
+				$this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5);
897
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
898
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
899
+				$this->_template_args['admin_page_header'] .= $datetime->name();
900
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
901
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
902
+			}
903
+		}
904
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
905
+		$this->display_admin_list_table_page_with_no_sidebar();
906
+	}
907
+
908
+
909
+
910
+	/**
911
+	 * This sets the _registration property for the registration details screen
912
+	 *
913
+	 * @access private
914
+	 * @return bool
915
+	 */
916
+	private function _set_registration_object()
917
+	{
918
+		//get out if we've already set the object
919
+		if (is_object($this->_registration)) {
920
+			return true;
921
+		}
922
+		$REG = EEM_Registration::instance();
923
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
924
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
925
+			return true;
926
+		} else {
927
+			$error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.',
928
+				'event_espresso'), $REG_ID);
929
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
930
+			$this->_registration = null;
931
+			return false;
932
+		}
933
+	}
934
+
935
+
936
+
937
+	/**
938
+	 * get registrations for given parameters (used by list table)
939
+	 *
940
+	 * @param  int     $per_page   how many registrations displayed per page
941
+	 * @param  boolean $count      return the count or objects
942
+	 * @param  boolean $this_month whether to return for just this month
943
+	 * @param  boolean $today      whether to return results for just today
944
+	 * @throws \EE_Error
945
+	 * @return mixed (int|array)  int = count || array of registration objects
946
+	 */
947
+	public function get_registrations($per_page = 10, $count = false, $this_month = false, $today = false)
948
+	{
949
+		$EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0
950
+			? absint($this->_req_data['event_id']) : false;
951
+		$CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0
952
+			? absint($this->_req_data['EVT_CAT']) : false;
953
+		$DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null;
954
+		$reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status'])
955
+			: false;
956
+		$month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range'])
957
+			: false;//should be like 2013-april
958
+		$today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false;
959
+		$this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false;
960
+		$start_date = false;
961
+		$end_date = false;
962
+		$_where = array();
963
+		$trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? true : false;
964
+		$incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? true : false;
965
+		//set orderby
966
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
967
+		switch ($this->_req_data['orderby']) {
968
+			case '_REG_ID':
969
+				$orderby = 'REG_ID';
970
+				break;
971
+			case '_Reg_status':
972
+				$orderby = 'STS_ID';
973
+				break;
974
+			case 'ATT_fname':
975
+				$orderby = 'Attendee.ATT_lname';
976
+				break;
977
+			case 'event_name':
978
+				$orderby = 'Event.EVT_name';
979
+				break;
980
+			case 'DTT_EVT_start':
981
+				$orderby = 'Event.Datetime.DTT_EVT_start';
982
+				break;
983
+			default: //'REG_date'
984
+				$orderby = 'REG_date';
985
+		}
986
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
987
+			: 'DESC';
988
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
989
+			? $this->_req_data['paged'] : 1;
990
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
991
+			? $this->_req_data['perpage'] : $per_page;
992
+		$offset = ($current_page - 1) * $per_page;
993
+		$limit = $count ? null : array($offset, $per_page);
994
+		if ($EVT_ID) {
995
+			$_where['EVT_ID'] = $EVT_ID;
996
+		}
997
+		if ($CAT_ID) {
998
+			$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
999
+		}
1000
+		//if DTT is included we filter by that datetime.
1001
+		if ($DTT_ID) {
1002
+			$_where['Ticket.Datetime.DTT_ID'] = $DTT_ID;
1003
+		}
1004
+		if ($incomplete) {
1005
+			$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
1006
+		} else if ( ! $trash) {
1007
+			$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1008
+		}
1009
+		if ($reg_status) {
1010
+			$_where['STS_ID'] = $reg_status;
1011
+		}
1012
+		$this_year_r = date('Y', current_time('timestamp'));
1013
+		$time_start = ' 00:00:00';
1014
+		$time_end = ' 23:59:59';
1015
+		if ($today_a || $today) {
1016
+			$curdate = date('Y-m-d', current_time('timestamp'));
1017
+			$_where['REG_date'] = array(
1018
+				'BETWEEN',
1019
+				array(
1020
+					EEM_Registration::instance()
1021
+									->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'),
1022
+					EEM_Registration::instance()
1023
+									->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'),
1024
+				),
1025
+			);
1026
+		} elseif ($this_month_a || $this_month) {
1027
+			$this_month_r = date('m', current_time('timestamp'));
1028
+			$days_this_month = date('t', current_time('timestamp'));
1029
+			$_where['REG_date'] = array(
1030
+				'BETWEEN',
1031
+				array(
1032
+					EEM_Registration::instance()
1033
+									->convert_datetime_for_query('REG_date',
1034
+										$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'),
1035
+					EEM_Registration::instance()
1036
+									->convert_datetime_for_query('REG_date',
1037
+										$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
1038
+										'Y-m-d H:i:s'),
1039
+				),
1040
+			);
1041
+		} elseif ($month_range) {
1042
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1043
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : '';
1044
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1045
+			$days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01'));
1046
+			$_where['REG_date'] = array(
1047
+				'BETWEEN',
1048
+				array(
1049
+					EEM_Registration::instance()
1050
+									->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00',
1051
+										'Y-m-d H:i:s'),
1052
+					EEM_Registration::instance()
1053
+									->convert_datetime_for_query('REG_date',
1054
+										$year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'),
1055
+				),
1056
+			);
1057
+		} elseif ($start_date && $end_date) {
1058
+			throw new EE_Error("not yet supported");
1059
+		} elseif ($start_date) {
1060
+			throw new EE_Error("not yet supported");
1061
+		} elseif ($end_date) {
1062
+			throw new EE_Error("not yet supported");
1063
+		}
1064
+		if ( ! empty($this->_req_data['s'])) {
1065
+			$sstr = '%' . $this->_req_data['s'] . '%';
1066
+			$_where['OR'] = array(
1067
+				'Event.EVT_name'                          => array('LIKE', $sstr),
1068
+				'Event.EVT_desc'                          => array('LIKE', $sstr),
1069
+				'Event.EVT_short_desc'                    => array('LIKE', $sstr),
1070
+				'Attendee.ATT_full_name'                  => array('LIKE', $sstr),
1071
+				'Attendee.ATT_fname'                      => array('LIKE', $sstr),
1072
+				'Attendee.ATT_lname'                      => array('LIKE', $sstr),
1073
+				'Attendee.ATT_short_bio'                  => array('LIKE', $sstr),
1074
+				'Attendee.ATT_email'                      => array('LIKE', $sstr),
1075
+				'Attendee.ATT_address'                    => array('LIKE', $sstr),
1076
+				'Attendee.ATT_address2'                   => array('LIKE', $sstr),
1077
+				'Attendee.ATT_city'                       => array('LIKE', $sstr),
1078
+				'REG_final_price'                         => array('LIKE', $sstr),
1079
+				'REG_code'                                => array('LIKE', $sstr),
1080
+				'REG_count'                               => array('LIKE', $sstr),
1081
+				'REG_group_size'                          => array('LIKE', $sstr),
1082
+				'Ticket.TKT_name'                         => array('LIKE', $sstr),
1083
+				'Ticket.TKT_description'                  => array('LIKE', $sstr),
1084
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr),
1085
+			);
1086
+		}
1087
+		//capability checks
1088
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
1089
+			$_where['AND'] = array(
1090
+				'Event.EVT_wp_user' => get_current_user_id(),
1091
+			);
1092
+		}
1093
+		if ($count) {
1094
+			if ($trash) {
1095
+				return EEM_Registration::instance()->count_deleted(array($_where));
1096
+			} else if ($incomplete) {
1097
+				return EEM_Registration::instance()->count(array($_where));
1098
+			} else {
1099
+				return EEM_Registration::instance()->count(array(
1100
+					$_where,
1101
+					'default_where_conditions' => 'this_model_only',
1102
+				));
1103
+			}
1104
+		} else {
1105
+			//make sure we remove default where conditions cause all registrations matching query are returned
1106
+			$query_params = array(
1107
+				$_where,
1108
+				'order_by'                 => array($orderby => $sort),
1109
+				'default_where_conditions' => 'this_model_only',
1110
+			);
1111
+			if ($per_page !== -1) {
1112
+				$query_params['limit'] = $limit;
1113
+			}
1114
+			$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params)
1115
+				: EEM_Registration::instance()->get_all($query_params);
1116
+			if ($EVT_ID
1117
+				&& isset($registrations[0])
1118
+				&& $registrations[0] instanceof EE_Registration
1119
+				&& $registrations[0]->event_obj()
1120
+			) {
1121
+				$first_registration = $registrations[0];
1122
+				//EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1123
+				$event_name = $first_registration->event_obj()->name();
1124
+				$event_date = $first_registration->date_obj()
1125
+												 ->start_date_and_time('l F j, Y,',
1126
+													 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1127
+				// edit event link
1128
+				if ($event_name != '') {
1129
+					$edit_event_url = self::add_query_args_and_nonce(array(
1130
+						'action' => 'edit_event',
1131
+						'EVT_ID' => $EVT_ID,
1132
+					), EVENTS_ADMIN_URL);
1133
+					$edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ',
1134
+							'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>';
1135
+					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>';
1136
+				}
1137
+				$back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL);
1138
+				$back_2_reg_lnk = '<a href="'
1139
+								  . $back_2_reg_url
1140
+								  . '" title="'
1141
+								  . esc_attr__('click to return to viewing all registrations ', 'event_espresso')
1142
+								  . '">&laquo; '
1143
+								  . __('Back to All Registrations', 'event_espresso')
1144
+								  . '</a>';
1145
+				$this->_template_args['before_admin_page_content'] = '
1146 1146
 			<div id="admin-page-header">
1147 1147
 				<h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso') . '</span>' . $event_name . '</h1>
1148 1148
 				<h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso') . '</span>' . $event_date . '</h3>
1149 1149
 				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1150 1150
 			</div>
1151 1151
 			';
1152
-            }
1153
-            return $registrations;
1154
-        }
1155
-    }
1156
-
1157
-
1158
-
1159
-    public function get_registration_status_array()
1160
-    {
1161
-        return self::$_reg_status;
1162
-    }
1163
-
1164
-
1165
-
1166
-
1167
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1168
-    /**
1169
-     *        generates HTML for the View Registration Details Admin page
1170
-     *
1171
-     * @access protected
1172
-     * @return void
1173
-     */
1174
-    protected function _registration_details()
1175
-    {
1176
-        $this->_template_args = array();
1177
-        $this->_set_registration_object();
1178
-        if (is_object($this->_registration)) {
1179
-            $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1180
-                : EE_Transaction::new_instance();
1181
-            $this->_session = $transaction->session_data();
1182
-            $event_id = $this->_registration->event_ID();
1183
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1184
-            $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1185
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1186
-            $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1187
-            $this->_template_args['grand_total'] = $transaction->total();
1188
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1189
-            // link back to overview
1190
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1191
-            $this->_template_args['registration'] = $this->_registration;
1192
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1193
-                'action'   => 'default',
1194
-                'event_id' => $event_id,
1195
-            ), REG_ADMIN_URL);
1196
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1197
-                'action' => 'default',
1198
-                'EVT_ID' => $event_id,
1199
-                'page'   => 'espresso_transactions',
1200
-            ), admin_url('admin.php'));
1201
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1202
-                'page'   => 'espresso_events',
1203
-                'action' => 'edit',
1204
-                'post'   => $event_id,
1205
-            ), admin_url('admin.php'));
1206
-            //next and previous links
1207
-            $next_reg = $this->_registration->next(null, array(), 'REG_ID');
1208
-            $this->_template_args['next_registration'] = $next_reg
1209
-                ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array(
1210
-                    'action'  => 'view_registration',
1211
-                    '_REG_ID' => $next_reg['REG_ID'],
1212
-                ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1213
-            $previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1214
-            $this->_template_args['previous_registration'] = $previous_reg
1215
-                ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array(
1216
-                    'action'  => 'view_registration',
1217
-                    '_REG_ID' => $previous_reg['REG_ID'],
1218
-                ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1219
-            // grab header
1220
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1221
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1222
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
1223
-                $this->_template_args, true);
1224
-        } else {
1225
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1226
-        }
1227
-        // the details template wrapper
1228
-        $this->display_admin_page_with_sidebar();
1229
-    }
1230
-
1231
-
1232
-
1233
-    protected function _registration_details_metaboxes()
1234
-    {
1235
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1236
-        $this->_set_registration_object();
1237
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1238
-        add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'),
1239
-            array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1240
-        add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'),
1241
-            array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1242
-        if ($attendee instanceof EE_Attendee
1243
-            && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')
1244
-        ) {
1245
-            add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'),
1246
-                array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1247
-        }
1248
-        add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'),
1249
-            array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1250
-        if ($this->_registration->group_size() > 1) {
1251
-            add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'),
1252
-                array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1253
-        }
1254
-    }
1255
-
1256
-
1257
-
1258
-    /**
1259
-     * set_reg_status_buttons_metabox
1260
-     *
1261
-     * @access protected
1262
-     * @return string
1263
-     * @throws \EE_Error
1264
-     */
1265
-    public function set_reg_status_buttons_metabox()
1266
-    {
1267
-        $this->_set_registration_object();
1268
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1269
-        echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array(
1270
-            'action' => 'change_reg_status',
1271
-        ), REG_ADMIN_URL));
1272
-        echo $change_reg_status_form->get_html();
1273
-        echo $change_reg_status_form->form_close();
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     * @return EE_Form_Section_Proper
1280
-     */
1281
-    protected function _generate_reg_status_change_form()
1282
-    {
1283
-        return new EE_Form_Section_Proper(array(
1284
-                'name'            => 'reg_status_change_form',
1285
-                'html_id'         => 'reg-status-change-form',
1286
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1287
-                'subsections'     => array(
1288
-                    'return'             => new EE_Hidden_Input(array(
1289
-                        'name'    => 'return',
1290
-                        'default' => 'view_registration',
1291
-                    )),
1292
-                    'REG_ID'             => new EE_Hidden_Input(array(
1293
-                        'name'    => 'REG_ID',
1294
-                        'default' => $this->_registration->ID(),
1295
-                    )),
1296
-                    'current_status'     => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status',
1297
-                            'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(),
1298
-                            '', 'status-' . $this->_registration->status_ID(),
1299
-                            'line-height: 1em; font-size: 1.5em; font-weight: bold;')))),
1300
-                    'reg_status'         => new EE_Select_Input($this->_get_reg_statuses(), array(
1301
-                            'html_label_text' => __('Change Registration Status to', 'event_espresso'),
1302
-                            'default'         => $this->_registration->status_ID(),
1303
-                        )),
1304
-                    'send_notifications' => new EE_Yes_No_Input(array(
1305
-                            'html_label_text' => __('Send Related Messages', 'event_espresso'),
1306
-                            'default'         => false,
1307
-                            'html_help_text'  => __('If set to "Yes", then the related messages will be sent to the registrant.',
1308
-                                'event_espresso'),
1309
-                        )),
1310
-                    'submit'             => new EE_Submit_Input(array(
1311
-                        'html_class'      => 'button-primary',
1312
-                        'html_label_text' => '&nbsp;',
1313
-                        'default'         => __('Update Registration Status', 'event_espresso'),
1314
-                    )),
1315
-                ),
1316
-            ));
1317
-    }
1318
-
1319
-
1320
-
1321
-    /**
1322
-     * Returns an array of all the buttons for the various statuses and switch status actions
1323
-     *
1324
-     * @return string
1325
-     */
1326
-    protected function _get_current_reg_status_help_text($STS_ID = '')
1327
-    {
1328
-        //$reg_status_help_text = array(
1329
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1330
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1331
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1332
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1333
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1334
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1335
-        //);
1336
-        //Approved
1337
-        //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant .
1338
-        //Cancelled
1339
-        //	A {
1340
-        //	cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved .
1341
-        //Declined
1342
-        //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved .
1343
-        //Not Approved
1344
-        //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved .
1345
-        //Pending Payment
1346
-        //A pending registration allows payments . The status will be automatically toggled to approved if the {
1347
-        //	payment} is made in full by registrant .
1348
-    }
1349
-
1350
-
1351
-
1352
-    /**
1353
-     * Returns an array of all the buttons for the various statuses and switch status actions
1354
-     *
1355
-     * @return array
1356
-     */
1357
-    protected function _get_reg_statuses()
1358
-    {
1359
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1360
-        unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1361
-        // get current reg status
1362
-        $current_status = $this->_registration->status_ID();
1363
-        // is registration for free event? This will determine whether to display the pending payment option
1364
-        if ($current_status != EEM_Registration::status_id_pending_payment
1365
-            && $this->_registration->transaction()
1366
-                                   ->is_free()
1367
-        ) {
1368
-            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1369
-        }
1370
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1371
-    }
1372
-
1373
-
1374
-
1375
-    /**
1376
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1377
-     *
1378
-     * @param bool $status REG status given for changing registrations to.
1379
-     * @param bool $notify Whether to send messages notifications or not.
1380
-     * @return array  (array with reg_id(s) updated and whether update was successful.
1381
-     */
1382
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1383
-    {
1384
-        if (isset($this->_req_data['reg_status_change_form'])) {
1385
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1386
-                ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array();
1387
-        } else {
1388
-            $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array();
1389
-        }
1390
-        $success = $this->_set_registration_status($REG_IDs, $status);
1391
-        //notify?
1392
-        if ($success
1393
-            && $notify
1394
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1395
-                'espresso_registrations_resend_registration')
1396
-        ) {
1397
-            $this->_process_resend_registration();
1398
-        }
1399
-        return $success;
1400
-    }
1401
-
1402
-
1403
-
1404
-    /**
1405
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1406
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1407
-     *
1408
-     * @param array $REG_IDs
1409
-     * @param bool  $status
1410
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1411
-     *               the array of updated registrations).
1412
-     */
1413
-    protected function _set_registration_status($REG_IDs = array(), $status = false)
1414
-    {
1415
-        $success = false;
1416
-        // typecast $REG_IDs
1417
-        $REG_IDs = (array)$REG_IDs;
1418
-        if ( ! empty($REG_IDs)) {
1419
-            $success = true;
1420
-            // set default status if none is passed
1421
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1422
-            // sanitize $REG_IDs
1423
-            $REG_IDs = array_filter($REG_IDs, 'absint');
1424
-            //loop through REG_ID's and change status
1425
-            foreach ($REG_IDs as $REG_ID) {
1426
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1427
-                if ($registration instanceof EE_Registration) {
1428
-                    $registration->set_status($status);
1429
-                    $result = $registration->save();
1430
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1431
-                    $success = $result !== false ? $success : false;
1432
-                }
1433
-            }
1434
-        }
1435
-        //reset _req_data['_REG_ID'] for any potential future messages notifications
1436
-        $this->_req_data['_REG_ID'] = $REG_IDs;
1437
-        //return $success and processed registrations
1438
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1439
-    }
1440
-
1441
-
1442
-
1443
-    /**
1444
-     * Common logic for setting up success message and redirecting to appropriate route
1445
-     *
1446
-     * @param  string $STS_ID status id for the registration changed to
1447
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1448
-     * @return void
1449
-     */
1450
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1451
-    {
1452
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1453
-            : array('success' => false);
1454
-        $success = isset($result['success']) && $result['success'];
1455
-        //setup success message
1456
-        if ($success) {
1457
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1458
-                $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'),
1459
-                    EEH_Template::pretty_status($STS_ID, false, 'lower'));
1460
-            } else {
1461
-                $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'),
1462
-                    EEH_Template::pretty_status($STS_ID, false, 'lower'));
1463
-            }
1464
-            EE_Error::add_success($msg);
1465
-        } else {
1466
-            EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__,
1467
-                __LINE__, __FUNCTION__);
1468
-        }
1469
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1470
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1471
-        } else {
1472
-            $route = array('action' => 'default');
1473
-        }
1474
-        //unset nonces
1475
-        foreach ($this->_req_data as $ref => $value) {
1476
-            if (strpos($ref, 'nonce') !== false) {
1477
-                unset($this->_req_data[$ref]);
1478
-                continue;
1479
-            }
1480
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1481
-            $this->_req_data[$ref] = $value;
1482
-        }
1483
-        //merge request vars so that the reloaded list table contains any existing filter query params
1484
-        $route = array_merge($this->_req_data, $route);
1485
-        $this->_redirect_after_action($success, '', '', $route, true);
1486
-    }
1487
-
1488
-
1489
-
1490
-    /**
1491
-     * incoming reg status change from reg details page.
1492
-     *
1493
-     * @return void
1494
-     */
1495
-    protected function _change_reg_status()
1496
-    {
1497
-        $this->_req_data['return'] = 'view_registration';
1498
-        //set notify based on whether the send notifications toggle is set or not
1499
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1500
-        //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1501
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
1502
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
1503
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1504
-            case EEM_Registration::status_id_approved :
1505
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1506
-                $this->approve_registration($notify);
1507
-                break;
1508
-            case EEM_Registration::status_id_pending_payment :
1509
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1510
-                $this->pending_registration($notify);
1511
-                break;
1512
-            case EEM_Registration::status_id_not_approved :
1513
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1514
-                $this->not_approve_registration($notify);
1515
-                break;
1516
-            case EEM_Registration::status_id_declined :
1517
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1518
-                $this->decline_registration($notify);
1519
-                break;
1520
-            case EEM_Registration::status_id_cancelled :
1521
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1522
-                $this->cancel_registration($notify);
1523
-                break;
1524
-            case EEM_Registration::status_id_wait_list :
1525
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
1526
-                $this->waitlist_registration($notify);
1527
-                break;
1528
-            case EEM_Registration::status_id_incomplete :
1529
-            default :
1530
-                $result['success'] = false;
1531
-                unset($this->_req_data['return']);
1532
-                $this->_reg_status_change_return('', false);
1533
-                break;
1534
-        }
1535
-    }
1536
-
1537
-
1538
-
1539
-    /**
1540
-     * approve_registration
1541
-     *
1542
-     * @access protected
1543
-     * @param bool $notify whether or not to notify the registrant about their approval.
1544
-     * @return void
1545
-     */
1546
-    protected function approve_registration($notify = false)
1547
-    {
1548
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1549
-    }
1550
-
1551
-
1552
-
1553
-    /**
1554
-     *        decline_registration
1555
-     *
1556
-     * @access protected
1557
-     * @param bool $notify whether or not to notify the registrant about their status change.
1558
-     * @return void
1559
-     */
1560
-    protected function decline_registration($notify = false)
1561
-    {
1562
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1563
-    }
1564
-
1565
-
1566
-
1567
-    /**
1568
-     *        cancel_registration
1569
-     *
1570
-     * @access protected
1571
-     * @param bool $notify whether or not to notify the registrant about their status change.
1572
-     * @return void
1573
-     */
1574
-    protected function cancel_registration($notify = false)
1575
-    {
1576
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1577
-    }
1578
-
1579
-
1580
-
1581
-    /**
1582
-     *        not_approve_registration
1583
-     *
1584
-     * @access protected
1585
-     * @param bool $notify whether or not to notify the registrant about their status change.
1586
-     * @return void
1587
-     */
1588
-    protected function not_approve_registration($notify = false)
1589
-    {
1590
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1591
-    }
1592
-
1593
-
1594
-
1595
-    /**
1596
-     *        decline_registration
1597
-     *
1598
-     * @access protected
1599
-     * @param bool $notify whether or not to notify the registrant about their status change.
1600
-     * @return void
1601
-     */
1602
-    protected function pending_registration($notify = false)
1603
-    {
1604
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1605
-    }
1606
-
1607
-
1608
-
1609
-    /**
1610
-     * waitlist_registration
1611
-     *
1612
-     * @access protected
1613
-     * @param bool $notify whether or not to notify the registrant about their status change.
1614
-     * @return void
1615
-     */
1616
-    protected function waitlist_registration($notify = false)
1617
-    {
1618
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1619
-    }
1620
-
1621
-
1622
-
1623
-    /**
1624
-     *        generates HTML for the Registration main meta box
1625
-     *
1626
-     * @access public
1627
-     * @return void
1628
-     */
1629
-    public function _reg_details_meta_box()
1630
-    {
1631
-        EEH_Autoloader::register_line_item_display_autoloaders();
1632
-        EEH_Autoloader::register_line_item_filter_autoloaders();
1633
-        EE_Registry::instance()->load_helper('Line_Item');
1634
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1635
-            : EE_Transaction::new_instance();
1636
-        $this->_session = $transaction->session_data();
1637
-        $filters = new EE_Line_Item_Filter_Collection();
1638
-        //$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1639
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1640
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1641
-        $filtered_line_item_tree = $line_item_filter_processor->process();
1642
-        $line_item_display = new EE_Line_Item_Display('reg_admin_table',
1643
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1644
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree,
1645
-            array('EE_Registration' => $this->_registration));
1646
-        $attendee = $this->_registration->attendee();
1647
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
1648
-            'espresso_transactions_view_transaction')
1649
-        ) {
1650
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1651
-                'action' => 'view_transaction',
1652
-                'TXN_ID' => $transaction->ID(),
1653
-            ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right',
1654
-                'dashicons dashicons-cart');
1655
-        } else {
1656
-            $this->_template_args['view_transaction_button'] = '';
1657
-        }
1658
-        if ($attendee instanceof EE_Attendee
1659
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1660
-                'espresso_registrations_resend_registration')
1661
-        ) {
1662
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1663
-                'action'      => 'resend_registration',
1664
-                '_REG_ID'     => $this->_registration->ID(),
1665
-                'redirect_to' => 'view_registration',
1666
-            ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right',
1667
-                'dashicons dashicons-email-alt');
1668
-        } else {
1669
-            $this->_template_args['resend_registration_button'] = '';
1670
-        }
1671
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1672
-        $payment = $transaction->get_first_related('Payment');
1673
-        $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1674
-        $payment_method = $payment->get_first_related('Payment_Method');
1675
-        $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance()
1676
-            : $payment_method;
1677
-        $reg_details = array(
1678
-            'payment_method'       => $payment_method->name(),
1679
-            'response_msg'         => $payment->gateway_response(),
1680
-            'registration_id'      => $this->_registration->get('REG_code'),
1681
-            'registration_session' => $this->_registration->session_ID(),
1682
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1683
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1684
-        );
1685
-        if (isset($reg_details['registration_id'])) {
1686
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1687
-            $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1688
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1689
-        }
1690
-        if (isset($reg_details['payment_method'])) {
1691
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1692
-            $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method',
1693
-                'event_espresso');
1694
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1695
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1696
-            $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response',
1697
-                'event_espresso');
1698
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1699
-        }
1700
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1701
-        $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session',
1702
-            'event_espresso');
1703
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1704
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1705
-        $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP',
1706
-            'event_espresso');
1707
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1708
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1709
-        $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1710
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1711
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1712
-            'action'   => 'default',
1713
-            'event_id' => $this->_registration->event_ID(),
1714
-        ), REG_ADMIN_URL);
1715
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
1716
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
1717
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1718
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1719
-    }
1720
-
1721
-
1722
-
1723
-    /**
1724
-     * generates HTML for the Registration Questions meta box.
1725
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
1726
-     * otherwise uses new forms system
1727
-     *
1728
-     * @access public
1729
-     * @return void
1730
-     */
1731
-    public function _reg_questions_meta_box()
1732
-    {
1733
-        //allow someone to override this method entirely
1734
-        if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this,
1735
-            $this->_registration)) {
1736
-            $form = $this->_get_reg_custom_questions_form($this->_registration->ID());
1737
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1738
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
1739
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1740
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1741
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
1742
-        }
1743
-    }
1744
-
1745
-
1746
-
1747
-    /**
1748
-     * form_before_question_group
1749
-     *
1750
-     * @deprecated    as of 4.8.32.rc.000
1751
-     * @access        public
1752
-     * @param        string $output
1753
-     * @return        string
1754
-     */
1755
-    public function form_before_question_group($output)
1756
-    {
1757
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1758
-            __('This method would have been protected but was used on a filter callback'
1759
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1760
-            '4.8.32.rc.000');
1761
-        return '
1152
+			}
1153
+			return $registrations;
1154
+		}
1155
+	}
1156
+
1157
+
1158
+
1159
+	public function get_registration_status_array()
1160
+	{
1161
+		return self::$_reg_status;
1162
+	}
1163
+
1164
+
1165
+
1166
+
1167
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1168
+	/**
1169
+	 *        generates HTML for the View Registration Details Admin page
1170
+	 *
1171
+	 * @access protected
1172
+	 * @return void
1173
+	 */
1174
+	protected function _registration_details()
1175
+	{
1176
+		$this->_template_args = array();
1177
+		$this->_set_registration_object();
1178
+		if (is_object($this->_registration)) {
1179
+			$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1180
+				: EE_Transaction::new_instance();
1181
+			$this->_session = $transaction->session_data();
1182
+			$event_id = $this->_registration->event_ID();
1183
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1184
+			$this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1185
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1186
+			$this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1187
+			$this->_template_args['grand_total'] = $transaction->total();
1188
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1189
+			// link back to overview
1190
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1191
+			$this->_template_args['registration'] = $this->_registration;
1192
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1193
+				'action'   => 'default',
1194
+				'event_id' => $event_id,
1195
+			), REG_ADMIN_URL);
1196
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1197
+				'action' => 'default',
1198
+				'EVT_ID' => $event_id,
1199
+				'page'   => 'espresso_transactions',
1200
+			), admin_url('admin.php'));
1201
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1202
+				'page'   => 'espresso_events',
1203
+				'action' => 'edit',
1204
+				'post'   => $event_id,
1205
+			), admin_url('admin.php'));
1206
+			//next and previous links
1207
+			$next_reg = $this->_registration->next(null, array(), 'REG_ID');
1208
+			$this->_template_args['next_registration'] = $next_reg
1209
+				? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array(
1210
+					'action'  => 'view_registration',
1211
+					'_REG_ID' => $next_reg['REG_ID'],
1212
+				), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1213
+			$previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1214
+			$this->_template_args['previous_registration'] = $previous_reg
1215
+				? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array(
1216
+					'action'  => 'view_registration',
1217
+					'_REG_ID' => $previous_reg['REG_ID'],
1218
+				), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1219
+			// grab header
1220
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1221
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1222
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
1223
+				$this->_template_args, true);
1224
+		} else {
1225
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1226
+		}
1227
+		// the details template wrapper
1228
+		$this->display_admin_page_with_sidebar();
1229
+	}
1230
+
1231
+
1232
+
1233
+	protected function _registration_details_metaboxes()
1234
+	{
1235
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1236
+		$this->_set_registration_object();
1237
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1238
+		add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'),
1239
+			array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1240
+		add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'),
1241
+			array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1242
+		if ($attendee instanceof EE_Attendee
1243
+			&& EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')
1244
+		) {
1245
+			add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'),
1246
+				array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1247
+		}
1248
+		add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'),
1249
+			array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1250
+		if ($this->_registration->group_size() > 1) {
1251
+			add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'),
1252
+				array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1253
+		}
1254
+	}
1255
+
1256
+
1257
+
1258
+	/**
1259
+	 * set_reg_status_buttons_metabox
1260
+	 *
1261
+	 * @access protected
1262
+	 * @return string
1263
+	 * @throws \EE_Error
1264
+	 */
1265
+	public function set_reg_status_buttons_metabox()
1266
+	{
1267
+		$this->_set_registration_object();
1268
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1269
+		echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array(
1270
+			'action' => 'change_reg_status',
1271
+		), REG_ADMIN_URL));
1272
+		echo $change_reg_status_form->get_html();
1273
+		echo $change_reg_status_form->form_close();
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 * @return EE_Form_Section_Proper
1280
+	 */
1281
+	protected function _generate_reg_status_change_form()
1282
+	{
1283
+		return new EE_Form_Section_Proper(array(
1284
+				'name'            => 'reg_status_change_form',
1285
+				'html_id'         => 'reg-status-change-form',
1286
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1287
+				'subsections'     => array(
1288
+					'return'             => new EE_Hidden_Input(array(
1289
+						'name'    => 'return',
1290
+						'default' => 'view_registration',
1291
+					)),
1292
+					'REG_ID'             => new EE_Hidden_Input(array(
1293
+						'name'    => 'REG_ID',
1294
+						'default' => $this->_registration->ID(),
1295
+					)),
1296
+					'current_status'     => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status',
1297
+							'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(),
1298
+							'', 'status-' . $this->_registration->status_ID(),
1299
+							'line-height: 1em; font-size: 1.5em; font-weight: bold;')))),
1300
+					'reg_status'         => new EE_Select_Input($this->_get_reg_statuses(), array(
1301
+							'html_label_text' => __('Change Registration Status to', 'event_espresso'),
1302
+							'default'         => $this->_registration->status_ID(),
1303
+						)),
1304
+					'send_notifications' => new EE_Yes_No_Input(array(
1305
+							'html_label_text' => __('Send Related Messages', 'event_espresso'),
1306
+							'default'         => false,
1307
+							'html_help_text'  => __('If set to "Yes", then the related messages will be sent to the registrant.',
1308
+								'event_espresso'),
1309
+						)),
1310
+					'submit'             => new EE_Submit_Input(array(
1311
+						'html_class'      => 'button-primary',
1312
+						'html_label_text' => '&nbsp;',
1313
+						'default'         => __('Update Registration Status', 'event_espresso'),
1314
+					)),
1315
+				),
1316
+			));
1317
+	}
1318
+
1319
+
1320
+
1321
+	/**
1322
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1323
+	 *
1324
+	 * @return string
1325
+	 */
1326
+	protected function _get_current_reg_status_help_text($STS_ID = '')
1327
+	{
1328
+		//$reg_status_help_text = array(
1329
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1330
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1331
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1332
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1333
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1334
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1335
+		//);
1336
+		//Approved
1337
+		//An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant .
1338
+		//Cancelled
1339
+		//	A {
1340
+		//	cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved .
1341
+		//Declined
1342
+		//A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved .
1343
+		//Not Approved
1344
+		//A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved .
1345
+		//Pending Payment
1346
+		//A pending registration allows payments . The status will be automatically toggled to approved if the {
1347
+		//	payment} is made in full by registrant .
1348
+	}
1349
+
1350
+
1351
+
1352
+	/**
1353
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1354
+	 *
1355
+	 * @return array
1356
+	 */
1357
+	protected function _get_reg_statuses()
1358
+	{
1359
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1360
+		unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1361
+		// get current reg status
1362
+		$current_status = $this->_registration->status_ID();
1363
+		// is registration for free event? This will determine whether to display the pending payment option
1364
+		if ($current_status != EEM_Registration::status_id_pending_payment
1365
+			&& $this->_registration->transaction()
1366
+								   ->is_free()
1367
+		) {
1368
+			unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1369
+		}
1370
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1371
+	}
1372
+
1373
+
1374
+
1375
+	/**
1376
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1377
+	 *
1378
+	 * @param bool $status REG status given for changing registrations to.
1379
+	 * @param bool $notify Whether to send messages notifications or not.
1380
+	 * @return array  (array with reg_id(s) updated and whether update was successful.
1381
+	 */
1382
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1383
+	{
1384
+		if (isset($this->_req_data['reg_status_change_form'])) {
1385
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1386
+				? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array();
1387
+		} else {
1388
+			$REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array();
1389
+		}
1390
+		$success = $this->_set_registration_status($REG_IDs, $status);
1391
+		//notify?
1392
+		if ($success
1393
+			&& $notify
1394
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1395
+				'espresso_registrations_resend_registration')
1396
+		) {
1397
+			$this->_process_resend_registration();
1398
+		}
1399
+		return $success;
1400
+	}
1401
+
1402
+
1403
+
1404
+	/**
1405
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1406
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1407
+	 *
1408
+	 * @param array $REG_IDs
1409
+	 * @param bool  $status
1410
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1411
+	 *               the array of updated registrations).
1412
+	 */
1413
+	protected function _set_registration_status($REG_IDs = array(), $status = false)
1414
+	{
1415
+		$success = false;
1416
+		// typecast $REG_IDs
1417
+		$REG_IDs = (array)$REG_IDs;
1418
+		if ( ! empty($REG_IDs)) {
1419
+			$success = true;
1420
+			// set default status if none is passed
1421
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1422
+			// sanitize $REG_IDs
1423
+			$REG_IDs = array_filter($REG_IDs, 'absint');
1424
+			//loop through REG_ID's and change status
1425
+			foreach ($REG_IDs as $REG_ID) {
1426
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1427
+				if ($registration instanceof EE_Registration) {
1428
+					$registration->set_status($status);
1429
+					$result = $registration->save();
1430
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1431
+					$success = $result !== false ? $success : false;
1432
+				}
1433
+			}
1434
+		}
1435
+		//reset _req_data['_REG_ID'] for any potential future messages notifications
1436
+		$this->_req_data['_REG_ID'] = $REG_IDs;
1437
+		//return $success and processed registrations
1438
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1439
+	}
1440
+
1441
+
1442
+
1443
+	/**
1444
+	 * Common logic for setting up success message and redirecting to appropriate route
1445
+	 *
1446
+	 * @param  string $STS_ID status id for the registration changed to
1447
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1448
+	 * @return void
1449
+	 */
1450
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1451
+	{
1452
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1453
+			: array('success' => false);
1454
+		$success = isset($result['success']) && $result['success'];
1455
+		//setup success message
1456
+		if ($success) {
1457
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1458
+				$msg = sprintf(__('Registration status has been set to %s', 'event_espresso'),
1459
+					EEH_Template::pretty_status($STS_ID, false, 'lower'));
1460
+			} else {
1461
+				$msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'),
1462
+					EEH_Template::pretty_status($STS_ID, false, 'lower'));
1463
+			}
1464
+			EE_Error::add_success($msg);
1465
+		} else {
1466
+			EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__,
1467
+				__LINE__, __FUNCTION__);
1468
+		}
1469
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1470
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1471
+		} else {
1472
+			$route = array('action' => 'default');
1473
+		}
1474
+		//unset nonces
1475
+		foreach ($this->_req_data as $ref => $value) {
1476
+			if (strpos($ref, 'nonce') !== false) {
1477
+				unset($this->_req_data[$ref]);
1478
+				continue;
1479
+			}
1480
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1481
+			$this->_req_data[$ref] = $value;
1482
+		}
1483
+		//merge request vars so that the reloaded list table contains any existing filter query params
1484
+		$route = array_merge($this->_req_data, $route);
1485
+		$this->_redirect_after_action($success, '', '', $route, true);
1486
+	}
1487
+
1488
+
1489
+
1490
+	/**
1491
+	 * incoming reg status change from reg details page.
1492
+	 *
1493
+	 * @return void
1494
+	 */
1495
+	protected function _change_reg_status()
1496
+	{
1497
+		$this->_req_data['return'] = 'view_registration';
1498
+		//set notify based on whether the send notifications toggle is set or not
1499
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1500
+		//$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1501
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
1502
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
1503
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1504
+			case EEM_Registration::status_id_approved :
1505
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1506
+				$this->approve_registration($notify);
1507
+				break;
1508
+			case EEM_Registration::status_id_pending_payment :
1509
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1510
+				$this->pending_registration($notify);
1511
+				break;
1512
+			case EEM_Registration::status_id_not_approved :
1513
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1514
+				$this->not_approve_registration($notify);
1515
+				break;
1516
+			case EEM_Registration::status_id_declined :
1517
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1518
+				$this->decline_registration($notify);
1519
+				break;
1520
+			case EEM_Registration::status_id_cancelled :
1521
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1522
+				$this->cancel_registration($notify);
1523
+				break;
1524
+			case EEM_Registration::status_id_wait_list :
1525
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
1526
+				$this->waitlist_registration($notify);
1527
+				break;
1528
+			case EEM_Registration::status_id_incomplete :
1529
+			default :
1530
+				$result['success'] = false;
1531
+				unset($this->_req_data['return']);
1532
+				$this->_reg_status_change_return('', false);
1533
+				break;
1534
+		}
1535
+	}
1536
+
1537
+
1538
+
1539
+	/**
1540
+	 * approve_registration
1541
+	 *
1542
+	 * @access protected
1543
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1544
+	 * @return void
1545
+	 */
1546
+	protected function approve_registration($notify = false)
1547
+	{
1548
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1549
+	}
1550
+
1551
+
1552
+
1553
+	/**
1554
+	 *        decline_registration
1555
+	 *
1556
+	 * @access protected
1557
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1558
+	 * @return void
1559
+	 */
1560
+	protected function decline_registration($notify = false)
1561
+	{
1562
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1563
+	}
1564
+
1565
+
1566
+
1567
+	/**
1568
+	 *        cancel_registration
1569
+	 *
1570
+	 * @access protected
1571
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1572
+	 * @return void
1573
+	 */
1574
+	protected function cancel_registration($notify = false)
1575
+	{
1576
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1577
+	}
1578
+
1579
+
1580
+
1581
+	/**
1582
+	 *        not_approve_registration
1583
+	 *
1584
+	 * @access protected
1585
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1586
+	 * @return void
1587
+	 */
1588
+	protected function not_approve_registration($notify = false)
1589
+	{
1590
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1591
+	}
1592
+
1593
+
1594
+
1595
+	/**
1596
+	 *        decline_registration
1597
+	 *
1598
+	 * @access protected
1599
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1600
+	 * @return void
1601
+	 */
1602
+	protected function pending_registration($notify = false)
1603
+	{
1604
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1605
+	}
1606
+
1607
+
1608
+
1609
+	/**
1610
+	 * waitlist_registration
1611
+	 *
1612
+	 * @access protected
1613
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1614
+	 * @return void
1615
+	 */
1616
+	protected function waitlist_registration($notify = false)
1617
+	{
1618
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1619
+	}
1620
+
1621
+
1622
+
1623
+	/**
1624
+	 *        generates HTML for the Registration main meta box
1625
+	 *
1626
+	 * @access public
1627
+	 * @return void
1628
+	 */
1629
+	public function _reg_details_meta_box()
1630
+	{
1631
+		EEH_Autoloader::register_line_item_display_autoloaders();
1632
+		EEH_Autoloader::register_line_item_filter_autoloaders();
1633
+		EE_Registry::instance()->load_helper('Line_Item');
1634
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1635
+			: EE_Transaction::new_instance();
1636
+		$this->_session = $transaction->session_data();
1637
+		$filters = new EE_Line_Item_Filter_Collection();
1638
+		//$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1639
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1640
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1641
+		$filtered_line_item_tree = $line_item_filter_processor->process();
1642
+		$line_item_display = new EE_Line_Item_Display('reg_admin_table',
1643
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1644
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree,
1645
+			array('EE_Registration' => $this->_registration));
1646
+		$attendee = $this->_registration->attendee();
1647
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
1648
+			'espresso_transactions_view_transaction')
1649
+		) {
1650
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1651
+				'action' => 'view_transaction',
1652
+				'TXN_ID' => $transaction->ID(),
1653
+			), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right',
1654
+				'dashicons dashicons-cart');
1655
+		} else {
1656
+			$this->_template_args['view_transaction_button'] = '';
1657
+		}
1658
+		if ($attendee instanceof EE_Attendee
1659
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1660
+				'espresso_registrations_resend_registration')
1661
+		) {
1662
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1663
+				'action'      => 'resend_registration',
1664
+				'_REG_ID'     => $this->_registration->ID(),
1665
+				'redirect_to' => 'view_registration',
1666
+			), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right',
1667
+				'dashicons dashicons-email-alt');
1668
+		} else {
1669
+			$this->_template_args['resend_registration_button'] = '';
1670
+		}
1671
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1672
+		$payment = $transaction->get_first_related('Payment');
1673
+		$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1674
+		$payment_method = $payment->get_first_related('Payment_Method');
1675
+		$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance()
1676
+			: $payment_method;
1677
+		$reg_details = array(
1678
+			'payment_method'       => $payment_method->name(),
1679
+			'response_msg'         => $payment->gateway_response(),
1680
+			'registration_id'      => $this->_registration->get('REG_code'),
1681
+			'registration_session' => $this->_registration->session_ID(),
1682
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1683
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1684
+		);
1685
+		if (isset($reg_details['registration_id'])) {
1686
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1687
+			$this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1688
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1689
+		}
1690
+		if (isset($reg_details['payment_method'])) {
1691
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1692
+			$this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method',
1693
+				'event_espresso');
1694
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1695
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1696
+			$this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response',
1697
+				'event_espresso');
1698
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1699
+		}
1700
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1701
+		$this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session',
1702
+			'event_espresso');
1703
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1704
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1705
+		$this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP',
1706
+			'event_espresso');
1707
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1708
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1709
+		$this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1710
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1711
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1712
+			'action'   => 'default',
1713
+			'event_id' => $this->_registration->event_ID(),
1714
+		), REG_ADMIN_URL);
1715
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
1716
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
1717
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1718
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1719
+	}
1720
+
1721
+
1722
+
1723
+	/**
1724
+	 * generates HTML for the Registration Questions meta box.
1725
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
1726
+	 * otherwise uses new forms system
1727
+	 *
1728
+	 * @access public
1729
+	 * @return void
1730
+	 */
1731
+	public function _reg_questions_meta_box()
1732
+	{
1733
+		//allow someone to override this method entirely
1734
+		if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this,
1735
+			$this->_registration)) {
1736
+			$form = $this->_get_reg_custom_questions_form($this->_registration->ID());
1737
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1738
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
1739
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1740
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1741
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
1742
+		}
1743
+	}
1744
+
1745
+
1746
+
1747
+	/**
1748
+	 * form_before_question_group
1749
+	 *
1750
+	 * @deprecated    as of 4.8.32.rc.000
1751
+	 * @access        public
1752
+	 * @param        string $output
1753
+	 * @return        string
1754
+	 */
1755
+	public function form_before_question_group($output)
1756
+	{
1757
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1758
+			__('This method would have been protected but was used on a filter callback'
1759
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1760
+			'4.8.32.rc.000');
1761
+		return '
1762 1762
 	<table class="form-table ee-width-100">
1763 1763
 		<tbody>
1764 1764
 			';
1765
-    }
1766
-
1767
-
1768
-
1769
-    /**
1770
-     * form_after_question_group
1771
-     *
1772
-     * @deprecated    as of 4.8.32.rc.000
1773
-     * @access        public
1774
-     * @param        string $output
1775
-     * @return        string
1776
-     */
1777
-    public function form_after_question_group($output)
1778
-    {
1779
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1780
-            __('This method would have been protected but was used on a filter callback'
1781
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1782
-            '4.8.32.rc.000');
1783
-        return '
1765
+	}
1766
+
1767
+
1768
+
1769
+	/**
1770
+	 * form_after_question_group
1771
+	 *
1772
+	 * @deprecated    as of 4.8.32.rc.000
1773
+	 * @access        public
1774
+	 * @param        string $output
1775
+	 * @return        string
1776
+	 */
1777
+	public function form_after_question_group($output)
1778
+	{
1779
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1780
+			__('This method would have been protected but was used on a filter callback'
1781
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1782
+			'4.8.32.rc.000');
1783
+		return '
1784 1784
 			<tr class="hide-if-no-js">
1785 1785
 				<th> </th>
1786 1786
 				<td class="reg-admin-edit-attendee-question-td">
1787 1787
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
1788
-               . esc_attr__('click to edit question', 'event_espresso')
1789
-               . '">
1788
+			   . esc_attr__('click to edit question', 'event_espresso')
1789
+			   . '">
1790 1790
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
1791
-               . __('edit the above question group', 'event_espresso')
1792
-               . '</span>
1791
+			   . __('edit the above question group', 'event_espresso')
1792
+			   . '</span>
1793 1793
 						<div class="dashicons dashicons-edit"></div>
1794 1794
 					</a>
1795 1795
 				</td>
@@ -1797,506 +1797,506 @@  discard block
 block discarded – undo
1797 1797
 		</tbody>
1798 1798
 	</table>
1799 1799
 ';
1800
-    }
1801
-
1802
-
1803
-
1804
-    /**
1805
-     * form_form_field_label_wrap
1806
-     *
1807
-     * @deprecated    as of 4.8.32.rc.000
1808
-     * @access        public
1809
-     * @param        string $label
1810
-     * @return        string
1811
-     */
1812
-    public function form_form_field_label_wrap($label)
1813
-    {
1814
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1815
-            __('This method would have been protected but was used on a filter callback'
1816
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1817
-            '4.8.32.rc.000');
1818
-        return '
1800
+	}
1801
+
1802
+
1803
+
1804
+	/**
1805
+	 * form_form_field_label_wrap
1806
+	 *
1807
+	 * @deprecated    as of 4.8.32.rc.000
1808
+	 * @access        public
1809
+	 * @param        string $label
1810
+	 * @return        string
1811
+	 */
1812
+	public function form_form_field_label_wrap($label)
1813
+	{
1814
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1815
+			__('This method would have been protected but was used on a filter callback'
1816
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1817
+			'4.8.32.rc.000');
1818
+		return '
1819 1819
 			<tr>
1820 1820
 				<th>
1821 1821
 					' . $label . '
1822 1822
 				</th>';
1823
-    }
1824
-
1825
-
1826
-
1827
-    /**
1828
-     * form_form_field_input__wrap
1829
-     *
1830
-     * @deprecated    as of 4.8.32.rc.000
1831
-     * @access        public
1832
-     * @param        string $input
1833
-     * @return        string
1834
-     */
1835
-    public function form_form_field_input__wrap($input)
1836
-    {
1837
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1838
-            __('This method would have been protected but was used on a filter callback'
1839
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1840
-            '4.8.32.rc.000');
1841
-        return '
1823
+	}
1824
+
1825
+
1826
+
1827
+	/**
1828
+	 * form_form_field_input__wrap
1829
+	 *
1830
+	 * @deprecated    as of 4.8.32.rc.000
1831
+	 * @access        public
1832
+	 * @param        string $input
1833
+	 * @return        string
1834
+	 */
1835
+	public function form_form_field_input__wrap($input)
1836
+	{
1837
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1838
+			__('This method would have been protected but was used on a filter callback'
1839
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1840
+			'4.8.32.rc.000');
1841
+		return '
1842 1842
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1843 1843
 					' . $input . '
1844 1844
 				</td>
1845 1845
 			</tr>';
1846
-    }
1847
-
1848
-
1849
-
1850
-    /**
1851
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
1852
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
1853
-     * to display the page
1854
-     *
1855
-     * @access protected
1856
-     * @return void
1857
-     */
1858
-    protected function _update_attendee_registration_form()
1859
-    {
1860
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
1861
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1862
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
1863
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
1864
-            if ($success) {
1865
-                $what = __('Registration Form', 'event_espresso');
1866
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
1867
-                    : array('action' => 'default');
1868
-                $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1869
-            }
1870
-        }
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Gets the form for saving registrations custom questions (if done
1877
-     * previously retrieves the cached form object, which may have validation errors in it)
1878
-     *
1879
-     * @param int $REG_ID
1880
-     * @return EE_Registration_Custom_Questions_Form
1881
-     */
1882
-    protected function _get_reg_custom_questions_form($REG_ID)
1883
-    {
1884
-        if ( ! $this->_reg_custom_questions_form) {
1885
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
1886
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()
1887
-                                                                                                          ->get_one_by_ID($REG_ID));
1888
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
1889
-        }
1890
-        return $this->_reg_custom_questions_form;
1891
-    }
1892
-
1893
-
1894
-
1895
-    /**
1896
-     * Saves
1897
-     *
1898
-     * @access private
1899
-     * @param bool $REG_ID
1900
-     * @return bool
1901
-     */
1902
-    private function _save_reg_custom_questions_form($REG_ID = false)
1903
-    {
1904
-        if ( ! $REG_ID) {
1905
-            EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__,
1906
-                __FUNCTION__, __LINE__);
1907
-        }
1908
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
1909
-        $form->receive_form_submission($this->_req_data);
1910
-        $success = false;
1911
-        if ($form->is_valid()) {
1912
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
1913
-                foreach ($question_group_form->inputs() as $question_id => $input) {
1914
-                    $where_conditions = array(
1915
-                        'QST_ID' => $question_id,
1916
-                        'REG_ID' => $REG_ID,
1917
-                    );
1918
-                    $possibly_new_values = array(
1919
-                        'ANS_value' => $input->normalized_value(),
1920
-                    );
1921
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
1922
-                    if ($answer instanceof EE_Answer) {
1923
-                        $success = $answer->save($possibly_new_values);
1924
-                    } else {
1925
-                        //insert it then
1926
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
1927
-                        $answer = EE_Answer::new_instance($cols_n_vals);
1928
-                        $success = $answer->save();
1929
-                    }
1930
-                }
1931
-            }
1932
-        } else {
1933
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
1934
-        }
1935
-        return $success;
1936
-    }
1937
-
1938
-
1939
-
1940
-    /**
1941
-     *        generates HTML for the Registration main meta box
1942
-     *
1943
-     * @access public
1944
-     * @return void
1945
-     */
1946
-    public function _reg_attendees_meta_box()
1947
-    {
1948
-        $REG = EEM_Registration::instance();
1949
-        //get all other registrations on this transaction, and cache
1950
-        //the attendees for them so we don't have to run another query using force_join
1951
-        $registrations = $REG->get_all(array(
1952
-            array(
1953
-                'TXN_ID' => $this->_registration->transaction_ID(),
1954
-                'REG_ID' => array('!=', $this->_registration->ID()),
1955
-            ),
1956
-            'force_join' => array('Attendee'),
1957
-        ));
1958
-        $this->_template_args['attendees'] = array();
1959
-        $this->_template_args['attendee_notice'] = '';
1960
-        if (empty($registrations)
1961
-            || (is_array($registrations)
1962
-                && ! EEH_Array::get_one_item_from_array($registrations))
1963
-        ) {
1964
-            EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration',
1965
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1966
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
1967
-        } else {
1968
-            $att_nmbr = 1;
1969
-            foreach ($registrations as $registration) {
1970
-                /* @var $registration EE_Registration */
1971
-                $attendee = $registration->attendee()
1972
-                    ? $registration->attendee()
1973
-                    : EEM_Attendee::instance()
1974
-                                  ->create_default_object();
1975
-                $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
1976
-                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1977
-                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1978
-                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1979
-                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1980
-                $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ',
1981
-                    $attendee->full_address_as_array());
1982
-                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array(
1983
-                    'action' => 'edit_attendee',
1984
-                    'post'   => $attendee->ID(),
1985
-                ), REG_ADMIN_URL);
1986
-                $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
1987
-                $att_nmbr++;
1988
-            }
1989
-            //EEH_Debug_Tools::printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' );
1990
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1991
-            //			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1992
-        }
1993
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1994
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1995
-    }
1996
-
1997
-
1998
-
1999
-    /**
2000
-     *        generates HTML for the Edit Registration side meta box
2001
-     *
2002
-     * @access public
2003
-     * @return void
2004
-     */
2005
-    public function _reg_registrant_side_meta_box()
2006
-    {
2007
-        /*@var $attendee EE_Attendee */
2008
-        $att_check = $this->_registration->attendee();
2009
-        $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2010
-        //now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not)
2011
-        if ( ! $this->_registration->is_primary_registrant()) {
2012
-            $primary_registration = $this->_registration->get_primary_registration();
2013
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2014
-                : null;
2015
-            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2016
-                //in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
2017
-                $primary_registration = null;
2018
-            }
2019
-        } else {
2020
-            $primary_registration = null;
2021
-        }
2022
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2023
-        $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
2024
-        $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
2025
-        $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
2026
-        $this->_template_args['phone'] = $attendee->phone();
2027
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2028
-        //edit link
2029
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
2030
-            'action' => 'edit_attendee',
2031
-            'post'   => $attendee->ID(),
2032
-        ), REG_ADMIN_URL);
2033
-        $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso');
2034
-        //create link
2035
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2036
-            ? EE_Admin_Page::add_query_args_and_nonce(array(
2037
-                'action'  => 'duplicate_attendee',
2038
-                '_REG_ID' => $this->_registration->ID(),
2039
-            ), REG_ADMIN_URL) : '';
2040
-        $this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
2041
-        $this->_template_args['att_check'] = $att_check;
2042
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2043
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2044
-    }
2045
-
2046
-
2047
-
2048
-    /**
2049
-     * trash or restore registrations
2050
-     *
2051
-     * @param  boolean $trash whether to archive or restore
2052
-     * @access protected
2053
-     * @return void
2054
-     */
2055
-    protected function _trash_or_restore_registrations($trash = true)
2056
-    {
2057
-        $REGM = EEM_Registration::instance();
2058
-        $success = 1;
2059
-        $error = 0;
2060
-        $tickets = array();
2061
-        $dtts = array();
2062
-        //if empty _REG_ID then get out because there's nothing to do
2063
-        if (empty($this->_req_data['_REG_ID'])) {
2064
-            $msg = $trash
2065
-                ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.',
2066
-                    'event_espresso')
2067
-                : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.',
2068
-                    'event_espresso');
2069
-            EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
2070
-            $this->_redirect_after_action(false, '', '', array(), true);
2071
-        }
2072
-        //Checkboxes
2073
-        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2074
-            // if array has more than one element than success message should be plural
2075
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2076
-            // cycle thru checkboxes
2077
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2078
-                /** @var EE_Registration $REG */
2079
-                $REG = $REGM->get_one_by_ID($REG_ID);
2080
-                $payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
2081
-                if ($payment_count > 0) {
2082
-                    $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name()
2083
-                        : __('Unknown Attendee', 'event_espresso');
2084
-                    $error = 1;
2085
-                    $success = 0;
2086
-                    EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2087
-                        'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
2088
-                    continue; //can't trash this registration because it has payments.
2089
-                }
2090
-                $ticket = $REG->get_first_related('Ticket');
2091
-                $tickets[$ticket->ID()] = $ticket;
2092
-                $dtt = $ticket->get_many_related('Datetime');
2093
-                $dtts = array_merge($dtts, $dtt);
2094
-                $updated = $trash ? $REG->delete() : $REG->restore();
2095
-                if ( ! $updated) {
2096
-                    $success = 0;
2097
-                } else {
2098
-                    $success = 2;
2099
-                }/**/
2100
-            }
2101
-        } else {
2102
-            // grab single id and delete
2103
-            $REG_ID = absint($this->_req_data['_REG_ID']);
2104
-            $REG = $REGM->get_one_by_ID($REG_ID);
2105
-            $ticket = $REG->get_first_related('Ticket');
2106
-            $tickets[$ticket->ID()] = $ticket;
2107
-            $dtts = $ticket->get_many_related('Datetime');
2108
-            $updated = $trash ? $REG->delete() : $REG->restore();
2109
-            if ( ! $updated) {
2110
-                $success = 0;
2111
-            }
2112
-        }
2113
-        //now let's update counts
2114
-        EEM_Ticket::instance()->update_tickets_sold($tickets);
2115
-        EEM_Datetime::instance()->update_sold($dtts);
2116
-        $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2117
-        $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2118
-        $overwrite_msgs = $error ? true : false;
2119
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
2120
-    }
2121
-
2122
-
2123
-
2124
-    /**
2125
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2126
-     * registration but also.
2127
-     * 1. Removing relations to EE_Attendee
2128
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2129
-     * ALSO trashed.
2130
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2131
-     * 4. Removing relationships between all tickets and the related registrations
2132
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2133
-     * 6. Deleting permanently any related Checkins.
2134
-     *
2135
-     * @return void
2136
-     */
2137
-    protected function _delete_registrations()
2138
-    {
2139
-        $REG_MDL = EEM_Registration::instance();
2140
-        $success = 1;
2141
-        //Checkboxes
2142
-        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2143
-            // if array has more than one element than success message should be plural
2144
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2145
-            // cycle thru checkboxes
2146
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2147
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2148
-                if ( ! $REG instanceof EE_Registration) {
2149
-                    continue;
2150
-                }
2151
-                $deleted = $this->_delete_registration($REG);
2152
-                if ( ! $deleted) {
2153
-                    $success = 0;
2154
-                }
2155
-            }
2156
-        } else {
2157
-            // grab single id and delete
2158
-            $REG_ID = $this->_req_data['_REG_ID'];
2159
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2160
-            $deleted = $this->_delete_registration($REG);
2161
-            if ( ! $deleted) {
2162
-                $success = 0;
2163
-            }
2164
-        }
2165
-        $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2166
-        $action_desc = __('permanently deleted.', 'event_espresso');
2167
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true);
2168
-    }
2169
-
2170
-
2171
-
2172
-    /**
2173
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2174
-     * models get affected.
2175
-     *
2176
-     * @param  EE_Registration $REG registration to be deleted permenantly
2177
-     * @return boolean              true = successful deletion, false = fail.
2178
-     */
2179
-    protected function _delete_registration(EE_Registration $REG)
2180
-    {
2181
-        //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
2182
-        $TXN = $REG->get_first_related('Transaction');
2183
-        $REGS = $TXN->get_many_related('Registration');
2184
-        $all_trashed = true;
2185
-        foreach ($REGS as $registration) {
2186
-            if ( ! $registration->get('REG_deleted')) {
2187
-                $all_trashed = false;
2188
-            }
2189
-        }
2190
-        if ( ! $all_trashed) {
2191
-            EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2192
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2193
-            return false;
2194
-        }
2195
-        //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
2196
-        foreach ($REGS as $registration) {
2197
-            //delete related answers
2198
-            $registration->delete_related_permanently('Answer');
2199
-            //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2200
-            $attendee = $registration->get_first_related('Attendee');
2201
-            if ($attendee instanceof EE_Attendee) {
2202
-                $registration->_remove_relation_to($attendee, 'Attendee');
2203
-            }
2204
-            //now remove relationships to tickets on this registration.
2205
-            $registration->_remove_relations('Ticket');
2206
-            //now delete permanently the checkins related to this registration.
2207
-            $registration->delete_related_permanently('Checkin');
2208
-            if ($registration->ID() === $REG->ID()) {
2209
-                continue;
2210
-            } //we don't want to delete permanently the existing registration just yet.
2211
-            //remove relation to transaction for these registrations if NOT the existing registrations
2212
-            $registration->_remove_relations('Transaction');
2213
-            //delete permanently any related messages.
2214
-            $registration->delete_related_permanently('Message');
2215
-            //now delete this registration permanently
2216
-            $registration->delete_permanently();
2217
-        }
2218
-        //now all related registrations on the transaction are handled.  So let's just handle this registration itself (the transaction and line items should be all that's left).
2219
-        //delete the line items related to the transaction for this registration.
2220
-        $TXN->delete_related_permanently('Line_Item');
2221
-        //we need to remove all the relationships on the transaction
2222
-        $TXN->delete_related_permanently('Payment');
2223
-        $TXN->delete_related_permanently('Extra_Meta');
2224
-        $TXN->delete_related_permanently('Message');
2225
-        //now we can delete this REG permanently (and the transaction of course)
2226
-        $REG->delete_related_permanently('Transaction');
2227
-        return $REG->delete_permanently();
2228
-    }
2229
-
2230
-
2231
-
2232
-    /**
2233
-     *    generates HTML for the Register New Attendee Admin page
2234
-     *
2235
-     * @access private
2236
-     * @throws \EE_Error
2237
-     * @return void
2238
-     */
2239
-    public function new_registration()
2240
-    {
2241
-        if ( ! $this->_set_reg_event()) {
2242
-            throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request',
2243
-                'event_espresso'));
2244
-        }
2245
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2246
-        // gotta start with a clean slate if we're not coming here via ajax
2247
-        if ( ! defined('DOING_AJAX')
2248
-             && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2249
-        ) {
2250
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2251
-        }
2252
-        $this->_template_args['event_name'] = '';
2253
-        // event name
2254
-        if ($this->_reg_event) {
2255
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2256
-            $edit_event_url = self::add_query_args_and_nonce(array(
2257
-                'action' => 'edit',
2258
-                'post'   => $this->_reg_event->ID(),
2259
-            ), EVENTS_ADMIN_URL);
2260
-            $edit_event_lnk = '<a href="'
2261
-                              . $edit_event_url
2262
-                              . '" title="'
2263
-                              . esc_attr__('Edit ', 'event_espresso')
2264
-                              . $this->_reg_event->name()
2265
-                              . '">'
2266
-                              . __('Edit Event', 'event_espresso')
2267
-                              . '</a>';
2268
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2269
-                                                   . $edit_event_lnk
2270
-                                                   . '</span>';
2271
-        }
2272
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2273
-        if (defined('DOING_AJAX')) {
2274
-            $this->_return_json();
2275
-        }
2276
-        // grab header
2277
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2278
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2279
-            $this->_template_args, true);
2280
-        //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2281
-        // the details template wrapper
2282
-        $this->display_admin_page_with_sidebar();
2283
-    }
2284
-
2285
-
2286
-
2287
-    /**
2288
-     * This returns the content for a registration step
2289
-     *
2290
-     * @access protected
2291
-     * @return string html
2292
-     */
2293
-    protected function _get_registration_step_content()
2294
-    {
2295
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2296
-            $warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2297
-                'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">',
2298
-                '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>');
2299
-            return '
1846
+	}
1847
+
1848
+
1849
+
1850
+	/**
1851
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
1852
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
1853
+	 * to display the page
1854
+	 *
1855
+	 * @access protected
1856
+	 * @return void
1857
+	 */
1858
+	protected function _update_attendee_registration_form()
1859
+	{
1860
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
1861
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1862
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
1863
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
1864
+			if ($success) {
1865
+				$what = __('Registration Form', 'event_espresso');
1866
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
1867
+					: array('action' => 'default');
1868
+				$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1869
+			}
1870
+		}
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Gets the form for saving registrations custom questions (if done
1877
+	 * previously retrieves the cached form object, which may have validation errors in it)
1878
+	 *
1879
+	 * @param int $REG_ID
1880
+	 * @return EE_Registration_Custom_Questions_Form
1881
+	 */
1882
+	protected function _get_reg_custom_questions_form($REG_ID)
1883
+	{
1884
+		if ( ! $this->_reg_custom_questions_form) {
1885
+			require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
1886
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()
1887
+																										  ->get_one_by_ID($REG_ID));
1888
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
1889
+		}
1890
+		return $this->_reg_custom_questions_form;
1891
+	}
1892
+
1893
+
1894
+
1895
+	/**
1896
+	 * Saves
1897
+	 *
1898
+	 * @access private
1899
+	 * @param bool $REG_ID
1900
+	 * @return bool
1901
+	 */
1902
+	private function _save_reg_custom_questions_form($REG_ID = false)
1903
+	{
1904
+		if ( ! $REG_ID) {
1905
+			EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__,
1906
+				__FUNCTION__, __LINE__);
1907
+		}
1908
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
1909
+		$form->receive_form_submission($this->_req_data);
1910
+		$success = false;
1911
+		if ($form->is_valid()) {
1912
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
1913
+				foreach ($question_group_form->inputs() as $question_id => $input) {
1914
+					$where_conditions = array(
1915
+						'QST_ID' => $question_id,
1916
+						'REG_ID' => $REG_ID,
1917
+					);
1918
+					$possibly_new_values = array(
1919
+						'ANS_value' => $input->normalized_value(),
1920
+					);
1921
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
1922
+					if ($answer instanceof EE_Answer) {
1923
+						$success = $answer->save($possibly_new_values);
1924
+					} else {
1925
+						//insert it then
1926
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
1927
+						$answer = EE_Answer::new_instance($cols_n_vals);
1928
+						$success = $answer->save();
1929
+					}
1930
+				}
1931
+			}
1932
+		} else {
1933
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
1934
+		}
1935
+		return $success;
1936
+	}
1937
+
1938
+
1939
+
1940
+	/**
1941
+	 *        generates HTML for the Registration main meta box
1942
+	 *
1943
+	 * @access public
1944
+	 * @return void
1945
+	 */
1946
+	public function _reg_attendees_meta_box()
1947
+	{
1948
+		$REG = EEM_Registration::instance();
1949
+		//get all other registrations on this transaction, and cache
1950
+		//the attendees for them so we don't have to run another query using force_join
1951
+		$registrations = $REG->get_all(array(
1952
+			array(
1953
+				'TXN_ID' => $this->_registration->transaction_ID(),
1954
+				'REG_ID' => array('!=', $this->_registration->ID()),
1955
+			),
1956
+			'force_join' => array('Attendee'),
1957
+		));
1958
+		$this->_template_args['attendees'] = array();
1959
+		$this->_template_args['attendee_notice'] = '';
1960
+		if (empty($registrations)
1961
+			|| (is_array($registrations)
1962
+				&& ! EEH_Array::get_one_item_from_array($registrations))
1963
+		) {
1964
+			EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration',
1965
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1966
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
1967
+		} else {
1968
+			$att_nmbr = 1;
1969
+			foreach ($registrations as $registration) {
1970
+				/* @var $registration EE_Registration */
1971
+				$attendee = $registration->attendee()
1972
+					? $registration->attendee()
1973
+					: EEM_Attendee::instance()
1974
+								  ->create_default_object();
1975
+				$this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
1976
+				$this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1977
+				$this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1978
+				$this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1979
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1980
+				$this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ',
1981
+					$attendee->full_address_as_array());
1982
+				$this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array(
1983
+					'action' => 'edit_attendee',
1984
+					'post'   => $attendee->ID(),
1985
+				), REG_ADMIN_URL);
1986
+				$this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
1987
+				$att_nmbr++;
1988
+			}
1989
+			//EEH_Debug_Tools::printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' );
1990
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1991
+			//			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1992
+		}
1993
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1994
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1995
+	}
1996
+
1997
+
1998
+
1999
+	/**
2000
+	 *        generates HTML for the Edit Registration side meta box
2001
+	 *
2002
+	 * @access public
2003
+	 * @return void
2004
+	 */
2005
+	public function _reg_registrant_side_meta_box()
2006
+	{
2007
+		/*@var $attendee EE_Attendee */
2008
+		$att_check = $this->_registration->attendee();
2009
+		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2010
+		//now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not)
2011
+		if ( ! $this->_registration->is_primary_registrant()) {
2012
+			$primary_registration = $this->_registration->get_primary_registration();
2013
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2014
+				: null;
2015
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2016
+				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
2017
+				$primary_registration = null;
2018
+			}
2019
+		} else {
2020
+			$primary_registration = null;
2021
+		}
2022
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2023
+		$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
2024
+		$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
2025
+		$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
2026
+		$this->_template_args['phone'] = $attendee->phone();
2027
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2028
+		//edit link
2029
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
2030
+			'action' => 'edit_attendee',
2031
+			'post'   => $attendee->ID(),
2032
+		), REG_ADMIN_URL);
2033
+		$this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso');
2034
+		//create link
2035
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2036
+			? EE_Admin_Page::add_query_args_and_nonce(array(
2037
+				'action'  => 'duplicate_attendee',
2038
+				'_REG_ID' => $this->_registration->ID(),
2039
+			), REG_ADMIN_URL) : '';
2040
+		$this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
2041
+		$this->_template_args['att_check'] = $att_check;
2042
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2043
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2044
+	}
2045
+
2046
+
2047
+
2048
+	/**
2049
+	 * trash or restore registrations
2050
+	 *
2051
+	 * @param  boolean $trash whether to archive or restore
2052
+	 * @access protected
2053
+	 * @return void
2054
+	 */
2055
+	protected function _trash_or_restore_registrations($trash = true)
2056
+	{
2057
+		$REGM = EEM_Registration::instance();
2058
+		$success = 1;
2059
+		$error = 0;
2060
+		$tickets = array();
2061
+		$dtts = array();
2062
+		//if empty _REG_ID then get out because there's nothing to do
2063
+		if (empty($this->_req_data['_REG_ID'])) {
2064
+			$msg = $trash
2065
+				? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.',
2066
+					'event_espresso')
2067
+				: __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.',
2068
+					'event_espresso');
2069
+			EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
2070
+			$this->_redirect_after_action(false, '', '', array(), true);
2071
+		}
2072
+		//Checkboxes
2073
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2074
+			// if array has more than one element than success message should be plural
2075
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2076
+			// cycle thru checkboxes
2077
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2078
+				/** @var EE_Registration $REG */
2079
+				$REG = $REGM->get_one_by_ID($REG_ID);
2080
+				$payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
2081
+				if ($payment_count > 0) {
2082
+					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name()
2083
+						: __('Unknown Attendee', 'event_espresso');
2084
+					$error = 1;
2085
+					$success = 0;
2086
+					EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2087
+						'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
2088
+					continue; //can't trash this registration because it has payments.
2089
+				}
2090
+				$ticket = $REG->get_first_related('Ticket');
2091
+				$tickets[$ticket->ID()] = $ticket;
2092
+				$dtt = $ticket->get_many_related('Datetime');
2093
+				$dtts = array_merge($dtts, $dtt);
2094
+				$updated = $trash ? $REG->delete() : $REG->restore();
2095
+				if ( ! $updated) {
2096
+					$success = 0;
2097
+				} else {
2098
+					$success = 2;
2099
+				}/**/
2100
+			}
2101
+		} else {
2102
+			// grab single id and delete
2103
+			$REG_ID = absint($this->_req_data['_REG_ID']);
2104
+			$REG = $REGM->get_one_by_ID($REG_ID);
2105
+			$ticket = $REG->get_first_related('Ticket');
2106
+			$tickets[$ticket->ID()] = $ticket;
2107
+			$dtts = $ticket->get_many_related('Datetime');
2108
+			$updated = $trash ? $REG->delete() : $REG->restore();
2109
+			if ( ! $updated) {
2110
+				$success = 0;
2111
+			}
2112
+		}
2113
+		//now let's update counts
2114
+		EEM_Ticket::instance()->update_tickets_sold($tickets);
2115
+		EEM_Datetime::instance()->update_sold($dtts);
2116
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2117
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2118
+		$overwrite_msgs = $error ? true : false;
2119
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
2120
+	}
2121
+
2122
+
2123
+
2124
+	/**
2125
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2126
+	 * registration but also.
2127
+	 * 1. Removing relations to EE_Attendee
2128
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2129
+	 * ALSO trashed.
2130
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2131
+	 * 4. Removing relationships between all tickets and the related registrations
2132
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2133
+	 * 6. Deleting permanently any related Checkins.
2134
+	 *
2135
+	 * @return void
2136
+	 */
2137
+	protected function _delete_registrations()
2138
+	{
2139
+		$REG_MDL = EEM_Registration::instance();
2140
+		$success = 1;
2141
+		//Checkboxes
2142
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2143
+			// if array has more than one element than success message should be plural
2144
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2145
+			// cycle thru checkboxes
2146
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2147
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2148
+				if ( ! $REG instanceof EE_Registration) {
2149
+					continue;
2150
+				}
2151
+				$deleted = $this->_delete_registration($REG);
2152
+				if ( ! $deleted) {
2153
+					$success = 0;
2154
+				}
2155
+			}
2156
+		} else {
2157
+			// grab single id and delete
2158
+			$REG_ID = $this->_req_data['_REG_ID'];
2159
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2160
+			$deleted = $this->_delete_registration($REG);
2161
+			if ( ! $deleted) {
2162
+				$success = 0;
2163
+			}
2164
+		}
2165
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2166
+		$action_desc = __('permanently deleted.', 'event_espresso');
2167
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true);
2168
+	}
2169
+
2170
+
2171
+
2172
+	/**
2173
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2174
+	 * models get affected.
2175
+	 *
2176
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2177
+	 * @return boolean              true = successful deletion, false = fail.
2178
+	 */
2179
+	protected function _delete_registration(EE_Registration $REG)
2180
+	{
2181
+		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
2182
+		$TXN = $REG->get_first_related('Transaction');
2183
+		$REGS = $TXN->get_many_related('Registration');
2184
+		$all_trashed = true;
2185
+		foreach ($REGS as $registration) {
2186
+			if ( ! $registration->get('REG_deleted')) {
2187
+				$all_trashed = false;
2188
+			}
2189
+		}
2190
+		if ( ! $all_trashed) {
2191
+			EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2192
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2193
+			return false;
2194
+		}
2195
+		//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
2196
+		foreach ($REGS as $registration) {
2197
+			//delete related answers
2198
+			$registration->delete_related_permanently('Answer');
2199
+			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2200
+			$attendee = $registration->get_first_related('Attendee');
2201
+			if ($attendee instanceof EE_Attendee) {
2202
+				$registration->_remove_relation_to($attendee, 'Attendee');
2203
+			}
2204
+			//now remove relationships to tickets on this registration.
2205
+			$registration->_remove_relations('Ticket');
2206
+			//now delete permanently the checkins related to this registration.
2207
+			$registration->delete_related_permanently('Checkin');
2208
+			if ($registration->ID() === $REG->ID()) {
2209
+				continue;
2210
+			} //we don't want to delete permanently the existing registration just yet.
2211
+			//remove relation to transaction for these registrations if NOT the existing registrations
2212
+			$registration->_remove_relations('Transaction');
2213
+			//delete permanently any related messages.
2214
+			$registration->delete_related_permanently('Message');
2215
+			//now delete this registration permanently
2216
+			$registration->delete_permanently();
2217
+		}
2218
+		//now all related registrations on the transaction are handled.  So let's just handle this registration itself (the transaction and line items should be all that's left).
2219
+		//delete the line items related to the transaction for this registration.
2220
+		$TXN->delete_related_permanently('Line_Item');
2221
+		//we need to remove all the relationships on the transaction
2222
+		$TXN->delete_related_permanently('Payment');
2223
+		$TXN->delete_related_permanently('Extra_Meta');
2224
+		$TXN->delete_related_permanently('Message');
2225
+		//now we can delete this REG permanently (and the transaction of course)
2226
+		$REG->delete_related_permanently('Transaction');
2227
+		return $REG->delete_permanently();
2228
+	}
2229
+
2230
+
2231
+
2232
+	/**
2233
+	 *    generates HTML for the Register New Attendee Admin page
2234
+	 *
2235
+	 * @access private
2236
+	 * @throws \EE_Error
2237
+	 * @return void
2238
+	 */
2239
+	public function new_registration()
2240
+	{
2241
+		if ( ! $this->_set_reg_event()) {
2242
+			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request',
2243
+				'event_espresso'));
2244
+		}
2245
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2246
+		// gotta start with a clean slate if we're not coming here via ajax
2247
+		if ( ! defined('DOING_AJAX')
2248
+			 && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2249
+		) {
2250
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2251
+		}
2252
+		$this->_template_args['event_name'] = '';
2253
+		// event name
2254
+		if ($this->_reg_event) {
2255
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2256
+			$edit_event_url = self::add_query_args_and_nonce(array(
2257
+				'action' => 'edit',
2258
+				'post'   => $this->_reg_event->ID(),
2259
+			), EVENTS_ADMIN_URL);
2260
+			$edit_event_lnk = '<a href="'
2261
+							  . $edit_event_url
2262
+							  . '" title="'
2263
+							  . esc_attr__('Edit ', 'event_espresso')
2264
+							  . $this->_reg_event->name()
2265
+							  . '">'
2266
+							  . __('Edit Event', 'event_espresso')
2267
+							  . '</a>';
2268
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2269
+												   . $edit_event_lnk
2270
+												   . '</span>';
2271
+		}
2272
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2273
+		if (defined('DOING_AJAX')) {
2274
+			$this->_return_json();
2275
+		}
2276
+		// grab header
2277
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2278
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2279
+			$this->_template_args, true);
2280
+		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2281
+		// the details template wrapper
2282
+		$this->display_admin_page_with_sidebar();
2283
+	}
2284
+
2285
+
2286
+
2287
+	/**
2288
+	 * This returns the content for a registration step
2289
+	 *
2290
+	 * @access protected
2291
+	 * @return string html
2292
+	 */
2293
+	protected function _get_registration_step_content()
2294
+	{
2295
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2296
+			$warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2297
+				'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">',
2298
+				'<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>');
2299
+			return '
2300 2300
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2301 2301
 	<script >
2302 2302
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2309,639 +2309,639 @@  discard block
 block discarded – undo
2309 2309
 	        }
2310 2310
 	    }, 800 );
2311 2311
 	</script >';
2312
-        }
2313
-        $template_args = array(
2314
-            'title'                    => '',
2315
-            'content'                  => '',
2316
-            'step_button_text'         => '',
2317
-            'show_notification_toggle' => false,
2318
-        );
2319
-        //to indicate we're processing a new registration
2320
-        $hidden_fields = array(
2321
-            'processing_registration' => array(
2322
-                'type'  => 'hidden',
2323
-                'value' => 0,
2324
-            ),
2325
-            'event_id'                => array(
2326
-                'type'  => 'hidden',
2327
-                'value' => $this->_reg_event->ID(),
2328
-            ),
2329
-        );
2330
-        //if the cart is empty then we know we're at step one so we'll display ticket selector
2331
-        $cart = EE_Registry::instance()->SSN->cart();
2332
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2333
-        switch ($step) {
2334
-            case 'ticket' :
2335
-                $hidden_fields['processing_registration']['value'] = 1;
2336
-                $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2337
-                $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2338
-                $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details',
2339
-                    'event_espresso');
2340
-                $template_args['show_notification_toggle'] = false;
2341
-                break;
2342
-            case 'questions' :
2343
-                $hidden_fields['processing_registration']['value'] = 2;
2344
-                $template_args['title'] = __('Step Two: Add Registrant Details for this Registration',
2345
-                    'event_espresso');
2346
-                //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run.
2347
-                $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2348
-                $template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso');
2349
-                $template_args['show_notification_toggle'] = true;
2350
-                break;
2351
-        }
2352
-        $this->_set_add_edit_form_tags('process_reg_step',
2353
-            $hidden_fields); //we come back to the process_registration_step route.
2354
-        return EEH_Template::display_template(REG_TEMPLATE_PATH
2355
-                                              . 'reg_admin_register_new_attendee_step_content.template.php',
2356
-            $template_args, true);
2357
-    }
2358
-
2359
-
2360
-
2361
-    /**
2362
-     *        set_reg_event
2363
-     *
2364
-     * @access private
2365
-     * @return boolean
2366
-     */
2367
-    private function _set_reg_event()
2368
-    {
2369
-        if (is_object($this->_reg_event)) {
2370
-            return true;
2371
-        }
2372
-        $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
2373
-        if ( ! $EVT_ID) {
2374
-            return false;
2375
-        }
2376
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2377
-        return true;
2378
-    }
2379
-
2380
-
2381
-
2382
-    /**
2383
-     *        process_reg_step
2384
-     *
2385
-     * @access        public
2386
-     * @return        string
2387
-     */
2388
-    public function process_reg_step()
2389
-    {
2390
-        EE_System::do_not_cache();
2391
-        $this->_set_reg_event();
2392
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2393
-        //what step are we on?
2394
-        $cart = EE_Registry::instance()->SSN->cart();
2395
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2396
-        //if doing ajax then we need to verify the nonce
2397
-        if (defined('DOING_AJAX')) {
2398
-            $nonce = isset($this->_req_data[$this->_req_nonce])
2399
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2400
-            $this->_verify_nonce($nonce, $this->_req_nonce);
2401
-        }
2402
-        switch ($step) {
2403
-            case 'ticket' :
2404
-                //process ticket selection
2405
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
2406
-                if ($success) {
2407
-                    EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.',
2408
-                        'event_espresso'));
2409
-                } else {
2410
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
2411
-                }
2412
-                if (defined('DOING_AJAX')) {
2413
-                    $this->new_registration(); //display next step
2414
-                } else {
2415
-                    $query_args['action'] = 'new_registration';
2416
-                    $query_args['processing_registration'] = 1;
2417
-                    $query_args['event_id'] = $this->_reg_event->ID();
2418
-                    $this->_redirect_after_action(false, '', '', $query_args, true);
2419
-                }
2420
-                break;
2421
-            case 'questions' :
2422
-                if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2423
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2424
-                }
2425
-                //process registration
2426
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2427
-                if ($cart instanceof EE_Cart) {
2428
-                    $grand_total = $cart->get_cart_grand_total();
2429
-                    if ($grand_total instanceof EE_Line_Item) {
2430
-                        $grand_total->save_this_and_descendants_to_txn();
2431
-                    }
2432
-                }
2433
-                if ( ! $transaction instanceof EE_Transaction) {
2434
-                    $query_args = array(
2435
-                        'action'                  => 'new_registration',
2436
-                        'processing_registration' => 2,
2437
-                        'event_id'                => $this->_reg_event->ID(),
2438
-                    );
2439
-                    if (defined('DOING_AJAX')) {
2440
-                        //display registration form again because there are errors (maybe validation?)
2441
-                        $this->new_registration();
2442
-                        return;
2443
-                    } else {
2444
-                        $this->_redirect_after_action(false, '', '', $query_args, true);
2445
-                        return;
2446
-                    }
2447
-                }
2448
-                // maybe update status, and make sure to save transaction if not done already
2449
-                if ( ! $transaction->update_status_based_on_total_paid()) {
2450
-                    $transaction->save();
2451
-                }
2452
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2453
-                $this->_req_data = array();
2454
-                $query_args = array(
2455
-                    'action'        => 'redirect_to_txn',
2456
-                    'TXN_ID'        => $transaction->ID(),
2457
-                    'EVT_ID'        => $this->_reg_event->ID(),
2458
-                    'event_name'    => urlencode($this->_reg_event->name()),
2459
-                    'redirect_from' => 'new_registration',
2460
-                );
2461
-                $this->_redirect_after_action(false, '', '', $query_args, true);
2462
-                break;
2463
-        }
2464
-        //what are you looking here for?  Should be nothing to do at this point.
2465
-    }
2466
-
2467
-
2468
-
2469
-    /**
2470
-     * redirect_to_txn
2471
-     *
2472
-     * @access public
2473
-     * @return void
2474
-     */
2475
-    public function redirect_to_txn()
2476
-    {
2477
-        EE_System::do_not_cache();
2478
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2479
-        $query_args = array(
2480
-            'action' => 'view_transaction',
2481
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
2482
-            'page'   => 'espresso_transactions',
2483
-        );
2484
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
2485
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
2486
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
2487
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
2488
-        }
2489
-        EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary',
2490
-                'event_espresso'));
2491
-        $this->_redirect_after_action(false, '', '', $query_args, true);
2492
-    }
2493
-
2494
-
2495
-
2496
-    /**
2497
-     *        generates HTML for the Attendee Contact List
2498
-     *
2499
-     * @access protected
2500
-     * @return void
2501
-     */
2502
-    protected function _attendee_contact_list_table()
2503
-    {
2504
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2505
-        $this->_search_btn_label = __('Contacts', 'event_espresso');
2506
-        $this->display_admin_list_table_page_with_no_sidebar();
2507
-    }
2508
-
2509
-
2510
-
2511
-    /**
2512
-     *        get_attendees
2513
-     *
2514
-     * @param bool $count whether to return count or data.
2515
-     * @access public
2516
-     * @return array
2517
-     */
2518
-    public function get_attendees($per_page, $count = false, $trash = false)
2519
-    {
2520
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2521
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
2522
-        $ATT_MDL = EEM_Attendee::instance();
2523
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2524
-        switch ($this->_req_data['orderby']) {
2525
-            case 'ATT_ID':
2526
-                $orderby = 'ATT_ID';
2527
-                break;
2528
-            case 'ATT_fname':
2529
-                $orderby = 'ATT_fname';
2530
-                break;
2531
-            case 'ATT_email':
2532
-                $orderby = 'ATT_email';
2533
-                break;
2534
-            case 'ATT_city':
2535
-                $orderby = 'ATT_city';
2536
-                break;
2537
-            case 'STA_ID':
2538
-                $orderby = 'STA_ID';
2539
-                break;
2540
-            case 'CNT_ID':
2541
-                $orderby = 'CNT_ID';
2542
-                break;
2543
-            default:
2544
-                $orderby = 'ATT_lname';
2545
-        }
2546
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
2547
-            : 'ASC';
2548
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
2549
-            ? $this->_req_data['paged'] : 1;
2550
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2551
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
2552
-            ? $this->_req_data['perpage'] : $per_page;
2553
-        $_where = array();
2554
-        if ( ! empty($this->_req_data['s'])) {
2555
-            $sstr = '%' . $this->_req_data['s'] . '%';
2556
-            $_where['OR'] = array(
2557
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
2558
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
2559
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2560
-                'ATT_fname'                         => array('LIKE', $sstr),
2561
-                'ATT_lname'                         => array('LIKE', $sstr),
2562
-                'ATT_short_bio'                     => array('LIKE', $sstr),
2563
-                'ATT_email'                         => array('LIKE', $sstr),
2564
-                'ATT_address'                       => array('LIKE', $sstr),
2565
-                'ATT_address2'                      => array('LIKE', $sstr),
2566
-                'ATT_city'                          => array('LIKE', $sstr),
2567
-                'Country.CNT_name'                  => array('LIKE', $sstr),
2568
-                'State.STA_name'                    => array('LIKE', $sstr),
2569
-                'ATT_phone'                         => array('LIKE', $sstr),
2570
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
2571
-                'Registration.REG_code'             => array('LIKE', $sstr),
2572
-                'Registration.REG_count'            => array('LIKE', $sstr),
2573
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
2574
-            );
2575
-        }
2576
-        $offset = ($current_page - 1) * $per_page;
2577
-        $limit = $count ? null : array($offset, $per_page);
2578
-        if ($trash) {
2579
-            $_where['status'] = array('!=', 'publish');
2580
-            $all_attendees = $count
2581
-                ? $ATT_MDL->count(array(
2582
-                    $_where,
2583
-                    'order_by' => array($orderby => $sort),
2584
-                    'limit'    => $limit,
2585
-                ), 'ATT_ID', true)
2586
-                : $ATT_MDL->get_all(array(
2587
-                    $_where,
2588
-                    'order_by' => array($orderby => $sort),
2589
-                    'limit'    => $limit,
2590
-                ));
2591
-        } else {
2592
-            $_where['status'] = array('IN', array('publish'));
2593
-            $all_attendees = $count
2594
-                ? $ATT_MDL->count(array(
2595
-                    $_where,
2596
-                    'order_by' => array($orderby => $sort),
2597
-                    'limit'    => $limit,
2598
-                ), 'ATT_ID', true)
2599
-                : $ATT_MDL->get_all(array(
2600
-                    $_where,
2601
-                    'order_by' => array($orderby => $sort),
2602
-                    'limit'    => $limit,
2603
-                ));
2604
-        }
2605
-        return $all_attendees;
2606
-    }
2607
-
2608
-
2609
-
2610
-    /**
2611
-     * This is just taking care of resending the registration confirmation
2612
-     *
2613
-     * @access protected
2614
-     * @return void
2615
-     */
2616
-    protected function _resend_registration()
2617
-    {
2618
-        $this->_process_resend_registration();
2619
-        $query_args = isset($this->_req_data['redirect_to'])
2620
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
2621
-            : array(
2622
-                'action' => 'default',
2623
-            );
2624
-        $this->_redirect_after_action(false, '', '', $query_args, true);
2625
-    }
2626
-
2627
-
2628
-
2629
-    public function _registrations_report()
2630
-    {
2631
-        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2632
-            wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2633
-                'page'        => 'espresso_batch',
2634
-                'batch'       => 'file',
2635
-                'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2636
-                'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2637
-                'return_url'  => urlencode($this->_req_data['return_url']),
2638
-            )));
2639
-        } else {
2640
-            $new_request_args = array(
2641
-                'export' => 'report',
2642
-                'action' => 'registrations_report_for_event',
2643
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2644
-            );
2645
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
2646
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2647
-                require_once(EE_CLASSES . 'EE_Export.class.php');
2648
-                $EE_Export = EE_Export::instance($this->_req_data);
2649
-                $EE_Export->export();
2650
-            }
2651
-        }
2652
-    }
2653
-
2654
-
2655
-
2656
-    public function _contact_list_export()
2657
-    {
2658
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2659
-            require_once(EE_CLASSES . 'EE_Export.class.php');
2660
-            $EE_Export = EE_Export::instance($this->_req_data);
2661
-            $EE_Export->export_attendees();
2662
-        }
2663
-    }
2664
-
2665
-
2666
-
2667
-    public function _contact_list_report()
2668
-    {
2669
-        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2670
-            wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2671
-                'page'        => 'espresso_batch',
2672
-                'batch'       => 'file',
2673
-                'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2674
-                'return_url'  => urlencode($this->_req_data['return_url']),
2675
-            )));
2676
-        } else {
2677
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2678
-                require_once(EE_CLASSES . 'EE_Export.class.php');
2679
-                $EE_Export = EE_Export::instance($this->_req_data);
2680
-                $EE_Export->report_attendees();
2681
-            }
2682
-        }
2683
-    }
2684
-
2685
-
2686
-
2687
-
2688
-
2689
-    /***************************************        ATTENDEE DETAILS        ***************************************/
2690
-    /**
2691
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
2692
-     *
2693
-     * @return void
2694
-     */
2695
-    protected function _duplicate_attendee()
2696
-    {
2697
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2698
-        //verify we have necessary info
2699
-        if (empty($this->_req_data['_REG_ID'])) {
2700
-            EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
2701
-                'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2702
-            $query_args = array('action' => $action);
2703
-            $this->_redirect_after_action('', '', '', $query_args, true);
2704
-        }
2705
-        //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2706
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2707
-        $attendee = $registration->attendee();
2708
-        //remove relation of existing attendee on registration
2709
-        $registration->_remove_relation_to($attendee, 'Attendee');
2710
-        //new attendee
2711
-        $new_attendee = clone $attendee;
2712
-        $new_attendee->set('ATT_ID', 0);
2713
-        $new_attendee->save();
2714
-        //add new attendee to reg
2715
-        $registration->_add_relation_to($new_attendee, 'Attendee');
2716
-        EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.',
2717
-            'event_espresso'));
2718
-        //redirect to edit page for attendee
2719
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2720
-        $this->_redirect_after_action('', '', '', $query_args, true);
2721
-    }
2722
-
2723
-
2724
-
2725
-    //related to cpt routes
2726
-    protected function _insert_update_cpt_item($post_id, $post)
2727
-    {
2728
-        $success = true;
2729
-        $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2730
-        //for attendee updates
2731
-        if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2732
-            //note we should only be UPDATING attendees at this point.
2733
-            $updated_fields = array(
2734
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
2735
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
2736
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2737
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2738
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2739
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2740
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2741
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2742
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2743
-                'ATT_email'     => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2744
-                'ATT_phone'     => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '',
2745
-            );
2746
-            foreach ($updated_fields as $field => $value) {
2747
-                $attendee->set($field, $value);
2748
-            }
2749
-            $success = $attendee->save();
2750
-            $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
2751
-                array());
2752
-            foreach ($attendee_update_callbacks as $a_callback) {
2753
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2754
-                    throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
2755
-                        'event_espresso'), $a_callback));
2756
-                }
2757
-            }
2758
-        }
2759
-        if ($success === false) {
2760
-            EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.',
2761
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2762
-        }
2763
-    }
2764
-
2765
-
2766
-
2767
-    public function trash_cpt_item($post_id)
2768
-    {
2769
-    }
2770
-
2771
-
2772
-
2773
-    public function delete_cpt_item($post_id)
2774
-    {
2775
-    }
2776
-
2777
-
2778
-
2779
-    public function restore_cpt_item($post_id)
2780
-    {
2781
-    }
2782
-
2783
-
2784
-
2785
-    protected function _restore_cpt_item($post_id, $revision_id)
2786
-    {
2787
-    }
2788
-
2789
-
2790
-
2791
-    public function attendee_editor_metaboxes()
2792
-    {
2793
-        $this->verify_cpt_object();
2794
-        remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action],
2795
-            'normal', 'core');
2796
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2797
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
2798
-            add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box',
2799
-                $this->_cpt_routes[$this->_req_action], 'normal');
2800
-        }
2801
-        if (post_type_supports('espresso_attendees', 'comments')) {
2802
-            add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box',
2803
-                $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2804
-        }
2805
-        add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'),
2806
-            array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2807
-        add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'),
2808
-            array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2809
-        add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'),
2810
-            array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2811
-    }
2812
-
2813
-
2814
-
2815
-    /**
2816
-     * Metabox for attendee contact info
2817
-     *
2818
-     * @param  WP_Post $post wp post object
2819
-     * @return string        attendee contact info ( and form )
2820
-     */
2821
-    public function attendee_contact_info($post)
2822
-    {
2823
-        //get attendee object ( should already have it )
2824
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
2825
-        $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2826
-        EEH_Template::display_template($template, $this->_template_args);
2827
-    }
2828
-
2829
-
2830
-
2831
-    /**
2832
-     * Metabox for attendee details
2833
-     *
2834
-     * @param  WP_Post $post wp post object
2835
-     * @return string        attendee address details (and form)
2836
-     */
2837
-    public function attendee_address_details($post)
2838
-    {
2839
-        //get attendee object (should already have it)
2840
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
2841
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2842
-            'QST_ID'           => 0,
2843
-            'QST_display_text' => __('State/Province', 'event_espresso'),
2844
-            'QST_system'       => 'admin-state',
2845
-        )), EE_Answer::new_instance(array(
2846
-            'ANS_ID'    => 0,
2847
-            'ANS_value' => $this->_cpt_model_obj->state_ID(),
2848
-        )), array(
2849
-                'input_id'       => 'STA_ID',
2850
-                'input_name'     => 'STA_ID',
2851
-                'input_prefix'   => '',
2852
-                'append_qstn_id' => false,
2853
-            )));
2854
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2855
-            'QST_ID'           => 0,
2856
-            'QST_display_text' => __('Country', 'event_espresso'),
2857
-            'QST_system'       => 'admin-country',
2858
-        )), EE_Answer::new_instance(array(
2859
-            'ANS_ID'    => 0,
2860
-            'ANS_value' => $this->_cpt_model_obj->country_ID(),
2861
-        )), array(
2862
-                'input_id'       => 'CNT_ISO',
2863
-                'input_name'     => 'CNT_ISO',
2864
-                'input_prefix'   => '',
2865
-                'append_qstn_id' => false,
2866
-            )));
2867
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2868
-        EEH_Template::display_template($template, $this->_template_args);
2869
-    }
2870
-
2871
-
2872
-
2873
-    /**
2874
-     *        _attendee_details
2875
-     *
2876
-     * @access protected
2877
-     * @return void
2878
-     */
2879
-    public function attendee_registrations_meta_box($post)
2880
-    {
2881
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
2882
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2883
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2884
-        EEH_Template::display_template($template, $this->_template_args);
2885
-    }
2886
-
2887
-
2888
-
2889
-    /**
2890
-     * add in the form fields for the attendee edit
2891
-     *
2892
-     * @param  WP_Post $post wp post object
2893
-     * @return string        html for new form.
2894
-     */
2895
-    public function after_title_form_fields($post)
2896
-    {
2897
-        if ($post->post_type == 'espresso_attendees') {
2898
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2899
-            $template_args['attendee'] = $this->_cpt_model_obj;
2900
-            EEH_Template::display_template($template, $template_args);
2901
-        }
2902
-    }
2903
-
2904
-
2905
-
2906
-    /**
2907
-     *        _trash_or_restore_attendee
2908
-     *
2909
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
2910
-     * @access protected
2911
-     * @return void
2912
-     */
2913
-    protected function _trash_or_restore_attendees($trash = true)
2914
-    {
2915
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2916
-        $ATT_MDL = EEM_Attendee::instance();
2917
-        $success = 1;
2918
-        //Checkboxes
2919
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2920
-            // if array has more than one element than success message should be plural
2921
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2922
-            // cycle thru checkboxes
2923
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2924
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
2925
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2926
-                if ( ! $updated) {
2927
-                    $success = 0;
2928
-                }
2929
-            }
2930
-        } else {
2931
-            // grab single id and delete
2932
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
2933
-            //get attendee
2934
-            $att = $ATT_MDL->get_one_by_ID($ATT_ID);
2935
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2936
-            $updated = $att->save();
2937
-            if ( ! $updated) {
2938
-                $success = 0;
2939
-            }
2940
-        }
2941
-        $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2942
-        $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2943
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2944
-    }
2312
+		}
2313
+		$template_args = array(
2314
+			'title'                    => '',
2315
+			'content'                  => '',
2316
+			'step_button_text'         => '',
2317
+			'show_notification_toggle' => false,
2318
+		);
2319
+		//to indicate we're processing a new registration
2320
+		$hidden_fields = array(
2321
+			'processing_registration' => array(
2322
+				'type'  => 'hidden',
2323
+				'value' => 0,
2324
+			),
2325
+			'event_id'                => array(
2326
+				'type'  => 'hidden',
2327
+				'value' => $this->_reg_event->ID(),
2328
+			),
2329
+		);
2330
+		//if the cart is empty then we know we're at step one so we'll display ticket selector
2331
+		$cart = EE_Registry::instance()->SSN->cart();
2332
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2333
+		switch ($step) {
2334
+			case 'ticket' :
2335
+				$hidden_fields['processing_registration']['value'] = 1;
2336
+				$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2337
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2338
+				$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details',
2339
+					'event_espresso');
2340
+				$template_args['show_notification_toggle'] = false;
2341
+				break;
2342
+			case 'questions' :
2343
+				$hidden_fields['processing_registration']['value'] = 2;
2344
+				$template_args['title'] = __('Step Two: Add Registrant Details for this Registration',
2345
+					'event_espresso');
2346
+				//in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run.
2347
+				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2348
+				$template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso');
2349
+				$template_args['show_notification_toggle'] = true;
2350
+				break;
2351
+		}
2352
+		$this->_set_add_edit_form_tags('process_reg_step',
2353
+			$hidden_fields); //we come back to the process_registration_step route.
2354
+		return EEH_Template::display_template(REG_TEMPLATE_PATH
2355
+											  . 'reg_admin_register_new_attendee_step_content.template.php',
2356
+			$template_args, true);
2357
+	}
2358
+
2359
+
2360
+
2361
+	/**
2362
+	 *        set_reg_event
2363
+	 *
2364
+	 * @access private
2365
+	 * @return boolean
2366
+	 */
2367
+	private function _set_reg_event()
2368
+	{
2369
+		if (is_object($this->_reg_event)) {
2370
+			return true;
2371
+		}
2372
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
2373
+		if ( ! $EVT_ID) {
2374
+			return false;
2375
+		}
2376
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2377
+		return true;
2378
+	}
2379
+
2380
+
2381
+
2382
+	/**
2383
+	 *        process_reg_step
2384
+	 *
2385
+	 * @access        public
2386
+	 * @return        string
2387
+	 */
2388
+	public function process_reg_step()
2389
+	{
2390
+		EE_System::do_not_cache();
2391
+		$this->_set_reg_event();
2392
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2393
+		//what step are we on?
2394
+		$cart = EE_Registry::instance()->SSN->cart();
2395
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2396
+		//if doing ajax then we need to verify the nonce
2397
+		if (defined('DOING_AJAX')) {
2398
+			$nonce = isset($this->_req_data[$this->_req_nonce])
2399
+				? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2400
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2401
+		}
2402
+		switch ($step) {
2403
+			case 'ticket' :
2404
+				//process ticket selection
2405
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2406
+				if ($success) {
2407
+					EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.',
2408
+						'event_espresso'));
2409
+				} else {
2410
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
2411
+				}
2412
+				if (defined('DOING_AJAX')) {
2413
+					$this->new_registration(); //display next step
2414
+				} else {
2415
+					$query_args['action'] = 'new_registration';
2416
+					$query_args['processing_registration'] = 1;
2417
+					$query_args['event_id'] = $this->_reg_event->ID();
2418
+					$this->_redirect_after_action(false, '', '', $query_args, true);
2419
+				}
2420
+				break;
2421
+			case 'questions' :
2422
+				if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2423
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2424
+				}
2425
+				//process registration
2426
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2427
+				if ($cart instanceof EE_Cart) {
2428
+					$grand_total = $cart->get_cart_grand_total();
2429
+					if ($grand_total instanceof EE_Line_Item) {
2430
+						$grand_total->save_this_and_descendants_to_txn();
2431
+					}
2432
+				}
2433
+				if ( ! $transaction instanceof EE_Transaction) {
2434
+					$query_args = array(
2435
+						'action'                  => 'new_registration',
2436
+						'processing_registration' => 2,
2437
+						'event_id'                => $this->_reg_event->ID(),
2438
+					);
2439
+					if (defined('DOING_AJAX')) {
2440
+						//display registration form again because there are errors (maybe validation?)
2441
+						$this->new_registration();
2442
+						return;
2443
+					} else {
2444
+						$this->_redirect_after_action(false, '', '', $query_args, true);
2445
+						return;
2446
+					}
2447
+				}
2448
+				// maybe update status, and make sure to save transaction if not done already
2449
+				if ( ! $transaction->update_status_based_on_total_paid()) {
2450
+					$transaction->save();
2451
+				}
2452
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2453
+				$this->_req_data = array();
2454
+				$query_args = array(
2455
+					'action'        => 'redirect_to_txn',
2456
+					'TXN_ID'        => $transaction->ID(),
2457
+					'EVT_ID'        => $this->_reg_event->ID(),
2458
+					'event_name'    => urlencode($this->_reg_event->name()),
2459
+					'redirect_from' => 'new_registration',
2460
+				);
2461
+				$this->_redirect_after_action(false, '', '', $query_args, true);
2462
+				break;
2463
+		}
2464
+		//what are you looking here for?  Should be nothing to do at this point.
2465
+	}
2466
+
2467
+
2468
+
2469
+	/**
2470
+	 * redirect_to_txn
2471
+	 *
2472
+	 * @access public
2473
+	 * @return void
2474
+	 */
2475
+	public function redirect_to_txn()
2476
+	{
2477
+		EE_System::do_not_cache();
2478
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2479
+		$query_args = array(
2480
+			'action' => 'view_transaction',
2481
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
2482
+			'page'   => 'espresso_transactions',
2483
+		);
2484
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
2485
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
2486
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
2487
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
2488
+		}
2489
+		EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary',
2490
+				'event_espresso'));
2491
+		$this->_redirect_after_action(false, '', '', $query_args, true);
2492
+	}
2493
+
2494
+
2495
+
2496
+	/**
2497
+	 *        generates HTML for the Attendee Contact List
2498
+	 *
2499
+	 * @access protected
2500
+	 * @return void
2501
+	 */
2502
+	protected function _attendee_contact_list_table()
2503
+	{
2504
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2505
+		$this->_search_btn_label = __('Contacts', 'event_espresso');
2506
+		$this->display_admin_list_table_page_with_no_sidebar();
2507
+	}
2508
+
2509
+
2510
+
2511
+	/**
2512
+	 *        get_attendees
2513
+	 *
2514
+	 * @param bool $count whether to return count or data.
2515
+	 * @access public
2516
+	 * @return array
2517
+	 */
2518
+	public function get_attendees($per_page, $count = false, $trash = false)
2519
+	{
2520
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2521
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
2522
+		$ATT_MDL = EEM_Attendee::instance();
2523
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2524
+		switch ($this->_req_data['orderby']) {
2525
+			case 'ATT_ID':
2526
+				$orderby = 'ATT_ID';
2527
+				break;
2528
+			case 'ATT_fname':
2529
+				$orderby = 'ATT_fname';
2530
+				break;
2531
+			case 'ATT_email':
2532
+				$orderby = 'ATT_email';
2533
+				break;
2534
+			case 'ATT_city':
2535
+				$orderby = 'ATT_city';
2536
+				break;
2537
+			case 'STA_ID':
2538
+				$orderby = 'STA_ID';
2539
+				break;
2540
+			case 'CNT_ID':
2541
+				$orderby = 'CNT_ID';
2542
+				break;
2543
+			default:
2544
+				$orderby = 'ATT_lname';
2545
+		}
2546
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
2547
+			: 'ASC';
2548
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
2549
+			? $this->_req_data['paged'] : 1;
2550
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2551
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
2552
+			? $this->_req_data['perpage'] : $per_page;
2553
+		$_where = array();
2554
+		if ( ! empty($this->_req_data['s'])) {
2555
+			$sstr = '%' . $this->_req_data['s'] . '%';
2556
+			$_where['OR'] = array(
2557
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
2558
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
2559
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2560
+				'ATT_fname'                         => array('LIKE', $sstr),
2561
+				'ATT_lname'                         => array('LIKE', $sstr),
2562
+				'ATT_short_bio'                     => array('LIKE', $sstr),
2563
+				'ATT_email'                         => array('LIKE', $sstr),
2564
+				'ATT_address'                       => array('LIKE', $sstr),
2565
+				'ATT_address2'                      => array('LIKE', $sstr),
2566
+				'ATT_city'                          => array('LIKE', $sstr),
2567
+				'Country.CNT_name'                  => array('LIKE', $sstr),
2568
+				'State.STA_name'                    => array('LIKE', $sstr),
2569
+				'ATT_phone'                         => array('LIKE', $sstr),
2570
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
2571
+				'Registration.REG_code'             => array('LIKE', $sstr),
2572
+				'Registration.REG_count'            => array('LIKE', $sstr),
2573
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
2574
+			);
2575
+		}
2576
+		$offset = ($current_page - 1) * $per_page;
2577
+		$limit = $count ? null : array($offset, $per_page);
2578
+		if ($trash) {
2579
+			$_where['status'] = array('!=', 'publish');
2580
+			$all_attendees = $count
2581
+				? $ATT_MDL->count(array(
2582
+					$_where,
2583
+					'order_by' => array($orderby => $sort),
2584
+					'limit'    => $limit,
2585
+				), 'ATT_ID', true)
2586
+				: $ATT_MDL->get_all(array(
2587
+					$_where,
2588
+					'order_by' => array($orderby => $sort),
2589
+					'limit'    => $limit,
2590
+				));
2591
+		} else {
2592
+			$_where['status'] = array('IN', array('publish'));
2593
+			$all_attendees = $count
2594
+				? $ATT_MDL->count(array(
2595
+					$_where,
2596
+					'order_by' => array($orderby => $sort),
2597
+					'limit'    => $limit,
2598
+				), 'ATT_ID', true)
2599
+				: $ATT_MDL->get_all(array(
2600
+					$_where,
2601
+					'order_by' => array($orderby => $sort),
2602
+					'limit'    => $limit,
2603
+				));
2604
+		}
2605
+		return $all_attendees;
2606
+	}
2607
+
2608
+
2609
+
2610
+	/**
2611
+	 * This is just taking care of resending the registration confirmation
2612
+	 *
2613
+	 * @access protected
2614
+	 * @return void
2615
+	 */
2616
+	protected function _resend_registration()
2617
+	{
2618
+		$this->_process_resend_registration();
2619
+		$query_args = isset($this->_req_data['redirect_to'])
2620
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
2621
+			: array(
2622
+				'action' => 'default',
2623
+			);
2624
+		$this->_redirect_after_action(false, '', '', $query_args, true);
2625
+	}
2626
+
2627
+
2628
+
2629
+	public function _registrations_report()
2630
+	{
2631
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2632
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2633
+				'page'        => 'espresso_batch',
2634
+				'batch'       => 'file',
2635
+				'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2636
+				'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2637
+				'return_url'  => urlencode($this->_req_data['return_url']),
2638
+			)));
2639
+		} else {
2640
+			$new_request_args = array(
2641
+				'export' => 'report',
2642
+				'action' => 'registrations_report_for_event',
2643
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2644
+			);
2645
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
2646
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2647
+				require_once(EE_CLASSES . 'EE_Export.class.php');
2648
+				$EE_Export = EE_Export::instance($this->_req_data);
2649
+				$EE_Export->export();
2650
+			}
2651
+		}
2652
+	}
2653
+
2654
+
2655
+
2656
+	public function _contact_list_export()
2657
+	{
2658
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2659
+			require_once(EE_CLASSES . 'EE_Export.class.php');
2660
+			$EE_Export = EE_Export::instance($this->_req_data);
2661
+			$EE_Export->export_attendees();
2662
+		}
2663
+	}
2664
+
2665
+
2666
+
2667
+	public function _contact_list_report()
2668
+	{
2669
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2670
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2671
+				'page'        => 'espresso_batch',
2672
+				'batch'       => 'file',
2673
+				'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2674
+				'return_url'  => urlencode($this->_req_data['return_url']),
2675
+			)));
2676
+		} else {
2677
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2678
+				require_once(EE_CLASSES . 'EE_Export.class.php');
2679
+				$EE_Export = EE_Export::instance($this->_req_data);
2680
+				$EE_Export->report_attendees();
2681
+			}
2682
+		}
2683
+	}
2684
+
2685
+
2686
+
2687
+
2688
+
2689
+	/***************************************        ATTENDEE DETAILS        ***************************************/
2690
+	/**
2691
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
2692
+	 *
2693
+	 * @return void
2694
+	 */
2695
+	protected function _duplicate_attendee()
2696
+	{
2697
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2698
+		//verify we have necessary info
2699
+		if (empty($this->_req_data['_REG_ID'])) {
2700
+			EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
2701
+				'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2702
+			$query_args = array('action' => $action);
2703
+			$this->_redirect_after_action('', '', '', $query_args, true);
2704
+		}
2705
+		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2706
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2707
+		$attendee = $registration->attendee();
2708
+		//remove relation of existing attendee on registration
2709
+		$registration->_remove_relation_to($attendee, 'Attendee');
2710
+		//new attendee
2711
+		$new_attendee = clone $attendee;
2712
+		$new_attendee->set('ATT_ID', 0);
2713
+		$new_attendee->save();
2714
+		//add new attendee to reg
2715
+		$registration->_add_relation_to($new_attendee, 'Attendee');
2716
+		EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.',
2717
+			'event_espresso'));
2718
+		//redirect to edit page for attendee
2719
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2720
+		$this->_redirect_after_action('', '', '', $query_args, true);
2721
+	}
2722
+
2723
+
2724
+
2725
+	//related to cpt routes
2726
+	protected function _insert_update_cpt_item($post_id, $post)
2727
+	{
2728
+		$success = true;
2729
+		$attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2730
+		//for attendee updates
2731
+		if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2732
+			//note we should only be UPDATING attendees at this point.
2733
+			$updated_fields = array(
2734
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
2735
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
2736
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2737
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2738
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2739
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2740
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2741
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2742
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2743
+				'ATT_email'     => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2744
+				'ATT_phone'     => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '',
2745
+			);
2746
+			foreach ($updated_fields as $field => $value) {
2747
+				$attendee->set($field, $value);
2748
+			}
2749
+			$success = $attendee->save();
2750
+			$attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
2751
+				array());
2752
+			foreach ($attendee_update_callbacks as $a_callback) {
2753
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2754
+					throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
2755
+						'event_espresso'), $a_callback));
2756
+				}
2757
+			}
2758
+		}
2759
+		if ($success === false) {
2760
+			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.',
2761
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2762
+		}
2763
+	}
2764
+
2765
+
2766
+
2767
+	public function trash_cpt_item($post_id)
2768
+	{
2769
+	}
2770
+
2771
+
2772
+
2773
+	public function delete_cpt_item($post_id)
2774
+	{
2775
+	}
2776
+
2777
+
2778
+
2779
+	public function restore_cpt_item($post_id)
2780
+	{
2781
+	}
2782
+
2783
+
2784
+
2785
+	protected function _restore_cpt_item($post_id, $revision_id)
2786
+	{
2787
+	}
2788
+
2789
+
2790
+
2791
+	public function attendee_editor_metaboxes()
2792
+	{
2793
+		$this->verify_cpt_object();
2794
+		remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action],
2795
+			'normal', 'core');
2796
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2797
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
2798
+			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box',
2799
+				$this->_cpt_routes[$this->_req_action], 'normal');
2800
+		}
2801
+		if (post_type_supports('espresso_attendees', 'comments')) {
2802
+			add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box',
2803
+				$this->_cpt_routes[$this->_req_action], 'normal', 'core');
2804
+		}
2805
+		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'),
2806
+			array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2807
+		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'),
2808
+			array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2809
+		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'),
2810
+			array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2811
+	}
2812
+
2813
+
2814
+
2815
+	/**
2816
+	 * Metabox for attendee contact info
2817
+	 *
2818
+	 * @param  WP_Post $post wp post object
2819
+	 * @return string        attendee contact info ( and form )
2820
+	 */
2821
+	public function attendee_contact_info($post)
2822
+	{
2823
+		//get attendee object ( should already have it )
2824
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2825
+		$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2826
+		EEH_Template::display_template($template, $this->_template_args);
2827
+	}
2828
+
2829
+
2830
+
2831
+	/**
2832
+	 * Metabox for attendee details
2833
+	 *
2834
+	 * @param  WP_Post $post wp post object
2835
+	 * @return string        attendee address details (and form)
2836
+	 */
2837
+	public function attendee_address_details($post)
2838
+	{
2839
+		//get attendee object (should already have it)
2840
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2841
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2842
+			'QST_ID'           => 0,
2843
+			'QST_display_text' => __('State/Province', 'event_espresso'),
2844
+			'QST_system'       => 'admin-state',
2845
+		)), EE_Answer::new_instance(array(
2846
+			'ANS_ID'    => 0,
2847
+			'ANS_value' => $this->_cpt_model_obj->state_ID(),
2848
+		)), array(
2849
+				'input_id'       => 'STA_ID',
2850
+				'input_name'     => 'STA_ID',
2851
+				'input_prefix'   => '',
2852
+				'append_qstn_id' => false,
2853
+			)));
2854
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2855
+			'QST_ID'           => 0,
2856
+			'QST_display_text' => __('Country', 'event_espresso'),
2857
+			'QST_system'       => 'admin-country',
2858
+		)), EE_Answer::new_instance(array(
2859
+			'ANS_ID'    => 0,
2860
+			'ANS_value' => $this->_cpt_model_obj->country_ID(),
2861
+		)), array(
2862
+				'input_id'       => 'CNT_ISO',
2863
+				'input_name'     => 'CNT_ISO',
2864
+				'input_prefix'   => '',
2865
+				'append_qstn_id' => false,
2866
+			)));
2867
+		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2868
+		EEH_Template::display_template($template, $this->_template_args);
2869
+	}
2870
+
2871
+
2872
+
2873
+	/**
2874
+	 *        _attendee_details
2875
+	 *
2876
+	 * @access protected
2877
+	 * @return void
2878
+	 */
2879
+	public function attendee_registrations_meta_box($post)
2880
+	{
2881
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2882
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2883
+		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2884
+		EEH_Template::display_template($template, $this->_template_args);
2885
+	}
2886
+
2887
+
2888
+
2889
+	/**
2890
+	 * add in the form fields for the attendee edit
2891
+	 *
2892
+	 * @param  WP_Post $post wp post object
2893
+	 * @return string        html for new form.
2894
+	 */
2895
+	public function after_title_form_fields($post)
2896
+	{
2897
+		if ($post->post_type == 'espresso_attendees') {
2898
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2899
+			$template_args['attendee'] = $this->_cpt_model_obj;
2900
+			EEH_Template::display_template($template, $template_args);
2901
+		}
2902
+	}
2903
+
2904
+
2905
+
2906
+	/**
2907
+	 *        _trash_or_restore_attendee
2908
+	 *
2909
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
2910
+	 * @access protected
2911
+	 * @return void
2912
+	 */
2913
+	protected function _trash_or_restore_attendees($trash = true)
2914
+	{
2915
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2916
+		$ATT_MDL = EEM_Attendee::instance();
2917
+		$success = 1;
2918
+		//Checkboxes
2919
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2920
+			// if array has more than one element than success message should be plural
2921
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2922
+			// cycle thru checkboxes
2923
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2924
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
2925
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2926
+				if ( ! $updated) {
2927
+					$success = 0;
2928
+				}
2929
+			}
2930
+		} else {
2931
+			// grab single id and delete
2932
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
2933
+			//get attendee
2934
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
2935
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2936
+			$updated = $att->save();
2937
+			if ( ! $updated) {
2938
+				$success = 0;
2939
+			}
2940
+		}
2941
+		$what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2942
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2943
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2944
+	}
2945 2945
 
2946 2946
 }
2947 2947
 
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
     {
587 587
         //style
588 588
         //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
589
-        wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'),
589
+        wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'),
590 590
             EVENT_ESPRESSO_VERSION);
591 591
         wp_enqueue_style('espresso_reg');
592 592
         //script
593
-        wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js',
593
+        wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js',
594 594
             array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
595 595
         wp_enqueue_script('espresso_reg');
596 596
     }
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     public function load_scripts_styles_contact_list()
625 625
     {
626 626
         wp_deregister_style('espresso_reg');
627
-        wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'),
627
+        wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'),
628 628
             EVENT_ESPRESSO_VERSION);
629 629
         wp_enqueue_style('espresso_att');
630 630
     }
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 
634 634
     public function load_scripts_styles_new_registration()
635 635
     {
636
-        wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'),
636
+        wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'),
637 637
             EVENT_ESPRESSO_VERSION, true);
638 638
         wp_enqueue_script('ee-spco-for-admin');
639 639
         add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
@@ -833,31 +833,31 @@  discard block
 block discarded – undo
833 833
         }
834 834
         $sc_items = array(
835 835
             'approved_status'   => array(
836
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
836
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
837 837
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
838 838
             ),
839 839
             'pending_status'    => array(
840
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
840
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
841 841
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
842 842
             ),
843 843
             'wait_list'         => array(
844
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
844
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
845 845
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
846 846
             ),
847 847
             'incomplete_status' => array(
848
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
848
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
849 849
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'),
850 850
             ),
851 851
             'not_approved'      => array(
852
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
852
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
853 853
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
854 854
             ),
855 855
             'declined_status'   => array(
856
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
856
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
857 857
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
858 858
             ),
859 859
             'cancelled_status'  => array(
860
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
860
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
861 861
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
862 862
             ),
863 863
         );
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
             if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations',
879 879
                 'espresso_registrations_new_registration', $EVT_ID)
880 880
             ) {
881
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant',
881
+                $this->_admin_page_title .= ' '.$this->get_action_link_or_button('new_registration', 'add-registrant',
882 882
                         array('event_id' => $EVT_ID), 'add-new-h2');
883 883
             }
884 884
             $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
885 885
             if ($event instanceof EE_Event) {
886 886
                 $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s',
887 887
                     'event_espresso'), '<h3 style="line-height:1.5em;">',
888
-                    '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array(
888
+                    '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce(array(
889 889
                         'action' => 'edit',
890 890
                         'post'   => $event->ID(),
891
-                    ), EVENTS_ADMIN_URL) . '">&nbsp;' . $event->get('EVT_name') . '&nbsp;</a>&nbsp;', '</h3>');
891
+                    ), EVENTS_ADMIN_URL).'">&nbsp;'.$event->get('EVT_name').'&nbsp;</a>&nbsp;', '</h3>');
892 892
             }
893 893
             $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
894 894
             $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
                 $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
898 898
                 $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
899 899
                 $this->_template_args['admin_page_header'] .= $datetime->name();
900
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
900
+                $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )';
901 901
                 $this->_template_args['admin_page_header'] .= '</span></h3>';
902 902
             }
903 903
         }
@@ -948,13 +948,13 @@  discard block
 block discarded – undo
948 948
     {
949 949
         $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0
950 950
             ? absint($this->_req_data['event_id']) : false;
951
-        $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0
951
+        $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0
952 952
             ? absint($this->_req_data['EVT_CAT']) : false;
953 953
         $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null;
954 954
         $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status'])
955 955
             : false;
956 956
         $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range'])
957
-            : false;//should be like 2013-april
957
+            : false; //should be like 2013-april
958 958
         $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false;
959 959
         $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false;
960 960
         $start_date = false;
@@ -1018,9 +1018,9 @@  discard block
 block discarded – undo
1018 1018
                 'BETWEEN',
1019 1019
                 array(
1020 1020
                     EEM_Registration::instance()
1021
-                                    ->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'),
1021
+                                    ->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'),
1022 1022
                     EEM_Registration::instance()
1023
-                                    ->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'),
1023
+                                    ->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'),
1024 1024
                 ),
1025 1025
             );
1026 1026
         } elseif ($this_month_a || $this_month) {
@@ -1031,10 +1031,10 @@  discard block
 block discarded – undo
1031 1031
                 array(
1032 1032
                     EEM_Registration::instance()
1033 1033
                                     ->convert_datetime_for_query('REG_date',
1034
-                                        $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'),
1034
+                                        $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'),
1035 1035
                     EEM_Registration::instance()
1036 1036
                                     ->convert_datetime_for_query('REG_date',
1037
-                                        $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
1037
+                                        $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
1038 1038
                                         'Y-m-d H:i:s'),
1039 1039
                 ),
1040 1040
             );
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
             $pieces = explode(' ', $this->_req_data['month_range'], 3);
1043 1043
             $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : '';
1044 1044
             $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1045
-            $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01'));
1045
+            $days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01'));
1046 1046
             $_where['REG_date'] = array(
1047 1047
                 'BETWEEN',
1048 1048
                 array(
1049 1049
                     EEM_Registration::instance()
1050
-                                    ->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00',
1050
+                                    ->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00',
1051 1051
                                         'Y-m-d H:i:s'),
1052 1052
                     EEM_Registration::instance()
1053 1053
                                     ->convert_datetime_for_query('REG_date',
1054
-                                        $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'),
1054
+                                        $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s'),
1055 1055
                 ),
1056 1056
             );
1057 1057
         } elseif ($start_date && $end_date) {
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
             throw new EE_Error("not yet supported");
1063 1063
         }
1064 1064
         if ( ! empty($this->_req_data['s'])) {
1065
-            $sstr = '%' . $this->_req_data['s'] . '%';
1065
+            $sstr = '%'.$this->_req_data['s'].'%';
1066 1066
             $_where['OR'] = array(
1067 1067
                 'Event.EVT_name'                          => array('LIKE', $sstr),
1068 1068
                 'Event.EVT_desc'                          => array('LIKE', $sstr),
@@ -1123,16 +1123,16 @@  discard block
 block discarded – undo
1123 1123
                 $event_name = $first_registration->event_obj()->name();
1124 1124
                 $event_date = $first_registration->date_obj()
1125 1125
                                                  ->start_date_and_time('l F j, Y,',
1126
-                                                     'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1126
+                                                     'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1127 1127
                 // edit event link
1128 1128
                 if ($event_name != '') {
1129 1129
                     $edit_event_url = self::add_query_args_and_nonce(array(
1130 1130
                         'action' => 'edit_event',
1131 1131
                         'EVT_ID' => $EVT_ID,
1132 1132
                     ), EVENTS_ADMIN_URL);
1133
-                    $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ',
1134
-                            'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>';
1135
-                    $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>';
1133
+                    $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ',
1134
+                            'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>';
1135
+                    $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
1136 1136
                 }
1137 1137
                 $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL);
1138 1138
                 $back_2_reg_lnk = '<a href="'
@@ -1144,9 +1144,9 @@  discard block
 block discarded – undo
1144 1144
                                   . '</a>';
1145 1145
                 $this->_template_args['before_admin_page_content'] = '
1146 1146
 			<div id="admin-page-header">
1147
-				<h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso') . '</span>' . $event_name . '</h1>
1148
-				<h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso') . '</span>' . $event_date . '</h3>
1149
-				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1147
+				<h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso').'</span>'.$event_name.'</h1>
1148
+				<h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso').'</span>'.$event_date.'</h3>
1149
+				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span>
1150 1150
 			</div>
1151 1151
 			';
1152 1152
             }
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
                     '_REG_ID' => $previous_reg['REG_ID'],
1218 1218
                 ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1219 1219
             // grab header
1220
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1220
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1221 1221
             $this->_template_args['REG_ID'] = $this->_registration->ID();
1222 1222
             $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
1223 1223
                 $this->_template_args, true);
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
                         'default' => $this->_registration->ID(),
1295 1295
                     )),
1296 1296
                     'current_status'     => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status',
1297
-                            'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(),
1298
-                            '', 'status-' . $this->_registration->status_ID(),
1297
+                            'event_espresso')))).EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(),
1298
+                            '', 'status-'.$this->_registration->status_ID(),
1299 1299
                             'line-height: 1em; font-size: 1.5em; font-weight: bold;')))),
1300 1300
                     'reg_status'         => new EE_Select_Input($this->_get_reg_statuses(), array(
1301 1301
                             'html_label_text' => __('Change Registration Status to', 'event_espresso'),
@@ -1383,9 +1383,9 @@  discard block
 block discarded – undo
1383 1383
     {
1384 1384
         if (isset($this->_req_data['reg_status_change_form'])) {
1385 1385
             $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1386
-                ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array();
1386
+                ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] : array();
1387 1387
         } else {
1388
-            $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array();
1388
+            $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array();
1389 1389
         }
1390 1390
         $success = $this->_set_registration_status($REG_IDs, $status);
1391 1391
         //notify?
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
     {
1415 1415
         $success = false;
1416 1416
         // typecast $REG_IDs
1417
-        $REG_IDs = (array)$REG_IDs;
1417
+        $REG_IDs = (array) $REG_IDs;
1418 1418
         if ( ! empty($REG_IDs)) {
1419 1419
             $success = true;
1420 1420
             // set default status if none is passed
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
         ), REG_ADMIN_URL);
1715 1715
         $this->_template_args['REG_ID'] = $this->_registration->ID();
1716 1716
         $this->_template_args['event_id'] = $this->_registration->event_ID();
1717
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1717
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
1718 1718
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1719 1719
     }
1720 1720
 
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
             $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1738 1738
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
1739 1739
             $this->_template_args['REG_ID'] = $this->_registration->ID();
1740
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1740
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
1741 1741
             echo EEH_Template::display_template($template_path, $this->_template_args, true);
1742 1742
         }
1743 1743
     }
@@ -1754,7 +1754,7 @@  discard block
 block discarded – undo
1754 1754
      */
1755 1755
     public function form_before_question_group($output)
1756 1756
     {
1757
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1757
+        EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__,
1758 1758
             __('This method would have been protected but was used on a filter callback'
1759 1759
                . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1760 1760
             '4.8.32.rc.000');
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
      */
1777 1777
     public function form_after_question_group($output)
1778 1778
     {
1779
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1779
+        EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__,
1780 1780
             __('This method would have been protected but was used on a filter callback'
1781 1781
                . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1782 1782
             '4.8.32.rc.000');
@@ -1811,14 +1811,14 @@  discard block
 block discarded – undo
1811 1811
      */
1812 1812
     public function form_form_field_label_wrap($label)
1813 1813
     {
1814
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1814
+        EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__,
1815 1815
             __('This method would have been protected but was used on a filter callback'
1816 1816
                . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1817 1817
             '4.8.32.rc.000');
1818 1818
         return '
1819 1819
 			<tr>
1820 1820
 				<th>
1821
-					' . $label . '
1821
+					' . $label.'
1822 1822
 				</th>';
1823 1823
     }
1824 1824
 
@@ -1834,13 +1834,13 @@  discard block
 block discarded – undo
1834 1834
      */
1835 1835
     public function form_form_field_input__wrap($input)
1836 1836
     {
1837
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1837
+        EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__,
1838 1838
             __('This method would have been protected but was used on a filter callback'
1839 1839
                . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1840 1840
             '4.8.32.rc.000');
1841 1841
         return '
1842 1842
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1843
-					' . $input . '
1843
+					' . $input.'
1844 1844
 				</td>
1845 1845
 			</tr>';
1846 1846
     }
@@ -1882,7 +1882,7 @@  discard block
 block discarded – undo
1882 1882
     protected function _get_reg_custom_questions_form($REG_ID)
1883 1883
     {
1884 1884
         if ( ! $this->_reg_custom_questions_form) {
1885
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
1885
+            require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php');
1886 1886
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()
1887 1887
                                                                                                           ->get_one_by_ID($REG_ID));
1888 1888
             $this->_reg_custom_questions_form->_construct_finalize(null, null);
@@ -1973,10 +1973,10 @@  discard block
 block discarded – undo
1973 1973
                     : EEM_Attendee::instance()
1974 1974
                                   ->create_default_object();
1975 1975
                 $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
1976
-                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1977
-                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1978
-                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1979
-                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1976
+                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1977
+                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1978
+                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1979
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1980 1980
                 $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ',
1981 1981
                     $attendee->full_address_as_array());
1982 1982
                 $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array(
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1991 1991
             //			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1992 1992
         }
1993
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1993
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
1994 1994
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1995 1995
     }
1996 1996
 
@@ -2020,9 +2020,9 @@  discard block
 block discarded – undo
2020 2020
             $primary_registration = null;
2021 2021
         }
2022 2022
         $this->_template_args['ATT_ID'] = $attendee->ID();
2023
-        $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
2024
-        $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
2025
-        $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
2023
+        $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname;
2024
+        $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname;
2025
+        $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email;
2026 2026
         $this->_template_args['phone'] = $attendee->phone();
2027 2027
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2028 2028
         //edit link
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
             ), REG_ADMIN_URL) : '';
2040 2040
         $this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
2041 2041
         $this->_template_args['att_check'] = $att_check;
2042
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2042
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2043 2043
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2044 2044
     }
2045 2045
 
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
             $this->_return_json();
2275 2275
         }
2276 2276
         // grab header
2277
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2277
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2278 2278
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2279 2279
             $this->_template_args, true);
2280 2280
         //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
@@ -2297,7 +2297,7 @@  discard block
 block discarded – undo
2297 2297
                 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">',
2298 2298
                 '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>');
2299 2299
             return '
2300
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2300
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2301 2301
 	<script >
2302 2302
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2303 2303
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
     public function get_attendees($per_page, $count = false, $trash = false)
2519 2519
     {
2520 2520
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2521
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
2521
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
2522 2522
         $ATT_MDL = EEM_Attendee::instance();
2523 2523
         $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2524 2524
         switch ($this->_req_data['orderby']) {
@@ -2552,7 +2552,7 @@  discard block
 block discarded – undo
2552 2552
             ? $this->_req_data['perpage'] : $per_page;
2553 2553
         $_where = array();
2554 2554
         if ( ! empty($this->_req_data['s'])) {
2555
-            $sstr = '%' . $this->_req_data['s'] . '%';
2555
+            $sstr = '%'.$this->_req_data['s'].'%';
2556 2556
             $_where['OR'] = array(
2557 2557
                 'Registration.Event.EVT_name'       => array('LIKE', $sstr),
2558 2558
                 'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
@@ -2643,8 +2643,8 @@  discard block
 block discarded – undo
2643 2643
                 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2644 2644
             );
2645 2645
             $this->_req_data = array_merge($this->_req_data, $new_request_args);
2646
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2647
-                require_once(EE_CLASSES . 'EE_Export.class.php');
2646
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2647
+                require_once(EE_CLASSES.'EE_Export.class.php');
2648 2648
                 $EE_Export = EE_Export::instance($this->_req_data);
2649 2649
                 $EE_Export->export();
2650 2650
             }
@@ -2655,8 +2655,8 @@  discard block
 block discarded – undo
2655 2655
 
2656 2656
     public function _contact_list_export()
2657 2657
     {
2658
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2659
-            require_once(EE_CLASSES . 'EE_Export.class.php');
2658
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2659
+            require_once(EE_CLASSES.'EE_Export.class.php');
2660 2660
             $EE_Export = EE_Export::instance($this->_req_data);
2661 2661
             $EE_Export->export_attendees();
2662 2662
         }
@@ -2674,8 +2674,8 @@  discard block
 block discarded – undo
2674 2674
                 'return_url'  => urlencode($this->_req_data['return_url']),
2675 2675
             )));
2676 2676
         } else {
2677
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2678
-                require_once(EE_CLASSES . 'EE_Export.class.php');
2677
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2678
+                require_once(EE_CLASSES.'EE_Export.class.php');
2679 2679
                 $EE_Export = EE_Export::instance($this->_req_data);
2680 2680
                 $EE_Export->report_attendees();
2681 2681
             }
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
             $updated_fields = array(
2734 2734
                 'ATT_fname'     => $this->_req_data['ATT_fname'],
2735 2735
                 'ATT_lname'     => $this->_req_data['ATT_lname'],
2736
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2736
+                'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
2737 2737
                 'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2738 2738
                 'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2739 2739
                 'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
@@ -2822,7 +2822,7 @@  discard block
 block discarded – undo
2822 2822
     {
2823 2823
         //get attendee object ( should already have it )
2824 2824
         $this->_template_args['attendee'] = $this->_cpt_model_obj;
2825
-        $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2825
+        $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php';
2826 2826
         EEH_Template::display_template($template, $this->_template_args);
2827 2827
     }
2828 2828
 
@@ -2864,7 +2864,7 @@  discard block
 block discarded – undo
2864 2864
                 'input_prefix'   => '',
2865 2865
                 'append_qstn_id' => false,
2866 2866
             )));
2867
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2867
+        $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
2868 2868
         EEH_Template::display_template($template, $this->_template_args);
2869 2869
     }
2870 2870
 
@@ -2880,7 +2880,7 @@  discard block
 block discarded – undo
2880 2880
     {
2881 2881
         $this->_template_args['attendee'] = $this->_cpt_model_obj;
2882 2882
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2883
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2883
+        $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
2884 2884
         EEH_Template::display_template($template, $this->_template_args);
2885 2885
     }
2886 2886
 
@@ -2895,7 +2895,7 @@  discard block
 block discarded – undo
2895 2895
     public function after_title_form_fields($post)
2896 2896
     {
2897 2897
         if ($post->post_type == 'espresso_attendees') {
2898
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2898
+            $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
2899 2899
             $template_args['attendee'] = $this->_cpt_model_obj;
2900 2900
             EEH_Template::display_template($template, $template_args);
2901 2901
         }
Please login to merge, or discard this patch.
modules/ticket_selector_caff/EED_Ticket_Selector_Caff.module.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 
104 104
 
105 105
 
106
-    /**
107
-     * @return \EE_Form_Section_Proper
108
-     * @throws \EE_Error
109
-     */
110
-    public static function _ticket_selector_appearance_settings() {
111
-	    // get option for whether to show datetime selector in TS
112
-	    $show_datetime_selector = \EE_Registry::instance()
113
-		    ->CFG
114
-		    ->template_settings
115
-		    ->EED_Ticket_Selector
116
-		    ->getShowDatetimeSelector();
117
-	    // and option for how may datetimes must exist if display is conditional
118
-	    $datetime_selector_threshold = \EE_Registry::instance()
119
-		    ->CFG
120
-		    ->template_settings
121
-		    ->EED_Ticket_Selector
122
-		    ->getDatetimeSelectorThreshold();
106
+	/**
107
+	 * @return \EE_Form_Section_Proper
108
+	 * @throws \EE_Error
109
+	 */
110
+	public static function _ticket_selector_appearance_settings() {
111
+		// get option for whether to show datetime selector in TS
112
+		$show_datetime_selector = \EE_Registry::instance()
113
+			->CFG
114
+			->template_settings
115
+			->EED_Ticket_Selector
116
+			->getShowDatetimeSelector();
117
+		// and option for how may datetimes must exist if display is conditional
118
+		$datetime_selector_threshold = \EE_Registry::instance()
119
+			->CFG
120
+			->template_settings
121
+			->EED_Ticket_Selector
122
+			->getDatetimeSelectorThreshold();
123 123
 
124 124
 		return new EE_Form_Section_Proper(
125 125
 			array(
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 								)
162 162
 							),
163 163
 							'show_datetime_selector' => new EE_Select_Input(
164
-                                \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false),
164
+								\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false),
165 165
 								array(
166 166
 									'html_label_text' => esc_html__( 'Show Datetime Selector?', 'event_espresso' ),
167 167
 									'html_help_text' => sprintf(
168
-									    esc_html__(
169
-									        'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates for the available tickets. Ticket options will then be hidden until a date is selected, and then only tickets for that date are shown.%1$sOptions include:%1$s &bull; do not show datetime selector%1$s &nbsp; this option will NEVER display a datetime selector, regardless of how many datetimes exist.%1$s &bull; maybe show datetime selector%1$s &nbsp; this option will conditionally display a datetime selector when the number of datetimes for the event matches the value set for "Datetime Selector Threshold".',
170
-                                            'event_espresso'
171
-                                        ),
172
-                                        '<br>'
173
-                                    ),
168
+										esc_html__(
169
+											'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates for the available tickets. Ticket options will then be hidden until a date is selected, and then only tickets for that date are shown.%1$sOptions include:%1$s &bull; do not show datetime selector%1$s &nbsp; this option will NEVER display a datetime selector, regardless of how many datetimes exist.%1$s &bull; maybe show datetime selector%1$s &nbsp; this option will conditionally display a datetime selector when the number of datetimes for the event matches the value set for "Datetime Selector Threshold".',
170
+											'event_espresso'
171
+										),
172
+										'<br>'
173
+									),
174 174
 									'default' => ! empty( $show_datetime_selector )
175 175
 										? $show_datetime_selector
176 176
 										: \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 								)
179 179
 							),
180 180
 							'datetime_selector_threshold' => new EE_Select_Input(
181
-                                range(0,10),
181
+								range(0,10),
182 182
 								array(
183 183
 									'html_label_text' => esc_html__( 'Datetime Selector Threshold', 'event_espresso' ),
184 184
 									'html_help_text' => esc_html__(
185
-                                        'The number of datetimes an event has to have before conditionally displaying a datetime selector',
186
-                                        'event_espresso'
187
-                                    ),
185
+										'The number of datetimes an event has to have before conditionally displaying a datetime selector',
186
+										'event_espresso'
187
+									),
188 188
 									'default' => ! empty( $datetime_selector_threshold )
189 189
 										? $datetime_selector_threshold
190 190
 										: 3,
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 					$CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
233 233
 					$CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
234 234
 					$CFG->EED_Ticket_Selector->setShowDatetimeSelector(
235
-					    $valid_data['appearance_settings']['show_datetime_selector']
236
-                    );
235
+						$valid_data['appearance_settings']['show_datetime_selector']
236
+					);
237 237
 					$CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
238
-					    $valid_data['appearance_settings']['datetime_selector_threshold']
239
-                    );
238
+						$valid_data['appearance_settings']['datetime_selector_threshold']
239
+					);
240 240
 				} else {
241 241
 					if ( $ticket_selector_form->submission_error_message() !== '' ) {
242 242
 						EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ );
Please login to merge, or discard this patch.