Completed
Branch BUG-10477-answer-cache-id (4bdd94)
by
unknown
36:00 queued 24:53
created
modules/ical/EED_Ical.module.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	public static function set_hooks() {
34 34
 		// create download buttons
35 35
 		add_filter(
36
-		    'FHEE__espresso_list_of_event_dates__datetime_html',
37
-            array( 'EED_Ical', 'generate_add_to_iCal_button' ),
38
-            10,
39
-            2
40
-        );
36
+			'FHEE__espresso_list_of_event_dates__datetime_html',
37
+			array( 'EED_Ical', 'generate_add_to_iCal_button' ),
38
+			10,
39
+			2
40
+		);
41 41
 		 // process ics download request
42 42
 		EE_Config::register_route( 'download_ics_file', 'EED_Ical', 'download_ics_file' );
43 43
 	}
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
 
67 67
 
68 68
 
69
-    /**
70
-     *    generate_add_to_iCal_button
71
-     *
72
-     * @access    public
73
-     * @param $html
74
-     * @param $datetime
75
-     * @return    string
76
-     * @throws \EE_Error
77
-     */
69
+	/**
70
+	 *    generate_add_to_iCal_button
71
+	 *
72
+	 * @access    public
73
+	 * @param $html
74
+	 * @param $datetime
75
+	 * @return    string
76
+	 * @throws \EE_Error
77
+	 */
78 78
 	public static function generate_add_to_iCal_button( $html, $datetime ) {
79 79
 		// first verify a proper datetime object has been received
80 80
 		if ( $datetime instanceof EE_Datetime ) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 					$html .= '</form>';
94 94
 					break;
95 95
 				// buttons are just links that have been styled to appear as buttons,
96
-                // but may not be blend with a theme as well as submit buttons
96
+				// but may not be blend with a theme as well as submit buttons
97 97
 				case 'button' :
98 98
 					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL;
99 99
 					$html .= '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 
115 115
 
116 116
 
117
-    /**
118
-     *    download_ics_file
119
-     *
120
-     * @access    public
121
-     * @return    void
122
-     * @throws \EE_Error
123
-     */
117
+	/**
118
+	 *    download_ics_file
119
+	 *
120
+	 * @access    public
121
+	 * @return    void
122
+	 * @throws \EE_Error
123
+	 */
124 124
 	public static function download_ics_file() {
125 125
 		if ( EE_Registry::instance()->REQ->is_set( 'ics_id' )) {
126 126
 			$DTT_ID = absint( EE_Registry::instance()->REQ->get( 'ics_id' ));
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
 			//Escape special chars within the description
229 229
 			$description = EED_Ical::_escape_ICal_data( $description );
230 230
 
231
-		    //Remove line breaks and output in iCal format
232
-		    $description = str_replace( array( "\r\n", "\n"), '\n', $description );
231
+			//Remove line breaks and output in iCal format
232
+			$description = str_replace( array( "\r\n", "\n"), '\n', $description );
233 233
 
234 234
 		return $description;
235 235
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 
3 5
 /**
4 6
  * EED_Ical Class
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @return EED_Ical|EED_Module
20 20
 	 */
21 21
 	public static function instance() {
22
-		return parent::get_instance( __CLASS__ );
22
+		return parent::get_instance(__CLASS__);
23 23
 	}
24 24
 
25 25
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		// create download buttons
35 35
 		add_filter(
36 36
 		    'FHEE__espresso_list_of_event_dates__datetime_html',
37
-            array( 'EED_Ical', 'generate_add_to_iCal_button' ),
37
+            array('EED_Ical', 'generate_add_to_iCal_button'),
38 38
             10,
39 39
             2
40 40
         );
41 41
 		 // process ics download request
42
-		EE_Config::register_route( 'download_ics_file', 'EED_Ical', 'download_ics_file' );
42
+		EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file');
43 43
 	}
44 44
 
45 45
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param    WP $WP
63 63
 	 * @return    void
64 64
 	 */
65
-	public function run( $WP ) {}
65
+	public function run($WP) {}
66 66
 
67 67
 
68 68
 
@@ -75,35 +75,35 @@  discard block
 block discarded – undo
75 75
      * @return    string
76 76
      * @throws \EE_Error
77 77
      */
78
-	public static function generate_add_to_iCal_button( $html, $datetime ) {
78
+	public static function generate_add_to_iCal_button($html, $datetime) {
79 79
 		// first verify a proper datetime object has been received
80
-		if ( $datetime instanceof EE_Datetime ) {
80
+		if ($datetime instanceof EE_Datetime) {
81 81
 			// set whether a link or submit button is shown
82
-			$iCal_type = apply_filters( 'FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit' );
82
+			$iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit');
83 83
 			// generate a link to the route we registered in set_hooks()
84
-			$URL = add_query_arg( array( 'ee' => 'download_ics_file', 'ics_id' => $datetime->ID() ), site_url() );
84
+			$URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $datetime->ID()), site_url());
85 85
 			// what type ?
86
-			switch ( $iCal_type ) {
86
+			switch ($iCal_type) {
87 87
 				// submit buttons appear as buttons and are very compatible with a theme's style
88 88
 				case 'submit' :
89
-					$html .= '<form id="download-iCal-frm-' . $datetime->ID();
90
-					$html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >';
89
+					$html .= '<form id="download-iCal-frm-'.$datetime->ID();
90
+					$html .= '" class="download-iCal-frm" action="'.$URL.'" method="post" >';
91 91
 					$html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="';
92
-					$html .= __( 'Add to iCal Calendar', 'event_espresso' ) . '"/>';
92
+					$html .= __('Add to iCal Calendar', 'event_espresso').'"/>';
93 93
 					$html .= '</form>';
94 94
 					break;
95 95
 				// buttons are just links that have been styled to appear as buttons,
96 96
                 // but may not be blend with a theme as well as submit buttons
97 97
 				case 'button' :
98
-					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL;
99
-					$html .= '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
98
+					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="'.$URL;
99
+					$html .= '" title="'.__('Add to iCal Calendar', 'event_espresso').'">';
100 100
 					$html .= ' <span class="dashicons dashicons-calendar"></span>';
101 101
 					$html .= '</a>';
102 102
 					break;
103 103
 				// links are just links that use the calendar dashicon
104 104
 				case 'icon' :
105
-					$html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="';
106
-					$html .= __( 'Add to iCal Calendar', 'event_espresso' ) . '">';
105
+					$html .= '<a class="ee-ical-lnk" href="'.$URL.'" title="';
106
+					$html .= __('Add to iCal Calendar', 'event_espresso').'">';
107 107
 					$html .= ' <span class="dashicons dashicons-calendar"></span>';
108 108
 					$html .= '</a>';
109 109
 					break;
@@ -122,29 +122,29 @@  discard block
 block discarded – undo
122 122
      * @throws \EE_Error
123 123
      */
124 124
 	public static function download_ics_file() {
125
-		if ( EE_Registry::instance()->REQ->is_set( 'ics_id' )) {
126
-			$DTT_ID = absint( EE_Registry::instance()->REQ->get( 'ics_id' ));
127
-			$datetime = EE_Registry::instance()->load_model( 'Datetime' )->get_one_by_ID( $DTT_ID );
128
-			if ( $datetime instanceof EE_Datetime ) {
125
+		if (EE_Registry::instance()->REQ->is_set('ics_id')) {
126
+			$DTT_ID = absint(EE_Registry::instance()->REQ->get('ics_id'));
127
+			$datetime = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($DTT_ID);
128
+			if ($datetime instanceof EE_Datetime) {
129 129
 				// get related event, venues, and event categories
130 130
 				$event = $datetime->event();
131 131
 				// get related category Term object and it's name
132 132
 				$category = $event->first_event_category();
133
-				if ( $category instanceof EE_Term ) {
133
+				if ($category instanceof EE_Term) {
134 134
 					$category = $category->name();
135 135
 				}
136 136
 				$location = '';
137 137
 				// get first related venue and convert to CSV string
138
-				$venue = $event->venues(array( 'limit'=>1 ));
139
-				if ( is_array( $venue ) && ! empty( $venue )) {
140
-					$venue = array_shift( $venue );
141
-					if ( $venue instanceof EE_Venue ) {
142
-						$location = espresso_venue_raw_address( 'inline', $venue->ID(), FALSE );
138
+				$venue = $event->venues(array('limit'=>1));
139
+				if (is_array($venue) && ! empty($venue)) {
140
+					$venue = array_shift($venue);
141
+					if ($venue instanceof EE_Venue) {
142
+						$location = espresso_venue_raw_address('inline', $venue->ID(), FALSE);
143 143
 					}
144 144
 				}
145 145
 
146 146
 				//Generate filename
147
-				$filename = $event->slug() . '-' . $datetime->start_date( 'Y-m-d' ) . '.ics';
147
+				$filename = $event->slug().'-'.$datetime->start_date('Y-m-d').'.ics';
148 148
 
149 149
 				//Check the datetime status has not been cancelled and set the ics value accordingly
150 150
 				$status = $datetime->get_active_status();
@@ -153,62 +153,62 @@  discard block
 block discarded – undo
153 153
 				// Create array of ics details, escape strings, convert timestamps to ics format, etc
154 154
 				$ics_data = array(
155 155
 					'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name,
156
-					'UID' => md5( $event->name() . $event->ID() . $datetime->ID() ),
156
+					'UID' => md5($event->name().$event->ID().$datetime->ID()),
157 157
 					'ORGANIZER' => EE_Registry::instance()->CFG->organization->email,
158
-					'DTSTAMP' => date( EED_Ical::iCal_datetime_format ),
158
+					'DTSTAMP' => date(EED_Ical::iCal_datetime_format),
159 159
 					'LOCATION' => $location,
160 160
 					'SUMMARY' => $event->name(),
161
-					'DESCRIPTION' => wp_strip_all_tags( $event->description() ),
161
+					'DESCRIPTION' => wp_strip_all_tags($event->description()),
162 162
 					'STATUS' => $status,
163 163
 					'CATEGORIES' => $category,
164
-					'URL;VALUE=URI' => get_permalink( $event->ID() ),
165
-					'DTSTART' => date( EED_Ical::iCal_datetime_format, $datetime->start() ),
166
-					'DTEND' => date( EED_Ical::iCal_datetime_format, $datetime->end() ),
164
+					'URL;VALUE=URI' => get_permalink($event->ID()),
165
+					'DTSTART' => date(EED_Ical::iCal_datetime_format, $datetime->start()),
166
+					'DTEND' => date(EED_Ical::iCal_datetime_format, $datetime->end()),
167 167
 				);
168 168
 
169 169
 				//Filter the values used within the ics output.
170 170
 				//NOTE - all values within ics_data will be escaped automatically.
171
-				$ics_data = apply_filters( 'FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime );
171
+				$ics_data = apply_filters('FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime);
172 172
 
173 173
 				//Escape all ics data
174
-				foreach( $ics_data as $key => $value ) {
174
+				foreach ($ics_data as $key => $value) {
175 175
 					//Description is escaped differently from all all values
176
-					if( $key === 'DESCRIPTION' ) {
177
-						$ics_data[$key] = EED_Ical::_escape_ICal_description( wp_strip_all_tags( $value ) );
176
+					if ($key === 'DESCRIPTION') {
177
+						$ics_data[$key] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value));
178 178
 					} else {
179
-						$ics_data[$key] = EED_Ical::_escape_ICal_data( $value );
179
+						$ics_data[$key] = EED_Ical::_escape_ICal_data($value);
180 180
 					}
181 181
 				}
182 182
 
183 183
 				//Pull the organizer name from ics_data and remove it from the array.
184
-				$organizer_name = isset( $ics_data['ORGANIZER_NAME'] ) ? $ics_data['ORGANIZER_NAME'] : '';
185
-				unset( $ics_data['ORGANIZER_NAME'] );
184
+				$organizer_name = isset($ics_data['ORGANIZER_NAME']) ? $ics_data['ORGANIZER_NAME'] : '';
185
+				unset($ics_data['ORGANIZER_NAME']);
186 186
 
187 187
 				// set headers
188
-				header( 'Content-type: text/calendar; charset=utf-8' );
189
-				header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
190
-				header( 'Cache-Control: private, max-age=0, must-revalidate' );
191
-				header( 'Pragma: public' );
192
-				header( 'Content-Type: application/octet-stream' );
193
-				header( 'Content-Type: application/force-download' );
194
-				header( 'Cache-Control: no-cache, must-revalidate' );
195
-				header( 'Content-Transfer-Encoding: binary' );
196
-				header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); // past date
197
-				ini_set( 'zlib.output_compression', '0' );
188
+				header('Content-type: text/calendar; charset=utf-8');
189
+				header('Content-Disposition: attachment; filename="'.$filename.'"');
190
+				header('Cache-Control: private, max-age=0, must-revalidate');
191
+				header('Pragma: public');
192
+				header('Content-Type: application/octet-stream');
193
+				header('Content-Type: application/force-download');
194
+				header('Cache-Control: no-cache, must-revalidate');
195
+				header('Content-Transfer-Encoding: binary');
196
+				header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date
197
+				ini_set('zlib.output_compression', '0');
198 198
 				// echo the output
199
-				echo "BEGIN:VCALENDAR" . PHP_EOL;
200
-				echo "VERSION:2.0" . PHP_EOL;
201
-				echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN" . PHP_EOL;
202
-				echo "CALSCALE:GREGORIAN" . PHP_EOL;
203
-				echo "BEGIN:VEVENT" . PHP_EOL;
199
+				echo "BEGIN:VCALENDAR".PHP_EOL;
200
+				echo "VERSION:2.0".PHP_EOL;
201
+				echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN".PHP_EOL;
202
+				echo "CALSCALE:GREGORIAN".PHP_EOL;
203
+				echo "BEGIN:VEVENT".PHP_EOL;
204 204
 				
205 205
 				//Output all remaining values from ics_data.
206
-				foreach( $ics_data as $key => $value ) {
207
-					echo $key . ':' . $value . PHP_EOL;
206
+				foreach ($ics_data as $key => $value) {
207
+					echo $key.':'.$value.PHP_EOL;
208 208
 				}
209 209
 
210
-				echo "END:VEVENT" . PHP_EOL;
211
-				echo "END:VCALENDAR" . PHP_EOL;
210
+				echo "END:VEVENT".PHP_EOL;
211
+				echo "END:VCALENDAR".PHP_EOL;
212 212
 			}
213 213
 		}
214 214
 		die();
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 *  	@param	string $string
224 224
 	 *  	@return	string
225 225
 	 */
226
-	private static function _escape_ICal_data( $string = '' ) {
227
-		return preg_replace( '/([\,;])/', '\\\$1', $string );
226
+	private static function _escape_ICal_data($string = '') {
227
+		return preg_replace('/([\,;])/', '\\\$1', $string);
228 228
 	}
229 229
 
230 230
 	/**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
 	 *  	@param	string $description
235 235
 	 *  	@return	string
236 236
 	 */
237
-	private static function _escape_ICal_description( $description = '' ) {
237
+	private static function _escape_ICal_description($description = '') {
238 238
 
239 239
 			//Escape special chars within the description
240
-			$description = EED_Ical::_escape_ICal_data( $description );
240
+			$description = EED_Ical::_escape_ICal_data($description);
241 241
 
242 242
 		    //Remove line breaks and output in iCal format
243
-		    $description = str_replace( array( "\r\n", "\n"), '\n', $description );
243
+		    $description = str_replace(array("\r\n", "\n"), '\n', $description);
244 244
 
245 245
 		return $description;
246 246
 	}
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$this->_columns = array_merge( $columns, $this->_columns );
88 88
 		$this->_primary_column = '_REG_att_checked_in';
89 89
 		if ( ! empty( $evt_id )
90
-		     && EE_Registry::instance()->CAP->current_user_can(
90
+			 && EE_Registry::instance()->CAP->current_user_can(
91 91
 				'ee_read_registrations',
92 92
 				'espresso_registrations_registrations_reports',
93 93
 				$evt_id
@@ -104,44 +104,44 @@  discard block
 block discarded – undo
104 104
 				),
105 105
 			);
106 106
 		}
107
-        $this->_bottom_buttons['report_filtered'] = array(
108
-            'route'         => 'registrations_checkin_report',
109
-            'extra_request' => array(
110
-                'use_filters' => true,
111
-                'filters'     => array_merge(
112
-                    array(
113
-                        'EVT_ID' => $evt_id,
114
-                    ),
115
-                    array_diff_key(
116
-                        $this->_req_data,
117
-                        array_flip(
118
-                            array(
119
-                                'page',
120
-                                'action',
121
-                                'default_nonce',
122
-                            )
123
-                        )
124
-                    )
125
-                ),
126
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
127
-            ),
128
-        );
107
+		$this->_bottom_buttons['report_filtered'] = array(
108
+			'route'         => 'registrations_checkin_report',
109
+			'extra_request' => array(
110
+				'use_filters' => true,
111
+				'filters'     => array_merge(
112
+					array(
113
+						'EVT_ID' => $evt_id,
114
+					),
115
+					array_diff_key(
116
+						$this->_req_data,
117
+						array_flip(
118
+							array(
119
+								'page',
120
+								'action',
121
+								'default_nonce',
122
+							)
123
+						)
124
+					)
125
+				),
126
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
127
+			),
128
+		);
129 129
 		$this->_sortable_columns = array(
130
-            /**
131
-             * Allows users to change the default sort if they wish.
132
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
133
-             *
134
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
135
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
136
-             * for a specific list table you can use the provided reference to this object instance.
137
-             */
130
+			/**
131
+			 * Allows users to change the default sort if they wish.
132
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
133
+			 *
134
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
135
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
136
+			 * for a specific list table you can use the provided reference to this object instance.
137
+			 */
138 138
 			'ATT_name' => array(
139
-                    'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
140
-                    true,
141
-                    $this
142
-                )
143
-                ? array( 'ATT_lname' => true )
144
-                : array( 'ATT_fname' => true ),
139
+					'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
140
+					true,
141
+					$this
142
+				)
143
+				? array( 'ATT_lname' => true )
144
+				: array( 'ATT_fname' => true ),
145 145
 			'Event'    => array( 'Event.EVT.Name' => false ),
146 146
 		);
147 147
 		$this->_hidden_columns = array();
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 			if ( count( $this->_dtts_for_event ) > 1 ) {
225 225
 				$dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' );
226 226
 				foreach ( $this->_dtts_for_event as $dtt ) {
227
-                    $datetime_string = $dtt->name();
228
-                    $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
227
+					$datetime_string = $dtt->name();
228
+					$datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
229 229
 					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
230 230
 					$dtts[ $dtt->ID() ] = $datetime_string;
231 231
 				}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		$checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id );
320 320
 		$nonce = wp_create_nonce( 'checkin_nonce' );
321 321
 		$toggle_active = ! empty ( $this->_cur_dtt_id )
322
-		                 && EE_Registry::instance()->CAP->current_user_can(
322
+						 && EE_Registry::instance()->CAP->current_user_can(
323 323
 			'ee_edit_checkin',
324 324
 			'espresso_registrations_toggle_checkin_status',
325 325
 			$item->ID()
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 			: '';
329 329
 		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
330 330
 		return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"'
331
-		       . ' data-_regid="' . $item->ID() . '"'
332
-		       . ' data-dttid="' . $this->_cur_dtt_id . '"'
333
-		       . ' data-nonce="' . $nonce . '">'
334
-		       . '</span>'
335
-		       . $mobile_view_content;
331
+			   . ' data-_regid="' . $item->ID() . '"'
332
+			   . ' data-dttid="' . $this->_cur_dtt_id . '"'
333
+			   . ' data-nonce="' . $nonce . '">'
334
+			   . '</span>'
335
+			   . $mobile_view_content;
336 336
 	}
337 337
 
338 338
 
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 			'espresso_registrations_edit_attendee'
358 358
 		)
359 359
 			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">'
360
-			    . $item->attendee()->full_name()
361
-			    . '</a>'
360
+				. $item->attendee()->full_name()
361
+				. '</a>'
362 362
 			: $item->attendee()->full_name();
363 363
 		$name_link .= $item->count() === 1
364 364
 			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			? $latest_related_datetime->ID()
394 394
 			: $DTT_ID;
395 395
 		if ( ! empty( $DTT_ID )
396
-		     && EE_Registry::instance()->CAP->current_user_can(
396
+			 && EE_Registry::instance()->CAP->current_user_can(
397 397
 				'ee_read_checkins',
398 398
 				'espresso_registrations_registration_checkins'
399 399
 			)
@@ -493,15 +493,15 @@  discard block
 block discarded – undo
493 493
 				) ? '
494 494
 				<span class="reg-pad-rght">
495 495
 					<a class="status-'
496
-				    . $item->transaction()->status_ID()
497
-				    . '" href="'
498
-				    . $view_txn_lnk_url
499
-				    . '"  title="'
500
-				    . esc_attr__( 'View Transaction', 'event_espresso' )
501
-				    . '">
496
+					. $item->transaction()->status_ID()
497
+					. '" href="'
498
+					. $view_txn_lnk_url
499
+					. '"  title="'
500
+					. esc_attr__( 'View Transaction', 'event_espresso' )
501
+					. '">
502 502
 						'
503
-				    . $item->transaction()->pretty_paid()
504
-				    . '
503
+					. $item->transaction()->pretty_paid()
504
+					. '
505 505
 					</a>
506 506
 				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
507 507
 			}
@@ -534,12 +534,12 @@  discard block
 block discarded – undo
534 534
 				'ee_read_transaction',
535 535
 				'espresso_transactions_view_transaction'
536 536
 			) ? '<a href="'
537
-			    . $view_txn_url
538
-			    . '" title="'
539
-			    . esc_attr__( 'View Transaction', 'event_espresso' )
540
-			    . '"><span class="reg-pad-rght">'
541
-			    . $txn_total
542
-			    . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
537
+				. $view_txn_url
538
+				. '" title="'
539
+				. esc_attr__( 'View Transaction', 'event_espresso' )
540
+				. '"><span class="reg-pad-rght">'
541
+				. $txn_total
542
+				. '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
543 543
 		} else {
544 544
 			return '<span class="reg-pad-rght"></span>';
545 545
 		}
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 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
 
@@ -42,51 +42,51 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param \Registrations_Admin_Page $admin_page
44 44
 	 */
45
-	public function __construct( $admin_page ) {
46
-		parent::__construct( $admin_page );
45
+	public function __construct($admin_page) {
46
+		parent::__construct($admin_page);
47 47
 		$this->_status = $this->_admin_page->get_registration_status_array();
48 48
 	}
49 49
 
50 50
 
51 51
 
52 52
 	protected function _setup_data() {
53
-		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page )
54
-			: $this->_admin_page->get_event_attendees( $this->_per_page, false, true );
53
+		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55 55
 		$this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56 56
 			$this->_per_page,
57 57
 			true
58
-		) : $this->_admin_page->get_event_attendees( $this->_per_page, true, true );
58
+		) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59 59
 	}
60 60
 
61 61
 
62 62
 
63 63
 	protected function _set_properties() {
64
-		$evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null;
64
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
65 65
 		$this->_wp_list_args = array(
66
-			'singular' => __( 'registrant', 'event_espresso' ),
67
-			'plural'   => __( 'registrants', 'event_espresso' ),
66
+			'singular' => __('registrant', 'event_espresso'),
67
+			'plural'   => __('registrants', 'event_espresso'),
68 68
 			'ajax'     => true,
69 69
 			'screen'   => $this->_admin_page->get_current_screen()->id,
70 70
 		);
71 71
 		$columns = array();
72 72
 		//$columns['_Reg_Status'] = '';
73
-		if ( ! empty( $evt_id ) ) {
73
+		if ( ! empty($evt_id)) {
74 74
 			$columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text
75 75
 			$this->_has_checkbox_column = true;
76 76
 		}
77 77
 		$this->_columns = array(
78 78
 			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
79
-			'ATT_name'            => __( 'Registrant', 'event_espresso' ),
80
-			'ATT_email'           => __( 'Email Address', 'event_espresso' ),
81
-			'Event'               => __( 'Event', 'event_espresso' ),
82
-			'PRC_name'            => __( 'TKT Option', 'event_espresso' ),
83
-			'_REG_final_price'    => __( 'Price', 'event_espresso' ),
84
-			'TXN_paid'            => __( 'Paid', 'event_espresso' ),
85
-			'TXN_total'           => __( 'Total', 'event_espresso' ),
79
+			'ATT_name'            => __('Registrant', 'event_espresso'),
80
+			'ATT_email'           => __('Email Address', 'event_espresso'),
81
+			'Event'               => __('Event', 'event_espresso'),
82
+			'PRC_name'            => __('TKT Option', 'event_espresso'),
83
+			'_REG_final_price'    => __('Price', 'event_espresso'),
84
+			'TXN_paid'            => __('Paid', 'event_espresso'),
85
+			'TXN_total'           => __('Total', 'event_espresso'),
86 86
 		);
87
-		$this->_columns = array_merge( $columns, $this->_columns );
87
+		$this->_columns = array_merge($columns, $this->_columns);
88 88
 		$this->_primary_column = '_REG_att_checked_in';
89
-		if ( ! empty( $evt_id )
89
+		if ( ! empty($evt_id)
90 90
 		     && EE_Registry::instance()->CAP->current_user_can(
91 91
 				'ee_read_registrations',
92 92
 				'espresso_registrations_registrations_reports',
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 					'extra_request' =>
100 100
 						array(
101 101
 							'EVT_ID'     => $evt_id,
102
-							'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ),
102
+							'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
103 103
 						),
104 104
 				),
105 105
 			);
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
                     true,
141 141
                     $this
142 142
                 )
143
-                ? array( 'ATT_lname' => true )
144
-                : array( 'ATT_fname' => true ),
145
-			'Event'    => array( 'Event.EVT.Name' => false ),
143
+                ? array('ATT_lname' => true)
144
+                : array('ATT_fname' => true),
145
+			'Event'    => array('Event.EVT.Name' => false),
146 146
 		);
147 147
 		$this->_hidden_columns = array();
148
-		$this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id );
148
+		$this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
149 149
 		$this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
150 150
 	}
151 151
 
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	 * @param \EE_Registration $item
156 156
 	 * @return string
157 157
 	 */
158
-	protected function _get_row_class( $item ) {
159
-		$class = parent::_get_row_class( $item );
158
+	protected function _get_row_class($item) {
159
+		$class = parent::_get_row_class($item);
160 160
 		//add status class
161
-		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
162
-		if ( $this->_has_checkbox_column ) {
161
+		$class .= ' ee-status-strip reg-status-'.$item->status_ID();
162
+		if ($this->_has_checkbox_column) {
163 163
 			$class .= ' has-checkbox-column';
164 164
 		}
165 165
 		return $class;
@@ -173,61 +173,61 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	protected function _get_table_filters() {
175 175
 		$filters = $where = array();
176
-		$current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0;
177
-		if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) {
176
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
177
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
178 178
 			//this means we don't have an event so let's setup a filter dropdown for all the events to select
179 179
 			//note possible capability restrictions
180
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
181
-				$where['status**'] = array( '!=', 'private' );
180
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
181
+				$where['status**'] = array('!=', 'private');
182 182
 			}
183
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
183
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
184 184
 				$where['EVT_wp_user'] = get_current_user_id();
185 185
 			}
186 186
 			$events = EEM_Event::instance()->get_all(
187 187
 				array(
188 188
 					$where,
189
-					'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ),
189
+					'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
190 190
 				)
191 191
 			);
192 192
 			$evts[] = array(
193 193
 				'id'   => 0,
194
-				'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ),
194
+				'text' => __('To toggle Check-in status, select an event', 'event_espresso'),
195 195
 			);
196 196
 			$checked = 'checked';
197 197
 			/** @var EE_Event $evt */
198
-			foreach ( $events as $evt ) {
198
+			foreach ($events as $evt) {
199 199
 				//any registrations for this event?
200
-				if ( ! $evt->get_count_of_all_registrations() ) {
200
+				if ( ! $evt->get_count_of_all_registrations()) {
201 201
 					continue;
202 202
 				}
203 203
 				$evts[] = array(
204 204
 					'id'    => $evt->ID(),
205
-					'text'  => $evt->get( 'EVT_name' ),
205
+					'text'  => $evt->get('EVT_name'),
206 206
 					'class' => $evt->is_expired() ? 'ee-expired-event' : '',
207 207
 				);
208
-				if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) {
208
+				if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
209 209
 					$checked = '';
210 210
 				}
211 211
 			}
212 212
 			$event_filter = '<div class="ee-event-filter">';
213
-			$event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID );
213
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
214 214
 			$event_filter .= '<span class="ee-event-filter-toggle">';
215
-			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
216
-			$event_filter .= __( 'Hide Expired Events', 'event_espresso' );
215
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> ';
216
+			$event_filter .= __('Hide Expired Events', 'event_espresso');
217 217
 			$event_filter .= '</span>';
218 218
 			$event_filter .= '</div>';
219 219
 			$filters[] = $event_filter;
220 220
 		}
221
-		if ( ! empty( $this->_dtts_for_event ) ) {
221
+		if ( ! empty($this->_dtts_for_event)) {
222 222
 			//DTT datetimes filter
223
-			$this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0;
224
-			if ( count( $this->_dtts_for_event ) > 1 ) {
225
-				$dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' );
226
-				foreach ( $this->_dtts_for_event as $dtt ) {
223
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
224
+			if (count($this->_dtts_for_event) > 1) {
225
+				$dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso');
226
+				foreach ($this->_dtts_for_event as $dtt) {
227 227
                     $datetime_string = $dtt->name();
228
-                    $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : '';
229
-					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
230
-					$dtts[ $dtt->ID() ] = $datetime_string;
228
+                    $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
229
+					$datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string;
230
+					$dtts[$dtt->ID()] = $datetime_string;
231 231
 				}
232 232
 				$input = new EE_Select_Input(
233 233
 					$dtts,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 					)
239 239
 				);
240 240
 				$filters[] = $input->get_html_for_input();
241
-				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
241
+				$filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
242 242
 			}
243 243
 		}
244 244
 		return $filters;
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
 	 * @throws \EE_Error
258 258
 	 */
259 259
 	protected function _get_total_event_attendees() {
260
-		$EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false;
260
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
261 261
 		$DTT_ID = $this->_cur_dtt_id;
262 262
 		$query_params = array();
263
-		if ( $EVT_ID ) {
263
+		if ($EVT_ID) {
264 264
 			$query_params[0]['EVT_ID'] = $EVT_ID;
265 265
 		}
266 266
 		//if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
267
-		if ( $DTT_ID ) {
267
+		if ($DTT_ID) {
268 268
 			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
269 269
 		}
270 270
 		$status_ids_array = apply_filters(
271 271
 			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
272
-			array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved )
272
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
273 273
 		);
274
-		$query_params[0]['STS_ID'] = array( 'IN', $status_ids_array );
275
-		return EEM_Registration::instance()->count( $query_params );
274
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
275
+		return EEM_Registration::instance()->count($query_params);
276 276
 	}
277 277
 
278 278
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param \EE_Registration $item
282 282
 	 * @return string
283 283
 	 */
284
-	public function column__Reg_Status( EE_Registration $item ) {
285
-		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
284
+	public function column__Reg_Status(EE_Registration $item) {
285
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
286 286
 	}
287 287
 
288 288
 
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @return string
293 293
 	 * @throws \EE_Error
294 294
 	 */
295
-	public function column_cb( $item ) {
296
-		return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() );
295
+	public function column_cb($item) {
296
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
297 297
 	}
298 298
 
299 299
 
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
 	 * @return string
306 306
 	 * @throws \EE_Error
307 307
 	 */
308
-	public function column__REG_att_checked_in( EE_Registration $item ) {
308
+	public function column__REG_att_checked_in(EE_Registration $item) {
309 309
 		$attendee = $item->attendee();
310 310
 		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
311 311
 
312
-		if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) {
312
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
313 313
 			$latest_related_datetime = $item->get_latest_related_datetime();
314
-			if ( $latest_related_datetime instanceof EE_Datetime ) {
314
+			if ($latest_related_datetime instanceof EE_Datetime) {
315 315
 				$this->_cur_dtt_id = $latest_related_datetime->ID();
316 316
 			}
317 317
 		}
318 318
 
319
-		$checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id );
320
-		$nonce = wp_create_nonce( 'checkin_nonce' );
321
-		$toggle_active = ! empty ( $this->_cur_dtt_id )
319
+		$checkinstatus = $item->check_in_status_for_datetime($this->_cur_dtt_id);
320
+		$nonce = wp_create_nonce('checkin_nonce');
321
+		$toggle_active = ! empty ($this->_cur_dtt_id)
322 322
 		                 && EE_Registry::instance()->CAP->current_user_can(
323 323
 			'ee_edit_checkin',
324 324
 			'espresso_registrations_toggle_checkin_status',
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 		)
327 327
 			? ' clickable trigger-checkin'
328 328
 			: '';
329
-		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
330
-		return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"'
331
-		       . ' data-_regid="' . $item->ID() . '"'
332
-		       . ' data-dttid="' . $this->_cur_dtt_id . '"'
333
-		       . ' data-nonce="' . $nonce . '">'
329
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
330
+		return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'"'
331
+		       . ' data-_regid="'.$item->ID().'"'
332
+		       . ' data-dttid="'.$this->_cur_dtt_id.'"'
333
+		       . ' data-nonce="'.$nonce.'">'
334 334
 		       . '</span>'
335 335
 		       . $mobile_view_content;
336 336
 	}
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 	 * @return mixed|string|void
343 343
 	 * @throws \EE_Error
344 344
 	 */
345
-	public function column_ATT_name( EE_Registration $item ) {
345
+	public function column_ATT_name(EE_Registration $item) {
346 346
 		$attendee = $item->attendee();
347
-		if ( ! $attendee instanceof EE_Attendee ) {
348
-			return __( 'No contact record for this registration.', 'event_espresso' );
347
+		if ( ! $attendee instanceof EE_Attendee) {
348
+			return __('No contact record for this registration.', 'event_espresso');
349 349
 		}
350 350
 		// edit attendee link
351 351
 		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
352
-			array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ),
352
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
353 353
 			REG_ADMIN_URL
354 354
 		);
355 355
 		$name_link = EE_Registry::instance()->CAP->current_user_can(
356 356
 			'ee_edit_contacts',
357 357
 			'espresso_registrations_edit_attendee'
358 358
 		)
359
-			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">'
359
+			? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
360 360
 			    . $item->attendee()->full_name()
361 361
 			    . '</a>'
362 362
 			: $item->attendee()->full_name();
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
 			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
365 365
 			: '';
366 366
 		//add group details
367
-		$name_link .= '&nbsp;' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() );
367
+		$name_link .= '&nbsp;'.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
368 368
 		//add regcode
369 369
 		$link = EE_Admin_Page::add_query_args_and_nonce(
370
-			array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ),
370
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
371 371
 			REG_ADMIN_URL
372 372
 		);
373 373
 		$name_link .= '<br>';
@@ -376,37 +376,37 @@  discard block
 block discarded – undo
376 376
 			'view_registration',
377 377
 			$item->ID()
378 378
 		)
379
-			? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">'
379
+			? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
380 380
 			  . $item->reg_code()
381 381
 			  . '</a>'
382 382
 			: $item->reg_code();
383 383
 		//status
384 384
 		$name_link .= '<br><span class="ee-status-text-small">';
385
-		$name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' );
385
+		$name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
386 386
 		$name_link .= '</span>';
387 387
 		$actions = array();
388 388
 		$DTT_ID = $this->_cur_dtt_id;
389
-		$latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration
389
+		$latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
390 390
 			? $item->get_latest_related_datetime()
391 391
 			: null;
392 392
 		$DTT_ID = $latest_related_datetime instanceof EE_Datetime
393 393
 			? $latest_related_datetime->ID()
394 394
 			: $DTT_ID;
395
-		if ( ! empty( $DTT_ID )
395
+		if ( ! empty($DTT_ID)
396 396
 		     && EE_Registry::instance()->CAP->current_user_can(
397 397
 				'ee_read_checkins',
398 398
 				'espresso_registrations_registration_checkins'
399 399
 			)
400 400
 		) {
401 401
 			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
402
-				array( 'action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID )
402
+				array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID)
403 403
 			);
404
-			$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__(
404
+			$actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__(
405 405
 					'View all the check-ins/checkouts for this registrant',
406 406
 					'event_espresso'
407
-				) . '">' . __( 'View', 'event_espresso' ) . '</a>';
407
+				).'">'.__('View', 'event_espresso').'</a>';
408 408
 		}
409
-		return ! empty( $DTT_ID ) ? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions ) ) : $name_link;
409
+		return ! empty($DTT_ID) ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)) : $name_link;
410 410
 	}
411 411
 
412 412
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	 * @param \EE_Registration $item
416 416
 	 * @return string
417 417
 	 */
418
-	public function column_ATT_email( EE_Registration $item ) {
418
+	public function column_ATT_email(EE_Registration $item) {
419 419
 		$attendee = $item->attendee();
420 420
 		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
421 421
 	}
@@ -427,22 +427,22 @@  discard block
 block discarded – undo
427 427
 	 * @return bool|string
428 428
 	 * @throws \EE_Error
429 429
 	 */
430
-	public function column_Event( EE_Registration $item ) {
430
+	public function column_Event(EE_Registration $item) {
431 431
 		try {
432 432
 			$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
433 433
 			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
434
-				array( 'action' => 'event_registrations', 'event_id' => $event->ID() ),
434
+				array('action' => 'event_registrations', 'event_id' => $event->ID()),
435 435
 				REG_ADMIN_URL
436 436
 			);
437 437
 			$event_label = EE_Registry::instance()->CAP->current_user_can(
438 438
 				'ee_read_checkins',
439 439
 				'espresso_registrations_registration_checkins'
440
-			) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__(
440
+			) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__(
441 441
 					'View Checkins for this Event',
442 442
 					'event_espresso'
443
-				) . '">' . $event->name() . '</a>' : $event->name();
444
-		} catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) {
445
-			$event_label = esc_html__( 'Unknown', 'event_espresso' );
443
+				).'">'.$event->name().'</a>' : $event->name();
444
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
445
+			$event_label = esc_html__('Unknown', 'event_espresso');
446 446
 		}
447 447
 		return $event_label;
448 448
 	}
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param \EE_Registration $item
454 454
 	 * @return mixed|string|void
455 455
 	 */
456
-	public function column_PRC_name( EE_Registration $item ) {
457
-		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" );
456
+	public function column_PRC_name(EE_Registration $item) {
457
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso");
458 458
 	}
459 459
 
460 460
 
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
 	 * @param \EE_Registration $item
466 466
 	 * @return string
467 467
 	 */
468
-	public function column__REG_final_price( EE_Registration $item ) {
469
-		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
468
+	public function column__REG_final_price(EE_Registration $item) {
469
+		return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
470 470
 	}
471 471
 
472 472
 
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	 * @return string
479 479
 	 * @throws \EE_Error
480 480
 	 */
481
-	public function column_TXN_paid( EE_Registration $item ) {
482
-		if ( $item->count() === 1 ) {
483
-			if ( $item->transaction()->paid() >= $item->transaction()->total() ) {
481
+	public function column_TXN_paid(EE_Registration $item) {
482
+		if ($item->count() === 1) {
483
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
484 484
 				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
485 485
 			} else {
486 486
 				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
487
-					array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ),
487
+					array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
488 488
 					TXN_ADMIN_URL
489 489
 				);
490 490
 				return EE_Registry::instance()->CAP->current_user_can(
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
 				    . '" href="'
498 498
 				    . $view_txn_lnk_url
499 499
 				    . '"  title="'
500
-				    . esc_attr__( 'View Transaction', 'event_espresso' )
500
+				    . esc_attr__('View Transaction', 'event_espresso')
501 501
 				    . '">
502 502
 						'
503 503
 				    . $item->transaction()->pretty_paid()
504 504
 				    . '
505 505
 					</a>
506
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
506
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
507 507
 			}
508 508
 		} else {
509 509
 			return '<span class="reg-pad-rght"></span>';
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 	 * @return string
520 520
 	 * @throws \EE_Error
521 521
 	 */
522
-	public function column_TXN_total( EE_Registration $item ) {
522
+	public function column_TXN_total(EE_Registration $item) {
523 523
 		$txn = $item->transaction();
524
-		$view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL );
525
-		if ( $item->get( 'REG_count' ) === 1 ) {
524
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
525
+		if ($item->get('REG_count') === 1) {
526 526
 			$line_total_obj = $txn->total_line_item();
527 527
 			$txn_total = $line_total_obj instanceof EE_Line_Item
528
-				? $line_total_obj->get_pretty( 'LIN_total' )
528
+				? $line_total_obj->get_pretty('LIN_total')
529 529
 				: __(
530 530
 					'View Transaction',
531 531
 					'event_espresso'
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
 			) ? '<a href="'
537 537
 			    . $view_txn_url
538 538
 			    . '" title="'
539
-			    . esc_attr__( 'View Transaction', 'event_espresso' )
539
+			    . esc_attr__('View Transaction', 'event_espresso')
540 540
 			    . '"><span class="reg-pad-rght">'
541 541
 			    . $txn_total
542
-			    . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
542
+			    . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
543 543
 		} else {
544 544
 			return '<span class="reg-pad-rght"></span>';
545 545
 		}
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 2 patches
Indentation   +1141 added lines, -1141 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -17,1145 +17,1145 @@  discard block
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * This is used to hold the reports template data which is setup early in the request.
22
-     *
23
-     * @type array
24
-     */
25
-    protected $_reports_template_data = array();
26
-
27
-
28
-
29
-    /**
30
-     * Extend_Registrations_Admin_Page constructor.
31
-     *
32
-     * @param bool $routing
33
-     */
34
-    public function __construct($routing = true)
35
-    {
36
-        parent::__construct($routing);
37
-        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
41
-        }
42
-    }
43
-
44
-
45
-
46
-    protected function _extend_page_config()
47
-    {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
-            ? $this->_req_data['_REG_ID']
51
-            : 0;
52
-        // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0;
53
-        // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] )
54
-        // 	? $this->_req_data['post'] : $att_id;
55
-        $new_page_routes = array(
56
-            'reports'                  => array(
57
-                'func'       => '_registration_reports',
58
-                'capability' => 'ee_read_registrations',
59
-            ),
60
-            'registration_checkins'    => array(
61
-                'func'       => '_registration_checkin_list_table',
62
-                'capability' => 'ee_read_checkins',
63
-            ),
64
-            'newsletter_selected_send' => array(
65
-                'func'       => '_newsletter_selected_send',
66
-                'noheader'   => true,
67
-                'capability' => 'ee_send_message',
68
-            ),
69
-            'delete_checkin_rows'      => array(
70
-                'func'       => '_delete_checkin_rows',
71
-                'noheader'   => true,
72
-                'capability' => 'ee_delete_checkins',
73
-            ),
74
-            'delete_checkin_row'       => array(
75
-                'func'       => '_delete_checkin_row',
76
-                'noheader'   => true,
77
-                'capability' => 'ee_delete_checkin',
78
-                'obj_id'     => $reg_id,
79
-            ),
80
-            'toggle_checkin_status'    => array(
81
-                'func'       => '_toggle_checkin_status',
82
-                'noheader'   => true,
83
-                'capability' => 'ee_edit_checkin',
84
-                'obj_id'     => $reg_id,
85
-            ),
86
-            'event_registrations'      => array(
87
-                'func'       => '_event_registrations_list_table',
88
-                'capability' => 'ee_read_checkins',
89
-            ),
90
-            'registrations_checkin_report' => array(
91
-                'func'       => '_registrations_checkin_report',
92
-                'noheader'   => true,
93
-                'capability' => 'ee_read_registrations',
94
-            ),
95
-        );
96
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
97
-        $new_page_config = array(
98
-            'reports'               => array(
99
-                'nav'           => array(
100
-                    'label' => __('Reports', 'event_espresso'),
101
-                    'order' => 30,
102
-                ),
103
-                'help_tabs'     => array(
104
-                    'registrations_reports_help_tab' => array(
105
-                        'title'    => __('Registration Reports', 'event_espresso'),
106
-                        'filename' => 'registrations_reports',
107
-                    ),
108
-                ),
109
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
110
-                'require_nonce' => false,
111
-            ),
112
-            'event_registrations'   => array(
113
-                'nav'           => array(
114
-                    'label'      => __('Event Check-In', 'event_espresso'),
115
-                    'order'      => 10,
116
-                    'persistent' => true,
117
-                ),
118
-                'help_tabs'     => array(
119
-                    'registrations_event_checkin_help_tab'                       => array(
120
-                        'title'    => __('Registrations Event Check-In', 'event_espresso'),
121
-                        'filename' => 'registrations_event_checkin',
122
-                    ),
123
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
124
-                        'title'    => __('Event Check-In Table Column Headings', 'event_espresso'),
125
-                        'filename' => 'registrations_event_checkin_table_column_headings',
126
-                    ),
127
-                    'registrations_event_checkin_filters_help_tab'               => array(
128
-                        'title'    => __('Event Check-In Filters', 'event_espresso'),
129
-                        'filename' => 'registrations_event_checkin_filters',
130
-                    ),
131
-                    'registrations_event_checkin_views_help_tab'                 => array(
132
-                        'title'    => __('Event Check-In Views', 'event_espresso'),
133
-                        'filename' => 'registrations_event_checkin_views',
134
-                    ),
135
-                    'registrations_event_checkin_other_help_tab'                 => array(
136
-                        'title'    => __('Event Check-In Other', 'event_espresso'),
137
-                        'filename' => 'registrations_event_checkin_other',
138
-                    ),
139
-                ),
140
-                'help_tour'     => array('Event_Checkin_Help_Tour'),
141
-                'qtips'         => array('Registration_List_Table_Tips'),
142
-                'list_table'    => 'EE_Event_Registrations_List_Table',
143
-                'metaboxes'     => array(),
144
-                'require_nonce' => false,
145
-            ),
146
-            'registration_checkins' => array(
147
-                'nav'           => array(
148
-                    'label'      => __('Check-In Records', 'event_espresso'),
149
-                    'order'      => 15,
150
-                    'persistent' => false,
151
-                ),
152
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
153
-                //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
154
-                'metaboxes'     => array(),
155
-                'require_nonce' => false,
156
-            ),
157
-        );
158
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
159
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
-    }
162
-
163
-
164
-
165
-    protected function _ajax_hooks()
166
-    {
167
-        parent::_ajax_hooks();
168
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
169
-    }
170
-
171
-
172
-
173
-    public function load_scripts_styles()
174
-    {
175
-        parent::load_scripts_styles();
176
-        //if newsletter message type is active then let's add filter and load js for it.
177
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
178
-            //enqueue newsletter js
179
-            wp_enqueue_script(
180
-                'ee-newsletter-trigger',
181
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
182
-                array('ee-dialog'),
183
-                EVENT_ESPRESSO_VERSION,
184
-                true
185
-            );
186
-            wp_enqueue_style(
187
-                'ee-newsletter-trigger-css',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
189
-                array(),
190
-                EVENT_ESPRESSO_VERSION
191
-            );
192
-            //hook in buttons for newsletter message type trigger.
193
-            add_action(
194
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
195
-                array($this, 'add_newsletter_action_buttons'),
196
-                10
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-
203
-    public function load_scripts_styles_reports()
204
-    {
205
-        wp_register_script(
206
-            'ee-reg-reports-js',
207
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
208
-            array('google-charts'),
209
-            EVENT_ESPRESSO_VERSION,
210
-            true
211
-        );
212
-        wp_enqueue_script('ee-reg-reports-js');
213
-        $this->_registration_reports_js_setup();
214
-    }
215
-
216
-
217
-
218
-    protected function _add_screen_options_event_registrations()
219
-    {
220
-        $this->_per_page_screen_option();
221
-    }
222
-
223
-
224
-
225
-    protected function _add_screen_options_registration_checkins()
226
-    {
227
-        $page_title = $this->_admin_page_title;
228
-        $this->_admin_page_title = __('Check-In Records', 'event_espresso');
229
-        $this->_per_page_screen_option();
230
-        $this->_admin_page_title = $page_title;
231
-    }
232
-
233
-
234
-
235
-    protected function _set_list_table_views_event_registrations()
236
-    {
237
-        $this->_views = array(
238
-            'all' => array(
239
-                'slug'        => 'all',
240
-                'label'       => __('All', 'event_espresso'),
241
-                'count'       => 0,
242
-                'bulk_action' => ! isset($this->_req_data['event_id'])
243
-                    ? array()
244
-                    : array(
245
-                        'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'),
246
-                        //'trash_registrations' => __('Trash Registrations', 'event_espresso')
247
-                    ),
248
-            ),
249
-        );
250
-    }
251
-
252
-
253
-
254
-    protected function _set_list_table_views_registration_checkins()
255
-    {
256
-        $this->_views = array(
257
-            'all' => array(
258
-                'slug'        => 'all',
259
-                'label'       => __('All', 'event_espresso'),
260
-                'count'       => 0,
261
-                'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')),
262
-            ),
263
-        );
264
-    }
265
-
266
-
267
-
268
-    /**
269
-     * callback for ajax action.
270
-     *
271
-     * @since 4.3.0
272
-     * @return void (JSON)
273
-     * @throws \EE_Error
274
-     */
275
-    public function get_newsletter_form_content()
276
-    {
277
-        //do a nonce check cause we're not coming in from an normal route here.
278
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
279
-            $this->_req_data['get_newsletter_form_content_nonce']
280
-        ) : '';
281
-        $nonce_ref = 'get_newsletter_form_content_nonce';
282
-        $this->_verify_nonce($nonce, $nonce_ref);
283
-        //let's get the mtp for the incoming MTP_ ID
284
-        if ( ! isset($this->_req_data['GRP_ID'])) {
285
-            EE_Error::add_error(
286
-                __(
287
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
288
-                    'event_espresso'
289
-                ),
290
-                __FILE__,
291
-                __FUNCTION__,
292
-                __LINE__
293
-            );
294
-            $this->_template_args['success'] = false;
295
-            $this->_template_args['error'] = true;
296
-            $this->_return_json();
297
-        }
298
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
299
-        if ( ! $MTPG instanceof EE_Message_Template_Group) {
300
-            EE_Error::add_error(
301
-                sprintf(
302
-                    __(
303
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
304
-                        'event_espresso'
305
-                    ),
306
-                    $this->_req_data['GRP_ID']
307
-                ),
308
-                __FILE__,
309
-                __FUNCTION__,
310
-                __LINE__
311
-            );
312
-            $this->_template_args['success'] = false;
313
-            $this->_template_args['error'] = true;
314
-            $this->_return_json();
315
-        }
316
-        $MTPs = $MTPG->context_templates();
317
-        $MTPs = $MTPs['attendee'];
318
-        $template_fields = array();
319
-        /** @var EE_Message_Template $MTP */
320
-        foreach ($MTPs as $MTP) {
321
-            $field = $MTP->get('MTP_template_field');
322
-            if ($field === 'content') {
323
-                $content = $MTP->get('MTP_content');
324
-                if ( ! empty($content['newsletter_content'])) {
325
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
326
-                }
327
-                continue;
328
-            }
329
-            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
330
-        }
331
-        $this->_template_args['success'] = true;
332
-        $this->_template_args['error'] = false;
333
-        $this->_template_args['data'] = array(
334
-            'batch_message_from'    => isset($template_fields['from'])
335
-                ? $template_fields['from']
336
-                : '',
337
-            'batch_message_subject' => isset($template_fields['subject'])
338
-                ? $template_fields['subject']
339
-                : '',
340
-            'batch_message_content' => isset($template_fields['newsletter_content'])
341
-                ? $template_fields['newsletter_content']
342
-                : '',
343
-        );
344
-        $this->_return_json();
345
-    }
346
-
347
-
348
-
349
-    /**
350
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
351
-     *
352
-     * @since 4.3.0
353
-     * @param EE_Admin_List_Table $list_table
354
-     * @return void
355
-     */
356
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
357
-    {
358
-        if ( ! EE_Registry::instance()->CAP->current_user_can(
359
-            'ee_send_message',
360
-            'espresso_registrations_newsletter_selected_send'
361
-        )
362
-        ) {
363
-            return;
364
-        }
365
-        $routes_to_add_to = array(
366
-            'contact_list',
367
-            'event_registrations',
368
-            'default',
369
-        );
370
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
371
-            if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
372
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
373
-            ) {
374
-                echo '';
375
-            } else {
376
-                $button_text = sprintf(
377
-                    __('Send Batch Message (%s selected)', 'event_espresso'),
378
-                    '<span class="send-selected-newsletter-count">0</span>'
379
-                );
380
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'
381
-                     . $button_text
382
-                     . '</button>';
383
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
384
-            }
385
-        }
386
-    }
387
-
388
-
389
-
390
-    public function newsletter_send_form_skeleton()
391
-    {
392
-        $list_table = $this->_list_table_object;
393
-        $codes = array();
394
-        //need to templates for the newsletter message type for the template selector.
395
-        $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0);
396
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
397
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
398
-        );
399
-        foreach ($mtps as $mtp) {
400
-            $name = $mtp->name();
401
-            $values[] = array(
402
-                'text' => empty($name) ? __('Global', 'event_espresso') : $name,
403
-                'id'   => $mtp->ID(),
404
-            );
405
-        }
406
-        //need to get a list of shortcodes that are available for the newsletter message type.
407
-        $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false);
408
-        foreach ($shortcodes as $field => $shortcode_array) {
409
-            $codes[$field] = implode(', ', array_keys($shortcode_array));
410
-        }
411
-        $shortcodes = $codes;
412
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
413
-        $form_template_args = array(
414
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
415
-            'form_route'        => 'newsletter_selected_send',
416
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
417
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
418
-            'redirect_back_to'  => $this->_req_action,
419
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
420
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
421
-            'shortcodes'        => $shortcodes,
422
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
423
-        );
424
-        EEH_Template::display_template($form_template, $form_template_args);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * Handles sending selected registrations/contacts a newsletter.
431
-     *
432
-     * @since  4.3.0
433
-     * @return void
434
-     * @throws \EE_Error
435
-     */
436
-    protected function _newsletter_selected_send()
437
-    {
438
-        $success = true;
439
-        //first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
440
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
441
-            EE_Error::add_error(
442
-                __(
443
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
444
-                    'event_espresso'
445
-                ),
446
-                __FILE__,
447
-                __FUNCTION__,
448
-                __LINE__
449
-            );
450
-            $success = false;
451
-        }
452
-        if ($success) {
453
-            //update Message template in case there are any changes
454
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
455
-                $this->_req_data['newsletter_mtp_selected']
456
-            );
457
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
458
-                ? $Message_Template_Group->context_templates()
459
-                : array();
460
-            if (empty($Message_Templates)) {
461
-                EE_Error::add_error(
462
-                    __(
463
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
464
-                        'event_espresso'
465
-                    ),
466
-                    __FILE__,
467
-                    __FUNCTION__,
468
-                    __LINE__
469
-                );
470
-            }
471
-            //let's just update the specific fields
472
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
473
-                if ($Message_Template instanceof EE_Message_Template) {
474
-                    $field = $Message_Template->get('MTP_template_field');
475
-                    $content = $Message_Template->get('MTP_content');
476
-                    $new_content = $content;
477
-                    switch ($field) {
478
-                        case 'from' :
479
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
480
-                                ? $this->_req_data['batch_message']['from']
481
-                                : $content;
482
-                            break;
483
-                        case 'subject' :
484
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
485
-                                ? $this->_req_data['batch_message']['subject']
486
-                                : $content;
487
-                            break;
488
-                        case 'content' :
489
-                            $new_content = $content;
490
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
491
-                                ? $this->_req_data['batch_message']['content']
492
-                                : $content['newsletter_content'];
493
-                            break;
494
-                        default :
495
-                            //continue the foreach loop, we don't want to set $new_content nor save.
496
-                            continue 2;
497
-                    }
498
-                    $Message_Template->set('MTP_content', $new_content);
499
-                    $Message_Template->save();
500
-                }
501
-            }
502
-            //great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
503
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
504
-                ? $this->_req_data['batch_message']['id_type']
505
-                : 'registration';
506
-            //id_type will affect how we assemble the ids.
507
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
508
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
509
-                : array();
510
-            $registrations_used_for_contact_data = array();
511
-            //using switch because eventually we'll have other contexts that will be used for generating messages.
512
-            switch ($id_type) {
513
-                case 'registration' :
514
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
515
-                        array(
516
-                            array(
517
-                                'REG_ID' => array('IN', $ids),
518
-                            ),
519
-                        )
520
-                    );
521
-                    break;
522
-                case 'contact' :
523
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
524
-                                                                           ->get_latest_registration_for_each_of_given_contacts($ids);
525
-                    break;
526
-            }
527
-            do_action(
528
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
529
-                $registrations_used_for_contact_data,
530
-                $Message_Template_Group->ID()
531
-            );
532
-            //kept for backward compat, internally we no longer use this action.
533
-            //@deprecated 4.8.36.rc.002
534
-            $contacts = $id_type === 'registration'
535
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
536
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
537
-            do_action(
538
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
539
-                $contacts,
540
-                $Message_Template_Group->ID()
541
-            );
542
-        }
543
-        $query_args = array(
544
-            'action' => ! empty($this->_req_data['redirect_back_to'])
545
-                ? $this->_req_data['redirect_back_to']
546
-                : 'default',
547
-        );
548
-        $this->_redirect_after_action(false, '', '', $query_args, true);
549
-    }
550
-
551
-
552
-
553
-    /**
554
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
555
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
556
-     */
557
-    protected function _registration_reports_js_setup()
558
-    {
559
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
560
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
561
-    }
562
-
563
-
564
-
565
-    /**
566
-     *        generates Business Reports regarding Registrations
567
-     *
568
-     * @access protected
569
-     * @return void
570
-     */
571
-    protected function _registration_reports()
572
-    {
573
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
574
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
575
-            $template_path,
576
-            $this->_reports_template_data,
577
-            true
578
-        );
579
-        // the final template wrapper
580
-        $this->display_admin_page_with_no_sidebar();
581
-    }
582
-
583
-
584
-
585
-    /**
586
-     * Generates Business Report showing total registrations per day.
587
-     *
588
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
589
-     * @return string
590
-     */
591
-    private function _registrations_per_day_report($period = '-1 month')
592
-    {
593
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
594
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
595
-        $results = (array)$results;
596
-        $regs = array();
597
-        $subtitle = '';
598
-        if ($results) {
599
-            $column_titles = array();
600
-            $tracker = 0;
601
-            foreach ($results as $result) {
602
-                $report_column_values = array();
603
-                foreach ($result as $property_name => $property_value) {
604
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
605
-                        : (int)$property_value;
606
-                    $report_column_values[] = $property_value;
607
-                    if ($tracker === 0) {
608
-                        if ($property_name === 'Registration_REG_date') {
609
-                            $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso');
610
-                        } else {
611
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
612
-                        }
613
-                    }
614
-                }
615
-                $tracker++;
616
-                $regs[] = $report_column_values;
617
-            }
618
-            //make sure the column_titles is pushed to the beginning of the array
619
-            array_unshift($regs, $column_titles);
620
-            //setup the date range.
621
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
622
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
623
-            $ending_date = new DateTime("now", $DateTimeZone);
624
-            $subtitle = sprintf(
625
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
626
-                $beginning_date->format('Y-m-d'),
627
-                $ending_date->format('Y-m-d')
628
-            );
629
-        }
630
-        $report_title = __('Total Registrations per Day', 'event_espresso');
631
-        $report_params = array(
632
-            'title'     => $report_title,
633
-            'subtitle'  => $subtitle,
634
-            'id'        => $report_ID,
635
-            'regs'      => $regs,
636
-            'noResults' => empty($regs),
637
-            'noRegsMsg' => sprintf(
638
-                __(
639
-                    '%sThere are currently no registration records in the last month for this report.%s',
640
-                    'event_espresso'
641
-                ),
642
-                '<h2>' . $report_title . '</h2><p>',
643
-                '</p>'
644
-            ),
645
-        );
646
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
647
-        return $report_ID;
648
-    }
649
-
650
-
651
-
652
-    /**
653
-     * Generates Business Report showing total registrations per event.
654
-     *
655
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
656
-     * @return string
657
-     */
658
-    private function _registrations_per_event_report($period = '-1 month')
659
-    {
660
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
661
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
662
-        $results = (array)$results;
663
-        $regs = array();
664
-        $subtitle = '';
665
-        if ($results) {
666
-            $column_titles = array();
667
-            $tracker = 0;
668
-            foreach ($results as $result) {
669
-                $report_column_values = array();
670
-                foreach ($result as $property_name => $property_value) {
671
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
672
-                        $property_value,
673
-                        4,
674
-                        '...'
675
-                    ) : (int)$property_value;
676
-                    $report_column_values[] = $property_value;
677
-                    if ($tracker === 0) {
678
-                        if ($property_name === 'Registration_Event') {
679
-                            $column_titles[] = __('Event', 'event_espresso');
680
-                        } else {
681
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
682
-                        }
683
-                    }
684
-                }
685
-                $tracker++;
686
-                $regs[] = $report_column_values;
687
-            }
688
-            //make sure the column_titles is pushed to the beginning of the array
689
-            array_unshift($regs, $column_titles);
690
-            //setup the date range.
691
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
692
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
693
-            $ending_date = new DateTime("now", $DateTimeZone);
694
-            $subtitle = sprintf(
695
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
696
-                $beginning_date->format('Y-m-d'),
697
-                $ending_date->format('Y-m-d')
698
-            );
699
-        }
700
-        $report_title = __('Total Registrations per Event', 'event_espresso');
701
-        $report_params = array(
702
-            'title'     => $report_title,
703
-            'subtitle'  => $subtitle,
704
-            'id'        => $report_ID,
705
-            'regs'      => $regs,
706
-            'noResults' => empty($regs),
707
-            'noRegsMsg' => sprintf(
708
-                __(
709
-                    '%sThere are currently no registration records in the last month for this report.%s',
710
-                    'event_espresso'
711
-                ),
712
-                '<h2>' . $report_title . '</h2><p>',
713
-                '</p>'
714
-            ),
715
-        );
716
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
717
-        return $report_ID;
718
-    }
719
-
720
-
721
-
722
-    /**
723
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
724
-     *
725
-     * @access protected
726
-     * @return void
727
-     * @throws \EE_Error
728
-     */
729
-    protected function _registration_checkin_list_table()
730
-    {
731
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
732
-        $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
733
-        /** @var EE_Registration $reg */
734
-        $reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
735
-        $this->_admin_page_title .= $this->get_action_link_or_button(
736
-            'new_registration',
737
-            'add-registrant',
738
-            array('event_id' => $reg->event_ID()),
739
-            'add-new-h2'
740
-        );
741
-        $legend_items = array(
742
-            'checkin'  => array(
743
-                'class' => 'ee-icon ee-icon-check-in',
744
-                'desc'  => __('This indicates the attendee has been checked in', 'event_espresso'),
745
-            ),
746
-            'checkout' => array(
747
-                'class' => 'ee-icon ee-icon-check-out',
748
-                'desc'  => __('This indicates the attendee has been checked out', 'event_espresso'),
749
-            ),
750
-        );
751
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
752
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
753
-        $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(
754
-            array(
755
-                'action'   => 'event_registrations',
756
-                'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(),
757
-                'DTT_ID'   => $dtt_id,
758
-            ),
759
-            $this->_admin_base_url
760
-        ) : '';
761
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
762
-            ? '<h2>' . sprintf(
763
-                __("%s's check in records for %s at the event, %s", 'event_espresso'),
764
-                '<span id="checkin-attendee-name">'
765
-                . EEM_Registration::instance()
766
-                                  ->get_one_by_ID($reg_id)
767
-                                  ->get_first_related('Attendee')
768
-                                  ->full_name() . '</span>',
769
-                '<span id="checkin-dtt"><a href="' . $go_back_url . '">'
770
-                . EEM_Datetime::instance()
771
-                              ->get_one_by_ID($dtt_id)
772
-                              ->start_date_and_time() . ' - '
773
-                . EEM_Datetime::instance()
774
-                              ->get_one_by_ID($dtt_id)
775
-                              ->end_date_and_time() . '</a></span>',
776
-                '<span id="checkin-event-name">'
777
-                . EEM_Datetime::instance()
778
-                              ->get_one_by_ID($dtt_id)
779
-                              ->get_first_related('Event')
780
-                              ->get('EVT_name') . '</span>'
781
-            ) . '</h2>'
782
-            : '';
783
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
784
-            ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
785
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
786
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
787
-        $this->display_admin_list_table_page_with_no_sidebar();
788
-    }
789
-
790
-
791
-
792
-    /**
793
-     * toggle the Check-in status for the given registration (coming from ajax)
794
-     *
795
-     * @return void (JSON)
796
-     */
797
-    public function toggle_checkin_status()
798
-    {
799
-        //first make sure we have the necessary data
800
-        if ( ! isset($this->_req_data['_regid'])) {
801
-            EE_Error::add_error(
802
-                __(
803
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
804
-                    'event_espresso'
805
-                ),
806
-                __FILE__,
807
-                __FUNCTION__,
808
-                __LINE__
809
-            );
810
-            $this->_template_args['success'] = false;
811
-            $this->_template_args['error'] = true;
812
-            $this->_return_json();
813
-        };
814
-        //do a nonce check cause we're not coming in from an normal route here.
815
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
816
-            : '';
817
-        $nonce_ref = 'checkin_nonce';
818
-        $this->_verify_nonce($nonce, $nonce_ref);
819
-        //beautiful! Made it this far so let's get the status.
820
-        $new_status = $this->_toggle_checkin_status();
821
-        //setup new class to return via ajax
822
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'
823
-                                                      . $new_status;
824
-        $this->_template_args['success'] = true;
825
-        $this->_return_json();
826
-    }
827
-
828
-
829
-
830
-    /**
831
-     * handles toggling the checkin status for the registration,
832
-     *
833
-     * @access protected
834
-     * @return int|void
835
-     */
836
-    protected function _toggle_checkin_status()
837
-    {
838
-        //first let's get the query args out of the way for the redirect
839
-        $query_args = array(
840
-            'action'   => 'event_registrations',
841
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
842
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
843
-        );
844
-        $new_status = false;
845
-        // bulk action check in toggle
846
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
847
-            // cycle thru checkboxes
848
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
849
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
850
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
851
-            }
852
-        } elseif (isset($this->_req_data['_regid'])) {
853
-            //coming from ajax request
854
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
855
-            $query_args['DTT_ID'] = $DTT_ID;
856
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
857
-        } else {
858
-            EE_Error::add_error(
859
-                __('Missing some required data to toggle the Check-in', 'event_espresso'),
860
-                __FILE__,
861
-                __FUNCTION__,
862
-                __LINE__
863
-            );
864
-        }
865
-        if (defined('DOING_AJAX')) {
866
-            return $new_status;
867
-        }
868
-        $this->_redirect_after_action(false, '', '', $query_args, true);
869
-    }
870
-
871
-
872
-
873
-    /**
874
-     * This is toggles a single Check-in for the given registration and datetime.
875
-     *
876
-     * @param  int $REG_ID The registration we're toggling
877
-     * @param  int $DTT_ID The datetime we're toggling
878
-     * @return int            The new status toggled to.
879
-     * @throws \EE_Error
880
-     */
881
-    private function _toggle_checkin($REG_ID, $DTT_ID)
882
-    {
883
-        /** @var EE_Registration $REG */
884
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
885
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
886
-        if ($new_status !== false) {
887
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
888
-        } else {
889
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
890
-            $new_status = false;
891
-        }
892
-        return $new_status;
893
-    }
894
-
895
-
896
-
897
-    /**
898
-     * Takes care of deleting multiple EE_Checkin table rows
899
-     *
900
-     * @access protected
901
-     * @return void
902
-     * @throws \EE_Error
903
-     */
904
-    protected function _delete_checkin_rows()
905
-    {
906
-        $query_args = array(
907
-            'action' => 'registration_checkins',
908
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
909
-            '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
910
-        );
911
-        $errors = 0;
912
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
913
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
914
-                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
915
-                    $errors++;
916
-                }
917
-            }
918
-        } else {
919
-            EE_Error::add_error(
920
-                __(
921
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
922
-                    'event_espresso'
923
-                ),
924
-                __FILE__,
925
-                __FUNCTION__,
926
-                __LINE__
927
-            );
928
-            $this->_redirect_after_action(false, '', '', $query_args, true);
929
-        }
930
-        if ($errors > 0) {
931
-            EE_Error::add_error(
932
-                sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
933
-                __FILE__,
934
-                __FUNCTION__,
935
-                __LINE__
936
-            );
937
-        } else {
938
-            EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
939
-        }
940
-        $this->_redirect_after_action(false, '', '', $query_args, true);
941
-    }
942
-
943
-
944
-
945
-    /**
946
-     * Deletes a single EE_Checkin row
947
-     *
948
-     * @return void
949
-     * @throws \EE_Error
950
-     */
951
-    protected function _delete_checkin_row()
952
-    {
953
-        $query_args = array(
954
-            'action' => 'registration_checkins',
955
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
956
-            '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
957
-        );
958
-        if ( ! empty($this->_req_data['CHK_ID'])) {
959
-            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
960
-                EE_Error::add_error(
961
-                    __('Something went wrong and this check-in record was not deleted', 'event_espresso'),
962
-                    __FILE__,
963
-                    __FUNCTION__,
964
-                    __LINE__
965
-                );
966
-            } else {
967
-                EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
968
-            }
969
-        } else {
970
-            EE_Error::add_error(
971
-                __(
972
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
973
-                    'event_espresso'
974
-                ),
975
-                __FILE__,
976
-                __FUNCTION__,
977
-                __LINE__
978
-            );
979
-        }
980
-        $this->_redirect_after_action(false, '', '', $query_args, true);
981
-    }
982
-
983
-
984
-
985
-    /**
986
-     *        generates HTML for the Event Registrations List Table
987
-     *
988
-     * @access protected
989
-     * @return void
990
-     * @throws \EE_Error
991
-     */
992
-    protected function _event_registrations_list_table()
993
-    {
994
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
995
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
996
-            ? $this->get_action_link_or_button(
997
-                'new_registration',
998
-                'add-registrant',
999
-                array('event_id' => $this->_req_data['event_id']),
1000
-                'add-new-h2',
1001
-                '',
1002
-                false
1003
-            )
1004
-            : '';
1005
-        $legend_items = array(
1006
-            'star-icon'        => array(
1007
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1008
-                'desc'  => __('This Registrant is the Primary Registrant', 'event_espresso'),
1009
-            ),
1010
-            'checkin'          => array(
1011
-                'class' => 'ee-icon ee-icon-check-in',
1012
-                'desc'  => __('This Registrant has been Checked In', 'event_espresso'),
1013
-            ),
1014
-            'checkout'         => array(
1015
-                'class' => 'ee-icon ee-icon-check-out',
1016
-                'desc'  => __('This Registrant has been Checked Out', 'event_espresso'),
1017
-            ),
1018
-            'nocheckinrecord'  => array(
1019
-                'class' => 'dashicons dashicons-no',
1020
-                'desc'  => __('No Check-in Record has been Created for this Registrant', 'event_espresso'),
1021
-            ),
1022
-            'view_details'     => array(
1023
-                'class' => 'dashicons dashicons-search',
1024
-                'desc'  => __('View All Check-in Records for this Registrant', 'event_espresso'),
1025
-            ),
1026
-            'approved_status'  => array(
1027
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1028
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1029
-            ),
1030
-            'cancelled_status' => array(
1031
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1032
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1033
-            ),
1034
-            'declined_status'  => array(
1035
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1036
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1037
-            ),
1038
-            'not_approved'     => array(
1039
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1040
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1041
-            ),
1042
-            'pending_status'   => array(
1043
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1044
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1045
-            ),
1046
-            'wait_list'        => array(
1047
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1048
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1049
-            ),
1050
-        );
1051
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1052
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1053
-        $this->_template_args['before_list_table'] = ! empty($event_id)
1054
-            ? '<h2>' . sprintf(
1055
-                __('Viewing Registrations for Event: %s', 'event_espresso'),
1056
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1057
-            ) . '</h2>'
1058
-            : '';
1059
-        //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event.
1060
-        /** @var EE_Event $event */
1061
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1062
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1063
-        $datetime = null;
1064
-        if ($event instanceof EE_Event) {
1065
-            $datetimes_on_event = $event->datetimes();
1066
-            if (count($datetimes_on_event) === 1) {
1067
-                $datetime = reset($datetimes_on_event);
1068
-            }
1069
-        }
1070
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1071
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1072
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1073
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1074
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1075
-            $this->_template_args['before_list_table'] .= $datetime->name();
1076
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1077
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1078
-        }
1079
-        //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column
1080
-        //represents
1081
-        if ( ! $datetime instanceof EE_Datetime) {
1082
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1083
-                                                          . __('In this view, the check-in status represents the latest check-in record for the registration in that row.',
1084
-                    'event_espresso')
1085
-                                                          . '</p>';
1086
-        }
1087
-        $this->display_admin_list_table_page_with_no_sidebar();
1088
-    }
1089
-
1090
-    /**
1091
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1092
-     * conditions)
1093
-     *
1094
-     * @return void ends the request by a redirect or download
1095
-     */
1096
-    public function _registrations_checkin_report()
1097
-    {
1098
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1099
-    }
1100
-
1101
-    /**
1102
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1103
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1104
-     *
1105
-     * @param array     $request
1106
-     * @param int  $per_page
1107
-     * @param bool $count
1108
-     * @return array
1109
-     */
1110
-    protected function _get_checkin_query_params_from_request(
1111
-        $request,
1112
-        $per_page = 10,
1113
-        $count = false
1114
-    ) {
1115
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1116
-        //unlike the regular registrations list table,
1117
-        $status_ids_array = apply_filters(
1118
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1119
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1120
-        );
1121
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1122
-        return $query_params;
1123
-    }
1124
-
1125
-
1126
-
1127
-
1128
-    /**
1129
-     * Gets registrations for an event
1130
-     *
1131
-     * @param int    $per_page
1132
-     * @param bool   $count whether to return count or data.
1133
-     * @param bool   $trash
1134
-     * @param string $orderby
1135
-     * @return EE_Registration[]|int
1136
-     * @throws \EE_Error
1137
-     */
1138
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1139
-    {
1140
-        //normalize some request params that get setup by the parent `get_registrations` method.
1141
-        $request = $this->_req_data;
1142
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1143
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
-        if($trash){
1145
-            $request['status'] = 'trash';
1146
-        }
1147
-        $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count );
1148
-        /**
1149
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1150
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1151
-         * @see EEM_Base::get_all()
1152
-         */
1153
-        $query_params['group_by'] = '';
1154
-
1155
-        return $count
1156
-            ? EEM_Registration::instance()->count($query_params)
1157
-            /** @type EE_Registration[] */
1158
-            : EEM_Registration::instance()->get_all($query_params);
1159
-    }
20
+	/**
21
+	 * This is used to hold the reports template data which is setup early in the request.
22
+	 *
23
+	 * @type array
24
+	 */
25
+	protected $_reports_template_data = array();
26
+
27
+
28
+
29
+	/**
30
+	 * Extend_Registrations_Admin_Page constructor.
31
+	 *
32
+	 * @param bool $routing
33
+	 */
34
+	public function __construct($routing = true)
35
+	{
36
+		parent::__construct($routing);
37
+		if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
41
+		}
42
+	}
43
+
44
+
45
+
46
+	protected function _extend_page_config()
47
+	{
48
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
+			? $this->_req_data['_REG_ID']
51
+			: 0;
52
+		// $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0;
53
+		// $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] )
54
+		// 	? $this->_req_data['post'] : $att_id;
55
+		$new_page_routes = array(
56
+			'reports'                  => array(
57
+				'func'       => '_registration_reports',
58
+				'capability' => 'ee_read_registrations',
59
+			),
60
+			'registration_checkins'    => array(
61
+				'func'       => '_registration_checkin_list_table',
62
+				'capability' => 'ee_read_checkins',
63
+			),
64
+			'newsletter_selected_send' => array(
65
+				'func'       => '_newsletter_selected_send',
66
+				'noheader'   => true,
67
+				'capability' => 'ee_send_message',
68
+			),
69
+			'delete_checkin_rows'      => array(
70
+				'func'       => '_delete_checkin_rows',
71
+				'noheader'   => true,
72
+				'capability' => 'ee_delete_checkins',
73
+			),
74
+			'delete_checkin_row'       => array(
75
+				'func'       => '_delete_checkin_row',
76
+				'noheader'   => true,
77
+				'capability' => 'ee_delete_checkin',
78
+				'obj_id'     => $reg_id,
79
+			),
80
+			'toggle_checkin_status'    => array(
81
+				'func'       => '_toggle_checkin_status',
82
+				'noheader'   => true,
83
+				'capability' => 'ee_edit_checkin',
84
+				'obj_id'     => $reg_id,
85
+			),
86
+			'event_registrations'      => array(
87
+				'func'       => '_event_registrations_list_table',
88
+				'capability' => 'ee_read_checkins',
89
+			),
90
+			'registrations_checkin_report' => array(
91
+				'func'       => '_registrations_checkin_report',
92
+				'noheader'   => true,
93
+				'capability' => 'ee_read_registrations',
94
+			),
95
+		);
96
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
97
+		$new_page_config = array(
98
+			'reports'               => array(
99
+				'nav'           => array(
100
+					'label' => __('Reports', 'event_espresso'),
101
+					'order' => 30,
102
+				),
103
+				'help_tabs'     => array(
104
+					'registrations_reports_help_tab' => array(
105
+						'title'    => __('Registration Reports', 'event_espresso'),
106
+						'filename' => 'registrations_reports',
107
+					),
108
+				),
109
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
110
+				'require_nonce' => false,
111
+			),
112
+			'event_registrations'   => array(
113
+				'nav'           => array(
114
+					'label'      => __('Event Check-In', 'event_espresso'),
115
+					'order'      => 10,
116
+					'persistent' => true,
117
+				),
118
+				'help_tabs'     => array(
119
+					'registrations_event_checkin_help_tab'                       => array(
120
+						'title'    => __('Registrations Event Check-In', 'event_espresso'),
121
+						'filename' => 'registrations_event_checkin',
122
+					),
123
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
124
+						'title'    => __('Event Check-In Table Column Headings', 'event_espresso'),
125
+						'filename' => 'registrations_event_checkin_table_column_headings',
126
+					),
127
+					'registrations_event_checkin_filters_help_tab'               => array(
128
+						'title'    => __('Event Check-In Filters', 'event_espresso'),
129
+						'filename' => 'registrations_event_checkin_filters',
130
+					),
131
+					'registrations_event_checkin_views_help_tab'                 => array(
132
+						'title'    => __('Event Check-In Views', 'event_espresso'),
133
+						'filename' => 'registrations_event_checkin_views',
134
+					),
135
+					'registrations_event_checkin_other_help_tab'                 => array(
136
+						'title'    => __('Event Check-In Other', 'event_espresso'),
137
+						'filename' => 'registrations_event_checkin_other',
138
+					),
139
+				),
140
+				'help_tour'     => array('Event_Checkin_Help_Tour'),
141
+				'qtips'         => array('Registration_List_Table_Tips'),
142
+				'list_table'    => 'EE_Event_Registrations_List_Table',
143
+				'metaboxes'     => array(),
144
+				'require_nonce' => false,
145
+			),
146
+			'registration_checkins' => array(
147
+				'nav'           => array(
148
+					'label'      => __('Check-In Records', 'event_espresso'),
149
+					'order'      => 15,
150
+					'persistent' => false,
151
+				),
152
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
153
+				//'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
154
+				'metaboxes'     => array(),
155
+				'require_nonce' => false,
156
+			),
157
+		);
158
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
159
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
160
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
161
+	}
162
+
163
+
164
+
165
+	protected function _ajax_hooks()
166
+	{
167
+		parent::_ajax_hooks();
168
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
169
+	}
170
+
171
+
172
+
173
+	public function load_scripts_styles()
174
+	{
175
+		parent::load_scripts_styles();
176
+		//if newsletter message type is active then let's add filter and load js for it.
177
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
178
+			//enqueue newsletter js
179
+			wp_enqueue_script(
180
+				'ee-newsletter-trigger',
181
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
182
+				array('ee-dialog'),
183
+				EVENT_ESPRESSO_VERSION,
184
+				true
185
+			);
186
+			wp_enqueue_style(
187
+				'ee-newsletter-trigger-css',
188
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
189
+				array(),
190
+				EVENT_ESPRESSO_VERSION
191
+			);
192
+			//hook in buttons for newsletter message type trigger.
193
+			add_action(
194
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
195
+				array($this, 'add_newsletter_action_buttons'),
196
+				10
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+
203
+	public function load_scripts_styles_reports()
204
+	{
205
+		wp_register_script(
206
+			'ee-reg-reports-js',
207
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
208
+			array('google-charts'),
209
+			EVENT_ESPRESSO_VERSION,
210
+			true
211
+		);
212
+		wp_enqueue_script('ee-reg-reports-js');
213
+		$this->_registration_reports_js_setup();
214
+	}
215
+
216
+
217
+
218
+	protected function _add_screen_options_event_registrations()
219
+	{
220
+		$this->_per_page_screen_option();
221
+	}
222
+
223
+
224
+
225
+	protected function _add_screen_options_registration_checkins()
226
+	{
227
+		$page_title = $this->_admin_page_title;
228
+		$this->_admin_page_title = __('Check-In Records', 'event_espresso');
229
+		$this->_per_page_screen_option();
230
+		$this->_admin_page_title = $page_title;
231
+	}
232
+
233
+
234
+
235
+	protected function _set_list_table_views_event_registrations()
236
+	{
237
+		$this->_views = array(
238
+			'all' => array(
239
+				'slug'        => 'all',
240
+				'label'       => __('All', 'event_espresso'),
241
+				'count'       => 0,
242
+				'bulk_action' => ! isset($this->_req_data['event_id'])
243
+					? array()
244
+					: array(
245
+						'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'),
246
+						//'trash_registrations' => __('Trash Registrations', 'event_espresso')
247
+					),
248
+			),
249
+		);
250
+	}
251
+
252
+
253
+
254
+	protected function _set_list_table_views_registration_checkins()
255
+	{
256
+		$this->_views = array(
257
+			'all' => array(
258
+				'slug'        => 'all',
259
+				'label'       => __('All', 'event_espresso'),
260
+				'count'       => 0,
261
+				'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')),
262
+			),
263
+		);
264
+	}
265
+
266
+
267
+
268
+	/**
269
+	 * callback for ajax action.
270
+	 *
271
+	 * @since 4.3.0
272
+	 * @return void (JSON)
273
+	 * @throws \EE_Error
274
+	 */
275
+	public function get_newsletter_form_content()
276
+	{
277
+		//do a nonce check cause we're not coming in from an normal route here.
278
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
279
+			$this->_req_data['get_newsletter_form_content_nonce']
280
+		) : '';
281
+		$nonce_ref = 'get_newsletter_form_content_nonce';
282
+		$this->_verify_nonce($nonce, $nonce_ref);
283
+		//let's get the mtp for the incoming MTP_ ID
284
+		if ( ! isset($this->_req_data['GRP_ID'])) {
285
+			EE_Error::add_error(
286
+				__(
287
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
288
+					'event_espresso'
289
+				),
290
+				__FILE__,
291
+				__FUNCTION__,
292
+				__LINE__
293
+			);
294
+			$this->_template_args['success'] = false;
295
+			$this->_template_args['error'] = true;
296
+			$this->_return_json();
297
+		}
298
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
299
+		if ( ! $MTPG instanceof EE_Message_Template_Group) {
300
+			EE_Error::add_error(
301
+				sprintf(
302
+					__(
303
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
304
+						'event_espresso'
305
+					),
306
+					$this->_req_data['GRP_ID']
307
+				),
308
+				__FILE__,
309
+				__FUNCTION__,
310
+				__LINE__
311
+			);
312
+			$this->_template_args['success'] = false;
313
+			$this->_template_args['error'] = true;
314
+			$this->_return_json();
315
+		}
316
+		$MTPs = $MTPG->context_templates();
317
+		$MTPs = $MTPs['attendee'];
318
+		$template_fields = array();
319
+		/** @var EE_Message_Template $MTP */
320
+		foreach ($MTPs as $MTP) {
321
+			$field = $MTP->get('MTP_template_field');
322
+			if ($field === 'content') {
323
+				$content = $MTP->get('MTP_content');
324
+				if ( ! empty($content['newsletter_content'])) {
325
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
326
+				}
327
+				continue;
328
+			}
329
+			$template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
330
+		}
331
+		$this->_template_args['success'] = true;
332
+		$this->_template_args['error'] = false;
333
+		$this->_template_args['data'] = array(
334
+			'batch_message_from'    => isset($template_fields['from'])
335
+				? $template_fields['from']
336
+				: '',
337
+			'batch_message_subject' => isset($template_fields['subject'])
338
+				? $template_fields['subject']
339
+				: '',
340
+			'batch_message_content' => isset($template_fields['newsletter_content'])
341
+				? $template_fields['newsletter_content']
342
+				: '',
343
+		);
344
+		$this->_return_json();
345
+	}
346
+
347
+
348
+
349
+	/**
350
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
351
+	 *
352
+	 * @since 4.3.0
353
+	 * @param EE_Admin_List_Table $list_table
354
+	 * @return void
355
+	 */
356
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
357
+	{
358
+		if ( ! EE_Registry::instance()->CAP->current_user_can(
359
+			'ee_send_message',
360
+			'espresso_registrations_newsletter_selected_send'
361
+		)
362
+		) {
363
+			return;
364
+		}
365
+		$routes_to_add_to = array(
366
+			'contact_list',
367
+			'event_registrations',
368
+			'default',
369
+		);
370
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
371
+			if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
372
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
373
+			) {
374
+				echo '';
375
+			} else {
376
+				$button_text = sprintf(
377
+					__('Send Batch Message (%s selected)', 'event_espresso'),
378
+					'<span class="send-selected-newsletter-count">0</span>'
379
+				);
380
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'
381
+					 . $button_text
382
+					 . '</button>';
383
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
384
+			}
385
+		}
386
+	}
387
+
388
+
389
+
390
+	public function newsletter_send_form_skeleton()
391
+	{
392
+		$list_table = $this->_list_table_object;
393
+		$codes = array();
394
+		//need to templates for the newsletter message type for the template selector.
395
+		$values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0);
396
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
397
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
398
+		);
399
+		foreach ($mtps as $mtp) {
400
+			$name = $mtp->name();
401
+			$values[] = array(
402
+				'text' => empty($name) ? __('Global', 'event_espresso') : $name,
403
+				'id'   => $mtp->ID(),
404
+			);
405
+		}
406
+		//need to get a list of shortcodes that are available for the newsletter message type.
407
+		$shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false);
408
+		foreach ($shortcodes as $field => $shortcode_array) {
409
+			$codes[$field] = implode(', ', array_keys($shortcode_array));
410
+		}
411
+		$shortcodes = $codes;
412
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
413
+		$form_template_args = array(
414
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
415
+			'form_route'        => 'newsletter_selected_send',
416
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
417
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
418
+			'redirect_back_to'  => $this->_req_action,
419
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
420
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
421
+			'shortcodes'        => $shortcodes,
422
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
423
+		);
424
+		EEH_Template::display_template($form_template, $form_template_args);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * Handles sending selected registrations/contacts a newsletter.
431
+	 *
432
+	 * @since  4.3.0
433
+	 * @return void
434
+	 * @throws \EE_Error
435
+	 */
436
+	protected function _newsletter_selected_send()
437
+	{
438
+		$success = true;
439
+		//first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
440
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
441
+			EE_Error::add_error(
442
+				__(
443
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
444
+					'event_espresso'
445
+				),
446
+				__FILE__,
447
+				__FUNCTION__,
448
+				__LINE__
449
+			);
450
+			$success = false;
451
+		}
452
+		if ($success) {
453
+			//update Message template in case there are any changes
454
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
455
+				$this->_req_data['newsletter_mtp_selected']
456
+			);
457
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
458
+				? $Message_Template_Group->context_templates()
459
+				: array();
460
+			if (empty($Message_Templates)) {
461
+				EE_Error::add_error(
462
+					__(
463
+						'Unable to retrieve message template fields from the db. Messages not sent.',
464
+						'event_espresso'
465
+					),
466
+					__FILE__,
467
+					__FUNCTION__,
468
+					__LINE__
469
+				);
470
+			}
471
+			//let's just update the specific fields
472
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
473
+				if ($Message_Template instanceof EE_Message_Template) {
474
+					$field = $Message_Template->get('MTP_template_field');
475
+					$content = $Message_Template->get('MTP_content');
476
+					$new_content = $content;
477
+					switch ($field) {
478
+						case 'from' :
479
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
480
+								? $this->_req_data['batch_message']['from']
481
+								: $content;
482
+							break;
483
+						case 'subject' :
484
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
485
+								? $this->_req_data['batch_message']['subject']
486
+								: $content;
487
+							break;
488
+						case 'content' :
489
+							$new_content = $content;
490
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
491
+								? $this->_req_data['batch_message']['content']
492
+								: $content['newsletter_content'];
493
+							break;
494
+						default :
495
+							//continue the foreach loop, we don't want to set $new_content nor save.
496
+							continue 2;
497
+					}
498
+					$Message_Template->set('MTP_content', $new_content);
499
+					$Message_Template->save();
500
+				}
501
+			}
502
+			//great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
503
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
504
+				? $this->_req_data['batch_message']['id_type']
505
+				: 'registration';
506
+			//id_type will affect how we assemble the ids.
507
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
508
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
509
+				: array();
510
+			$registrations_used_for_contact_data = array();
511
+			//using switch because eventually we'll have other contexts that will be used for generating messages.
512
+			switch ($id_type) {
513
+				case 'registration' :
514
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
515
+						array(
516
+							array(
517
+								'REG_ID' => array('IN', $ids),
518
+							),
519
+						)
520
+					);
521
+					break;
522
+				case 'contact' :
523
+					$registrations_used_for_contact_data = EEM_Registration::instance()
524
+																		   ->get_latest_registration_for_each_of_given_contacts($ids);
525
+					break;
526
+			}
527
+			do_action(
528
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
529
+				$registrations_used_for_contact_data,
530
+				$Message_Template_Group->ID()
531
+			);
532
+			//kept for backward compat, internally we no longer use this action.
533
+			//@deprecated 4.8.36.rc.002
534
+			$contacts = $id_type === 'registration'
535
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
536
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
537
+			do_action(
538
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
539
+				$contacts,
540
+				$Message_Template_Group->ID()
541
+			);
542
+		}
543
+		$query_args = array(
544
+			'action' => ! empty($this->_req_data['redirect_back_to'])
545
+				? $this->_req_data['redirect_back_to']
546
+				: 'default',
547
+		);
548
+		$this->_redirect_after_action(false, '', '', $query_args, true);
549
+	}
550
+
551
+
552
+
553
+	/**
554
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
555
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
556
+	 */
557
+	protected function _registration_reports_js_setup()
558
+	{
559
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
560
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
561
+	}
562
+
563
+
564
+
565
+	/**
566
+	 *        generates Business Reports regarding Registrations
567
+	 *
568
+	 * @access protected
569
+	 * @return void
570
+	 */
571
+	protected function _registration_reports()
572
+	{
573
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
574
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
575
+			$template_path,
576
+			$this->_reports_template_data,
577
+			true
578
+		);
579
+		// the final template wrapper
580
+		$this->display_admin_page_with_no_sidebar();
581
+	}
582
+
583
+
584
+
585
+	/**
586
+	 * Generates Business Report showing total registrations per day.
587
+	 *
588
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
589
+	 * @return string
590
+	 */
591
+	private function _registrations_per_day_report($period = '-1 month')
592
+	{
593
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
594
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
595
+		$results = (array)$results;
596
+		$regs = array();
597
+		$subtitle = '';
598
+		if ($results) {
599
+			$column_titles = array();
600
+			$tracker = 0;
601
+			foreach ($results as $result) {
602
+				$report_column_values = array();
603
+				foreach ($result as $property_name => $property_value) {
604
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
605
+						: (int)$property_value;
606
+					$report_column_values[] = $property_value;
607
+					if ($tracker === 0) {
608
+						if ($property_name === 'Registration_REG_date') {
609
+							$column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso');
610
+						} else {
611
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
612
+						}
613
+					}
614
+				}
615
+				$tracker++;
616
+				$regs[] = $report_column_values;
617
+			}
618
+			//make sure the column_titles is pushed to the beginning of the array
619
+			array_unshift($regs, $column_titles);
620
+			//setup the date range.
621
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
622
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
623
+			$ending_date = new DateTime("now", $DateTimeZone);
624
+			$subtitle = sprintf(
625
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
626
+				$beginning_date->format('Y-m-d'),
627
+				$ending_date->format('Y-m-d')
628
+			);
629
+		}
630
+		$report_title = __('Total Registrations per Day', 'event_espresso');
631
+		$report_params = array(
632
+			'title'     => $report_title,
633
+			'subtitle'  => $subtitle,
634
+			'id'        => $report_ID,
635
+			'regs'      => $regs,
636
+			'noResults' => empty($regs),
637
+			'noRegsMsg' => sprintf(
638
+				__(
639
+					'%sThere are currently no registration records in the last month for this report.%s',
640
+					'event_espresso'
641
+				),
642
+				'<h2>' . $report_title . '</h2><p>',
643
+				'</p>'
644
+			),
645
+		);
646
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
647
+		return $report_ID;
648
+	}
649
+
650
+
651
+
652
+	/**
653
+	 * Generates Business Report showing total registrations per event.
654
+	 *
655
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
656
+	 * @return string
657
+	 */
658
+	private function _registrations_per_event_report($period = '-1 month')
659
+	{
660
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
661
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
662
+		$results = (array)$results;
663
+		$regs = array();
664
+		$subtitle = '';
665
+		if ($results) {
666
+			$column_titles = array();
667
+			$tracker = 0;
668
+			foreach ($results as $result) {
669
+				$report_column_values = array();
670
+				foreach ($result as $property_name => $property_value) {
671
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
672
+						$property_value,
673
+						4,
674
+						'...'
675
+					) : (int)$property_value;
676
+					$report_column_values[] = $property_value;
677
+					if ($tracker === 0) {
678
+						if ($property_name === 'Registration_Event') {
679
+							$column_titles[] = __('Event', 'event_espresso');
680
+						} else {
681
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
682
+						}
683
+					}
684
+				}
685
+				$tracker++;
686
+				$regs[] = $report_column_values;
687
+			}
688
+			//make sure the column_titles is pushed to the beginning of the array
689
+			array_unshift($regs, $column_titles);
690
+			//setup the date range.
691
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
692
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
693
+			$ending_date = new DateTime("now", $DateTimeZone);
694
+			$subtitle = sprintf(
695
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
696
+				$beginning_date->format('Y-m-d'),
697
+				$ending_date->format('Y-m-d')
698
+			);
699
+		}
700
+		$report_title = __('Total Registrations per Event', 'event_espresso');
701
+		$report_params = array(
702
+			'title'     => $report_title,
703
+			'subtitle'  => $subtitle,
704
+			'id'        => $report_ID,
705
+			'regs'      => $regs,
706
+			'noResults' => empty($regs),
707
+			'noRegsMsg' => sprintf(
708
+				__(
709
+					'%sThere are currently no registration records in the last month for this report.%s',
710
+					'event_espresso'
711
+				),
712
+				'<h2>' . $report_title . '</h2><p>',
713
+				'</p>'
714
+			),
715
+		);
716
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
717
+		return $report_ID;
718
+	}
719
+
720
+
721
+
722
+	/**
723
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
724
+	 *
725
+	 * @access protected
726
+	 * @return void
727
+	 * @throws \EE_Error
728
+	 */
729
+	protected function _registration_checkin_list_table()
730
+	{
731
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
732
+		$reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
733
+		/** @var EE_Registration $reg */
734
+		$reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
735
+		$this->_admin_page_title .= $this->get_action_link_or_button(
736
+			'new_registration',
737
+			'add-registrant',
738
+			array('event_id' => $reg->event_ID()),
739
+			'add-new-h2'
740
+		);
741
+		$legend_items = array(
742
+			'checkin'  => array(
743
+				'class' => 'ee-icon ee-icon-check-in',
744
+				'desc'  => __('This indicates the attendee has been checked in', 'event_espresso'),
745
+			),
746
+			'checkout' => array(
747
+				'class' => 'ee-icon ee-icon-check-out',
748
+				'desc'  => __('This indicates the attendee has been checked out', 'event_espresso'),
749
+			),
750
+		);
751
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
752
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
753
+		$go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(
754
+			array(
755
+				'action'   => 'event_registrations',
756
+				'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(),
757
+				'DTT_ID'   => $dtt_id,
758
+			),
759
+			$this->_admin_base_url
760
+		) : '';
761
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
762
+			? '<h2>' . sprintf(
763
+				__("%s's check in records for %s at the event, %s", 'event_espresso'),
764
+				'<span id="checkin-attendee-name">'
765
+				. EEM_Registration::instance()
766
+								  ->get_one_by_ID($reg_id)
767
+								  ->get_first_related('Attendee')
768
+								  ->full_name() . '</span>',
769
+				'<span id="checkin-dtt"><a href="' . $go_back_url . '">'
770
+				. EEM_Datetime::instance()
771
+							  ->get_one_by_ID($dtt_id)
772
+							  ->start_date_and_time() . ' - '
773
+				. EEM_Datetime::instance()
774
+							  ->get_one_by_ID($dtt_id)
775
+							  ->end_date_and_time() . '</a></span>',
776
+				'<span id="checkin-event-name">'
777
+				. EEM_Datetime::instance()
778
+							  ->get_one_by_ID($dtt_id)
779
+							  ->get_first_related('Event')
780
+							  ->get('EVT_name') . '</span>'
781
+			) . '</h2>'
782
+			: '';
783
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
784
+			? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
785
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
786
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
787
+		$this->display_admin_list_table_page_with_no_sidebar();
788
+	}
789
+
790
+
791
+
792
+	/**
793
+	 * toggle the Check-in status for the given registration (coming from ajax)
794
+	 *
795
+	 * @return void (JSON)
796
+	 */
797
+	public function toggle_checkin_status()
798
+	{
799
+		//first make sure we have the necessary data
800
+		if ( ! isset($this->_req_data['_regid'])) {
801
+			EE_Error::add_error(
802
+				__(
803
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
804
+					'event_espresso'
805
+				),
806
+				__FILE__,
807
+				__FUNCTION__,
808
+				__LINE__
809
+			);
810
+			$this->_template_args['success'] = false;
811
+			$this->_template_args['error'] = true;
812
+			$this->_return_json();
813
+		};
814
+		//do a nonce check cause we're not coming in from an normal route here.
815
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
816
+			: '';
817
+		$nonce_ref = 'checkin_nonce';
818
+		$this->_verify_nonce($nonce, $nonce_ref);
819
+		//beautiful! Made it this far so let's get the status.
820
+		$new_status = $this->_toggle_checkin_status();
821
+		//setup new class to return via ajax
822
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'
823
+													  . $new_status;
824
+		$this->_template_args['success'] = true;
825
+		$this->_return_json();
826
+	}
827
+
828
+
829
+
830
+	/**
831
+	 * handles toggling the checkin status for the registration,
832
+	 *
833
+	 * @access protected
834
+	 * @return int|void
835
+	 */
836
+	protected function _toggle_checkin_status()
837
+	{
838
+		//first let's get the query args out of the way for the redirect
839
+		$query_args = array(
840
+			'action'   => 'event_registrations',
841
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
842
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
843
+		);
844
+		$new_status = false;
845
+		// bulk action check in toggle
846
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
847
+			// cycle thru checkboxes
848
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
849
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
850
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
851
+			}
852
+		} elseif (isset($this->_req_data['_regid'])) {
853
+			//coming from ajax request
854
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
855
+			$query_args['DTT_ID'] = $DTT_ID;
856
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
857
+		} else {
858
+			EE_Error::add_error(
859
+				__('Missing some required data to toggle the Check-in', 'event_espresso'),
860
+				__FILE__,
861
+				__FUNCTION__,
862
+				__LINE__
863
+			);
864
+		}
865
+		if (defined('DOING_AJAX')) {
866
+			return $new_status;
867
+		}
868
+		$this->_redirect_after_action(false, '', '', $query_args, true);
869
+	}
870
+
871
+
872
+
873
+	/**
874
+	 * This is toggles a single Check-in for the given registration and datetime.
875
+	 *
876
+	 * @param  int $REG_ID The registration we're toggling
877
+	 * @param  int $DTT_ID The datetime we're toggling
878
+	 * @return int            The new status toggled to.
879
+	 * @throws \EE_Error
880
+	 */
881
+	private function _toggle_checkin($REG_ID, $DTT_ID)
882
+	{
883
+		/** @var EE_Registration $REG */
884
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
885
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
886
+		if ($new_status !== false) {
887
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
888
+		} else {
889
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
890
+			$new_status = false;
891
+		}
892
+		return $new_status;
893
+	}
894
+
895
+
896
+
897
+	/**
898
+	 * Takes care of deleting multiple EE_Checkin table rows
899
+	 *
900
+	 * @access protected
901
+	 * @return void
902
+	 * @throws \EE_Error
903
+	 */
904
+	protected function _delete_checkin_rows()
905
+	{
906
+		$query_args = array(
907
+			'action' => 'registration_checkins',
908
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
909
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
910
+		);
911
+		$errors = 0;
912
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
913
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
914
+				if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
915
+					$errors++;
916
+				}
917
+			}
918
+		} else {
919
+			EE_Error::add_error(
920
+				__(
921
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
922
+					'event_espresso'
923
+				),
924
+				__FILE__,
925
+				__FUNCTION__,
926
+				__LINE__
927
+			);
928
+			$this->_redirect_after_action(false, '', '', $query_args, true);
929
+		}
930
+		if ($errors > 0) {
931
+			EE_Error::add_error(
932
+				sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
933
+				__FILE__,
934
+				__FUNCTION__,
935
+				__LINE__
936
+			);
937
+		} else {
938
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
939
+		}
940
+		$this->_redirect_after_action(false, '', '', $query_args, true);
941
+	}
942
+
943
+
944
+
945
+	/**
946
+	 * Deletes a single EE_Checkin row
947
+	 *
948
+	 * @return void
949
+	 * @throws \EE_Error
950
+	 */
951
+	protected function _delete_checkin_row()
952
+	{
953
+		$query_args = array(
954
+			'action' => 'registration_checkins',
955
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
956
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0,
957
+		);
958
+		if ( ! empty($this->_req_data['CHK_ID'])) {
959
+			if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
960
+				EE_Error::add_error(
961
+					__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
962
+					__FILE__,
963
+					__FUNCTION__,
964
+					__LINE__
965
+				);
966
+			} else {
967
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
968
+			}
969
+		} else {
970
+			EE_Error::add_error(
971
+				__(
972
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
973
+					'event_espresso'
974
+				),
975
+				__FILE__,
976
+				__FUNCTION__,
977
+				__LINE__
978
+			);
979
+		}
980
+		$this->_redirect_after_action(false, '', '', $query_args, true);
981
+	}
982
+
983
+
984
+
985
+	/**
986
+	 *        generates HTML for the Event Registrations List Table
987
+	 *
988
+	 * @access protected
989
+	 * @return void
990
+	 * @throws \EE_Error
991
+	 */
992
+	protected function _event_registrations_list_table()
993
+	{
994
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
995
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
996
+			? $this->get_action_link_or_button(
997
+				'new_registration',
998
+				'add-registrant',
999
+				array('event_id' => $this->_req_data['event_id']),
1000
+				'add-new-h2',
1001
+				'',
1002
+				false
1003
+			)
1004
+			: '';
1005
+		$legend_items = array(
1006
+			'star-icon'        => array(
1007
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1008
+				'desc'  => __('This Registrant is the Primary Registrant', 'event_espresso'),
1009
+			),
1010
+			'checkin'          => array(
1011
+				'class' => 'ee-icon ee-icon-check-in',
1012
+				'desc'  => __('This Registrant has been Checked In', 'event_espresso'),
1013
+			),
1014
+			'checkout'         => array(
1015
+				'class' => 'ee-icon ee-icon-check-out',
1016
+				'desc'  => __('This Registrant has been Checked Out', 'event_espresso'),
1017
+			),
1018
+			'nocheckinrecord'  => array(
1019
+				'class' => 'dashicons dashicons-no',
1020
+				'desc'  => __('No Check-in Record has been Created for this Registrant', 'event_espresso'),
1021
+			),
1022
+			'view_details'     => array(
1023
+				'class' => 'dashicons dashicons-search',
1024
+				'desc'  => __('View All Check-in Records for this Registrant', 'event_espresso'),
1025
+			),
1026
+			'approved_status'  => array(
1027
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1028
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1029
+			),
1030
+			'cancelled_status' => array(
1031
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1032
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1033
+			),
1034
+			'declined_status'  => array(
1035
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1036
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1037
+			),
1038
+			'not_approved'     => array(
1039
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1040
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1041
+			),
1042
+			'pending_status'   => array(
1043
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1044
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1045
+			),
1046
+			'wait_list'        => array(
1047
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1048
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1049
+			),
1050
+		);
1051
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1052
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1053
+		$this->_template_args['before_list_table'] = ! empty($event_id)
1054
+			? '<h2>' . sprintf(
1055
+				__('Viewing Registrations for Event: %s', 'event_espresso'),
1056
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1057
+			) . '</h2>'
1058
+			: '';
1059
+		//need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event.
1060
+		/** @var EE_Event $event */
1061
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1062
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1063
+		$datetime = null;
1064
+		if ($event instanceof EE_Event) {
1065
+			$datetimes_on_event = $event->datetimes();
1066
+			if (count($datetimes_on_event) === 1) {
1067
+				$datetime = reset($datetimes_on_event);
1068
+			}
1069
+		}
1070
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1071
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1072
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1073
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1074
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1075
+			$this->_template_args['before_list_table'] .= $datetime->name();
1076
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1077
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1078
+		}
1079
+		//if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column
1080
+		//represents
1081
+		if ( ! $datetime instanceof EE_Datetime) {
1082
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1083
+														  . __('In this view, the check-in status represents the latest check-in record for the registration in that row.',
1084
+					'event_espresso')
1085
+														  . '</p>';
1086
+		}
1087
+		$this->display_admin_list_table_page_with_no_sidebar();
1088
+	}
1089
+
1090
+	/**
1091
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1092
+	 * conditions)
1093
+	 *
1094
+	 * @return void ends the request by a redirect or download
1095
+	 */
1096
+	public function _registrations_checkin_report()
1097
+	{
1098
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1099
+	}
1100
+
1101
+	/**
1102
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1103
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1104
+	 *
1105
+	 * @param array     $request
1106
+	 * @param int  $per_page
1107
+	 * @param bool $count
1108
+	 * @return array
1109
+	 */
1110
+	protected function _get_checkin_query_params_from_request(
1111
+		$request,
1112
+		$per_page = 10,
1113
+		$count = false
1114
+	) {
1115
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1116
+		//unlike the regular registrations list table,
1117
+		$status_ids_array = apply_filters(
1118
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1119
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1120
+		);
1121
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1122
+		return $query_params;
1123
+	}
1124
+
1125
+
1126
+
1127
+
1128
+	/**
1129
+	 * Gets registrations for an event
1130
+	 *
1131
+	 * @param int    $per_page
1132
+	 * @param bool   $count whether to return count or data.
1133
+	 * @param bool   $trash
1134
+	 * @param string $orderby
1135
+	 * @return EE_Registration[]|int
1136
+	 * @throws \EE_Error
1137
+	 */
1138
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1139
+	{
1140
+		//normalize some request params that get setup by the parent `get_registrations` method.
1141
+		$request = $this->_req_data;
1142
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1143
+		$request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
+		if($trash){
1145
+			$request['status'] = 'trash';
1146
+		}
1147
+		$query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count );
1148
+		/**
1149
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1150
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1151
+		 * @see EEM_Base::get_all()
1152
+		 */
1153
+		$query_params['group_by'] = '';
1154
+
1155
+		return $count
1156
+			? EEM_Registration::instance()->count($query_params)
1157
+			/** @type EE_Registration[] */
1158
+			: EEM_Registration::instance()->get_all($query_params);
1159
+	}
1160 1160
 
1161 1161
 } //end class Registrations Admin Page
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
     {
36 36
         parent::__construct($routing);
37 37
         if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
38
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
39
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
40
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
38
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
39
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
40
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
41 41
         }
42 42
     }
43 43
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
     protected function _extend_page_config()
47 47
     {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
48
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
49 49
         $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50 50
             ? $this->_req_data['_REG_ID']
51 51
             : 0;
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
             //enqueue newsletter js
179 179
             wp_enqueue_script(
180 180
                 'ee-newsletter-trigger',
181
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
181
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
182 182
                 array('ee-dialog'),
183 183
                 EVENT_ESPRESSO_VERSION,
184 184
                 true
185 185
             );
186 186
             wp_enqueue_style(
187 187
                 'ee-newsletter-trigger-css',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
188
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
189 189
                 array(),
190 190
                 EVENT_ESPRESSO_VERSION
191 191
             );
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     {
205 205
         wp_register_script(
206 206
             'ee-reg-reports-js',
207
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
207
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
208 208
             array('google-charts'),
209 209
             EVENT_ESPRESSO_VERSION,
210 210
             true
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
             $codes[$field] = implode(', ', array_keys($shortcode_array));
410 410
         }
411 411
         $shortcodes = $codes;
412
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
412
+        $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
413 413
         $form_template_args = array(
414 414
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
415 415
             'form_route'        => 'newsletter_selected_send',
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
      */
571 571
     protected function _registration_reports()
572 572
     {
573
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
573
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
574 574
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
575 575
             $template_path,
576 576
             $this->_reports_template_data,
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
     {
593 593
         $report_ID = 'reg-admin-registrations-per-day-report-dv';
594 594
         $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
595
-        $results = (array)$results;
595
+        $results = (array) $results;
596 596
         $regs = array();
597 597
         $subtitle = '';
598 598
         if ($results) {
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
                 $report_column_values = array();
603 603
                 foreach ($result as $property_name => $property_value) {
604 604
                     $property_value = $property_name === 'Registration_REG_date' ? $property_value
605
-                        : (int)$property_value;
605
+                        : (int) $property_value;
606 606
                     $report_column_values[] = $property_value;
607 607
                     if ($tracker === 0) {
608 608
                         if ($property_name === 'Registration_REG_date') {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
             array_unshift($regs, $column_titles);
620 620
             //setup the date range.
621 621
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
622
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
622
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
623 623
             $ending_date = new DateTime("now", $DateTimeZone);
624 624
             $subtitle = sprintf(
625 625
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                     '%sThere are currently no registration records in the last month for this report.%s',
640 640
                     'event_espresso'
641 641
                 ),
642
-                '<h2>' . $report_title . '</h2><p>',
642
+                '<h2>'.$report_title.'</h2><p>',
643 643
                 '</p>'
644 644
             ),
645 645
         );
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
     {
660 660
         $report_ID = 'reg-admin-registrations-per-event-report-dv';
661 661
         $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
662
-        $results = (array)$results;
662
+        $results = (array) $results;
663 663
         $regs = array();
664 664
         $subtitle = '';
665 665
         if ($results) {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
                         $property_value,
673 673
                         4,
674 674
                         '...'
675
-                    ) : (int)$property_value;
675
+                    ) : (int) $property_value;
676 676
                     $report_column_values[] = $property_value;
677 677
                     if ($tracker === 0) {
678 678
                         if ($property_name === 'Registration_Event') {
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
             array_unshift($regs, $column_titles);
690 690
             //setup the date range.
691 691
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
692
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
692
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
693 693
             $ending_date = new DateTime("now", $DateTimeZone);
694 694
             $subtitle = sprintf(
695 695
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
                     '%sThere are currently no registration records in the last month for this report.%s',
710 710
                     'event_espresso'
711 711
                 ),
712
-                '<h2>' . $report_title . '</h2><p>',
712
+                '<h2>'.$report_title.'</h2><p>',
713 713
                 '</p>'
714 714
             ),
715 715
         );
@@ -759,31 +759,31 @@  discard block
 block discarded – undo
759 759
             $this->_admin_base_url
760 760
         ) : '';
761 761
         $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
762
-            ? '<h2>' . sprintf(
762
+            ? '<h2>'.sprintf(
763 763
                 __("%s's check in records for %s at the event, %s", 'event_espresso'),
764 764
                 '<span id="checkin-attendee-name">'
765 765
                 . EEM_Registration::instance()
766 766
                                   ->get_one_by_ID($reg_id)
767 767
                                   ->get_first_related('Attendee')
768
-                                  ->full_name() . '</span>',
769
-                '<span id="checkin-dtt"><a href="' . $go_back_url . '">'
768
+                                  ->full_name().'</span>',
769
+                '<span id="checkin-dtt"><a href="'.$go_back_url.'">'
770 770
                 . EEM_Datetime::instance()
771 771
                               ->get_one_by_ID($dtt_id)
772
-                              ->start_date_and_time() . ' - '
772
+                              ->start_date_and_time().' - '
773 773
                 . EEM_Datetime::instance()
774 774
                               ->get_one_by_ID($dtt_id)
775
-                              ->end_date_and_time() . '</a></span>',
775
+                              ->end_date_and_time().'</a></span>',
776 776
                 '<span id="checkin-event-name">'
777 777
                 . EEM_Datetime::instance()
778 778
                               ->get_one_by_ID($dtt_id)
779 779
                               ->get_first_related('Event')
780
-                              ->get('EVT_name') . '</span>'
781
-            ) . '</h2>'
780
+                              ->get('EVT_name').'</span>'
781
+            ).'</h2>'
782 782
             : '';
783 783
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
784
-            ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
784
+            ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : '';
785 785
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
786
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
786
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
787 787
         $this->display_admin_list_table_page_with_no_sidebar();
788 788
     }
789 789
 
@@ -1024,37 +1024,37 @@  discard block
 block discarded – undo
1024 1024
                 'desc'  => __('View All Check-in Records for this Registrant', 'event_espresso'),
1025 1025
             ),
1026 1026
             'approved_status'  => array(
1027
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1027
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1028 1028
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1029 1029
             ),
1030 1030
             'cancelled_status' => array(
1031
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1031
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1032 1032
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1033 1033
             ),
1034 1034
             'declined_status'  => array(
1035
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1035
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1036 1036
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1037 1037
             ),
1038 1038
             'not_approved'     => array(
1039
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1039
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1040 1040
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1041 1041
             ),
1042 1042
             'pending_status'   => array(
1043
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1043
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1044 1044
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1045 1045
             ),
1046 1046
             'wait_list'        => array(
1047
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1047
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1048 1048
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1049 1049
             ),
1050 1050
         );
1051 1051
         $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1052 1052
         $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1053 1053
         $this->_template_args['before_list_table'] = ! empty($event_id)
1054
-            ? '<h2>' . sprintf(
1054
+            ? '<h2>'.sprintf(
1055 1055
                 __('Viewing Registrations for Event: %s', 'event_espresso'),
1056 1056
                 EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1057
-            ) . '</h2>'
1057
+            ).'</h2>'
1058 1058
             : '';
1059 1059
         //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event.
1060 1060
         /** @var EE_Event $event */
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
             $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1074 1074
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1075 1075
             $this->_template_args['before_list_table'] .= $datetime->name();
1076
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1076
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1077 1077
             $this->_template_args['before_list_table'] .= '</span></h2>';
1078 1078
         }
1079 1079
         //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column
@@ -1140,11 +1140,11 @@  discard block
 block discarded – undo
1140 1140
         //normalize some request params that get setup by the parent `get_registrations` method.
1141 1141
         $request = $this->_req_data;
1142 1142
         $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1143
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
-        if($trash){
1143
+        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1144
+        if ($trash) {
1145 1145
             $request['status'] = 'trash';
1146 1146
         }
1147
-        $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count );
1147
+        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1148 1148
         /**
1149 1149
          * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1150 1150
          * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 1 patch
Indentation   +660 added lines, -660 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -23,665 +23,665 @@  discard block
 block discarded – undo
23 23
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
24 24
 {
25 25
 
26
-    /**
27
-     * Sets some dynamic defaults
28
-     *
29
-     * @param array  $fieldValues
30
-     * @param bool   $bydb
31
-     * @param string $timezone
32
-     * @param array  $date_formats
33
-     */
34
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
-    {
36
-        if (! isset($fieldValues['ATT_full_name'])) {
37
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
-            $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
-            $fieldValues['ATT_full_name'] = $fname . $lname;
40
-        }
41
-        if (! isset($fieldValues['ATT_slug'])) {
42
-            //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
-        }
45
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
-        }
48
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
-    }
50
-
51
-
52
-    /**
53
-     * @param array  $props_n_values          incoming values
54
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
-     *                                        used.)
56
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
-     *                                        date_format and the second value is the time format
58
-     * @return EE_Attendee
59
-     */
60
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
-    {
62
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param array  $props_n_values  incoming values from the database
69
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
-     *                                the website will be used.
71
-     * @return EE_Attendee
72
-     */
73
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
-    {
75
-        return new self($props_n_values, true, $timezone);
76
-    }
77
-
78
-
79
-    /**
80
-     *        Set Attendee First Name
81
-     *
82
-     * @access        public
83
-     * @param string $fname
84
-     */
85
-    public function set_fname($fname = '')
86
-    {
87
-        $this->set('ATT_fname', $fname);
88
-    }
89
-
90
-
91
-    /**
92
-     *        Set Attendee Last Name
93
-     *
94
-     * @access        public
95
-     * @param string $lname
96
-     */
97
-    public function set_lname($lname = '')
98
-    {
99
-        $this->set('ATT_lname', $lname);
100
-    }
101
-
102
-
103
-    /**
104
-     *        Set Attendee Address
105
-     *
106
-     * @access        public
107
-     * @param string $address
108
-     */
109
-    public function set_address($address = '')
110
-    {
111
-        $this->set('ATT_address', $address);
112
-    }
113
-
114
-
115
-    /**
116
-     *        Set Attendee Address2
117
-     *
118
-     * @access        public
119
-     * @param        string $address2
120
-     */
121
-    public function set_address2($address2 = '')
122
-    {
123
-        $this->set('ATT_address2', $address2);
124
-    }
125
-
126
-
127
-    /**
128
-     *        Set Attendee City
129
-     *
130
-     * @access        public
131
-     * @param        string $city
132
-     */
133
-    public function set_city($city = '')
134
-    {
135
-        $this->set('ATT_city', $city);
136
-    }
137
-
138
-
139
-    /**
140
-     *        Set Attendee State ID
141
-     *
142
-     * @access        public
143
-     * @param        int $STA_ID
144
-     */
145
-    public function set_state($STA_ID = 0)
146
-    {
147
-        $this->set('STA_ID', $STA_ID);
148
-    }
149
-
150
-
151
-    /**
152
-     *        Set Attendee Country ISO Code
153
-     *
154
-     * @access        public
155
-     * @param        string $CNT_ISO
156
-     */
157
-    public function set_country($CNT_ISO = '')
158
-    {
159
-        $this->set('CNT_ISO', $CNT_ISO);
160
-    }
161
-
162
-
163
-    /**
164
-     *        Set Attendee Zip/Postal Code
165
-     *
166
-     * @access        public
167
-     * @param        string $zip
168
-     */
169
-    public function set_zip($zip = '')
170
-    {
171
-        $this->set('ATT_zip', $zip);
172
-    }
173
-
174
-
175
-    /**
176
-     *        Set Attendee Email Address
177
-     *
178
-     * @access        public
179
-     * @param        string $email
180
-     */
181
-    public function set_email($email = '')
182
-    {
183
-        $this->set('ATT_email', $email);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Phone
189
-     *
190
-     * @access        public
191
-     * @param        string $phone
192
-     */
193
-    public function set_phone($phone = '')
194
-    {
195
-        $this->set('ATT_phone', $phone);
196
-    }
197
-
198
-
199
-    /**
200
-     *        set deleted
201
-     *
202
-     * @access        public
203
-     * @param        bool $ATT_deleted
204
-     */
205
-    public function set_deleted($ATT_deleted = false)
206
-    {
207
-        $this->set('ATT_deleted', $ATT_deleted);
208
-    }
209
-
210
-
211
-    /**
212
-     * Returns the value for the post_author id saved with the cpt
213
-     *
214
-     * @since 4.5.0
215
-     * @return int
216
-     */
217
-    public function wp_user()
218
-    {
219
-        return $this->get('ATT_author');
220
-    }
221
-
222
-
223
-    /**
224
-     *        get Attendee First Name
225
-     *
226
-     * @access        public
227
-     * @return string
228
-     */
229
-    public function fname()
230
-    {
231
-        return $this->get('ATT_fname');
232
-    }
233
-
234
-
235
-    /**
236
-     * echoes out the attendee's first name
237
-     *
238
-     * @return void
239
-     */
240
-    public function e_full_name()
241
-    {
242
-        echo $this->full_name();
243
-    }
244
-
245
-
246
-    /**
247
-     * Returns the first and last name concatenated together with a space.
248
-     *
249
-     * @param bool $apply_html_entities
250
-     * @return string
251
-     */
252
-    public function full_name($apply_html_entities = false)
253
-    {
254
-        $full_name = $this->fname() . ' ' . $this->lname();
255
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256
-    }
257
-
258
-
259
-    /**
260
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
261
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
262
-     * attendee.
263
-     *
264
-     * @param bool $apply_html_entities
265
-     * @return string
266
-     */
267
-    public function ATT_full_name($apply_html_entities = false)
268
-    {
269
-        return $apply_html_entities
270
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
271
-            : $this->get('ATT_full_name');
272
-    }
273
-
274
-
275
-    /**
276
-     *        get Attendee Last Name
277
-     *
278
-     * @access        public
279
-     * @return string
280
-     */
281
-    public function lname()
282
-    {
283
-        return $this->get('ATT_lname');
284
-    }
285
-
286
-
287
-    /**
288
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
289
-     *
290
-     * @return array numerically indexed, with each part of the address that is known.
291
-     * Eg, if the user only responded to state and country,
292
-     * it would be array(0=>'Alabama',1=>'USA')
293
-     * @return array
294
-     */
295
-    public function full_address_as_array()
296
-    {
297
-        $full_address_array     = array();
298
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
299
-        foreach ($initial_address_fields as $address_field_name) {
300
-            $address_fields_value = $this->get($address_field_name);
301
-            if (! empty($address_fields_value)) {
302
-                $full_address_array[] = $address_fields_value;
303
-            }
304
-        }
305
-        //now handle state and country
306
-        $state_obj = $this->state_obj();
307
-        if (! empty($state_obj)) {
308
-            $full_address_array[] = $state_obj->name();
309
-        }
310
-        $country_obj = $this->country_obj();
311
-        if (! empty($country_obj)) {
312
-            $full_address_array[] = $country_obj->name();
313
-        }
314
-        //lastly get the xip
315
-        $zip_value = $this->zip();
316
-        if (! empty($zip_value)) {
317
-            $full_address_array[] = $zip_value;
318
-        }
319
-        return $full_address_array;
320
-    }
321
-
322
-
323
-    /**
324
-     *        get Attendee Address
325
-     *
326
-     * @return string
327
-     */
328
-    public function address()
329
-    {
330
-        return $this->get('ATT_address');
331
-    }
332
-
333
-
334
-    /**
335
-     *        get Attendee Address2
336
-     *
337
-     * @return string
338
-     */
339
-    public function address2()
340
-    {
341
-        return $this->get('ATT_address2');
342
-    }
343
-
344
-
345
-    /**
346
-     *        get Attendee City
347
-     *
348
-     * @return string
349
-     */
350
-    public function city()
351
-    {
352
-        return $this->get('ATT_city');
353
-    }
354
-
355
-
356
-    /**
357
-     *        get Attendee State ID
358
-     *
359
-     * @return string
360
-     */
361
-    public function state_ID()
362
-    {
363
-        return $this->get('STA_ID');
364
-    }
365
-
366
-
367
-    /**
368
-     * @return string
369
-     */
370
-    public function state_abbrev()
371
-    {
372
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
373
-    }
374
-
375
-
376
-    /**
377
-     * Gets the state set to this attendee
378
-     *
379
-     * @return EE_State
380
-     */
381
-    public function state_obj()
382
-    {
383
-        return $this->get_first_related('State');
384
-    }
385
-
386
-
387
-    /**
388
-     * Returns the state's name, otherwise 'Unknown'
389
-     *
390
-     * @return string
391
-     */
392
-    public function state_name()
393
-    {
394
-        if ($this->state_obj()) {
395
-            return $this->state_obj()->name();
396
-        } else {
397
-            return '';
398
-        }
399
-    }
400
-
401
-
402
-    /**
403
-     * either displays the state abbreviation or the state name, as determined
404
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
405
-     * defaults to abbreviation
406
-     *
407
-     * @return string
408
-     */
409
-    public function state()
410
-    {
411
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
412
-            return $this->state_abbrev();
413
-        } else {
414
-            return $this->state_name();
415
-        }
416
-    }
417
-
418
-
419
-    /**
420
-     *    get Attendee Country ISO Code
421
-     *
422
-     * @return string
423
-     */
424
-    public function country_ID()
425
-    {
426
-        return $this->get('CNT_ISO');
427
-    }
428
-
429
-
430
-    /**
431
-     * Gets country set for this attendee
432
-     *
433
-     * @return EE_Country
434
-     */
435
-    public function country_obj()
436
-    {
437
-        return $this->get_first_related('Country');
438
-    }
439
-
440
-
441
-    /**
442
-     * Returns the country's name if known, otherwise 'Unknown'
443
-     *
444
-     * @return string
445
-     */
446
-    public function country_name()
447
-    {
448
-        if ($this->country_obj()) {
449
-            return $this->country_obj()->name();
450
-        } else {
451
-            return '';
452
-        }
453
-    }
454
-
455
-
456
-    /**
457
-     * either displays the country ISO2 code or the country name, as determined
458
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
459
-     * defaults to abbreviation
460
-     *
461
-     * @return string
462
-     */
463
-    public function country()
464
-    {
465
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
466
-            return $this->country_ID();
467
-        } else {
468
-            return $this->country_name();
469
-        }
470
-    }
471
-
472
-
473
-    /**
474
-     *        get Attendee Zip/Postal Code
475
-     *
476
-     * @return string
477
-     */
478
-    public function zip()
479
-    {
480
-        return $this->get('ATT_zip');
481
-    }
482
-
483
-
484
-    /**
485
-     *        get Attendee Email Address
486
-     *
487
-     * @return string
488
-     */
489
-    public function email()
490
-    {
491
-        return $this->get('ATT_email');
492
-    }
493
-
494
-
495
-    /**
496
-     *        get Attendee Phone #
497
-     *
498
-     * @return string
499
-     */
500
-    public function phone()
501
-    {
502
-        return $this->get('ATT_phone');
503
-    }
504
-
505
-
506
-    /**
507
-     *    get deleted
508
-     *
509
-     * @return        bool
510
-     */
511
-    public function deleted()
512
-    {
513
-        return $this->get('ATT_deleted');
514
-    }
515
-
516
-
517
-    /**
518
-     * Gets registrations of this attendee
519
-     *
520
-     * @param array $query_params
521
-     * @return EE_Registration[]
522
-     */
523
-    public function get_registrations($query_params = array())
524
-    {
525
-        return $this->get_many_related('Registration', $query_params);
526
-    }
527
-
528
-
529
-    /**
530
-     * Gets the most recent registration of this attendee
531
-     *
532
-     * @return EE_Registration
533
-     */
534
-    public function get_most_recent_registration()
535
-    {
536
-        return $this->get_first_related('Registration',
537
-            array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
538
-    }
539
-
540
-
541
-    /**
542
-     * Gets the most recent registration for this attend at this event
543
-     *
544
-     * @param int $event_id
545
-     * @return EE_Registration
546
-     */
547
-    public function get_most_recent_registration_for_event($event_id)
548
-    {
549
-        return $this->get_first_related('Registration',
550
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
551
-    }
552
-
553
-
554
-    /**
555
-     * returns any events attached to this attendee ($_Event property);
556
-     *
557
-     * @return array
558
-     */
559
-    public function events()
560
-    {
561
-        return $this->get_many_related('Event');
562
-    }
563
-
564
-
565
-    /**
566
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
567
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
568
-     * used to save the billing info
569
-     *
570
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
571
-     * @return EE_Form_Section_Proper|null
572
-     */
573
-    public function billing_info_for_payment_method($payment_method)
574
-    {
575
-        $pm_type = $payment_method->type_obj();
576
-        if (! $pm_type instanceof EE_PMT_Base) {
577
-            return null;
578
-        }
579
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
580
-        if (! $billing_info) {
581
-            return null;
582
-        }
583
-        $billing_form = $pm_type->billing_form();
584
-        if ($billing_form instanceof EE_Form_Section_Proper) {
585
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
586
-        }
587
-        return $billing_form;
588
-    }
589
-
590
-
591
-    /**
592
-     * Gets the postmeta key that holds this attendee's billing info for the
593
-     * specified payment method
594
-     *
595
-     * @param EE_Payment_Method $payment_method
596
-     * @return string
597
-     */
598
-    public function get_billing_info_postmeta_name($payment_method)
599
-    {
600
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
601
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
602
-        } else {
603
-            return null;
604
-        }
605
-    }
606
-
607
-
608
-    /**
609
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
610
-     * retrieve it
611
-     *
612
-     * @param EE_Billing_Attendee_Info_Form $billing_form
613
-     * @param EE_Payment_Method             $payment_method
614
-     * @return boolean
615
-     */
616
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
617
-    {
618
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
619
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
620
-            return false;
621
-        }
622
-        $billing_form->clean_sensitive_data();
623
-        return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
624
-            $billing_form->input_values(true));
625
-    }
626
-
627
-
628
-    /**
629
-     * Return the link to the admin details for the object.
630
-     *
631
-     * @return string
632
-     */
633
-    public function get_admin_details_link()
634
-    {
635
-        return $this->get_admin_edit_link();
636
-    }
637
-
638
-
639
-    /**
640
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
641
-     *
642
-     * @return string
643
-     */
644
-    public function get_admin_edit_link()
645
-    {
646
-        EE_Registry::instance()->load_helper('URL');
647
-        return EEH_URL::add_query_args_and_nonce(
648
-            array(
649
-                'page'   => 'espresso_registrations',
650
-                'action' => 'edit_attendee',
651
-                'post'   => $this->ID(),
652
-            ),
653
-            admin_url('admin.php')
654
-        );
655
-    }
656
-
657
-
658
-    /**
659
-     * Returns the link to a settings page for the object.
660
-     *
661
-     * @return string
662
-     */
663
-    public function get_admin_settings_link()
664
-    {
665
-        return $this->get_admin_edit_link();
666
-    }
667
-
668
-
669
-    /**
670
-     * Returns the link to the "overview" for the object (typically the "list table" view).
671
-     *
672
-     * @return string
673
-     */
674
-    public function get_admin_overview_link()
675
-    {
676
-        EE_Registry::instance()->load_helper('URL');
677
-        return EEH_URL::add_query_args_and_nonce(
678
-            array(
679
-                'page'   => 'espresso_registrations',
680
-                'action' => 'contact_list',
681
-            ),
682
-            admin_url('admin.php')
683
-        );
684
-    }
26
+	/**
27
+	 * Sets some dynamic defaults
28
+	 *
29
+	 * @param array  $fieldValues
30
+	 * @param bool   $bydb
31
+	 * @param string $timezone
32
+	 * @param array  $date_formats
33
+	 */
34
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
+	{
36
+		if (! isset($fieldValues['ATT_full_name'])) {
37
+			$fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
+			$lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
+			$fieldValues['ATT_full_name'] = $fname . $lname;
40
+		}
41
+		if (! isset($fieldValues['ATT_slug'])) {
42
+			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
+		}
45
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
+		}
48
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
+	}
50
+
51
+
52
+	/**
53
+	 * @param array  $props_n_values          incoming values
54
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
+	 *                                        used.)
56
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
+	 *                                        date_format and the second value is the time format
58
+	 * @return EE_Attendee
59
+	 */
60
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
+	{
62
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param array  $props_n_values  incoming values from the database
69
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
+	 *                                the website will be used.
71
+	 * @return EE_Attendee
72
+	 */
73
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
+	{
75
+		return new self($props_n_values, true, $timezone);
76
+	}
77
+
78
+
79
+	/**
80
+	 *        Set Attendee First Name
81
+	 *
82
+	 * @access        public
83
+	 * @param string $fname
84
+	 */
85
+	public function set_fname($fname = '')
86
+	{
87
+		$this->set('ATT_fname', $fname);
88
+	}
89
+
90
+
91
+	/**
92
+	 *        Set Attendee Last Name
93
+	 *
94
+	 * @access        public
95
+	 * @param string $lname
96
+	 */
97
+	public function set_lname($lname = '')
98
+	{
99
+		$this->set('ATT_lname', $lname);
100
+	}
101
+
102
+
103
+	/**
104
+	 *        Set Attendee Address
105
+	 *
106
+	 * @access        public
107
+	 * @param string $address
108
+	 */
109
+	public function set_address($address = '')
110
+	{
111
+		$this->set('ATT_address', $address);
112
+	}
113
+
114
+
115
+	/**
116
+	 *        Set Attendee Address2
117
+	 *
118
+	 * @access        public
119
+	 * @param        string $address2
120
+	 */
121
+	public function set_address2($address2 = '')
122
+	{
123
+		$this->set('ATT_address2', $address2);
124
+	}
125
+
126
+
127
+	/**
128
+	 *        Set Attendee City
129
+	 *
130
+	 * @access        public
131
+	 * @param        string $city
132
+	 */
133
+	public function set_city($city = '')
134
+	{
135
+		$this->set('ATT_city', $city);
136
+	}
137
+
138
+
139
+	/**
140
+	 *        Set Attendee State ID
141
+	 *
142
+	 * @access        public
143
+	 * @param        int $STA_ID
144
+	 */
145
+	public function set_state($STA_ID = 0)
146
+	{
147
+		$this->set('STA_ID', $STA_ID);
148
+	}
149
+
150
+
151
+	/**
152
+	 *        Set Attendee Country ISO Code
153
+	 *
154
+	 * @access        public
155
+	 * @param        string $CNT_ISO
156
+	 */
157
+	public function set_country($CNT_ISO = '')
158
+	{
159
+		$this->set('CNT_ISO', $CNT_ISO);
160
+	}
161
+
162
+
163
+	/**
164
+	 *        Set Attendee Zip/Postal Code
165
+	 *
166
+	 * @access        public
167
+	 * @param        string $zip
168
+	 */
169
+	public function set_zip($zip = '')
170
+	{
171
+		$this->set('ATT_zip', $zip);
172
+	}
173
+
174
+
175
+	/**
176
+	 *        Set Attendee Email Address
177
+	 *
178
+	 * @access        public
179
+	 * @param        string $email
180
+	 */
181
+	public function set_email($email = '')
182
+	{
183
+		$this->set('ATT_email', $email);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Phone
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $phone
192
+	 */
193
+	public function set_phone($phone = '')
194
+	{
195
+		$this->set('ATT_phone', $phone);
196
+	}
197
+
198
+
199
+	/**
200
+	 *        set deleted
201
+	 *
202
+	 * @access        public
203
+	 * @param        bool $ATT_deleted
204
+	 */
205
+	public function set_deleted($ATT_deleted = false)
206
+	{
207
+		$this->set('ATT_deleted', $ATT_deleted);
208
+	}
209
+
210
+
211
+	/**
212
+	 * Returns the value for the post_author id saved with the cpt
213
+	 *
214
+	 * @since 4.5.0
215
+	 * @return int
216
+	 */
217
+	public function wp_user()
218
+	{
219
+		return $this->get('ATT_author');
220
+	}
221
+
222
+
223
+	/**
224
+	 *        get Attendee First Name
225
+	 *
226
+	 * @access        public
227
+	 * @return string
228
+	 */
229
+	public function fname()
230
+	{
231
+		return $this->get('ATT_fname');
232
+	}
233
+
234
+
235
+	/**
236
+	 * echoes out the attendee's first name
237
+	 *
238
+	 * @return void
239
+	 */
240
+	public function e_full_name()
241
+	{
242
+		echo $this->full_name();
243
+	}
244
+
245
+
246
+	/**
247
+	 * Returns the first and last name concatenated together with a space.
248
+	 *
249
+	 * @param bool $apply_html_entities
250
+	 * @return string
251
+	 */
252
+	public function full_name($apply_html_entities = false)
253
+	{
254
+		$full_name = $this->fname() . ' ' . $this->lname();
255
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
256
+	}
257
+
258
+
259
+	/**
260
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
261
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
262
+	 * attendee.
263
+	 *
264
+	 * @param bool $apply_html_entities
265
+	 * @return string
266
+	 */
267
+	public function ATT_full_name($apply_html_entities = false)
268
+	{
269
+		return $apply_html_entities
270
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
271
+			: $this->get('ATT_full_name');
272
+	}
273
+
274
+
275
+	/**
276
+	 *        get Attendee Last Name
277
+	 *
278
+	 * @access        public
279
+	 * @return string
280
+	 */
281
+	public function lname()
282
+	{
283
+		return $this->get('ATT_lname');
284
+	}
285
+
286
+
287
+	/**
288
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
289
+	 *
290
+	 * @return array numerically indexed, with each part of the address that is known.
291
+	 * Eg, if the user only responded to state and country,
292
+	 * it would be array(0=>'Alabama',1=>'USA')
293
+	 * @return array
294
+	 */
295
+	public function full_address_as_array()
296
+	{
297
+		$full_address_array     = array();
298
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
299
+		foreach ($initial_address_fields as $address_field_name) {
300
+			$address_fields_value = $this->get($address_field_name);
301
+			if (! empty($address_fields_value)) {
302
+				$full_address_array[] = $address_fields_value;
303
+			}
304
+		}
305
+		//now handle state and country
306
+		$state_obj = $this->state_obj();
307
+		if (! empty($state_obj)) {
308
+			$full_address_array[] = $state_obj->name();
309
+		}
310
+		$country_obj = $this->country_obj();
311
+		if (! empty($country_obj)) {
312
+			$full_address_array[] = $country_obj->name();
313
+		}
314
+		//lastly get the xip
315
+		$zip_value = $this->zip();
316
+		if (! empty($zip_value)) {
317
+			$full_address_array[] = $zip_value;
318
+		}
319
+		return $full_address_array;
320
+	}
321
+
322
+
323
+	/**
324
+	 *        get Attendee Address
325
+	 *
326
+	 * @return string
327
+	 */
328
+	public function address()
329
+	{
330
+		return $this->get('ATT_address');
331
+	}
332
+
333
+
334
+	/**
335
+	 *        get Attendee Address2
336
+	 *
337
+	 * @return string
338
+	 */
339
+	public function address2()
340
+	{
341
+		return $this->get('ATT_address2');
342
+	}
343
+
344
+
345
+	/**
346
+	 *        get Attendee City
347
+	 *
348
+	 * @return string
349
+	 */
350
+	public function city()
351
+	{
352
+		return $this->get('ATT_city');
353
+	}
354
+
355
+
356
+	/**
357
+	 *        get Attendee State ID
358
+	 *
359
+	 * @return string
360
+	 */
361
+	public function state_ID()
362
+	{
363
+		return $this->get('STA_ID');
364
+	}
365
+
366
+
367
+	/**
368
+	 * @return string
369
+	 */
370
+	public function state_abbrev()
371
+	{
372
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
373
+	}
374
+
375
+
376
+	/**
377
+	 * Gets the state set to this attendee
378
+	 *
379
+	 * @return EE_State
380
+	 */
381
+	public function state_obj()
382
+	{
383
+		return $this->get_first_related('State');
384
+	}
385
+
386
+
387
+	/**
388
+	 * Returns the state's name, otherwise 'Unknown'
389
+	 *
390
+	 * @return string
391
+	 */
392
+	public function state_name()
393
+	{
394
+		if ($this->state_obj()) {
395
+			return $this->state_obj()->name();
396
+		} else {
397
+			return '';
398
+		}
399
+	}
400
+
401
+
402
+	/**
403
+	 * either displays the state abbreviation or the state name, as determined
404
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
405
+	 * defaults to abbreviation
406
+	 *
407
+	 * @return string
408
+	 */
409
+	public function state()
410
+	{
411
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
412
+			return $this->state_abbrev();
413
+		} else {
414
+			return $this->state_name();
415
+		}
416
+	}
417
+
418
+
419
+	/**
420
+	 *    get Attendee Country ISO Code
421
+	 *
422
+	 * @return string
423
+	 */
424
+	public function country_ID()
425
+	{
426
+		return $this->get('CNT_ISO');
427
+	}
428
+
429
+
430
+	/**
431
+	 * Gets country set for this attendee
432
+	 *
433
+	 * @return EE_Country
434
+	 */
435
+	public function country_obj()
436
+	{
437
+		return $this->get_first_related('Country');
438
+	}
439
+
440
+
441
+	/**
442
+	 * Returns the country's name if known, otherwise 'Unknown'
443
+	 *
444
+	 * @return string
445
+	 */
446
+	public function country_name()
447
+	{
448
+		if ($this->country_obj()) {
449
+			return $this->country_obj()->name();
450
+		} else {
451
+			return '';
452
+		}
453
+	}
454
+
455
+
456
+	/**
457
+	 * either displays the country ISO2 code or the country name, as determined
458
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
459
+	 * defaults to abbreviation
460
+	 *
461
+	 * @return string
462
+	 */
463
+	public function country()
464
+	{
465
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
466
+			return $this->country_ID();
467
+		} else {
468
+			return $this->country_name();
469
+		}
470
+	}
471
+
472
+
473
+	/**
474
+	 *        get Attendee Zip/Postal Code
475
+	 *
476
+	 * @return string
477
+	 */
478
+	public function zip()
479
+	{
480
+		return $this->get('ATT_zip');
481
+	}
482
+
483
+
484
+	/**
485
+	 *        get Attendee Email Address
486
+	 *
487
+	 * @return string
488
+	 */
489
+	public function email()
490
+	{
491
+		return $this->get('ATT_email');
492
+	}
493
+
494
+
495
+	/**
496
+	 *        get Attendee Phone #
497
+	 *
498
+	 * @return string
499
+	 */
500
+	public function phone()
501
+	{
502
+		return $this->get('ATT_phone');
503
+	}
504
+
505
+
506
+	/**
507
+	 *    get deleted
508
+	 *
509
+	 * @return        bool
510
+	 */
511
+	public function deleted()
512
+	{
513
+		return $this->get('ATT_deleted');
514
+	}
515
+
516
+
517
+	/**
518
+	 * Gets registrations of this attendee
519
+	 *
520
+	 * @param array $query_params
521
+	 * @return EE_Registration[]
522
+	 */
523
+	public function get_registrations($query_params = array())
524
+	{
525
+		return $this->get_many_related('Registration', $query_params);
526
+	}
527
+
528
+
529
+	/**
530
+	 * Gets the most recent registration of this attendee
531
+	 *
532
+	 * @return EE_Registration
533
+	 */
534
+	public function get_most_recent_registration()
535
+	{
536
+		return $this->get_first_related('Registration',
537
+			array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
538
+	}
539
+
540
+
541
+	/**
542
+	 * Gets the most recent registration for this attend at this event
543
+	 *
544
+	 * @param int $event_id
545
+	 * @return EE_Registration
546
+	 */
547
+	public function get_most_recent_registration_for_event($event_id)
548
+	{
549
+		return $this->get_first_related('Registration',
550
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
551
+	}
552
+
553
+
554
+	/**
555
+	 * returns any events attached to this attendee ($_Event property);
556
+	 *
557
+	 * @return array
558
+	 */
559
+	public function events()
560
+	{
561
+		return $this->get_many_related('Event');
562
+	}
563
+
564
+
565
+	/**
566
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
567
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
568
+	 * used to save the billing info
569
+	 *
570
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
571
+	 * @return EE_Form_Section_Proper|null
572
+	 */
573
+	public function billing_info_for_payment_method($payment_method)
574
+	{
575
+		$pm_type = $payment_method->type_obj();
576
+		if (! $pm_type instanceof EE_PMT_Base) {
577
+			return null;
578
+		}
579
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
580
+		if (! $billing_info) {
581
+			return null;
582
+		}
583
+		$billing_form = $pm_type->billing_form();
584
+		if ($billing_form instanceof EE_Form_Section_Proper) {
585
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
586
+		}
587
+		return $billing_form;
588
+	}
589
+
590
+
591
+	/**
592
+	 * Gets the postmeta key that holds this attendee's billing info for the
593
+	 * specified payment method
594
+	 *
595
+	 * @param EE_Payment_Method $payment_method
596
+	 * @return string
597
+	 */
598
+	public function get_billing_info_postmeta_name($payment_method)
599
+	{
600
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
601
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
602
+		} else {
603
+			return null;
604
+		}
605
+	}
606
+
607
+
608
+	/**
609
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
610
+	 * retrieve it
611
+	 *
612
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
613
+	 * @param EE_Payment_Method             $payment_method
614
+	 * @return boolean
615
+	 */
616
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
617
+	{
618
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
619
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
620
+			return false;
621
+		}
622
+		$billing_form->clean_sensitive_data();
623
+		return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
624
+			$billing_form->input_values(true));
625
+	}
626
+
627
+
628
+	/**
629
+	 * Return the link to the admin details for the object.
630
+	 *
631
+	 * @return string
632
+	 */
633
+	public function get_admin_details_link()
634
+	{
635
+		return $this->get_admin_edit_link();
636
+	}
637
+
638
+
639
+	/**
640
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
641
+	 *
642
+	 * @return string
643
+	 */
644
+	public function get_admin_edit_link()
645
+	{
646
+		EE_Registry::instance()->load_helper('URL');
647
+		return EEH_URL::add_query_args_and_nonce(
648
+			array(
649
+				'page'   => 'espresso_registrations',
650
+				'action' => 'edit_attendee',
651
+				'post'   => $this->ID(),
652
+			),
653
+			admin_url('admin.php')
654
+		);
655
+	}
656
+
657
+
658
+	/**
659
+	 * Returns the link to a settings page for the object.
660
+	 *
661
+	 * @return string
662
+	 */
663
+	public function get_admin_settings_link()
664
+	{
665
+		return $this->get_admin_edit_link();
666
+	}
667
+
668
+
669
+	/**
670
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
671
+	 *
672
+	 * @return string
673
+	 */
674
+	public function get_admin_overview_link()
675
+	{
676
+		EE_Registry::instance()->load_helper('URL');
677
+		return EEH_URL::add_query_args_and_nonce(
678
+			array(
679
+				'page'   => 'espresso_registrations',
680
+				'action' => 'contact_list',
681
+			),
682
+			admin_url('admin.php')
683
+		);
684
+	}
685 685
 
686 686
 
687 687
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +840 added lines, -840 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -26,869 +26,869 @@  discard block
 block discarded – undo
26 26
 
27 27
 
28 28
 
29
-    private $_status;
30
-
31
-
32
-
33
-    /**
34
-     * An array of transaction details for the related transaction to the registration being processed.
35
-     * This is set via the _set_related_details method.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_transaction_details = array();
40
-
41
-
42
-
43
-    /**
44
-     * An array of event details for the related event to the registration being processed.
45
-     * This is set via the _set_related_details method.
46
-     *
47
-     * @var array
48
-     */
49
-    protected $_event_details = array();
50
-
51
-
52
-
53
-    /**
54
-     * @param \Registrations_Admin_Page $admin_page
55
-     */
56
-    public function __construct(Registrations_Admin_Page $admin_page)
57
-    {
58
-        if ( ! empty($_GET['event_id'])) {
59
-            $extra_query_args = array();
60
-            foreach ($admin_page->get_views() as $key => $view_details) {
61
-                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
-            }
63
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
-        }
65
-        parent::__construct($admin_page);
66
-        $this->_status = $this->_admin_page->get_registration_status_array();
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     *    _setup_data
73
-     *
74
-     * @access protected
75
-     * @return void
76
-     */
77
-    protected function _setup_data()
78
-    {
79
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     *    _set_properties
87
-     *
88
-     * @access protected
89
-     * @return void
90
-     */
91
-    protected function _set_properties()
92
-    {
93
-        $this->_wp_list_args = array(
94
-            'singular' => __('registration', 'event_espresso'),
95
-            'plural'   => __('registrations', 'event_espresso'),
96
-            'ajax'     => true,
97
-            'screen'   => $this->_admin_page->get_current_screen()->id,
98
-        );
99
-        $ID_column_name = __('ID', 'event_espresso');
100
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
102
-        $ID_column_name .= '</span> ';
103
-        if (isset($_GET['event_id'])) {
104
-            $this->_columns = array(
105
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
-                '_REG_ID'          => $ID_column_name,
107
-                'ATT_fname'        => __('Name', 'event_espresso'),
108
-                'ATT_email'        => __('Email', 'event_espresso'),
109
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
110
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
112
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
113
-                'TXN_paid'         => __('Paid', 'event_espresso'),
114
-                'actions'          => __('Actions', 'event_espresso'),
115
-            );
116
-            $this->_bottom_buttons = array(
117
-                'report' => array(
118
-                    'route'         => 'registrations_report',
119
-                    'extra_request' => array(
120
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
-                    ),
123
-                ),
124
-            );
125
-        } else {
126
-            $this->_columns = array(
127
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
-                '_REG_ID'          => $ID_column_name,
129
-                'ATT_fname'        => __('Name', 'event_espresso'),
130
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
131
-                'event_name'       => __('Event', 'event_espresso'),
132
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
-                '_REG_final_price' => __('Price', 'event_espresso'),
134
-                '_REG_paid'        => __('Paid', 'event_espresso'),
135
-                'actions'          => __('Actions', 'event_espresso'),
136
-            );
137
-            $this->_bottom_buttons = array(
138
-                'report_all' => array(
139
-                    'route'         => 'registrations_report',
140
-                    'extra_request' => array(
141
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
-                    ),
143
-                ),
144
-            );
145
-        }
146
-        $this->_bottom_buttons['report_filtered'] = array(
147
-            'route'         => 'registrations_report',
148
-            'extra_request' => array(
149
-                'use_filters' => true,
150
-                'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
-                            'page',
152
-                            'action',
153
-                            'default_nonce',
154
-                        ))),
155
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
-            ),
157
-        );
158
-        $this->_primary_column = '_REG_ID';
159
-        $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
-            /**
162
-             * Allows users to change the default sort if they wish.
163
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
164
-             */
165
-            'ATT_fname'     => array(
166
-                    'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
167
-                    true,
168
-                    $this
169
-                )
170
-                ? array('ATT_lname' => false)
171
-                : array('ATT_fname' => false),
172
-            'event_name'    => array('event_name' => false),
173
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
174
-            '_REG_ID'       => array('_REG_ID' => false),
175
-        );
176
-        $this->_hidden_columns = array();
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * This simply sets up the row class for the table rows.
183
-     * Allows for easier overriding of child methods for setting up sorting.
184
-     *
185
-     * @param  EE_Registration $item the current item
186
-     * @return string
187
-     */
188
-    protected function _get_row_class($item)
189
-    {
190
-        $class = parent::_get_row_class($item);
191
-        //add status class
192
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
193
-        if ($this->_has_checkbox_column) {
194
-            $class .= ' has-checkbox-column';
195
-        }
196
-        return $class;
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * Set the $_transaction_details property if not set yet.
203
-     *
204
-     * @param EE_Registration $registration
205
-     * @throws \EE_Error
206
-     */
207
-    protected function _set_related_details(EE_Registration $registration)
208
-    {
209
-        $transaction = $registration->get_first_related('Transaction');
210
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
211
-            : EEM_Transaction::failed_status_code;
212
-        $this->_transaction_details = array(
213
-            'transaction' => $transaction,
214
-            'status'      => $status,
215
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
216
-            'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
217
-                EEH_Template::pretty_status($status, false, 'sentence')),
218
-        );
219
-        try {
220
-            $event = $registration->event();
221
-        } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
222
-            $event = null;
223
-        }
224
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
225
-        $this->_event_details = array(
226
-            'event'      => $event,
227
-            'status'     => $status,
228
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
229
-            'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
230
-                EEH_Template::pretty_status($status, false, 'sentence')),
231
-        );
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     *    _get_table_filters
238
-     *
239
-     * @access protected
240
-     * @return array
241
-     */
242
-    protected function _get_table_filters()
243
-    {
244
-        $filters = array();
245
-        //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
246
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
247
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
248
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
249
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
250
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
251
-        $status = array();
252
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
253
-        foreach ($this->_status as $key => $value) {
254
-            $status[] = array('id' => $key, 'text' => $value);
255
-        }
256
-        if ($this->_view !== 'incomplete') {
257
-            $filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
258
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
259
-                    : '');
260
-        }
261
-        if (isset($this->_req_data['event_id'])) {
262
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
263
-        }
264
-        return $filters;
265
-    }
266
-
267
-
268
-
269
-    /**
270
-     *    _add_view_counts
271
-     *
272
-     * @access protected
273
-     * @return void
274
-     * @throws \EE_Error
275
-     */
276
-    protected function _add_view_counts()
277
-    {
278
-        $this->_views['all']['count'] = $this->_total_registrations();
279
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
280
-        $this->_views['today']['count'] = $this->_total_registrations_today();
281
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
282
-            'espresso_registrations_trash_registrations')
283
-        ) {
284
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
285
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
286
-        }
287
-    }
288
-
289
-
290
-
291
-    /**
292
-     * _total_registrations
293
-     *
294
-     * @access protected
295
-     * @param string $view
296
-     * @return int
297
-     * @throws \EE_Error
298
-     */
299
-    protected function _total_registrations($view = '')
300
-    {
301
-        $_where = array();
302
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
303
-        if ($EVT_ID) {
304
-            $_where['EVT_ID'] = $EVT_ID;
305
-        }
306
-        switch ($view) {
307
-            case 'trash' :
308
-                return EEM_Registration::instance()->count_deleted(array($_where));
309
-                break;
310
-            case 'incomplete' :
311
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
312
-                break;
313
-            default :
314
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
315
-        }
316
-        return EEM_Registration::instance()->count(array($_where));
317
-    }
318
-
319
-
320
-
321
-    /**
322
-     * _total_registrations_this_month
323
-     *
324
-     * @access protected
325
-     * @return int
326
-     * @throws \EE_Error
327
-     */
328
-    protected function _total_registrations_this_month()
329
-    {
330
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
331
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
332
-        $this_year_r = date('Y', current_time('timestamp'));
333
-        $time_start = ' 00:00:00';
334
-        $time_end = ' 23:59:59';
335
-        $this_month_r = date('m', current_time('timestamp'));
336
-        $days_this_month = date('t', current_time('timestamp'));
337
-        //setup date query.
338
-        $beginning_string = EEM_Registration::instance()
339
-                                            ->convert_datetime_for_query('REG_date',
340
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
341
-                                                'Y-m-d H:i:s');
342
-        $end_string = EEM_Registration::instance()
343
-                                      ->convert_datetime_for_query('REG_date',
344
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
345
-                                          'Y-m-d H:i:s');
346
-        $_where['REG_date'] = array(
347
-            'BETWEEN',
348
-            array(
349
-                $beginning_string,
350
-                $end_string,
351
-            ),
352
-        );
353
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
354
-        return EEM_Registration::instance()->count(array($_where));
355
-    }
356
-
357
-
358
-
359
-    /**
360
-     * _total_registrations_today
361
-     *
362
-     * @access protected
363
-     * @return int
364
-     * @throws \EE_Error
365
-     */
366
-    protected function _total_registrations_today()
367
-    {
368
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
369
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
370
-        $current_date = date('Y-m-d', current_time('timestamp'));
371
-        $time_start = ' 00:00:00';
372
-        $time_end = ' 23:59:59';
373
-        $_where['REG_date'] = array(
374
-            'BETWEEN',
375
-            array(
376
-                EEM_Registration::instance()
377
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
378
-                EEM_Registration::instance()
379
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
380
-            ),
381
-        );
382
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
383
-        return EEM_Registration::instance()->count(array($_where));
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * column_cb
390
-     *
391
-     * @access public
392
-     * @param \EE_Registration $item
393
-     * @return string
394
-     * @throws \EE_Error
395
-     */
396
-    public function column_cb($item)
397
-    {
398
-        /** checkbox/lock **/
399
-        $transaction = $item->get_first_related('Transaction');
400
-        $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
401
-        return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
402
-                                    . '<span class="ee-lock-icon"></span>'
403
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * column__REG_ID
410
-     *
411
-     * @access public
412
-     * @param \EE_Registration $item
413
-     * @return string
414
-     * @throws \EE_Error
415
-     */
416
-    public function column__REG_ID(EE_Registration $item)
417
-    {
418
-        $attendee = $item->attendee();
419
-        $content = $item->ID();
420
-        $content .= '<div class="show-on-mobile-view-only">';
421
-        $content .= '<br>';
422
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
423
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
425
-        $content .= '</div>';
426
-        return $content;
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * column__REG_date
433
-     *
434
-     * @access public
435
-     * @param \EE_Registration $item
436
-     * @return string
437
-     * @throws \EE_Error
438
-     */
439
-    public function column__REG_date(EE_Registration $item)
440
-    {
441
-        $this->_set_related_details($item);
442
-        //Build row actions
443
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
444
-            'action' => 'view_transaction',
445
-            'TXN_ID' => $this->_transaction_details['id'],
446
-        ), TXN_ADMIN_URL);
447
-        $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
448
-            'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
449
-                                                        . $this->_transaction_details['status']
450
-                                                        . '" href="'
451
-                                                        . $view_lnk_url
452
-                                                        . '" title="'
453
-                                                        . esc_attr($this->_transaction_details['title_attr'])
454
-                                                        . '">'
455
-                                                        . $item->get_i18n_datetime('REG_date')
456
-                                                        . '</a>' : $item->get_i18n_datetime('REG_date');
457
-        $view_link .= '<br><span class="ee-status-text-small">'
458
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
459
-                      . '</span>';
460
-        return $view_link;
461
-    }
462
-
463
-
464
-
465
-    /**
466
-     * column_event_name
467
-     *
468
-     * @access public
469
-     * @param \EE_Registration $item
470
-     * @return string
471
-     * @throws \EE_Error
472
-     */
473
-    public function column_event_name(EE_Registration $item)
474
-    {
475
-        $this->_set_related_details($item);
476
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
477
-        $EVT_ID = $item->event_ID();
478
-        $event_name = $item->event_name();
479
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
480
-        $event_name = wp_trim_words($event_name, 30, '...');
481
-        if ($EVT_ID) {
482
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
483
-                EVENTS_ADMIN_URL);
484
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
485
-                ? '<a class="ee-status-color-'
486
-                  . $this->_event_details['status']
487
-                  . '" href="'
488
-                  . $edit_event_url
489
-                  . '" title="'
490
-                  . esc_attr($this->_event_details['title_attr'])
491
-                  . '">'
492
-                  . $event_name
493
-                  . '</a>' : $event_name;
494
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
495
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
496
-            $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
497
-                'event_espresso'), $event_name);
498
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
499
-        } else {
500
-            $edit_event = $event_name;
501
-            $actions['event_filter'] = '';
502
-        }
503
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
504
-    }
505
-
506
-
507
-
508
-    /**
509
-     * column_DTT_EVT_start
510
-     *
511
-     * @access public
512
-     * @param \EE_Registration $item
513
-     * @return string
514
-     * @throws \EE_Error
515
-     */
516
-    public function column_DTT_EVT_start(EE_Registration $item)
517
-    {
518
-        $datetime_strings = array();
519
-        $ticket = $item->ticket(true);
520
-        if ($ticket instanceof EE_Ticket) {
521
-            $remove_defaults = array('default_where_conditions' => 'none');
522
-            $datetimes = $ticket->datetimes($remove_defaults);
523
-            foreach ($datetimes as $datetime) {
524
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
525
-            }
526
-            return implode("<br />", $datetime_strings);
527
-        } else {
528
-            return __('There is no ticket on this registration', 'event_espresso');
529
-        }
530
-    }
531
-
532
-
533
-
534
-    /**
535
-     * column_ATT_fname
536
-     *
537
-     * @access public
538
-     * @param \EE_Registration $item
539
-     * @return string
540
-     * @throws \EE_Error
541
-     */
542
-    public function column_ATT_fname(EE_Registration $item)
543
-    {
544
-        $attendee = $item->attendee();
545
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
546
-            'action'  => 'view_registration',
547
-            '_REG_ID' => $item->ID(),
548
-        ), REG_ADMIN_URL);
549
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
550
-        $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
551
-            'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
552
-                                                                       . $edit_lnk_url
553
-                                                                       . '" title="'
554
-                                                                       . esc_attr__('View Registration Details',
555
-                'event_espresso')
556
-                                                                       . '">'
557
-                                                                       . $attendee_name
558
-                                                                       . '</a>' : $attendee_name;
559
-        $link .= $item->count() === 1
560
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
561
-        $t = $item->get_first_related('Transaction');
562
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
563
-        //append group count to name
564
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
565
-        //append reg_code
566
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
567
-        //reg status text for accessibility
568
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
569
-                'sentence') . '</span>';
570
-        //trash/restore/delete actions
571
-        $actions = array();
572
-        if ($this->_view !== 'trash'
573
-            && $payment_count === 0
574
-            && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
575
-                'espresso_registrations_trash_registrations', $item->ID())
576
-        ) {
577
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
578
-                'action'  => 'trash_registrations',
579
-                '_REG_ID' => $item->ID(),
580
-            ), REG_ADMIN_URL);
581
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
582
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
583
-        } elseif ($this->_view === 'trash') {
584
-            // restore registration link
585
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586
-                'espresso_registrations_restore_registrations', $item->ID())
587
-            ) {
588
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
589
-                    'action'  => 'restore_registrations',
590
-                    '_REG_ID' => $item->ID(),
591
-                ), REG_ADMIN_URL);
592
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
593
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
594
-            }
595
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
596
-                'espresso_registrations_ee_delete_registrations', $item->ID())
597
-            ) {
598
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
599
-                    'action'  => 'delete_registrations',
600
-                    '_REG_ID' => $item->ID(),
601
-                ), REG_ADMIN_URL);
602
-                $actions['delete'] = '<a href="'
603
-                                     . $delete_lnk_url
604
-                                     . '" title="'
605
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
606
-                                     . '">'
607
-                                     . __('Delete', 'event_espresso')
608
-                                     . '</a>';
609
-            }
610
-        }
611
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
612
-    }
613
-
614
-
615
-
616
-    /**
617
-     * column_ATT_email
618
-     *
619
-     * @access public
620
-     * @param \EE_Registration $item
621
-     * @return string
622
-     * @throws \EE_Error
623
-     */
624
-    public function column_ATT_email(EE_Registration $item)
625
-    {
626
-        $attendee = $item->get_first_related('Attendee');
627
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
628
-            : $attendee->email();
629
-    }
630
-
631
-
632
-
633
-    /**
634
-     * column__REG_count
635
-     *
636
-     * @access public
637
-     * @param \EE_Registration $item
638
-     * @return string
639
-     */
640
-    public function column__REG_count(EE_Registration $item)
641
-    {
642
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
643
-    }
644
-
645
-
646
-
647
-    /**
648
-     * column_PRC_amount
649
-     *
650
-     * @access public
651
-     * @param \EE_Registration $item
652
-     * @return string
653
-     */
654
-    public function column_PRC_amount(EE_Registration $item)
655
-    {
656
-        $ticket = $item->ticket();
657
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
658
-                                                                              . $ticket->name()
659
-                                                                              . '</span><br />' : '';
660
-        if ($item->final_price() > 0) {
661
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
662
-        } else {
663
-            // free event
664
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
665
-                        . __('free', 'event_espresso')
666
-                        . '</span>';
667
-        }
668
-        return $content;
669
-    }
670
-
671
-
672
-
673
-    /**
674
-     * column__REG_final_price
675
-     *
676
-     * @access public
677
-     * @param \EE_Registration $item
678
-     * @return string
679
-     */
680
-    public function column__REG_final_price(EE_Registration $item)
681
-    {
682
-        $ticket = $item->ticket();
683
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
684
-            ? ''
685
-            : '<span class="TKT_name">'
686
-              . $ticket->name()
687
-              . '</span><br />';
688
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
689
-        return $content;
690
-    }
691
-
692
-
693
-
694
-    /**
695
-     * column__REG_paid
696
-     *
697
-     * @access public
698
-     * @param \EE_Registration $item
699
-     * @return string
700
-     */
701
-    public function column__REG_paid(EE_Registration $item)
702
-    {
703
-        $payment_method = $item->payment_method();
704
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
705
-            : __('Unknown', 'event_espresso');
706
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
707
-        if ($item->paid() > 0) {
708
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
709
-                    $payment_method_name) . '</span>';
710
-        }
711
-        return $content;
712
-    }
713
-
714
-
715
-
716
-    /**
717
-     * column_TXN_total
718
-     *
719
-     * @access public
720
-     * @param \EE_Registration $item
721
-     * @return string
722
-     * @throws \EE_Error
723
-     */
724
-    public function column_TXN_total(EE_Registration $item)
725
-    {
726
-        if ($item->transaction()) {
727
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
728
-                'action' => 'view_transaction',
729
-                'TXN_ID' => $item->transaction_ID(),
730
-            ), TXN_ADMIN_URL);
731
-            return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
732
-                'espresso_transactions_view_transaction', $item->transaction_ID())
733
-                ? '<span class="reg-pad-rght"><a class="status-'
734
-                  . $item->transaction()->status_ID()
735
-                  . '" href="'
736
-                  . $view_txn_lnk_url
737
-                  . '"  title="'
738
-                  . esc_attr__('View Transaction', 'event_espresso')
739
-                  . '">'
740
-                  . $item->transaction()->pretty_total()
741
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
742
-        } else {
743
-            return __("None", "event_espresso");
744
-        }
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     * column_TXN_paid
751
-     *
752
-     * @access public
753
-     * @param \EE_Registration $item
754
-     * @return string
755
-     * @throws \EE_Error
756
-     */
757
-    public function column_TXN_paid(EE_Registration $item)
758
-    {
759
-        if ($item->count() === 1) {
760
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
761
-            if ($transaction->paid() >= $transaction->total()) {
762
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
763
-            } else {
764
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
765
-                    'action' => 'view_transaction',
766
-                    'TXN_ID' => $item->transaction_ID(),
767
-                ), TXN_ADMIN_URL);
768
-                return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
769
-                    'espresso_transactions_view_transaction', $item->transaction_ID())
770
-                    ? '<span class="reg-pad-rght"><a class="status-'
771
-                      . $transaction->status_ID()
772
-                      . '" href="'
773
-                      . $view_txn_lnk_url
774
-                      . '"  title="'
775
-                      . esc_attr__('View Transaction', 'event_espresso')
776
-                      . '">'
777
-                      . $item->transaction()->pretty_paid()
778
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
779
-            }
780
-        }
781
-        return '&nbsp;';
782
-    }
783
-
784
-
785
-
786
-    /**
787
-     * column_actions
788
-     *
789
-     * @access public
790
-     * @param \EE_Registration $item
791
-     * @return string
792
-     * @throws \EE_Error
793
-     */
794
-    public function column_actions(EE_Registration $item)
795
-    {
796
-        $actions = array();
797
-        $attendee = $item->attendee();
798
-        $this->_set_related_details($item);
799
-        //Build row actions
800
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
801
-            'action'  => 'view_registration',
802
-            '_REG_ID' => $item->ID(),
803
-        ), REG_ADMIN_URL);
804
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
805
-            'action' => 'edit_attendee',
806
-            'post'   => $item->attendee_ID(),
807
-        ), REG_ADMIN_URL);
808
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
809
-        //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
810
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
811
-            'action'  => 'resend_registration',
812
-            '_REG_ID' => $item->ID(),
813
-        ), REG_ADMIN_URL, true);
814
-        //Build row actions
815
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
816
-            'espresso_registrations_view_registration', $item->ID()) ? '
29
+	private $_status;
30
+
31
+
32
+
33
+	/**
34
+	 * An array of transaction details for the related transaction to the registration being processed.
35
+	 * This is set via the _set_related_details method.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_transaction_details = array();
40
+
41
+
42
+
43
+	/**
44
+	 * An array of event details for the related event to the registration being processed.
45
+	 * This is set via the _set_related_details method.
46
+	 *
47
+	 * @var array
48
+	 */
49
+	protected $_event_details = array();
50
+
51
+
52
+
53
+	/**
54
+	 * @param \Registrations_Admin_Page $admin_page
55
+	 */
56
+	public function __construct(Registrations_Admin_Page $admin_page)
57
+	{
58
+		if ( ! empty($_GET['event_id'])) {
59
+			$extra_query_args = array();
60
+			foreach ($admin_page->get_views() as $key => $view_details) {
61
+				$extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
+			}
63
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
+		}
65
+		parent::__construct($admin_page);
66
+		$this->_status = $this->_admin_page->get_registration_status_array();
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 *    _setup_data
73
+	 *
74
+	 * @access protected
75
+	 * @return void
76
+	 */
77
+	protected function _setup_data()
78
+	{
79
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 *    _set_properties
87
+	 *
88
+	 * @access protected
89
+	 * @return void
90
+	 */
91
+	protected function _set_properties()
92
+	{
93
+		$this->_wp_list_args = array(
94
+			'singular' => __('registration', 'event_espresso'),
95
+			'plural'   => __('registrations', 'event_espresso'),
96
+			'ajax'     => true,
97
+			'screen'   => $this->_admin_page->get_current_screen()->id,
98
+		);
99
+		$ID_column_name = __('ID', 'event_espresso');
100
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
102
+		$ID_column_name .= '</span> ';
103
+		if (isset($_GET['event_id'])) {
104
+			$this->_columns = array(
105
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
+				'_REG_ID'          => $ID_column_name,
107
+				'ATT_fname'        => __('Name', 'event_espresso'),
108
+				'ATT_email'        => __('Email', 'event_espresso'),
109
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
110
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
112
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
113
+				'TXN_paid'         => __('Paid', 'event_espresso'),
114
+				'actions'          => __('Actions', 'event_espresso'),
115
+			);
116
+			$this->_bottom_buttons = array(
117
+				'report' => array(
118
+					'route'         => 'registrations_report',
119
+					'extra_request' => array(
120
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
+					),
123
+				),
124
+			);
125
+		} else {
126
+			$this->_columns = array(
127
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
+				'_REG_ID'          => $ID_column_name,
129
+				'ATT_fname'        => __('Name', 'event_espresso'),
130
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
131
+				'event_name'       => __('Event', 'event_espresso'),
132
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
+				'_REG_final_price' => __('Price', 'event_espresso'),
134
+				'_REG_paid'        => __('Paid', 'event_espresso'),
135
+				'actions'          => __('Actions', 'event_espresso'),
136
+			);
137
+			$this->_bottom_buttons = array(
138
+				'report_all' => array(
139
+					'route'         => 'registrations_report',
140
+					'extra_request' => array(
141
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
+					),
143
+				),
144
+			);
145
+		}
146
+		$this->_bottom_buttons['report_filtered'] = array(
147
+			'route'         => 'registrations_report',
148
+			'extra_request' => array(
149
+				'use_filters' => true,
150
+				'filters'     => array_diff_key($this->_req_data, array_flip(array(
151
+							'page',
152
+							'action',
153
+							'default_nonce',
154
+						))),
155
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
156
+			),
157
+		);
158
+		$this->_primary_column = '_REG_ID';
159
+		$this->_sortable_columns = array(
160
+			'_REG_date'     => array('_REG_date' => true),   //true means its already sorted
161
+			/**
162
+			 * Allows users to change the default sort if they wish.
163
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
164
+			 */
165
+			'ATT_fname'     => array(
166
+					'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
167
+					true,
168
+					$this
169
+				)
170
+				? array('ATT_lname' => false)
171
+				: array('ATT_fname' => false),
172
+			'event_name'    => array('event_name' => false),
173
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
174
+			'_REG_ID'       => array('_REG_ID' => false),
175
+		);
176
+		$this->_hidden_columns = array();
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * This simply sets up the row class for the table rows.
183
+	 * Allows for easier overriding of child methods for setting up sorting.
184
+	 *
185
+	 * @param  EE_Registration $item the current item
186
+	 * @return string
187
+	 */
188
+	protected function _get_row_class($item)
189
+	{
190
+		$class = parent::_get_row_class($item);
191
+		//add status class
192
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
193
+		if ($this->_has_checkbox_column) {
194
+			$class .= ' has-checkbox-column';
195
+		}
196
+		return $class;
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * Set the $_transaction_details property if not set yet.
203
+	 *
204
+	 * @param EE_Registration $registration
205
+	 * @throws \EE_Error
206
+	 */
207
+	protected function _set_related_details(EE_Registration $registration)
208
+	{
209
+		$transaction = $registration->get_first_related('Transaction');
210
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
211
+			: EEM_Transaction::failed_status_code;
212
+		$this->_transaction_details = array(
213
+			'transaction' => $transaction,
214
+			'status'      => $status,
215
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
216
+			'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
217
+				EEH_Template::pretty_status($status, false, 'sentence')),
218
+		);
219
+		try {
220
+			$event = $registration->event();
221
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
222
+			$event = null;
223
+		}
224
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
225
+		$this->_event_details = array(
226
+			'event'      => $event,
227
+			'status'     => $status,
228
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
229
+			'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
230
+				EEH_Template::pretty_status($status, false, 'sentence')),
231
+		);
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 *    _get_table_filters
238
+	 *
239
+	 * @access protected
240
+	 * @return array
241
+	 */
242
+	protected function _get_table_filters()
243
+	{
244
+		$filters = array();
245
+		//todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
246
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
247
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
248
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
249
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
250
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
251
+		$status = array();
252
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
253
+		foreach ($this->_status as $key => $value) {
254
+			$status[] = array('id' => $key, 'text' => $value);
255
+		}
256
+		if ($this->_view !== 'incomplete') {
257
+			$filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
258
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
259
+					: '');
260
+		}
261
+		if (isset($this->_req_data['event_id'])) {
262
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
263
+		}
264
+		return $filters;
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 *    _add_view_counts
271
+	 *
272
+	 * @access protected
273
+	 * @return void
274
+	 * @throws \EE_Error
275
+	 */
276
+	protected function _add_view_counts()
277
+	{
278
+		$this->_views['all']['count'] = $this->_total_registrations();
279
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
280
+		$this->_views['today']['count'] = $this->_total_registrations_today();
281
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
282
+			'espresso_registrations_trash_registrations')
283
+		) {
284
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
285
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
286
+		}
287
+	}
288
+
289
+
290
+
291
+	/**
292
+	 * _total_registrations
293
+	 *
294
+	 * @access protected
295
+	 * @param string $view
296
+	 * @return int
297
+	 * @throws \EE_Error
298
+	 */
299
+	protected function _total_registrations($view = '')
300
+	{
301
+		$_where = array();
302
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
303
+		if ($EVT_ID) {
304
+			$_where['EVT_ID'] = $EVT_ID;
305
+		}
306
+		switch ($view) {
307
+			case 'trash' :
308
+				return EEM_Registration::instance()->count_deleted(array($_where));
309
+				break;
310
+			case 'incomplete' :
311
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
312
+				break;
313
+			default :
314
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
315
+		}
316
+		return EEM_Registration::instance()->count(array($_where));
317
+	}
318
+
319
+
320
+
321
+	/**
322
+	 * _total_registrations_this_month
323
+	 *
324
+	 * @access protected
325
+	 * @return int
326
+	 * @throws \EE_Error
327
+	 */
328
+	protected function _total_registrations_this_month()
329
+	{
330
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
331
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
332
+		$this_year_r = date('Y', current_time('timestamp'));
333
+		$time_start = ' 00:00:00';
334
+		$time_end = ' 23:59:59';
335
+		$this_month_r = date('m', current_time('timestamp'));
336
+		$days_this_month = date('t', current_time('timestamp'));
337
+		//setup date query.
338
+		$beginning_string = EEM_Registration::instance()
339
+											->convert_datetime_for_query('REG_date',
340
+												$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
341
+												'Y-m-d H:i:s');
342
+		$end_string = EEM_Registration::instance()
343
+									  ->convert_datetime_for_query('REG_date',
344
+										  $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
345
+										  'Y-m-d H:i:s');
346
+		$_where['REG_date'] = array(
347
+			'BETWEEN',
348
+			array(
349
+				$beginning_string,
350
+				$end_string,
351
+			),
352
+		);
353
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
354
+		return EEM_Registration::instance()->count(array($_where));
355
+	}
356
+
357
+
358
+
359
+	/**
360
+	 * _total_registrations_today
361
+	 *
362
+	 * @access protected
363
+	 * @return int
364
+	 * @throws \EE_Error
365
+	 */
366
+	protected function _total_registrations_today()
367
+	{
368
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
369
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
370
+		$current_date = date('Y-m-d', current_time('timestamp'));
371
+		$time_start = ' 00:00:00';
372
+		$time_end = ' 23:59:59';
373
+		$_where['REG_date'] = array(
374
+			'BETWEEN',
375
+			array(
376
+				EEM_Registration::instance()
377
+								->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
378
+				EEM_Registration::instance()
379
+								->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
380
+			),
381
+		);
382
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
383
+		return EEM_Registration::instance()->count(array($_where));
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * column_cb
390
+	 *
391
+	 * @access public
392
+	 * @param \EE_Registration $item
393
+	 * @return string
394
+	 * @throws \EE_Error
395
+	 */
396
+	public function column_cb($item)
397
+	{
398
+		/** checkbox/lock **/
399
+		$transaction = $item->get_first_related('Transaction');
400
+		$payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
401
+		return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
402
+									. '<span class="ee-lock-icon"></span>'
403
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * column__REG_ID
410
+	 *
411
+	 * @access public
412
+	 * @param \EE_Registration $item
413
+	 * @return string
414
+	 * @throws \EE_Error
415
+	 */
416
+	public function column__REG_ID(EE_Registration $item)
417
+	{
418
+		$attendee = $item->attendee();
419
+		$content = $item->ID();
420
+		$content .= '<div class="show-on-mobile-view-only">';
421
+		$content .= '<br>';
422
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
423
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
425
+		$content .= '</div>';
426
+		return $content;
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * column__REG_date
433
+	 *
434
+	 * @access public
435
+	 * @param \EE_Registration $item
436
+	 * @return string
437
+	 * @throws \EE_Error
438
+	 */
439
+	public function column__REG_date(EE_Registration $item)
440
+	{
441
+		$this->_set_related_details($item);
442
+		//Build row actions
443
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
444
+			'action' => 'view_transaction',
445
+			'TXN_ID' => $this->_transaction_details['id'],
446
+		), TXN_ADMIN_URL);
447
+		$view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
448
+			'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
449
+														. $this->_transaction_details['status']
450
+														. '" href="'
451
+														. $view_lnk_url
452
+														. '" title="'
453
+														. esc_attr($this->_transaction_details['title_attr'])
454
+														. '">'
455
+														. $item->get_i18n_datetime('REG_date')
456
+														. '</a>' : $item->get_i18n_datetime('REG_date');
457
+		$view_link .= '<br><span class="ee-status-text-small">'
458
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
459
+					  . '</span>';
460
+		return $view_link;
461
+	}
462
+
463
+
464
+
465
+	/**
466
+	 * column_event_name
467
+	 *
468
+	 * @access public
469
+	 * @param \EE_Registration $item
470
+	 * @return string
471
+	 * @throws \EE_Error
472
+	 */
473
+	public function column_event_name(EE_Registration $item)
474
+	{
475
+		$this->_set_related_details($item);
476
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
477
+		$EVT_ID = $item->event_ID();
478
+		$event_name = $item->event_name();
479
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
480
+		$event_name = wp_trim_words($event_name, 30, '...');
481
+		if ($EVT_ID) {
482
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
483
+				EVENTS_ADMIN_URL);
484
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
485
+				? '<a class="ee-status-color-'
486
+				  . $this->_event_details['status']
487
+				  . '" href="'
488
+				  . $edit_event_url
489
+				  . '" title="'
490
+				  . esc_attr($this->_event_details['title_attr'])
491
+				  . '">'
492
+				  . $event_name
493
+				  . '</a>' : $event_name;
494
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
495
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
496
+			$actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
497
+				'event_espresso'), $event_name);
498
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
499
+		} else {
500
+			$edit_event = $event_name;
501
+			$actions['event_filter'] = '';
502
+		}
503
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
504
+	}
505
+
506
+
507
+
508
+	/**
509
+	 * column_DTT_EVT_start
510
+	 *
511
+	 * @access public
512
+	 * @param \EE_Registration $item
513
+	 * @return string
514
+	 * @throws \EE_Error
515
+	 */
516
+	public function column_DTT_EVT_start(EE_Registration $item)
517
+	{
518
+		$datetime_strings = array();
519
+		$ticket = $item->ticket(true);
520
+		if ($ticket instanceof EE_Ticket) {
521
+			$remove_defaults = array('default_where_conditions' => 'none');
522
+			$datetimes = $ticket->datetimes($remove_defaults);
523
+			foreach ($datetimes as $datetime) {
524
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
525
+			}
526
+			return implode("<br />", $datetime_strings);
527
+		} else {
528
+			return __('There is no ticket on this registration', 'event_espresso');
529
+		}
530
+	}
531
+
532
+
533
+
534
+	/**
535
+	 * column_ATT_fname
536
+	 *
537
+	 * @access public
538
+	 * @param \EE_Registration $item
539
+	 * @return string
540
+	 * @throws \EE_Error
541
+	 */
542
+	public function column_ATT_fname(EE_Registration $item)
543
+	{
544
+		$attendee = $item->attendee();
545
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
546
+			'action'  => 'view_registration',
547
+			'_REG_ID' => $item->ID(),
548
+		), REG_ADMIN_URL);
549
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
550
+		$link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
551
+			'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
552
+																	   . $edit_lnk_url
553
+																	   . '" title="'
554
+																	   . esc_attr__('View Registration Details',
555
+				'event_espresso')
556
+																	   . '">'
557
+																	   . $attendee_name
558
+																	   . '</a>' : $attendee_name;
559
+		$link .= $item->count() === 1
560
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
561
+		$t = $item->get_first_related('Transaction');
562
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
563
+		//append group count to name
564
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
565
+		//append reg_code
566
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
567
+		//reg status text for accessibility
568
+		$link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
569
+				'sentence') . '</span>';
570
+		//trash/restore/delete actions
571
+		$actions = array();
572
+		if ($this->_view !== 'trash'
573
+			&& $payment_count === 0
574
+			&& EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
575
+				'espresso_registrations_trash_registrations', $item->ID())
576
+		) {
577
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
578
+				'action'  => 'trash_registrations',
579
+				'_REG_ID' => $item->ID(),
580
+			), REG_ADMIN_URL);
581
+			$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
582
+					'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
583
+		} elseif ($this->_view === 'trash') {
584
+			// restore registration link
585
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586
+				'espresso_registrations_restore_registrations', $item->ID())
587
+			) {
588
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
589
+					'action'  => 'restore_registrations',
590
+					'_REG_ID' => $item->ID(),
591
+				), REG_ADMIN_URL);
592
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
593
+						'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
594
+			}
595
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
596
+				'espresso_registrations_ee_delete_registrations', $item->ID())
597
+			) {
598
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
599
+					'action'  => 'delete_registrations',
600
+					'_REG_ID' => $item->ID(),
601
+				), REG_ADMIN_URL);
602
+				$actions['delete'] = '<a href="'
603
+									 . $delete_lnk_url
604
+									 . '" title="'
605
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
606
+									 . '">'
607
+									 . __('Delete', 'event_espresso')
608
+									 . '</a>';
609
+			}
610
+		}
611
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
612
+	}
613
+
614
+
615
+
616
+	/**
617
+	 * column_ATT_email
618
+	 *
619
+	 * @access public
620
+	 * @param \EE_Registration $item
621
+	 * @return string
622
+	 * @throws \EE_Error
623
+	 */
624
+	public function column_ATT_email(EE_Registration $item)
625
+	{
626
+		$attendee = $item->get_first_related('Attendee');
627
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
628
+			: $attendee->email();
629
+	}
630
+
631
+
632
+
633
+	/**
634
+	 * column__REG_count
635
+	 *
636
+	 * @access public
637
+	 * @param \EE_Registration $item
638
+	 * @return string
639
+	 */
640
+	public function column__REG_count(EE_Registration $item)
641
+	{
642
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
643
+	}
644
+
645
+
646
+
647
+	/**
648
+	 * column_PRC_amount
649
+	 *
650
+	 * @access public
651
+	 * @param \EE_Registration $item
652
+	 * @return string
653
+	 */
654
+	public function column_PRC_amount(EE_Registration $item)
655
+	{
656
+		$ticket = $item->ticket();
657
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
658
+																			  . $ticket->name()
659
+																			  . '</span><br />' : '';
660
+		if ($item->final_price() > 0) {
661
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
662
+		} else {
663
+			// free event
664
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
665
+						. __('free', 'event_espresso')
666
+						. '</span>';
667
+		}
668
+		return $content;
669
+	}
670
+
671
+
672
+
673
+	/**
674
+	 * column__REG_final_price
675
+	 *
676
+	 * @access public
677
+	 * @param \EE_Registration $item
678
+	 * @return string
679
+	 */
680
+	public function column__REG_final_price(EE_Registration $item)
681
+	{
682
+		$ticket = $item->ticket();
683
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
684
+			? ''
685
+			: '<span class="TKT_name">'
686
+			  . $ticket->name()
687
+			  . '</span><br />';
688
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
689
+		return $content;
690
+	}
691
+
692
+
693
+
694
+	/**
695
+	 * column__REG_paid
696
+	 *
697
+	 * @access public
698
+	 * @param \EE_Registration $item
699
+	 * @return string
700
+	 */
701
+	public function column__REG_paid(EE_Registration $item)
702
+	{
703
+		$payment_method = $item->payment_method();
704
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
705
+			: __('Unknown', 'event_espresso');
706
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
707
+		if ($item->paid() > 0) {
708
+			$content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
709
+					$payment_method_name) . '</span>';
710
+		}
711
+		return $content;
712
+	}
713
+
714
+
715
+
716
+	/**
717
+	 * column_TXN_total
718
+	 *
719
+	 * @access public
720
+	 * @param \EE_Registration $item
721
+	 * @return string
722
+	 * @throws \EE_Error
723
+	 */
724
+	public function column_TXN_total(EE_Registration $item)
725
+	{
726
+		if ($item->transaction()) {
727
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
728
+				'action' => 'view_transaction',
729
+				'TXN_ID' => $item->transaction_ID(),
730
+			), TXN_ADMIN_URL);
731
+			return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
732
+				'espresso_transactions_view_transaction', $item->transaction_ID())
733
+				? '<span class="reg-pad-rght"><a class="status-'
734
+				  . $item->transaction()->status_ID()
735
+				  . '" href="'
736
+				  . $view_txn_lnk_url
737
+				  . '"  title="'
738
+				  . esc_attr__('View Transaction', 'event_espresso')
739
+				  . '">'
740
+				  . $item->transaction()->pretty_total()
741
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
742
+		} else {
743
+			return __("None", "event_espresso");
744
+		}
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 * column_TXN_paid
751
+	 *
752
+	 * @access public
753
+	 * @param \EE_Registration $item
754
+	 * @return string
755
+	 * @throws \EE_Error
756
+	 */
757
+	public function column_TXN_paid(EE_Registration $item)
758
+	{
759
+		if ($item->count() === 1) {
760
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
761
+			if ($transaction->paid() >= $transaction->total()) {
762
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
763
+			} else {
764
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
765
+					'action' => 'view_transaction',
766
+					'TXN_ID' => $item->transaction_ID(),
767
+				), TXN_ADMIN_URL);
768
+				return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
769
+					'espresso_transactions_view_transaction', $item->transaction_ID())
770
+					? '<span class="reg-pad-rght"><a class="status-'
771
+					  . $transaction->status_ID()
772
+					  . '" href="'
773
+					  . $view_txn_lnk_url
774
+					  . '"  title="'
775
+					  . esc_attr__('View Transaction', 'event_espresso')
776
+					  . '">'
777
+					  . $item->transaction()->pretty_paid()
778
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
779
+			}
780
+		}
781
+		return '&nbsp;';
782
+	}
783
+
784
+
785
+
786
+	/**
787
+	 * column_actions
788
+	 *
789
+	 * @access public
790
+	 * @param \EE_Registration $item
791
+	 * @return string
792
+	 * @throws \EE_Error
793
+	 */
794
+	public function column_actions(EE_Registration $item)
795
+	{
796
+		$actions = array();
797
+		$attendee = $item->attendee();
798
+		$this->_set_related_details($item);
799
+		//Build row actions
800
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
801
+			'action'  => 'view_registration',
802
+			'_REG_ID' => $item->ID(),
803
+		), REG_ADMIN_URL);
804
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
805
+			'action' => 'edit_attendee',
806
+			'post'   => $item->attendee_ID(),
807
+		), REG_ADMIN_URL);
808
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
809
+		//$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
810
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
811
+			'action'  => 'resend_registration',
812
+			'_REG_ID' => $item->ID(),
813
+		), REG_ADMIN_URL, true);
814
+		//Build row actions
815
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
816
+			'espresso_registrations_view_registration', $item->ID()) ? '
817 817
 			<li>
818 818
 			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
819 819
 				<div class="dashicons dashicons-clipboard"></div>
820 820
 			</a>
821 821
 			</li>' : '';
822
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
823
-            'espresso_registrations_edit_attendee')
824
-                               && $attendee instanceof EE_Attendee ? '
822
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
823
+			'espresso_registrations_edit_attendee')
824
+							   && $attendee instanceof EE_Attendee ? '
825 825
 			<li>
826 826
 			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
827 827
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
828 828
 			</a>
829 829
 			</li>' : '';
830
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
831
-                                     && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
832
-            'espresso_registrations_resend_registration', $item->ID()) ? '
830
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
831
+									 && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
832
+			'espresso_registrations_resend_registration', $item->ID()) ? '
833 833
 			<li>
834 834
 			<a href="'
835
-                                                                         . $resend_reg_lnk_url
836
-                                                                         . '" title="'
837
-                                                                         . esc_attr__('Resend Registration Details',
838
-                'event_espresso')
839
-                                                                         . '" class="tiny-text">
835
+																		 . $resend_reg_lnk_url
836
+																		 . '" title="'
837
+																		 . esc_attr__('Resend Registration Details',
838
+				'event_espresso')
839
+																		 . '" class="tiny-text">
840 840
 				<div class="dashicons dashicons-email-alt"></div>
841 841
 			</a>
842 842
 			</li>' : '';
843
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
844
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
845
-            'action' => 'view_transaction',
846
-            'TXN_ID' => $this->_transaction_details['id'],
847
-        ), TXN_ADMIN_URL);
848
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
849
-            'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
843
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
844
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
845
+			'action' => 'view_transaction',
846
+			'TXN_ID' => $this->_transaction_details['id'],
847
+		), TXN_ADMIN_URL);
848
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
849
+			'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
850 850
 			<li>
851 851
 			<a class="ee-status-color-'
852
-                                                                                           . $this->_transaction_details['status']
853
-                                                                                           . ' tiny-text" href="'
854
-                                                                                           . $view_txn_lnk_url
855
-                                                                                           . '"  title="'
856
-                                                                                           . $this->_transaction_details['title_attr']
857
-                                                                                           . '">
852
+																						   . $this->_transaction_details['status']
853
+																						   . ' tiny-text" href="'
854
+																						   . $view_txn_lnk_url
855
+																						   . '"  title="'
856
+																						   . $this->_transaction_details['title_attr']
857
+																						   . '">
858 858
 				<div class="dashicons dashicons-cart"></div>
859 859
 			</a>
860 860
 			</li>' : '';
861
-        //invoice link
862
-        $actions['dl_invoice_lnk'] = '';
863
-        $dl_invoice_lnk_url = $item->invoice_url();
864
-        //only show invoice link if message type is active.
865
-        if ($attendee instanceof EE_Attendee
866
-            && $item->is_primary_registrant()
867
-            && EEH_MSG_Template::is_mt_active('invoice')
868
-        ) {
869
-            $actions['dl_invoice_lnk'] = '
861
+		//invoice link
862
+		$actions['dl_invoice_lnk'] = '';
863
+		$dl_invoice_lnk_url = $item->invoice_url();
864
+		//only show invoice link if message type is active.
865
+		if ($attendee instanceof EE_Attendee
866
+			&& $item->is_primary_registrant()
867
+			&& EEH_MSG_Template::is_mt_active('invoice')
868
+		) {
869
+			$actions['dl_invoice_lnk'] = '
870 870
 		<li>
871 871
 			<a title="'
872
-                                         . esc_attr__('View Transaction Invoice', 'event_espresso')
873
-                                         . '" target="_blank" href="'
874
-                                         . $dl_invoice_lnk_url
875
-                                         . '" class="tiny-text">
872
+										 . esc_attr__('View Transaction Invoice', 'event_espresso')
873
+										 . '" target="_blank" href="'
874
+										 . $dl_invoice_lnk_url
875
+										 . '" class="tiny-text">
876 876
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
877 877
 			</a>
878 878
 		</li>';
879
-        }
880
-        $actions['filtered_messages_link'] = '';
881
-        //message list table link (filtered by REG_ID
882
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
883
-            $actions['filtered_messages_link'] = '<li>'
884
-                                                 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
885
-                    null, array(
886
-                        '_REG_ID' => $item->ID(),
887
-                    ))
888
-                                                 . '</li>';
889
-        }
890
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
891
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
892
-    }
879
+		}
880
+		$actions['filtered_messages_link'] = '';
881
+		//message list table link (filtered by REG_ID
882
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
883
+			$actions['filtered_messages_link'] = '<li>'
884
+												 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
885
+					null, array(
886
+						'_REG_ID' => $item->ID(),
887
+					))
888
+												 . '</li>';
889
+		}
890
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
891
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
892
+	}
893 893
 
894 894
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         );
158 158
         $this->_primary_column = '_REG_ID';
159 159
         $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
160
+            '_REG_date'     => array('_REG_date' => true), //true means its already sorted
161 161
             /**
162 162
              * Allows users to change the default sort if they wish.
163 163
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     {
190 190
         $class = parent::_get_row_class($item);
191 191
         //add status class
192
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
192
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
193 193
         if ($this->_has_checkbox_column) {
194 194
             $class .= ' has-checkbox-column';
195 195
         }
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
         //setup date query.
338 338
         $beginning_string = EEM_Registration::instance()
339 339
                                             ->convert_datetime_for_query('REG_date',
340
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
340
+                                                $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
341 341
                                                 'Y-m-d H:i:s');
342 342
         $end_string = EEM_Registration::instance()
343 343
                                       ->convert_datetime_for_query('REG_date',
344
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
344
+                                          $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
345 345
                                           'Y-m-d H:i:s');
346 346
         $_where['REG_date'] = array(
347 347
             'BETWEEN',
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
             'BETWEEN',
375 375
             array(
376 376
                 EEM_Registration::instance()
377
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
377
+                                ->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'),
378 378
                 EEM_Registration::instance()
379
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
379
+                                ->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s'),
380 380
             ),
381 381
         );
382 382
         $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
         $content .= '<div class="show-on-mobile-view-only">';
421 421
         $content .= '<br>';
422 422
         $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
423
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
423
+        $content .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
424
+        $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
425 425
         $content .= '</div>';
426 426
         return $content;
427 427
     }
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
                   . $event_name
493 493
                   . '</a>' : $event_name;
494 494
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
495
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
495
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
496 496
             $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
497 497
                 'event_espresso'), $event_name);
498
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
498
+            $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>';
499 499
         } else {
500 500
             $edit_event = $event_name;
501 501
             $actions['event_filter'] = '';
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
         $t = $item->get_first_related('Transaction');
562 562
         $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
563 563
         //append group count to name
564
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
564
+        $link .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
565 565
         //append reg_code
566
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
566
+        $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
567 567
         //reg status text for accessibility
568
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
569
-                'sentence') . '</span>';
568
+        $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false,
569
+                'sentence').'</span>';
570 570
         //trash/restore/delete actions
571 571
         $actions = array();
572 572
         if ($this->_view !== 'trash'
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
                 'action'  => 'trash_registrations',
579 579
                 '_REG_ID' => $item->ID(),
580 580
             ), REG_ADMIN_URL);
581
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
582
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
581
+            $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration',
582
+                    'event_espresso').'">'.__('Trash', 'event_espresso').'</a>';
583 583
         } elseif ($this->_view === 'trash') {
584 584
             // restore registration link
585 585
             if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
@@ -589,8 +589,8 @@  discard block
 block discarded – undo
589 589
                     'action'  => 'restore_registrations',
590 590
                     '_REG_ID' => $item->ID(),
591 591
                 ), REG_ADMIN_URL);
592
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
593
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
592
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration',
593
+                        'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
594 594
             }
595 595
             if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
596 596
                 'espresso_registrations_ee_delete_registrations', $item->ID())
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                                                                               . $ticket->name()
659 659
                                                                               . '</span><br />' : '';
660 660
         if ($item->final_price() > 0) {
661
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
661
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
662 662
         } else {
663 663
             // free event
664 664
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
             : '<span class="TKT_name">'
686 686
               . $ticket->name()
687 687
               . '</span><br />';
688
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
688
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
689 689
         return $content;
690 690
     }
691 691
 
@@ -703,10 +703,10 @@  discard block
 block discarded – undo
703 703
         $payment_method = $item->payment_method();
704 704
         $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
705 705
             : __('Unknown', 'event_espresso');
706
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
706
+        $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
707 707
         if ($item->paid() > 0) {
708
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
709
-                    $payment_method_name) . '</span>';
708
+            $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'),
709
+                    $payment_method_name).'</span>';
710 710
         }
711 711
         return $content;
712 712
     }
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
                   . esc_attr__('View Transaction', 'event_espresso')
739 739
                   . '">'
740 740
                   . $item->transaction()->pretty_total()
741
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
741
+                  . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
742 742
         } else {
743 743
             return __("None", "event_espresso");
744 744
         }
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
                       . esc_attr__('View Transaction', 'event_espresso')
776 776
                       . '">'
777 777
                       . $item->transaction()->pretty_paid()
778
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
778
+                      . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
779 779
             }
780 780
         }
781 781
         return '&nbsp;';
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
         $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
816 816
             'espresso_registrations_view_registration', $item->ID()) ? '
817 817
 			<li>
818
-			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
818
+			<a href="' . $view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
819 819
 				<div class="dashicons dashicons-clipboard"></div>
820 820
 			</a>
821 821
 			</li>' : '';
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
             'espresso_registrations_edit_attendee')
824 824
                                && $attendee instanceof EE_Attendee ? '
825 825
 			<li>
826
-			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
826
+			<a href="' . $edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text">
827 827
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
828 828
 			</a>
829 829
 			</li>' : '';
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 * @param    int $EVT_ID
41 41
 	 * @return    object
42 42
 	 */
43
-	public static function get_event( $EVT_ID = 0 ) {
44
-		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
43
+	public static function get_event($EVT_ID = 0) {
44
+		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
45 45
 		// do we already have the Event  you are looking for?
46
-		if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) {
46
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
47 47
 			return EEH_Event_View::$_event;
48 48
 		}
49 49
 		EEH_Event_View::$_event = NULL;
50 50
 		// international newspaper?
51 51
 		global $post;
52 52
 		// if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
53
-		 if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) {
53
+		 if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
54 54
 //			d( $post );
55 55
 			// grab the event we're looking for
56
-			if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) {
56
+			if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) {
57 57
 				EEH_Event_View::$_event = $post->EE_Event;
58 58
 //				d( EEH_Event_View::$_event );
59 59
 			}
60 60
 			// now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
61
-			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) {
61
+			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
62 62
 				// sigh... pull it from the db
63
-				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
63
+				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
64 64
 //				d( EEH_Event_View::$_event );
65 65
 			}
66 66
 		}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @param    int $EVT_ID
77 77
 	 * @return    boolean
78 78
 	 */
79
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
80
-		$event = EEH_Event_View::get_event( $EVT_ID );
79
+	public static function display_ticket_selector($EVT_ID = 0) {
80
+		$event = EEH_Event_View::get_event($EVT_ID);
81 81
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
82 82
 	}
83 83
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param    int $EVT_ID
91 91
 	 * @return    string
92 92
 	 */
93
-	public static function event_status( $EVT_ID = 0 ) {
94
-		$event = EEH_Event_View::get_event( $EVT_ID );
95
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
93
+	public static function event_status($EVT_ID = 0) {
94
+		$event = EEH_Event_View::get_event($EVT_ID);
95
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
96 96
 	}
97 97
 
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param    int $EVT_ID
105 105
 	 *  @return 	string
106 106
 	 */
107
-	public static function event_active_status( $EVT_ID = 0 ) {
108
-		$event = EEH_Event_View::get_event( $EVT_ID );
107
+	public static function event_active_status($EVT_ID = 0) {
108
+		$event = EEH_Event_View::get_event($EVT_ID);
109 109
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
110 110
 	}
111 111
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 * @param    int $EVT_ID
119 119
 	 *  @return 	string
120 120
 	 */
121
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122
-		$event = EEH_Event_View::get_event( $EVT_ID );
121
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
122
+		$event = EEH_Event_View::get_event($EVT_ID);
123 123
 		$has_content_or_excerpt = FALSE;
124
-		if ( $event instanceof EE_Event ) {
125
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
124
+		if ($event instanceof EE_Event) {
125
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
126 126
 		}
127
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
127
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
128 128
 			$has_content_or_excerpt = FALSE;
129 129
 		}
130 130
 		return $has_content_or_excerpt;
@@ -140,34 +140,34 @@  discard block
 block discarded – undo
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
143
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
143
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
144 144
 		global $post;
145 145
 
146 146
 		ob_start();
147
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
147
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
148 148
 			// admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option
149 149
 			the_content();
150
-		} else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) {
150
+		} else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
151 151
             // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
152 152
 			// AND an excerpt actually exists
153 153
 			the_excerpt();
154
-		} else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) {
154
+		} else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
155 155
             // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
156 156
 			// but NO excerpt actually exists, so we need to create one
157
-			if ( ! empty( $num_words )) {
158
-				if ( empty( $more )) {
159
-					$more_link_text = __( '(more&hellip;)' );
160
-					$more = ' <a href="' . get_permalink() . '"';
157
+			if ( ! empty($num_words)) {
158
+				if (empty($more)) {
159
+					$more_link_text = __('(more&hellip;)');
160
+					$more = ' <a href="'.get_permalink().'"';
161 161
 					$more .= ' class="more-link"';
162 162
 					$more .= \EED_Events_Archive::link_target();
163
-					$more .= '>' . $more_link_text . '</a>';
164
-                    $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
163
+					$more .= '>'.$more_link_text.'</a>';
164
+                    $more = apply_filters('the_content_more_link', $more, $more_link_text);
165 165
 				}
166
-				$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
166
+				$content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
167 167
 
168
-				$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
168
+				$content = wp_trim_words($content, $num_words, ' ').$more;
169 169
             } else {
170
-                $content =  get_the_content();
170
+                $content = get_the_content();
171 171
 			}
172 172
 			global $allowedtags;
173 173
 			// make sure links are allowed
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
             // but get previous value so we can reset it
182 182
             $prev_value = $allowedtags['a']['target'];
183 183
             $allowedtags['a']['target'] = true;
184
-			$content = wp_kses( $content, $allowedtags );
185
-			$content = strip_shortcodes( $content );
186
-			echo apply_filters( 'the_content', $content );
184
+			$content = wp_kses($content, $allowedtags);
185
+			$content = strip_shortcodes($content);
186
+			echo apply_filters('the_content', $content);
187 187
 			$allowedtags['a']['target'] = $prev_value;
188 188
         } else {
189 189
             // admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option
190
-			echo apply_filters( 'the_content', '' );
190
+			echo apply_filters('the_content', '');
191 191
 		}
192 192
 		return ob_get_clean();
193 193
 	}
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	 * @param    int $EVT_ID
202 202
 	 *  @return 	EE_Ticket[]
203 203
 	 */
204
-	public static function event_tickets_available( $EVT_ID = 0 ) {
205
-		$event = EEH_Event_View::get_event( $EVT_ID );
204
+	public static function event_tickets_available($EVT_ID = 0) {
205
+		$event = EEH_Event_View::get_event($EVT_ID);
206 206
 		$tickets_available_for_purchase = array();
207
-		if( $event instanceof EE_Event ) {
208
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
209
-			foreach( $datetimes as $datetime ) {
210
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
207
+		if ($event instanceof EE_Event) {
208
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
209
+			foreach ($datetimes as $datetime) {
210
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
211 211
 			}
212 212
 		}
213 213
 		return $tickets_available_for_purchase;
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 	 * @param 	  bool   $hide_uncategorized
224 224
 	 * @return    string
225 225
 	 */
226
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
226
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
227 227
 		$category_links = array();
228
-		$event = EEH_Event_View::get_event( $EVT_ID );
229
-		if ( $event instanceof EE_Event ) {
230
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
231
-			if ( $event_categories ) {
228
+		$event = EEH_Event_View::get_event($EVT_ID);
229
+		if ($event instanceof EE_Event) {
230
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
231
+			if ($event_categories) {
232 232
 				// loop thru terms and create links
233
-				foreach ( $event_categories as $term ) {
234
-					$url = get_term_link( $term, 'espresso_venue_categories' );
235
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
236
-						$category_links[] = '<a href="' . esc_url( $url )
233
+				foreach ($event_categories as $term) {
234
+					$url = get_term_link($term, 'espresso_venue_categories');
235
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
236
+						$category_links[] = '<a href="'.esc_url($url)
237 237
                                             . '" rel="tag"'
238 238
                                             . \EED_Events_Archive::link_target()
239 239
                                             .'>'
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				}
244 244
 			}
245 245
 		}
246
-		return implode( ', ', $category_links );
246
+		return implode(', ', $category_links);
247 247
 	}
248 248
 
249 249
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 * @param int    $EVT_ID
258 258
 	 * @return    string
259 259
 	 */
260
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
261
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
262
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
263
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
260
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
261
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
262
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
263
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
264 264
 	}
265 265
 
266 266
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 * @param int    $EVT_ID
275 275
 	 * @return    string
276 276
 	 */
277
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
278
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
279
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
280
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
277
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
278
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
279
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
280
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
281 281
 	}
282 282
 
283 283
 
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 	 * @param int    $EVT_ID
292 292
 	 * @return    string
293 293
 	 */
294
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
295
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
296
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
297
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
294
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
295
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
296
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
297
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
298 298
 	}
299 299
 
300 300
 
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 	 * @param int    $EVT_ID
309 309
 	 * @return    string
310 310
 	 */
311
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
312
-		$datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID );
313
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
314
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
311
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
312
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
313
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
314
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
315 315
 	}
316 316
 
317 317
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 	 * @param int $EVT_ID
324 324
 	 * @return    string
325 325
 	 */
326
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
327
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
328
-		if ( $datetime instanceof EE_Datetime ) {
326
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
327
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
328
+		if ($datetime instanceof EE_Datetime) {
329 329
 	?>
330 330
 		<div class="event-date-calendar-page-dv">
331
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
332
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
331
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
332
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
333 333
 		</div>
334 334
 	<?php
335 335
 		}
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
 	 * @param int $EVT_ID
345 345
 	 * @return    string
346 346
 	 */
347
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
348
-		$event = EEH_Event_View::get_event( $EVT_ID );
349
-		if ( $event instanceof EE_Event ) {
347
+	public static function get_primary_date_obj($EVT_ID = 0) {
348
+		$event = EEH_Event_View::get_event($EVT_ID);
349
+		if ($event instanceof EE_Event) {
350 350
 			$datetimes = $event->get_many_related(
351 351
 				'Datetime',
352 352
 				array(
353 353
 					'limit' => 1,
354
-					'order_by' => array( 'DTT_order' => 'ASC' )
354
+					'order_by' => array('DTT_order' => 'ASC')
355 355
 				)
356 356
 			);
357
-			return reset( $datetimes );
357
+			return reset($datetimes);
358 358
 		} else {
359 359
 			 return FALSE;
360 360
 		}
@@ -369,17 +369,17 @@  discard block
 block discarded – undo
369 369
 	 * @param int $EVT_ID
370 370
 	 * @return    string
371 371
 	 */
372
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
373
-		$event = EEH_Event_View::get_event( $EVT_ID );
374
-		if ( $event instanceof EE_Event ) {
372
+	public static function get_last_date_obj($EVT_ID = 0) {
373
+		$event = EEH_Event_View::get_event($EVT_ID);
374
+		if ($event instanceof EE_Event) {
375 375
 			$datetimes = $event->get_many_related(
376 376
 				'Datetime',
377 377
 				array(
378 378
 					'limit' => 1,
379
-					'order_by' => array( 'DTT_order' => 'DESC' )
379
+					'order_by' => array('DTT_order' => 'DESC')
380 380
 				)
381 381
 			);
382
-			return end( $datetimes );
382
+			return end($datetimes);
383 383
 		} else {
384 384
 			return FALSE;
385 385
 		}
@@ -394,17 +394,17 @@  discard block
 block discarded – undo
394 394
 	 * @param int $EVT_ID
395 395
 	 * @return    string
396 396
 	 */
397
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
398
-		$event = EEH_Event_View::get_event( $EVT_ID );
399
-		if ( $event instanceof EE_Event ) {
397
+	public static function get_earliest_date_obj($EVT_ID = 0) {
398
+		$event = EEH_Event_View::get_event($EVT_ID);
399
+		if ($event instanceof EE_Event) {
400 400
 			$datetimes = $event->get_many_related(
401 401
 				'Datetime',
402 402
 				array(
403 403
 					'limit' => 1,
404
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
404
+					'order_by' => array('DTT_EVT_start' => 'ASC')
405 405
 				)
406 406
 			);
407
-			return reset( $datetimes );
407
+			return reset($datetimes);
408 408
 		} else {
409 409
 			 return FALSE;
410 410
 		}
@@ -419,17 +419,17 @@  discard block
 block discarded – undo
419 419
 	 * @param int $EVT_ID
420 420
 	 * @return    string
421 421
 	 */
422
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
423
-		$event = EEH_Event_View::get_event( $EVT_ID );
424
-		if ( $event instanceof EE_Event ) {
422
+	public static function get_latest_date_obj($EVT_ID = 0) {
423
+		$event = EEH_Event_View::get_event($EVT_ID);
424
+		if ($event instanceof EE_Event) {
425 425
 			$datetimes = $event->get_many_related(
426 426
 				'Datetime',
427 427
 				array(
428 428
 					'limit' => 1,
429
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
429
+					'order_by' => array('DTT_EVT_start' => 'DESC')
430 430
 				)
431 431
 			);
432
-			return end( $datetimes );
432
+			return end($datetimes);
433 433
 		} else {
434 434
 			return FALSE;
435 435
 		}
@@ -447,17 +447,17 @@  discard block
 block discarded – undo
447 447
 	 * @param null $limit
448 448
 	 * @return EE_Datetime[]
449 449
 	 */
450
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
451
-		$event = EEH_Event_View::get_event( $EVT_ID );
452
-		if($include_expired === null){
453
-			if($event instanceof EE_Event && $event->is_expired()){
450
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
451
+		$event = EEH_Event_View::get_event($EVT_ID);
452
+		if ($include_expired === null) {
453
+			if ($event instanceof EE_Event && $event->is_expired()) {
454 454
 				$include_expired = true;
455
-			}else{
455
+			} else {
456 456
 				$include_expired = false;
457 457
 			}
458 458
 		}
459 459
 
460
-		if ( $event instanceof EE_Event ) {
460
+		if ($event instanceof EE_Event) {
461 461
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
462 462
 		} else {
463 463
 			 return array();
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 	 * @param int $EVT_ID
474 474
 	 * @return    string
475 475
 	 */
476
-	public static function event_link_url( $EVT_ID = 0 ) {
477
-		$event = EEH_Event_View::get_event( $EVT_ID );
478
-		if ( $event instanceof EE_Event ) {
479
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
480
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
476
+	public static function event_link_url($EVT_ID = 0) {
477
+		$event = EEH_Event_View::get_event($EVT_ID);
478
+		if ($event instanceof EE_Event) {
479
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
480
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
481 481
 		}
482 482
 		return NULL;
483 483
 	}
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 	 * @param int $EVT_ID
492 492
 	 * @return    string
493 493
 	 */
494
-	public static function event_phone( $EVT_ID = 0 ) {
495
-		$event = EEH_Event_View::get_event( $EVT_ID );
496
-		if ( $event instanceof EE_Event ) {
497
-			return EEH_Schema::telephone( $event->phone() );
494
+	public static function event_phone($EVT_ID = 0) {
495
+		$event = EEH_Event_View::get_event($EVT_ID);
496
+		if ($event instanceof EE_Event) {
497
+			return EEH_Schema::telephone($event->phone());
498 498
 		}
499 499
 		return NULL;
500 500
 	}
@@ -511,26 +511,26 @@  discard block
 block discarded – undo
511 511
 	 * @param string $after
512 512
 	 * @return    string
513 513
 	 */
514
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
515
-		$event = EEH_Event_View::get_event( $EVT_ID );
516
-		if ( $event instanceof EE_Event ) {
514
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
515
+		$event = EEH_Event_View::get_event($EVT_ID);
516
+		if ($event instanceof EE_Event) {
517 517
 			// can the user edit this post ?
518
-			if ( current_user_can( 'edit_post', $event->ID() )) {
518
+			if (current_user_can('edit_post', $event->ID())) {
519 519
 				// set link text
520
-				$link_text = ! empty( $link ) ? $link : __('edit this event');
520
+				$link_text = ! empty($link) ? $link : __('edit this event');
521 521
 				// generate nonce
522
-				$nonce = wp_create_nonce( 'edit_nonce' );
522
+				$nonce = wp_create_nonce('edit_nonce');
523 523
 				// generate url to event editor for this event
524
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
524
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
525 525
 				// get edit CPT text
526
-				$post_type_obj = get_post_type_object( 'espresso_events' );
526
+				$post_type_obj = get_post_type_object('espresso_events');
527 527
 				// build final link html
528
-				$link = '<a class="post-edit-link" href="' . $url . '" ';
529
-				$link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"';
528
+				$link = '<a class="post-edit-link" href="'.$url.'" ';
529
+				$link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"';
530 530
 				$link .= \EED_Events_Archive::link_target();
531
-				$link .='>' . $link_text . '</a>';
531
+				$link .= '>'.$link_text.'</a>';
532 532
 				// put it all together
533
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
533
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
534 534
 			}
535 535
 		}
536 536
 		return '';
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRowStandard.php 2 patches
Indentation   +455 added lines, -455 removed lines patch added patch discarded remove patch
@@ -16,461 +16,461 @@
 block discarded – undo
16 16
 class TicketSelectorRowStandard extends TicketSelectorRow
17 17
 {
18 18
 
19
-    /**
20
-     * @var TicketDetails $ticket_details
21
-     */
22
-    protected $ticket_details;
23
-
24
-    /**
25
-     * @var \EE_Ticket_Selector_Config $template_settings
26
-     */
27
-    protected $template_settings;
28
-
29
-    /**
30
-     * @var \EE_Tax_Config $tax_settings
31
-     */
32
-    protected $tax_settings;
33
-
34
-    /**
35
-     * @var boolean $required_ticket_sold_out
36
-     */
37
-    protected $required_ticket_sold_out;
38
-
39
-    /**
40
-     * @var boolean $prices_displayed_including_taxes
41
-     */
42
-    protected $prices_displayed_including_taxes;
43
-
44
-    /**
45
-     * @var string $event_status
46
-     */
47
-    protected $event_status;
48
-
49
-    /**
50
-     * @var int $row
51
-     */
52
-    protected $row;
53
-
54
-    /**
55
-     * @var int $cols
56
-     */
57
-    protected $cols;
58
-
59
-    /**
60
-     * @var boolean $hidden_input_qty
61
-     */
62
-    protected $hidden_input_qty;
63
-
64
-    /**
65
-     * @var string $ticket_datetime_classes
66
-     */
67
-    protected $ticket_datetime_classes;
68
-
69
-
70
-
71
-    /**
72
-     * TicketDetails constructor.
73
-     *
74
-     * @param \EE_Ticket $ticket
75
-     * @param TicketDetails              $ticket_details
76
-     * @param \EE_Ticket_Selector_Config $template_settings
77
-     * @param \EE_Tax_Config             $tax_settings
78
-     * @param int                        $max_atndz
79
-     * @param int                        $row
80
-     * @param int                        $cols
81
-     * @param boolean                    $required_ticket_sold_out
82
-     * @param string                     $event_status
83
-     * @param string                     $date_format
84
-     * @param string                     $ticket_datetime_classes
85
-     */
86
-    public function __construct(
87
-        \EE_Ticket $ticket,
88
-        TicketDetails $ticket_details,
89
-        \EE_Ticket_Selector_Config $template_settings,
90
-        \EE_Tax_Config $tax_settings,
91
-        $max_atndz,
92
-        $row,
93
-        $cols,
94
-        $required_ticket_sold_out,
95
-        $event_status,
96
-        $date_format,
97
-        $ticket_datetime_classes
98
-    ) {
99
-        $this->ticket = $ticket;
100
-        $this->ticket_details = $ticket_details;
101
-        $this->template_settings = $template_settings;
102
-        $this->tax_settings = $tax_settings;
103
-        $this->max_atndz = $max_atndz;
104
-        $this->row = $row;
105
-        $this->cols = $cols;
106
-        $this->required_ticket_sold_out = $required_ticket_sold_out;
107
-        $this->event_status = $event_status;
108
-        $this->date_format = $date_format;
109
-        $this->ticket_datetime_classes = $ticket_datetime_classes;
110
-        parent::__construct($ticket, $max_atndz, $date_format);
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * other ticket rows will need to know if a required ticket is sold out,
117
-     * so that they are not offered for sale
118
-     *
119
-     * @return boolean
120
-     */
121
-    public function getRequiredTicketSoldOut()
122
-    {
123
-        return $this->required_ticket_sold_out;
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * @return int
130
-     */
131
-    public function getCols()
132
-    {
133
-        return $this->cols;
134
-    }
135
-
136
-
137
-
138
-    /**
139
-     * getHtml
140
-     *
141
-     * @return string
142
-     * @throws \EE_Error
143
-     */
144
-    public function getHtml()
145
-    {
146
-        $min = 0;
147
-        $max = $this->ticket->max();
148
-        $remaining = $this->ticket->remaining();
149
-        if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
150
-            list($min, $max) = $this->setTicketMinAndMax($remaining);
151
-        } else {
152
-            // set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
153
-            $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
154
-                ? $this->ticket->start_date()
155
-                : $this->required_ticket_sold_out;
156
-        }
157
-        list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
158
-        list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
159
-        /**
160
-         * Allow plugins to hook in and abort the generation and display of this row to do
161
-         * something else if they want.
162
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
163
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
164
-         * current row.
165
-         *
166
-         * @var string|bool
167
-         */
168
-        $ticket_selector_row_html = apply_filters(
169
-            'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
170
-            false,
171
-            $this->ticket,
172
-            $max,
173
-            $min,
174
-            $this->required_ticket_sold_out,
175
-            $ticket_price,
176
-            $ticket_bundle,
177
-            $ticket_status,
178
-            $status_class
179
-        );
180
-        if ($ticket_selector_row_html !== false) {
181
-            return $ticket_selector_row_html;
182
-        }
183
-        $ticket_selector_row_html = \EEH_HTML::tr(
184
-            '', '',
185
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
186
-        );
187
-        /**
188
-         * Allow plugins to hook in and abort the generation and display of the contents of this
189
-         * row to do something else if they want.
190
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
191
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
192
-         * current row.
193
-         *
194
-         * @var string|bool
195
-         */
196
-        $new_row_cells_content = apply_filters(
197
-            'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
198
-            false,
199
-            $this->ticket,
200
-            $max,
201
-            $min,
202
-            $this->required_ticket_sold_out,
203
-            $ticket_price,
204
-            $ticket_bundle,
205
-            $ticket_status,
206
-            $status_class
207
-        );
208
-        if ($new_row_cells_content !== false) {
209
-            return $ticket_selector_row_html
210
-                   . $new_row_cells_content
211
-                   . $this->ticketQtyAndIdHiddenInputs()
212
-                   . \EEH_HTML::trx();
213
-        }
214
-        $this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
215
-
216
-        $ticket_selector_row_html .= $this->ticketNameTableCell();
217
-        $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
218
-        $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
219
-        $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
220
-        if (empty($this->ticket_status_display)) {
221
-            if ($this->max_atndz === 1) {
222
-                // only ONE attendee is allowed to register at a time
223
-                $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
224
-            } else if ($max > 0) {
225
-                $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
226
-            }
227
-        }
228
-        $ticket_selector_row_html .= $this->ticket_status_display;
229
-        $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
230
-        $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
231
-        $ticket_selector_row_html .= \EEH_HTML::tdx();
232
-        $ticket_selector_row_html .= \EEH_HTML::trx();
233
-
234
-
235
-        $this->row++;
236
-        return $ticket_selector_row_html;
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * setTicketMinAndMax
243
-     *
244
-     * @param int $remaining
245
-     * @return array
246
-     */
247
-    protected function setTicketMinAndMax($remaining)
248
-    {
249
-        // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
250
-        $max = min($remaining, $this->max_atndz);
251
-        // but... we also want to restrict the number of tickets by the ticket max setting,
252
-        // however, the max still can't be higher than what was just set above
253
-        $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
254
-        // and we also want to restrict the minimum number of tickets by the ticket min setting
255
-        $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
256
-        // and if the ticket is required, then make sure that min qty is at least 1
257
-        $min = $this->ticket->required() ? max($min, 1) : $min;
258
-        return array($min, $max);
259
-    }
260
-
261
-
262
-    /**
263
-     * getTicketPriceDetails
264
-     *
265
-     * @return array
266
-     */
267
-    protected function getTicketPriceDetails()
268
-    {
269
-        $ticket_price = $this->tax_settings->prices_displayed_including_taxes
270
-            ? $this->ticket->get_ticket_total_with_taxes()
271
-            : $this->ticket->get_ticket_subtotal();
272
-        $ticket_bundle = false;
273
-        $ticket_min = $this->ticket->min();
274
-        // for ticket bundles, set min and max qty the same
275
-        if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
276
-            $ticket_price *= $ticket_min;
277
-            $ticket_bundle = true;
278
-        }
279
-        $ticket_price = apply_filters(
280
-            'FHEE__ticket_selector_chart_template__ticket_price',
281
-            $ticket_price,
282
-            $this->ticket
283
-        );
284
-        return array($ticket_price, $ticket_bundle);
285
-    }
286
-
287
-
288
-
289
-    /**
290
-     * getTicketStatusClasses
291
-     *
292
-     * @param int $remaining
293
-     * @return array
294
-     * @throws \EE_Error
295
-     */
296
-    protected function getTicketStatusClasses($remaining = 0)
297
-    {
298
-        // if a previous required ticket with the same sale start date is sold out,
299
-        // then mark this ticket as sold out as well.
300
-        // tickets that go on sale at a later date than the required ticket  will NOT be affected
301
-        $tkt_status = $this->required_ticket_sold_out !== false
302
-                      && $this->required_ticket_sold_out === $this->ticket->start_date()
303
-            ? \EE_Ticket::sold_out
304
-            : $this->ticket->ticket_status();
305
-        $tkt_status = $this->event_status === \EE_Datetime::sold_out
306
-            ? \EE_Ticket::sold_out
307
-            : $tkt_status;
308
-        // check ticket status
309
-        switch ($tkt_status) {
310
-            // sold_out
311
-            case \EE_Ticket::sold_out :
312
-                $ticket_status = 'ticket-sales-sold-out';
313
-                $status_class = 'ticket-sales-sold-out lt-grey-text';
314
-                break;
315
-            // expired
316
-            case \EE_Ticket::expired :
317
-                $ticket_status = 'ticket-sales-expired';
318
-                $status_class = 'ticket-sales-expired lt-grey-text';
319
-                break;
320
-            // archived
321
-            case \EE_Ticket::archived :
322
-                $ticket_status = 'archived-ticket';
323
-                $status_class = 'archived-ticket hidden';
324
-                break;
325
-            // pending
326
-            case \EE_Ticket::pending :
327
-                $ticket_status = 'ticket-pending';
328
-                $status_class = 'ticket-pending';
329
-                break;
330
-            // onsale
331
-            case \EE_Ticket::onsale :
332
-            default :
333
-                $ticket_status = 'ticket-on-sale';
334
-                $status_class = 'ticket-on-sale';
335
-                break;
336
-        }
337
-        $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status);
338
-        return array($tkt_status, $ticket_status, $status_class);
339
-    }
340
-
341
-
342
-
343
-    /**
344
-     * ticketNameTableCell
345
-     *
346
-     * @return string
347
-     * @throws \EE_Error
348
-     */
349
-    protected function ticketNameTableCell()
350
-    {
351
-        $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
352
-        $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
353
-        $html .= $this->ticket_details->getShowHideLinks();
354
-        if ($this->ticket->required()) {
355
-            $html .= \EEH_HTML::p(
356
-                    apply_filters(
357
-                            'FHEE__ticket_selector_chart_template__ticket_required_message',
358
-                            esc_html__('This ticket is required and must be purchased.', 'event_espresso')
359
-                    ),
360
-                    '', 'ticket-required-pg'
361
-            );
362
-        }
363
-        $html .= \EEH_HTML::tdx();
364
-        return $html;
365
-    }
366
-
367
-
368
-
369
-    /**
370
-     * ticketPriceTableCell
371
-     *
372
-     * @param float $ticket_price
373
-     * @param bool  $ticket_bundle
374
-     * @return string
375
-     * @throws \EE_Error
376
-     */
377
-    protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
378
-    {
379
-        $html = '';
380
-        if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
381
-            $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382
-            $html .= \EEH_Template::format_currency($ticket_price);
383
-            $html .= $this->ticket->taxable()
384
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
385
-                : '';
386
-            $html .= '&nbsp;';
387
-            $html .= \EEH_HTML::span(
388
-                $ticket_bundle
389
-                    ? apply_filters(
390
-                        'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
391
-                        __(' / bundle', 'event_espresso')
392
-                    )
393
-                    : apply_filters(
394
-                        'FHEE__ticket_selector_chart_template__per_ticket_text',
395
-                        __('', 'event_espresso')
396
-                    ),
397
-                '', 'smaller-text no-bold'
398
-            );
399
-            $html .= '&nbsp;';
400
-            $html .= \EEH_HTML::tdx();
401
-            $this->cols++;
402
-        }
403
-        return $html;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * onlyOneAttendeeCanRegister
410
-     *
411
-     * @return string
412
-     */
413
-    protected function onlyOneAttendeeCanRegister()
414
-    {
415
-        // display submit button since we have tickets available
416
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417
-        $this->hidden_input_qty = false;
418
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
421
-        $html .= $this->row === 1 ? ' checked="checked"' : '';
422
-        $html .= ' title=""/>';
423
-        return $html;
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * ticketQuantitySelector
430
-     *
431
-     * @param int $min
432
-     * @param int $max
433
-     * @return string
434
-     */
435
-    protected function ticketQuantitySelector($min = 0, $max = 0)
436
-    {
437
-        // display submit button since we have tickets available
438
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
439
-        $this->hidden_input_qty = false;
440
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
441
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
442
-        $html .= ' class="ticket-selector-tbl-qty-slct">';
443
-        // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
444
-        if ($min !== 0 && ! $this->ticket->required()) {
445
-            $html .= '<option value="0">&nbsp;0&nbsp;</option>';
446
-        }
447
-        // offer ticket quantities from the min to the max
448
-        for ($i = $min; $i <= $max; $i++) {
449
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
450
-        }
451
-        $html .= '</select>';
452
-        return $html;
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     * getHiddenInputs
459
-     *
460
-     * @return string
461
-     * @throws \EE_Error
462
-     */
463
-    protected function ticketQtyAndIdHiddenInputs()
464
-    {
465
-        $html = '';
466
-        // depending on group reg we need to change the format for qty
467
-        if ($this->hidden_input_qty) {
468
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
469
-        }
470
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
471
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
472
-        return $html;
473
-    }
19
+	/**
20
+	 * @var TicketDetails $ticket_details
21
+	 */
22
+	protected $ticket_details;
23
+
24
+	/**
25
+	 * @var \EE_Ticket_Selector_Config $template_settings
26
+	 */
27
+	protected $template_settings;
28
+
29
+	/**
30
+	 * @var \EE_Tax_Config $tax_settings
31
+	 */
32
+	protected $tax_settings;
33
+
34
+	/**
35
+	 * @var boolean $required_ticket_sold_out
36
+	 */
37
+	protected $required_ticket_sold_out;
38
+
39
+	/**
40
+	 * @var boolean $prices_displayed_including_taxes
41
+	 */
42
+	protected $prices_displayed_including_taxes;
43
+
44
+	/**
45
+	 * @var string $event_status
46
+	 */
47
+	protected $event_status;
48
+
49
+	/**
50
+	 * @var int $row
51
+	 */
52
+	protected $row;
53
+
54
+	/**
55
+	 * @var int $cols
56
+	 */
57
+	protected $cols;
58
+
59
+	/**
60
+	 * @var boolean $hidden_input_qty
61
+	 */
62
+	protected $hidden_input_qty;
63
+
64
+	/**
65
+	 * @var string $ticket_datetime_classes
66
+	 */
67
+	protected $ticket_datetime_classes;
68
+
69
+
70
+
71
+	/**
72
+	 * TicketDetails constructor.
73
+	 *
74
+	 * @param \EE_Ticket $ticket
75
+	 * @param TicketDetails              $ticket_details
76
+	 * @param \EE_Ticket_Selector_Config $template_settings
77
+	 * @param \EE_Tax_Config             $tax_settings
78
+	 * @param int                        $max_atndz
79
+	 * @param int                        $row
80
+	 * @param int                        $cols
81
+	 * @param boolean                    $required_ticket_sold_out
82
+	 * @param string                     $event_status
83
+	 * @param string                     $date_format
84
+	 * @param string                     $ticket_datetime_classes
85
+	 */
86
+	public function __construct(
87
+		\EE_Ticket $ticket,
88
+		TicketDetails $ticket_details,
89
+		\EE_Ticket_Selector_Config $template_settings,
90
+		\EE_Tax_Config $tax_settings,
91
+		$max_atndz,
92
+		$row,
93
+		$cols,
94
+		$required_ticket_sold_out,
95
+		$event_status,
96
+		$date_format,
97
+		$ticket_datetime_classes
98
+	) {
99
+		$this->ticket = $ticket;
100
+		$this->ticket_details = $ticket_details;
101
+		$this->template_settings = $template_settings;
102
+		$this->tax_settings = $tax_settings;
103
+		$this->max_atndz = $max_atndz;
104
+		$this->row = $row;
105
+		$this->cols = $cols;
106
+		$this->required_ticket_sold_out = $required_ticket_sold_out;
107
+		$this->event_status = $event_status;
108
+		$this->date_format = $date_format;
109
+		$this->ticket_datetime_classes = $ticket_datetime_classes;
110
+		parent::__construct($ticket, $max_atndz, $date_format);
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * other ticket rows will need to know if a required ticket is sold out,
117
+	 * so that they are not offered for sale
118
+	 *
119
+	 * @return boolean
120
+	 */
121
+	public function getRequiredTicketSoldOut()
122
+	{
123
+		return $this->required_ticket_sold_out;
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * @return int
130
+	 */
131
+	public function getCols()
132
+	{
133
+		return $this->cols;
134
+	}
135
+
136
+
137
+
138
+	/**
139
+	 * getHtml
140
+	 *
141
+	 * @return string
142
+	 * @throws \EE_Error
143
+	 */
144
+	public function getHtml()
145
+	{
146
+		$min = 0;
147
+		$max = $this->ticket->max();
148
+		$remaining = $this->ticket->remaining();
149
+		if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
150
+			list($min, $max) = $this->setTicketMinAndMax($remaining);
151
+		} else {
152
+			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
153
+			$this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
154
+				? $this->ticket->start_date()
155
+				: $this->required_ticket_sold_out;
156
+		}
157
+		list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
158
+		list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
159
+		/**
160
+		 * Allow plugins to hook in and abort the generation and display of this row to do
161
+		 * something else if they want.
162
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
163
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
164
+		 * current row.
165
+		 *
166
+		 * @var string|bool
167
+		 */
168
+		$ticket_selector_row_html = apply_filters(
169
+			'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
170
+			false,
171
+			$this->ticket,
172
+			$max,
173
+			$min,
174
+			$this->required_ticket_sold_out,
175
+			$ticket_price,
176
+			$ticket_bundle,
177
+			$ticket_status,
178
+			$status_class
179
+		);
180
+		if ($ticket_selector_row_html !== false) {
181
+			return $ticket_selector_row_html;
182
+		}
183
+		$ticket_selector_row_html = \EEH_HTML::tr(
184
+			'', '',
185
+			"tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
186
+		);
187
+		/**
188
+		 * Allow plugins to hook in and abort the generation and display of the contents of this
189
+		 * row to do something else if they want.
190
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
191
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
192
+		 * current row.
193
+		 *
194
+		 * @var string|bool
195
+		 */
196
+		$new_row_cells_content = apply_filters(
197
+			'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
198
+			false,
199
+			$this->ticket,
200
+			$max,
201
+			$min,
202
+			$this->required_ticket_sold_out,
203
+			$ticket_price,
204
+			$ticket_bundle,
205
+			$ticket_status,
206
+			$status_class
207
+		);
208
+		if ($new_row_cells_content !== false) {
209
+			return $ticket_selector_row_html
210
+				   . $new_row_cells_content
211
+				   . $this->ticketQtyAndIdHiddenInputs()
212
+				   . \EEH_HTML::trx();
213
+		}
214
+		$this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
215
+
216
+		$ticket_selector_row_html .= $this->ticketNameTableCell();
217
+		$ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
218
+		$ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
219
+		$this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
220
+		if (empty($this->ticket_status_display)) {
221
+			if ($this->max_atndz === 1) {
222
+				// only ONE attendee is allowed to register at a time
223
+				$ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
224
+			} else if ($max > 0) {
225
+				$ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
226
+			}
227
+		}
228
+		$ticket_selector_row_html .= $this->ticket_status_display;
229
+		$ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
230
+		$ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
231
+		$ticket_selector_row_html .= \EEH_HTML::tdx();
232
+		$ticket_selector_row_html .= \EEH_HTML::trx();
233
+
234
+
235
+		$this->row++;
236
+		return $ticket_selector_row_html;
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * setTicketMinAndMax
243
+	 *
244
+	 * @param int $remaining
245
+	 * @return array
246
+	 */
247
+	protected function setTicketMinAndMax($remaining)
248
+	{
249
+		// offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
250
+		$max = min($remaining, $this->max_atndz);
251
+		// but... we also want to restrict the number of tickets by the ticket max setting,
252
+		// however, the max still can't be higher than what was just set above
253
+		$max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
254
+		// and we also want to restrict the minimum number of tickets by the ticket min setting
255
+		$min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
256
+		// and if the ticket is required, then make sure that min qty is at least 1
257
+		$min = $this->ticket->required() ? max($min, 1) : $min;
258
+		return array($min, $max);
259
+	}
260
+
261
+
262
+	/**
263
+	 * getTicketPriceDetails
264
+	 *
265
+	 * @return array
266
+	 */
267
+	protected function getTicketPriceDetails()
268
+	{
269
+		$ticket_price = $this->tax_settings->prices_displayed_including_taxes
270
+			? $this->ticket->get_ticket_total_with_taxes()
271
+			: $this->ticket->get_ticket_subtotal();
272
+		$ticket_bundle = false;
273
+		$ticket_min = $this->ticket->min();
274
+		// for ticket bundles, set min and max qty the same
275
+		if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
276
+			$ticket_price *= $ticket_min;
277
+			$ticket_bundle = true;
278
+		}
279
+		$ticket_price = apply_filters(
280
+			'FHEE__ticket_selector_chart_template__ticket_price',
281
+			$ticket_price,
282
+			$this->ticket
283
+		);
284
+		return array($ticket_price, $ticket_bundle);
285
+	}
286
+
287
+
288
+
289
+	/**
290
+	 * getTicketStatusClasses
291
+	 *
292
+	 * @param int $remaining
293
+	 * @return array
294
+	 * @throws \EE_Error
295
+	 */
296
+	protected function getTicketStatusClasses($remaining = 0)
297
+	{
298
+		// if a previous required ticket with the same sale start date is sold out,
299
+		// then mark this ticket as sold out as well.
300
+		// tickets that go on sale at a later date than the required ticket  will NOT be affected
301
+		$tkt_status = $this->required_ticket_sold_out !== false
302
+					  && $this->required_ticket_sold_out === $this->ticket->start_date()
303
+			? \EE_Ticket::sold_out
304
+			: $this->ticket->ticket_status();
305
+		$tkt_status = $this->event_status === \EE_Datetime::sold_out
306
+			? \EE_Ticket::sold_out
307
+			: $tkt_status;
308
+		// check ticket status
309
+		switch ($tkt_status) {
310
+			// sold_out
311
+			case \EE_Ticket::sold_out :
312
+				$ticket_status = 'ticket-sales-sold-out';
313
+				$status_class = 'ticket-sales-sold-out lt-grey-text';
314
+				break;
315
+			// expired
316
+			case \EE_Ticket::expired :
317
+				$ticket_status = 'ticket-sales-expired';
318
+				$status_class = 'ticket-sales-expired lt-grey-text';
319
+				break;
320
+			// archived
321
+			case \EE_Ticket::archived :
322
+				$ticket_status = 'archived-ticket';
323
+				$status_class = 'archived-ticket hidden';
324
+				break;
325
+			// pending
326
+			case \EE_Ticket::pending :
327
+				$ticket_status = 'ticket-pending';
328
+				$status_class = 'ticket-pending';
329
+				break;
330
+			// onsale
331
+			case \EE_Ticket::onsale :
332
+			default :
333
+				$ticket_status = 'ticket-on-sale';
334
+				$status_class = 'ticket-on-sale';
335
+				break;
336
+		}
337
+		$ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status);
338
+		return array($tkt_status, $ticket_status, $status_class);
339
+	}
340
+
341
+
342
+
343
+	/**
344
+	 * ticketNameTableCell
345
+	 *
346
+	 * @return string
347
+	 * @throws \EE_Error
348
+	 */
349
+	protected function ticketNameTableCell()
350
+	{
351
+		$html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
352
+		$html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
353
+		$html .= $this->ticket_details->getShowHideLinks();
354
+		if ($this->ticket->required()) {
355
+			$html .= \EEH_HTML::p(
356
+					apply_filters(
357
+							'FHEE__ticket_selector_chart_template__ticket_required_message',
358
+							esc_html__('This ticket is required and must be purchased.', 'event_espresso')
359
+					),
360
+					'', 'ticket-required-pg'
361
+			);
362
+		}
363
+		$html .= \EEH_HTML::tdx();
364
+		return $html;
365
+	}
366
+
367
+
368
+
369
+	/**
370
+	 * ticketPriceTableCell
371
+	 *
372
+	 * @param float $ticket_price
373
+	 * @param bool  $ticket_bundle
374
+	 * @return string
375
+	 * @throws \EE_Error
376
+	 */
377
+	protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
378
+	{
379
+		$html = '';
380
+		if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
381
+			$html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382
+			$html .= \EEH_Template::format_currency($ticket_price);
383
+			$html .= $this->ticket->taxable()
384
+				? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
385
+				: '';
386
+			$html .= '&nbsp;';
387
+			$html .= \EEH_HTML::span(
388
+				$ticket_bundle
389
+					? apply_filters(
390
+						'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
391
+						__(' / bundle', 'event_espresso')
392
+					)
393
+					: apply_filters(
394
+						'FHEE__ticket_selector_chart_template__per_ticket_text',
395
+						__('', 'event_espresso')
396
+					),
397
+				'', 'smaller-text no-bold'
398
+			);
399
+			$html .= '&nbsp;';
400
+			$html .= \EEH_HTML::tdx();
401
+			$this->cols++;
402
+		}
403
+		return $html;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * onlyOneAttendeeCanRegister
410
+	 *
411
+	 * @return string
412
+	 */
413
+	protected function onlyOneAttendeeCanRegister()
414
+	{
415
+		// display submit button since we have tickets available
416
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417
+		$this->hidden_input_qty = false;
418
+		$html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
+		$html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
421
+		$html .= $this->row === 1 ? ' checked="checked"' : '';
422
+		$html .= ' title=""/>';
423
+		return $html;
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * ticketQuantitySelector
430
+	 *
431
+	 * @param int $min
432
+	 * @param int $max
433
+	 * @return string
434
+	 */
435
+	protected function ticketQuantitySelector($min = 0, $max = 0)
436
+	{
437
+		// display submit button since we have tickets available
438
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
439
+		$this->hidden_input_qty = false;
440
+		$html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
441
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
442
+		$html .= ' class="ticket-selector-tbl-qty-slct">';
443
+		// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
444
+		if ($min !== 0 && ! $this->ticket->required()) {
445
+			$html .= '<option value="0">&nbsp;0&nbsp;</option>';
446
+		}
447
+		// offer ticket quantities from the min to the max
448
+		for ($i = $min; $i <= $max; $i++) {
449
+			$html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
450
+		}
451
+		$html .= '</select>';
452
+		return $html;
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 * getHiddenInputs
459
+	 *
460
+	 * @return string
461
+	 * @throws \EE_Error
462
+	 */
463
+	protected function ticketQtyAndIdHiddenInputs()
464
+	{
465
+		$html = '';
466
+		// depending on group reg we need to change the format for qty
467
+		if ($this->hidden_input_qty) {
468
+			$html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
469
+		}
470
+		$html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
471
+		$html .= ' value="' . $this->ticket->ID() . '"/>';
472
+		return $html;
473
+	}
474 474
 
475 475
 }
476 476
 // End of file TicketSelectorRowStandard.php
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         }
183 183
         $ticket_selector_row_html = \EEH_HTML::tr(
184 184
             '', '',
185
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
185
+            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} ".espresso_get_object_css_class($this->ticket)
186 186
         );
187 187
         /**
188 188
          * Allow plugins to hook in and abort the generation and display of the contents of this
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382 382
             $html .= \EEH_Template::format_currency($ticket_price);
383 383
             $html .= $this->ticket->taxable()
384
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
384
+                ? \EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text')
385 385
                 : '';
386 386
             $html .= '&nbsp;';
387 387
             $html .= \EEH_HTML::span(
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
         // display submit button since we have tickets available
416 416
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417 417
         $this->hidden_input_qty = false;
418
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
418
+        $html = '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"';
419
+        $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"';
420
+        $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"';
421 421
         $html .= $this->row === 1 ? ' checked="checked"' : '';
422 422
         $html .= ' title=""/>';
423 423
         return $html;
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
         // display submit button since we have tickets available
438 438
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
439 439
         $this->hidden_input_qty = false;
440
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
441
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
440
+        $html = '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"';
441
+        $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"';
442 442
         $html .= ' class="ticket-selector-tbl-qty-slct">';
443 443
         // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
444 444
         if ($min !== 0 && ! $this->ticket->required()) {
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
         }
447 447
         // offer ticket quantities from the min to the max
448 448
         for ($i = $min; $i <= $max; $i++) {
449
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
449
+            $html .= '<option value="'.$i.'">&nbsp;'.$i.'&nbsp;</option>';
450 450
         }
451 451
         $html .= '</select>';
452 452
         return $html;
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
         $html = '';
466 466
         // depending on group reg we need to change the format for qty
467 467
         if ($this->hidden_input_qty) {
468
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
468
+            $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>';
469 469
         }
470
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
471
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
470
+        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"';
471
+        $html .= ' value="'.$this->ticket->ID().'"/>';
472 472
         return $html;
473 473
     }
474 474
 
Please login to merge, or discard this patch.
modules/batch/EED_Batch.module.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
  * @since		 	   4.8.30.rc.007
18 18
  *
19 19
  */
20
-if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
21
-	exit( 'No direct script access allowed' );
20
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
21
+	exit('No direct script access allowed');
22 22
 }
23 23
 
24
-define( 'BATCH_URL', plugin_dir_url( __FILE__ ) );
24
+define('BATCH_URL', plugin_dir_url(__FILE__));
25 25
 
26
-class EED_Batch extends EED_Module{
26
+class EED_Batch extends EED_Module {
27 27
 	
28 28
 	/**
29 29
 	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 	public static function set_hooks() {
71 71
 		//because this is a possibel attack vector, let's have this disabled until 
72 72
 		//we at least have a real use for it on the frontend
73
-		if( apply_filters( 'FHEE__EED_Batch__set_hooks__enable_frontend_batch', false ) ) {
74
-			add_action( 'wp_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) );
75
-			add_filter( 'template_include', array( self::instance(), 'override_template' ), 99 );
73
+		if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
74
+			add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
75
+			add_filter('template_include', array(self::instance(), 'override_template'), 99);
76 76
 		}
77 77
 	}
78 78
 	
@@ -80,28 +80,28 @@  discard block
 block discarded – undo
80 80
 	 * Initializes some hooks for the admin in order to run batch jobs
81 81
 	 */
82 82
 	public static function set_hooks_admin() {
83
-		add_action( 'admin_menu', array( self::instance(), 'register_admin_pages' ) );
84
-		add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) );
83
+		add_action('admin_menu', array(self::instance(), 'register_admin_pages'));
84
+		add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
85 85
 		
86 86
 		//ajax
87
-		add_action('wp_ajax_espresso_batch_continue',array(self::instance(),'batch_continue'));
88
-		add_action('wp_ajax_espresso_batch_cleanup',array(self::instance(),'batch_cleanup'));
89
-		add_action('wp_ajax_nopriv_espresso_batch_continue',array(self::instance(),'batch_continue'));
90
-		add_action('wp_ajax_nopriv_espresso_batch_cleanup',array(self::instance(),'batch_cleanup'));
87
+		add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue'));
88
+		add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
89
+		add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue'));
90
+		add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
91 91
 	}
92 92
 	
93 93
 	/**
94 94
 	 * Enqueues batch scripts on the frontend or admin, and creates a job
95 95
 	 */
96 96
 	public function enqueue_scripts() { 
97
-		if( isset( $_REQUEST[ 'espresso_batch' ] ) 
97
+		if (isset($_REQUEST['espresso_batch']) 
98 98
 			|| 
99 99
 			( 
100
-				isset( $_REQUEST[ 'page' ] )
101
-				&& $_REQUEST[ 'page' ] == 'espresso_batch'
100
+				isset($_REQUEST['page'])
101
+				&& $_REQUEST['page'] == 'espresso_batch'
102 102
 			) 
103 103
 		) { 
104
-			switch( $this->batch_request_type() ) {
104
+			switch ($this->batch_request_type()) {
105 105
 				case self::batch_job:
106 106
 					$this->enqueue_scripts_styles_batch_create();
107 107
 					break;
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function enqueue_scripts_styles_batch_create() {	
119 119
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
120
-		wp_enqueue_script( 'batch_runner_init', BATCH_URL . 'assets/batch_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true );
121
-		wp_localize_script( 'batch_runner_init', 'ee_job_response', $job_response->to_array() );
122
-		wp_localize_script( 'batch_runner_init', 'ee_job_i18n', 
120
+		wp_enqueue_script('batch_runner_init', BATCH_URL.'assets/batch_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true);
121
+		wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
122
+		wp_localize_script('batch_runner_init', 'ee_job_i18n', 
123 123
 			array(
124
-				'return_url' => $_REQUEST['return_url' ],
124
+				'return_url' => $_REQUEST['return_url'],
125 125
 			));
126 126
 	}
127 127
 	
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 	public function enqueue_scripts_styles_batch_file_create() {
132 132
 		//creates a job based on the request variable
133 133
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
134
-		wp_enqueue_script( 'batch_file_runner_init', BATCH_URL . 'assets/batch_file_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true );
135
-		wp_localize_script( 'batch_file_runner_init', 'ee_job_response', $job_response->to_array() );
136
-		wp_localize_script( 'batch_file_runner_init', 'ee_job_i18n', 
134
+		wp_enqueue_script('batch_file_runner_init', BATCH_URL.'assets/batch_file_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true);
135
+		wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
136
+		wp_localize_script('batch_file_runner_init', 'ee_job_i18n', 
137 137
 				array(
138 138
 					'download_and_redirecting' => sprintf( 
139 139
 							__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
140
-							'<a href="' . $_REQUEST['return_url' ] .'">',
140
+							'<a href="'.$_REQUEST['return_url'].'">',
141 141
 							'</a>' ),
142
-					'return_url' => $_REQUEST['return_url' ],
142
+					'return_url' => $_REQUEST['return_url'],
143 143
 				));
144 144
 	}
145 145
 	
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
151 151
 	 */
152 152
 	protected function _enqueue_batch_job_scripts_and_styles_and_start_job() {
153
-		wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) );
154
-		wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION );
155
-		wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' ));
153
+		wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery'));
154
+		wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION);
155
+		wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar'));
156 156
 		//just copy the bits of EE admin's eei18n that we need in the JS
157
-		wp_localize_script( 'batch_runner', 'eei18n', array( 'ajax_url' => WP_AJAX_URL, 'is_admin' => (bool)is_admin() ) );
158
-		$job_handler_classname = stripslashes( $_GET[ 'job_handler' ] );
157
+		wp_localize_script('batch_runner', 'eei18n', array('ajax_url' => WP_AJAX_URL, 'is_admin' => (bool) is_admin()));
158
+		$job_handler_classname = stripslashes($_GET['job_handler']);
159 159
 		$request_data = array_diff_key( 
160 160
 				$_REQUEST, 
161
-				array_flip( array( 'action',  'page', 'ee', 'batch' ) ) );
161
+				array_flip(array('action', 'page', 'ee', 'batch')) );
162 162
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
163 163
 		//eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
164
-		$job_response = $batch_runner->create_job( $job_handler_classname, $request_data );
164
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
165 165
 		//remember the response for later. We need it to display the page body
166 166
 		$this->_job_step_response = $job_response;
167 167
 		return $job_response;
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @param string $template
173 173
 	 * @return string
174 174
 	 */
175
-	public function override_template( $template ) {
176
-		if( isset( $_REQUEST[ 'espresso_batch' ] ) && isset( $_REQUEST[ 'batch' ] ) ) {
177
-			return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
175
+	public function override_template($template) {
176
+		if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
177
+			return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html';
178 178
 		}
179 179
 		return $template;
180 180
 	}
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	public function register_admin_pages() {
186 186
 		add_submenu_page( 
187 187
 			'', //parent slug. we don't want this to actually appear in the menu
188
-			__( 'Batch Job', 'event_espresso' ), //page title
188
+			__('Batch Job', 'event_espresso'), //page title
189 189
 			'n/a', //menu title
190 190
 			'read', //we want this page to actually be accessible to anyone,  
191 191
 			'espresso_batch', //menu slug
192
-			array( self::instance(), 'show_admin_page' )
192
+			array(self::instance(), 'show_admin_page')
193 193
 		);
194 194
 	}
195 195
 	
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function show_admin_page() { 
201 201
 		echo EEH_Template::locate_template( 
202
-			EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', 
203
-			array( 'batch_request_type' => $this->batch_request_type() )
202
+			EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', 
203
+			array('batch_request_type' => $this->batch_request_type())
204 204
 		);
205 205
 	}
206 206
 	
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 	 * Receives ajax calls for continuing a job
209 209
 	 */
210 210
 	public function batch_continue() {
211
-		$job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] );
211
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
212 212
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
213
-		$response_obj = $batch_runner->continue_job( $job_id);
214
-		$this->_return_json( $response_obj->to_array() );
213
+		$response_obj = $batch_runner->continue_job($job_id);
214
+		$this->_return_json($response_obj->to_array());
215 215
 	}
216 216
 	
217 217
 	/**
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	 * @return type
220 220
 	 */
221 221
 	public function batch_cleanup() {
222
-		$job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] );
222
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
223 223
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
224
-		$response_obj = $batch_runner->cleanup_job( $job_id );
225
-		$this->_return_json( $response_obj->to_array() );
224
+		$response_obj = $batch_runner->cleanup_job($job_id);
225
+		$this->_return_json($response_obj->to_array());
226 226
 	}
227 227
 	
228 228
 	
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 *	'isEEajax' => true,//indicates this is a response from EE
239 239
 	 * )
240 240
 	 */
241
-	protected function _return_json( $data ) {
241
+	protected function _return_json($data) {
242 242
 		$json = array(
243 243
 			'notices' => EE_Error::get_notices(),
244 244
 			'data' => $data,
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 
248 248
 
249 249
 		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
250
-		if ( NULL === error_get_last() || ! headers_sent() ) {
250
+		if (NULL === error_get_last() || ! headers_sent()) {
251 251
 			header('Content-Type: application/json; charset=UTF-8');
252 252
 		}
253
-        echo wp_json_encode( $json );
253
+        echo wp_json_encode($json);
254 254
 		exit();
255 255
 	}
256 256
 	
@@ -266,16 +266,16 @@  discard block
 block discarded – undo
266 266
 	 * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
267 267
 	 */
268 268
 	public function batch_request_type() {
269
-		if( $this->_batch_request_type === null ) {
270
-			if( isset( $_GET[ 'batch' ] ) ) {
271
-				if( $_GET[ 'batch' ] == self::batch_job ) {
269
+		if ($this->_batch_request_type === null) {
270
+			if (isset($_GET['batch'])) {
271
+				if ($_GET['batch'] == self::batch_job) {
272 272
 					$this->_batch_request_type = self::batch_job;
273
-				} elseif( $_GET[ 'batch' ] == self::batch_file_job ) {
273
+				} elseif ($_GET['batch'] == self::batch_file_job) {
274 274
 					$this->_batch_request_type = self::batch_file_job;
275 275
 				}
276 276
 			}
277 277
 			//if we didn't find that it was a batch request, indicate it wasn't
278
-			if( $this->_batch_request_type === null ) {
278
+			if ($this->_batch_request_type === null) {
279 279
 				$this->_batch_request_type = self::batch_not_job;
280 280
 			}
281 281
 		}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * Unnecessary
287 287
 	 * @param type $WP
288 288
 	 */
289
-	public function run( $WP ) {
289
+	public function run($WP) {
290 290
 		
291 291
 	}
292 292
 
Please login to merge, or discard this patch.
registration_form/templates/questions_main_meta_box.template.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -98,14 +98,14 @@
 block discarded – undo
98 98
 				</th>
99 99
 				<td>
100 100
 					<?php
101
-                        $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone;
102
-                        if( $disabled ){
103
-                            $disabled_attr =  'disabled="disabled"';
104
-						    $id =  '_disabled';
105
-                        } else {
106
-                            $disabled_attr = '';
107
-                            $id = '';
108
-                        }
101
+						$disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone;
102
+						if( $disabled ){
103
+							$disabled_attr =  'disabled="disabled"';
104
+							$id =  '_disabled';
105
+						} else {
106
+							$disabled_attr = '';
107
+							$id = '';
108
+						}
109 109
 
110 110
 						echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr );
111 111
 						if( $disabled ) { ?>
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 //does question have any answers? cause if it does then we have to disable type
16 16
 $has_answers = $question->has_answers();
17 17
 
18
-if ( $QST_system === 'country' ) {
18
+if ($QST_system === 'country') {
19 19
 	echo EEH_HTML::div(
20
-		EEH_HTML::h4( '<span class="dashicons dashicons-info"></span>' . esc_html__( 'Did you know...', 'event_espresso' ) ) .
20
+		EEH_HTML::h4('<span class="dashicons dashicons-info"></span>'.esc_html__('Did you know...', 'event_espresso')).
21 21
 		EEH_HTML::p(
22 22
 			esc_html__(
23 23
 				'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.',
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		<tbody>
35 35
 			<tr>
36 36
 				<th>
37
-					<label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?>
37
+					<label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?>
38 38
 				</th>
39 39
 				<td>
40 40
 					<input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/>
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
 
45 45
 			<tr>
46 46
 				<th>
47
-					<label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?>
47
+					<label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?>
48 48
 				</th>
49 49
 				<td>
50 50
 					<?php
51
-						$disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : '';
52
-						$id =  ! empty( $QST_system ) ? '_disabled' : '';
51
+						$disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : '';
52
+						$id = ! empty($QST_system) ? '_disabled' : '';
53 53
 					?>
54 54
 					<input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled_attr?>/>
55 55
 					<input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" />
56
-					<?php if ( ! empty( $QST_system )) { ?>
56
+					<?php if ( ! empty($QST_system)) { ?>
57 57
 						<input type="hidden"  id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/>
58 58
 					<?php } ?>
59 59
 					<br/>
60 60
 					<p class="description">
61
-					<?php if ( ! empty( $QST_system )) { ?>
61
+					<?php if ( ! empty($QST_system)) { ?>
62 62
 					<span class="description" style="color:#D54E21;">
63
-						<?php esc_html_e('System question! This field cannot be changed.','event_espresso')?>
63
+						<?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?>
64 64
 					</span>
65 65
 					<?php } ?>
66 66
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 
71 71
 			<tr>
72 72
 				<th>
73
-					<label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?>
73
+					<label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?>
74 74
 				</th>
75 75
 				<td>
76 76
 					<?php
77
-						$disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : '';
78
-						$id =  ! empty( $QST_system ) ? '_disabled' : '';
77
+						$disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : '';
78
+						$id = ! empty($QST_system) ? '_disabled' : '';
79 79
 						$admin_only = $question->get('QST_admin_only');
80
-						$checked = !empty( $admin_only ) ? ' checked="checked"' : '';
80
+						$checked = ! empty($admin_only) ? ' checked="checked"' : '';
81 81
 					?>
82 82
 					<input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled_attr; echo $checked; ?>/>
83 83
 					<br/>
84 84
 					<p class="description">
85
-					<?php if ( ! empty( $QST_system )) { ?>
85
+					<?php if ( ! empty($QST_system)) { ?>
86 86
 					<span class="description" style="color:#D54E21;">
87
-						<?php esc_html_e('System question! This field cannot be changed.','event_espresso')?>
87
+						<?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?>
88 88
 					</span>
89 89
 					<?php } ?>
90 90
 
@@ -94,28 +94,28 @@  discard block
 block discarded – undo
94 94
 
95 95
 			<tr>
96 96
 				<th>
97
-					<label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?>
97
+					<label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?>
98 98
 				</th>
99 99
 				<td>
100 100
 					<?php
101
-                        $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone;
102
-                        if( $disabled ){
103
-                            $disabled_attr =  'disabled="disabled"';
104
-						    $id =  '_disabled';
101
+                        $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone;
102
+                        if ($disabled) {
103
+                            $disabled_attr = 'disabled="disabled"';
104
+						    $id = '_disabled';
105 105
                         } else {
106 106
                             $disabled_attr = '';
107 107
                             $id = '';
108 108
                         }
109 109
 
110
-						echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr );
111
-						if( $disabled ) { ?>
110
+						echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled_attr);
111
+						if ($disabled) { ?>
112 112
 							<input type="hidden"  id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/>
113 113
 						<?php
114
-							$explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso');
115
-						}else{
116
-							$explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso');
114
+							$explanatory_text = esc_html__('System question! This field cannot be changed.', 'event_espresso');
115
+						} else {
116
+							$explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso');
117 117
 						}
118
-						if ( $disabled || $has_answers ) { ?>
118
+						if ($disabled || $has_answers) { ?>
119 119
 							<p><span class="description" style="color:#D54E21;">
120 120
 								<?php echo $explanatory_text; ?>
121 121
 							</span></p>
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 			<tr id="text_input_question_options">
129 129
 				<th>
130 130
 					<label>
131
-						<?php esc_html_e( 'Maximum Allowed Response Size', 'event_espresso' );?>
131
+						<?php esc_html_e('Maximum Allowed Response Size', 'event_espresso'); ?>
132 132
 					</label>
133 133
 				</th>
134 134
 				<td>
135
-					<input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1">
135
+					<input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1">
136 136
 					<p>
137 137
 						<span class="description">
138
-							<?php esc_html_e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?>
138
+							<?php esc_html_e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?>
139 139
 						</span>
140 140
 					</p>
141
-					<?php if ( $QST_system ) { ?>
141
+					<?php if ($QST_system) { ?>
142 142
 					<p>
143 143
 						<span class="description" style="color:#D54E21;">
144 144
 							<?php printf(
145
-									esc_html__( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ),
146
-									$max_max );?>
145
+									esc_html__('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'),
146
+									$max_max ); ?>
147 147
 						</span>
148 148
 					</p>
149 149
 					<?php } ?>
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			<tr id="question_options">
153 153
 				<th>
154 154
 					<label>
155
-						<?php esc_html_e('Answer Options','event_espresso')?>
155
+						<?php esc_html_e('Answer Options', 'event_espresso')?>
156 156
 					</label>
157 157
 				</th>
158 158
 				<td>
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 						<thead>
162 162
 							<tr>
163 163
 								<th class="option-value-header">
164
-									<?php esc_html_e('Value','event_espresso')?>
164
+									<?php esc_html_e('Value', 'event_espresso')?>
165 165
 								</th>
166 166
 								<th class="option-desc-header">
167
-									<?php esc_html_e('Description (optional, only shown on registration form)','event_espresso')?>
167
+									<?php esc_html_e('Description (optional, only shown on registration form)', 'event_espresso')?>
168 168
 								</th>
169 169
 								<th>
170 170
 								</th>
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 							</tr>
188 188
 
189 189
 							<?php
190
-							$count=0;
190
+							$count = 0;
191 191
 							$question_options = $question->options();
192
-							if ( ! empty( $question_options )) {
193
-								foreach( $question_options as $option_id => $option ) {
194
-									$disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"'  : '';
192
+							if ( ! empty($question_options)) {
193
+								foreach ($question_options as $option_id => $option) {
194
+									$disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : '';
195 195
 							?>
196 196
 								<tr class="question-option ee-options-sortable">
197 197
 									<td class="option-value-cell">
198 198
 										<input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>">
199 199
 										<input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php  $option->f('QSO_value')?>"<?php echo $disabled_attr; ?>>
200
-										<?php if ( $has_answers ) : ?>
200
+										<?php if ($has_answers) : ?>
201 201
 											<input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" >
202 202
 										<?php endif; ?>
203 203
 									</td>
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 										<input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>">
206 206
 									</td>
207 207
 									<td>
208
-										<?php if ( ! $option->system() ) { ?>
208
+										<?php if ( ! $option->system()) { ?>
209 209
 											<span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span>
210 210
 										<?php } ?>
211 211
                                         <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span>
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 					</table>
245 245
 
246 246
 					<a id="new-question-option" class="button" style="margin:0 0 1em 3px;">
247
-						<?php esc_html_e('Add Another Answer Option','event_espresso')?>
247
+						<?php esc_html_e('Add Another Answer Option', 'event_espresso')?>
248 248
 					</a><br/>
249 249
 
250 250
 					<p class="description">
251
-						<?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?>
251
+						<?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?>
252 252
 					</p>
253
-					<?php if ( $has_answers ) : ?>
253
+					<?php if ($has_answers) : ?>
254 254
 					<p class="description" style="color:#D54E21;">
255 255
 							<?php esc_html_e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question.  If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes.  This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?>
256 256
 					</p>
@@ -261,32 +261,32 @@  discard block
 block discarded – undo
261 261
 
262 262
 			<tr>
263 263
 				<th>
264
-					<label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?>
264
+					<label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?>
265 265
 				</th>
266 266
 				<td>
267 267
 					<?php
268
-					$system_required = array( 'fname', 'email' );
269
-					$disabled_attr = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : '';
268
+					$system_required = array('fname', 'email');
269
+					$disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : '';
270 270
 					$required_on = $question->get('QST_admin_only');
271 271
 					$show_required_msg = $required_on ? '' : ' display:none;';
272
-					$disabled_attr = $required_on || ! empty( $disabled_attr ) ? ' disabled="disabled"' : '';
273
-					$id = ! empty( $disabled_attr ) && in_array( $QST_system, $system_required) ? '_disabled' : '';
274
-					$requiredOptions=array(
275
-						array( 'text'=> esc_html__( 'Optional', 'event_espresso' ), 'id'=>0 ),
276
-						array( 'text'=> esc_html__( 'Required', 'event_espresso' ), 'id'=>1 )
272
+					$disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : '';
273
+					$id = ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : '';
274
+					$requiredOptions = array(
275
+						array('text'=> esc_html__('Optional', 'event_espresso'), 'id'=>0),
276
+						array('text'=> esc_html__('Required', 'event_espresso'), 'id'=>1)
277 277
 					);
278
-					echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled_attr );
278
+					echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled_attr);
279 279
 					?>
280 280
 						<p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>">
281
-						<?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?>
281
+						<?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?>
282 282
 						</span></p>
283 283
 						<p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;">
284
-							<?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?>
284
+							<?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?>
285 285
 						</span></p>
286
-					<?php if (! empty( $disabled_attr ) && in_array( $QST_system, $system_required ) ) { ?>
286
+					<?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
287 287
 						<input type="hidden"  id="QST_required" name="QST_required" value="1"/>
288 288
 						<p><span class="description" style="color:#D54E21;">
289
-						<?php esc_html_e('System question! This field cannot be changed.','event_espresso')?>
289
+						<?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?>
290 290
 					</span></p>
291 291
 					<?php } ?>
292 292
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 			<tr>
297 297
 				<th>
298
-					<label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?>
298
+					<label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?>
299 299
 				</th>
300 300
 				<td>
301 301
 					<input type="text" maxlength="100" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php  $question->f('QST_required_text')?>"/>
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@
 block discarded – undo
112 112
 							<input type="hidden"  id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/>
113 113
 						<?php
114 114
 							$explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso');
115
-						}else{
115
+						} else{
116 116
 							$explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso');
117 117
 						}
118 118
 						if ( $disabled || $has_answers ) { ?>
Please login to merge, or discard this patch.