Completed
Pull Request — master (#193)
by Michael
11:57
created
public/template_tags.php 1 patch
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
  * @param int | \EE_Event $event
28 28
  * @return bool
29 29
  */
30
-function is_espresso_event( $event = NULL ) {
31
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
30
+function is_espresso_event($event = NULL) {
31
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
32 32
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
33
-		$event = EEH_Event_View::get_event( $event );
33
+		$event = EEH_Event_View::get_event($event);
34 34
 		// do we have a valid event ?
35
-		return $event instanceof EE_Event  ? TRUE : FALSE;
35
+		return $event instanceof EE_Event ? TRUE : FALSE;
36 36
 	}
37 37
 	return FALSE;
38 38
 }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  * @return bool
45 45
  */
46 46
 function is_espresso_event_single() {
47
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
47
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
48 48
 		global $wp_query;
49 49
 		// return conditionals set by CPTs
50 50
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  * @return bool
60 60
  */
61 61
 function is_espresso_event_archive() {
62
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
62
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
63 63
 		global $wp_query;
64 64
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
65 65
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  * @return bool
74 74
  */
75 75
 function is_espresso_event_taxonomy() {
76
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
76
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
77 77
 		global $wp_query;
78 78
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
79 79
 	}
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
  * @param int | \EE_Venue $venue
88 88
  * @return bool
89 89
  */
90
-function is_espresso_venue( $venue = NULL ) {
91
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
90
+function is_espresso_venue($venue = NULL) {
91
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
92 92
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
93
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
93
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
94 94
 		// do we have a valid event ?
95 95
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
96 96
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function is_espresso_venue_single() {
107
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
107
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
108 108
 		global $wp_query;
109 109
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
110 110
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
  * @return bool
119 119
  */
120 120
 function is_espresso_venue_archive() {
121
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
121
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
122 122
 		global $wp_query;
123 123
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
124 124
 	}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  * @return bool
133 133
  */
134 134
 function is_espresso_venue_taxonomy() {
135
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
135
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
136 136
 		global $wp_query;
137 137
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
138 138
 	}
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
  * @param $conditional_tag
147 147
  * @return bool
148 148
  */
149
-function can_use_espresso_conditionals( $conditional_tag ) {
150
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
149
+function can_use_espresso_conditionals($conditional_tag) {
150
+	if ( ! did_action('AHEE__EE_System__initialize')) {
151 151
 		EE_Error::doing_it_wrong(
152 152
 			__FUNCTION__,
153 153
 			sprintf(
154
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
154
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
155 155
 				$conditional_tag
156 156
 			),
157 157
 			'4.4.0'
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 
167 167
 /*************************** Event Queries ***************************/
168 168
 
169
-if ( ! function_exists( 'espresso_get_events' )) {
169
+if ( ! function_exists('espresso_get_events')) {
170 170
 	/**
171 171
 	 * 	espresso_get_events
172 172
 	 * @param array $params
173 173
 	 * @return array
174 174
 	 */
175
-	function espresso_get_events( $params = array() ) {
175
+	function espresso_get_events($params = array()) {
176 176
 		//set default params
177 177
 		$default_espresso_events_params = array(
178 178
 			'limit' => 10,
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
 			'sort' => 'ASC'
184 184
 		);
185 185
 		// allow the defaults to be filtered
186
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
186
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
187 187
 		// grab params and merge with defaults, then extract
188
-		$params = array_merge( $default_espresso_events_params, $params );
188
+		$params = array_merge($default_espresso_events_params, $params);
189 189
 		// run the query
190
-		$events_query = new EE_Event_List_Query( $params );
190
+		$events_query = new EE_Event_List_Query($params);
191 191
 		// assign results to a variable so we can return it
192 192
 		$events = $events_query->have_posts() ? $events_query->posts : array();
193 193
 		// but first reset the query and postdata
194 194
 		wp_reset_query();
195 195
 		wp_reset_postdata();
196 196
 		EED_Events_Archive::remove_all_events_archive_filters();
197
-		unset( $events_query );
197
+		unset($events_query);
198 198
 		return $events;
199 199
 	}
200 200
 }
@@ -208,32 +208,32 @@  discard block
 block discarded – undo
208 208
  * espresso_load_ticket_selector
209 209
  */
210 210
 function espresso_load_ticket_selector() {
211
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
211
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
212 212
 }
213 213
 
214
-if ( ! function_exists( 'espresso_ticket_selector' )) {
214
+if ( ! function_exists('espresso_ticket_selector')) {
215 215
 	/**
216 216
 	 * espresso_ticket_selector
217 217
 	 * @param null $event
218 218
 	 */
219
-	function espresso_ticket_selector( $event = NULL ) {
220
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
219
+	function espresso_ticket_selector($event = NULL) {
220
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
221 221
 			espresso_load_ticket_selector();
222
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
222
+			echo EED_Ticket_Selector::display_ticket_selector($event);
223 223
 		}
224 224
 	}
225 225
 }
226 226
 
227 227
 
228
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
228
+	if ( ! function_exists('espresso_view_details_btn')) {
229 229
 	/**
230 230
 	 * espresso_view_details_btn
231 231
 	 * @param null $event
232 232
 	 */
233
-	function espresso_view_details_btn( $event = NULL ) {
234
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
233
+	function espresso_view_details_btn($event = NULL) {
234
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
235 235
 			espresso_load_ticket_selector();
236
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
236
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
237 237
 		}
238 238
 	}
239 239
 }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 /*************************** EEH_Event_View ***************************/
245 245
 
246
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
246
+if ( ! function_exists('espresso_load_event_list_assets')) {
247 247
 	/**
248 248
 	 * espresso_load_event_list_assets
249 249
 	 * ensures that event list styles and scripts are loaded
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	function espresso_load_event_list_assets() {
254 254
 		$event_list = EED_Events_Archive::instance();
255
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
256
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
255
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
256
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
257 257
 	}
258 258
 }
259 259
 
260 260
 
261
-if ( ! function_exists( 'espresso_event_reg_button' )) {
261
+if ( ! function_exists('espresso_event_reg_button')) {
262 262
 	/**
263 263
 	 * espresso_event_reg_button
264 264
 	 * returns the "Register Now" button if event is active,
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param bool $EVT_ID
271 271
 	 * @return string
272 272
 	 */
273
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
274
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
275
-		switch ( $event_status ) {
273
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
274
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
275
+		switch ($event_status) {
276 276
 			case EE_Datetime::sold_out :
277 277
 				$btn_text = __('Sold Out', 'event_espresso');
278 278
 				$class = 'ee-pink';
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 			case EE_Datetime::upcoming :
289 289
 			case EE_Datetime::active :
290 290
 			default :
291
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
291
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
292 292
 				$class = 'ee-green';
293 293
 		}
294
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
294
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
295 295
 			$btn_text = $btn_text_if_inactive;
296 296
 			$class = 'ee-grey';
297 297
 		}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
 
307 307
 
308
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
308
+if ( ! function_exists('espresso_display_ticket_selector')) {
309 309
 	/**
310 310
 	 * espresso_display_ticket_selector
311 311
 	 * whether or not to display the Ticket Selector for an event
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	 * @param bool $EVT_ID
314 314
 	 * @return boolean
315 315
 	 */
316
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
317
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
316
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
317
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
318 318
 	}
319 319
 }
320 320
 
321 321
 
322 322
 
323
-if ( ! function_exists( 'espresso_event_status_banner' )) {
323
+if ( ! function_exists('espresso_event_status_banner')) {
324 324
 	/**
325 325
 	 * espresso_event_status
326 326
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 	 * @param bool $EVT_ID
329 329
 	 * @return string
330 330
 	 */
331
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
332
-		return EEH_Event_View::event_status( $EVT_ID );
331
+	function espresso_event_status_banner($EVT_ID = FALSE) {
332
+		return EEH_Event_View::event_status($EVT_ID);
333 333
 	}
334 334
 }
335 335
 
336 336
 
337
-if ( ! function_exists( 'espresso_event_status' )) {
337
+if ( ! function_exists('espresso_event_status')) {
338 338
 	/**
339 339
 	 * espresso_event_status
340 340
 	 * returns the event status if it is sold out, expired, or inactive
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 	 * @param bool $echo
344 344
 	 * @return string
345 345
 	 */
346
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
347
-		if ( $echo ) {
348
-			echo EEH_Event_View::event_active_status( $EVT_ID );
346
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
347
+		if ($echo) {
348
+			echo EEH_Event_View::event_active_status($EVT_ID);
349 349
 			return '';
350 350
 		}
351
-		return EEH_Event_View::event_active_status( $EVT_ID );
351
+		return EEH_Event_View::event_active_status($EVT_ID);
352 352
 	}
353 353
 }
354 354
 
355 355
 
356
-if ( ! function_exists( 'espresso_event_categories' )) {
356
+if ( ! function_exists('espresso_event_categories')) {
357 357
 	/**
358 358
 	 * espresso_event_categories
359 359
 	 * returns the terms associated with an event
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	 * @param bool $echo
364 364
 	 * @return string
365 365
 	 */
366
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
367
-		if ( $echo ) {
368
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
366
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
367
+		if ($echo) {
368
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
369 369
 			return '';
370 370
 		}
371
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
371
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
372 372
 	}
373 373
 }
374 374
 
375 375
 
376
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
376
+if ( ! function_exists('espresso_event_tickets_available')) {
377 377
 	/**
378 378
 	 * espresso_event_tickets_available
379 379
 	 * returns the ticket types available for purchase for an event
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
 	 * @param bool $format
384 384
 	 * @return string
385 385
 	 */
386
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
387
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
388
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
386
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
387
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
388
+		if (is_array($tickets) && ! empty($tickets)) {
389 389
 			// if formatting then $html will be a string, else it will be an array of ticket objects
390
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
391
-			foreach ( $tickets as $ticket ) {
392
-				if ( $ticket instanceof EE_Ticket ) {
393
-					if ( $format ) {
394
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
395
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
390
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
391
+			foreach ($tickets as $ticket) {
392
+				if ($ticket instanceof EE_Ticket) {
393
+					if ($format) {
394
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
395
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
396 396
 						$html .= '</li>';
397 397
 					} else {
398 398
 						$html[] = $ticket;
399 399
 					}
400 400
 				}
401 401
 			}
402
-			if ( $format ) {
402
+			if ($format) {
403 403
 				$html .= '</ul>';
404 404
 			}
405
-			if ( $echo && ! $format ) {
405
+			if ($echo && ! $format) {
406 406
 				echo $html;
407 407
 				return '';
408 408
 			}
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	}
413 413
 }
414 414
 
415
-if ( ! function_exists( 'espresso_event_date_obj' )) {
415
+if ( ! function_exists('espresso_event_date_obj')) {
416 416
 	/**
417 417
 	 * espresso_event_date_obj
418 418
 	 * returns the primary date object for an event
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	 * @param bool $EVT_ID
421 421
 	 * @return object
422 422
 	 */
423
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
424
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
423
+	function espresso_event_date_obj($EVT_ID = FALSE) {
424
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
425 425
 	}
426 426
 }
427 427
 
428 428
 
429
-if ( ! function_exists( 'espresso_event_date' )) {
429
+if ( ! function_exists('espresso_event_date')) {
430 430
 	/**
431 431
 	 * espresso_event_date
432 432
 	 * returns the primary date for an event
@@ -437,22 +437,22 @@  discard block
 block discarded – undo
437 437
 	 * @param bool $echo
438 438
 	 * @return string
439 439
 	 */
440
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
441
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
442
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
443
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
444
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
445
-		if($echo){
446
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
440
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
441
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
442
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
443
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
444
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
445
+		if ($echo) {
446
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
447 447
 			return '';
448 448
 		}
449
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
449
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
450 450
 
451 451
 	}
452 452
 }
453 453
 
454 454
 
455
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
455
+if ( ! function_exists('espresso_list_of_event_dates')) {
456 456
 	/**
457 457
 	 * espresso_list_of_event_dates
458 458
 	 * returns a unordered list of dates for an event
@@ -467,53 +467,53 @@  discard block
 block discarded – undo
467 467
 	 * @param null   $limit
468 468
 	 * @return string
469 469
 	 */
470
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
471
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
472
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
473
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
474
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
475
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
476
-		if ( ! $format ) {
477
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
470
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
471
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
472
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
473
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
474
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
475
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
476
+		if ( ! $format) {
477
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
478 478
 		}
479 479
 		//d( $datetimes );
480
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
480
+		if (is_array($datetimes) && ! empty($datetimes)) {
481 481
 			global $post;
482
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : '';
483
-			foreach ( $datetimes as $datetime ) {
484
-				if ( $datetime instanceof EE_Datetime ) {
485
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
486
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
482
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : '';
483
+			foreach ($datetimes as $datetime) {
484
+				if ($datetime instanceof EE_Datetime) {
485
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
486
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
487 487
 					
488 488
 					$datetime_name = $datetime->name();
489
-					if (!empty( $datetime_name )) {
490
-						$html .= '<strong class="ee-event-datetime-name'.($add_breaks ? ' ee-break-after' : '').'">' . $datetime_name . '</strong>';
489
+					if ( ! empty($datetime_name)) {
490
+						$html .= '<strong class="ee-event-datetime-name'.($add_breaks ? ' ee-break-after' : '').'">'.$datetime_name.'</strong>';
491 491
 					}
492 492
 					
493 493
 					$html .= '<span class="ee-event-datetime-date">';
494
-					$html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format );
494
+					$html .= '<span class="dashicons dashicons-calendar"></span>'.$datetime->date_range($date_format);
495 495
 					$html .= '</span>';
496 496
 					
497 497
 					$html .= '<span class="ee-event-datetime-time">';
498
-					$html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format );
498
+					$html .= '<span class="dashicons dashicons-clock"></span>'.$datetime->time_range($time_format);
499 499
 					$html .= '</span>';
500 500
 					
501 501
 					$datetime_description = $datetime->description();
502
-					if (!empty( $datetime_description )) {
502
+					if ( ! empty($datetime_description)) {
503 503
 						$html .= '<span class="ee-event-datetime-description'.($add_breaks ? ' ee-break-before' : '').'">';
504
-						$html .= ' - ' . $datetime_description;
504
+						$html .= ' - '.$datetime_description;
505 505
 						$html .= '</span>';
506 506
 					}
507 507
 					
508
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
508
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
509 509
 					$html .= '</li>';
510 510
 				}
511 511
 			}
512 512
 			$html .= $format ? '</ul>' : '';
513 513
 		} else {
514
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
514
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
515 515
 		}
516
-		if ( $echo ) {
516
+		if ($echo) {
517 517
 			echo $html;
518 518
 			return '';
519 519
 		}
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 }
523 523
 
524 524
 
525
-if ( ! function_exists( 'espresso_event_end_date' )) {
525
+if ( ! function_exists('espresso_event_end_date')) {
526 526
 	/**
527 527
 	 * espresso_event_end_date
528 528
 	 * returns the last date for an event
@@ -533,20 +533,20 @@  discard block
 block discarded – undo
533 533
 	 * @param bool   $echo
534 534
 	 * @return string
535 535
 	 */
536
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
537
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
538
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
539
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
540
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
541
-		if($echo){
542
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
536
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
537
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
538
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
539
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
540
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
541
+		if ($echo) {
542
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
543 543
 			return '';
544 544
 		}
545
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
545
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
546 546
 	}
547 547
 }
548 548
 
549
-if ( ! function_exists( 'espresso_event_date_range' )) {
549
+if ( ! function_exists('espresso_event_date_range')) {
550 550
 	/**
551 551
 	 * espresso_event_date_range
552 552
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -559,31 +559,31 @@  discard block
 block discarded – undo
559 559
 	 * @param bool   $echo
560 560
 	 * @return string
561 561
 	 */
562
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
562
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
563 563
 		// set and filter date and time formats when a range is returned
564
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
565
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
564
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
565
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
566 566
 		// get the start and end date with NO time portion
567
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
568
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
567
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
568
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
569 569
 		// now we can determine if date range spans more than one day
570
-		if ( $the_event_date != $the_event_end_date ) {
571
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
572
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
570
+		if ($the_event_date != $the_event_end_date) {
571
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
572
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
573 573
 			$html = sprintf(
574
-				__( '%1$s - %2$s', 'event_espresso' ),
575
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
576
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
574
+				__('%1$s - %2$s', 'event_espresso'),
575
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
576
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
577 577
 			);
578 578
 		} else {
579 579
 			// set and filter date and time formats when only a single datetime is returned
580
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
581
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
582
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
583
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
584
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
580
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
581
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
582
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
583
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
584
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
585 585
 		}
586
-		if ( $echo ) {
586
+		if ($echo) {
587 587
 			echo $html;
588 588
 			return '';
589 589
 		}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 }
593 593
 
594 594
 
595
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
595
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
596 596
 	/**
597 597
 	 * espresso_event_date_as_calendar_page
598 598
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -600,15 +600,15 @@  discard block
 block discarded – undo
600 600
 	 * @param bool $EVT_ID
601 601
 	 * @return string
602 602
 	 */
603
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
604
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
603
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
604
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
605 605
 	}
606 606
 }
607 607
 
608 608
 
609 609
 
610 610
 
611
-if ( ! function_exists( 'espresso_event_link_url' )) {
611
+if ( ! function_exists('espresso_event_link_url')) {
612 612
 	/**
613 613
 	 * espresso_event_link_url
614 614
 	 *
@@ -616,18 +616,18 @@  discard block
 block discarded – undo
616 616
 	 * @param bool $echo
617 617
 	 * @return string
618 618
 	 */
619
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
620
-		if ( $echo ) {
621
-			echo EEH_Event_View::event_link_url( $EVT_ID );
619
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
620
+		if ($echo) {
621
+			echo EEH_Event_View::event_link_url($EVT_ID);
622 622
 			return '';
623 623
 		}
624
-		return EEH_Event_View::event_link_url( $EVT_ID );
624
+		return EEH_Event_View::event_link_url($EVT_ID);
625 625
 	}
626 626
 }
627 627
 
628 628
 
629 629
 
630
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
630
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
631 631
 	/**
632 632
 	 *    espresso_event_has_content_or_excerpt
633 633
 	 *
@@ -635,15 +635,15 @@  discard block
 block discarded – undo
635 635
 	 * @param bool $EVT_ID
636 636
 	 * @return    boolean
637 637
 	 */
638
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
639
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
638
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
639
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
640 640
 	}
641 641
 }
642 642
 
643 643
 
644 644
 
645 645
 
646
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
646
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
647 647
 	/**
648 648
 	 * espresso_event_content_or_excerpt
649 649
 	 *
@@ -652,18 +652,18 @@  discard block
 block discarded – undo
652 652
 	 * @param bool $echo
653 653
 	 * @return string
654 654
 	 */
655
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
656
-		if ( $echo ) {
657
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
655
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
656
+		if ($echo) {
657
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
658 658
 			return '';
659 659
 		}
660
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
660
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
661 661
 	}
662 662
 }
663 663
 
664 664
 
665 665
 
666
-if ( ! function_exists( 'espresso_event_phone' )) {
666
+if ( ! function_exists('espresso_event_phone')) {
667 667
 	/**
668 668
 	 * espresso_event_phone
669 669
 	 *
@@ -671,18 +671,18 @@  discard block
 block discarded – undo
671 671
 	 * @param bool $echo
672 672
 	 * @return string
673 673
 	 */
674
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
675
-		if ( $echo ) {
676
-			echo EEH_Event_View::event_phone( $EVT_ID );
674
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
675
+		if ($echo) {
676
+			echo EEH_Event_View::event_phone($EVT_ID);
677 677
 			return '';
678 678
 		}
679
-		return EEH_Event_View::event_phone( $EVT_ID );
679
+		return EEH_Event_View::event_phone($EVT_ID);
680 680
 	}
681 681
 }
682 682
 
683 683
 
684 684
 
685
-if ( ! function_exists( 'espresso_edit_event_link' )) {
685
+if ( ! function_exists('espresso_edit_event_link')) {
686 686
 	/**
687 687
 	 * espresso_edit_event_link
688 688
 	 * returns a link to edit an event
@@ -691,39 +691,39 @@  discard block
 block discarded – undo
691 691
 	 * @param bool $echo
692 692
 	 * @return string
693 693
 	 */
694
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
695
-		if ( $echo ) {
696
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
694
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
695
+		if ($echo) {
696
+			echo EEH_Event_View::edit_event_link($EVT_ID);
697 697
 			return '';
698 698
 		}
699
-		return EEH_Event_View::edit_event_link( $EVT_ID );
699
+		return EEH_Event_View::edit_event_link($EVT_ID);
700 700
 	}
701 701
 }
702 702
 
703 703
 
704
-if ( ! function_exists( 'espresso_organization_name' )) {
704
+if ( ! function_exists('espresso_organization_name')) {
705 705
 	/**
706 706
 	 * espresso_organization_name
707 707
 	 * @param bool $echo
708 708
 	 * @return string
709 709
 	 */
710 710
 	function espresso_organization_name($echo = TRUE) {
711
-		if($echo){
712
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
711
+		if ($echo) {
712
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
713 713
 			return '';
714 714
 		}
715
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
715
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
716 716
 	}
717 717
 }
718 718
 
719
-if ( ! function_exists( 'espresso_organization_address' )) {
719
+if ( ! function_exists('espresso_organization_address')) {
720 720
 	/**
721 721
 	 * espresso_organization_address
722 722
 	 * @param string $type
723 723
 	 * @return string
724 724
 	 */
725
-	function espresso_organization_address( $type = 'inline' ) {
726
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
725
+	function espresso_organization_address($type = 'inline') {
726
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
727 727
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
728 728
 				EE_Registry::instance()->CFG->organization->address_1,
729 729
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -732,129 +732,129 @@  discard block
 block discarded – undo
732 732
 				EE_Registry::instance()->CFG->organization->zip,
733 733
 				EE_Registry::instance()->CFG->organization->CNT_ISO
734 734
 			);
735
-			return EEH_Address::format( $address, $type );
735
+			return EEH_Address::format($address, $type);
736 736
 		}
737 737
 		return '';
738 738
 	}
739 739
 }
740 740
 
741
-if ( ! function_exists( 'espresso_organization_email' )) {
741
+if ( ! function_exists('espresso_organization_email')) {
742 742
 	/**
743 743
 	 * espresso_organization_email
744 744
 	 * @param bool $echo
745 745
 	 * @return string
746 746
 	 */
747
-	function espresso_organization_email( $echo = TRUE ) {
748
-		if($echo){
749
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
747
+	function espresso_organization_email($echo = TRUE) {
748
+		if ($echo) {
749
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
750 750
 			return '';
751 751
 		}
752
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
752
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
753 753
 	}
754 754
 }
755 755
 
756
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
756
+if ( ! function_exists('espresso_organization_logo_url')) {
757 757
 	/**
758 758
 	 * espresso_organization_logo_url
759 759
 	 * @param bool $echo
760 760
 	 * @return string
761 761
 	 */
762
-	function espresso_organization_logo_url( $echo = TRUE ) {
763
-		if($echo){
764
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
762
+	function espresso_organization_logo_url($echo = TRUE) {
763
+		if ($echo) {
764
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
765 765
 			return '';
766 766
 		}
767
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
767
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
768 768
 	}
769 769
 }
770 770
 
771
-if ( ! function_exists( 'espresso_organization_facebook' )) {
771
+if ( ! function_exists('espresso_organization_facebook')) {
772 772
 	/**
773 773
 	 * espresso_organization_facebook
774 774
 	 * @param bool $echo
775 775
 	 * @return string
776 776
 	 */
777
-	function espresso_organization_facebook( $echo = TRUE ) {
778
-		if($echo){
779
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
777
+	function espresso_organization_facebook($echo = TRUE) {
778
+		if ($echo) {
779
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
780 780
 			return '';
781 781
 		}
782
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
782
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
783 783
 	}
784 784
 }
785 785
 
786
-if ( ! function_exists( 'espresso_organization_twitter' )) {
786
+if ( ! function_exists('espresso_organization_twitter')) {
787 787
 	/**
788 788
 	 * espresso_organization_twitter
789 789
 	 * @param bool $echo
790 790
 	 * @return string
791 791
 	 */
792
-	function espresso_organization_twitter( $echo = TRUE ) {
793
-		if($echo){
794
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
792
+	function espresso_organization_twitter($echo = TRUE) {
793
+		if ($echo) {
794
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
795 795
 			return '';
796 796
 		}
797
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
797
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
798 798
 	}
799 799
 }
800 800
 
801
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
801
+if ( ! function_exists('espresso_organization_linkedin')) {
802 802
 	/**
803 803
 	 * espresso_organization_linkedin
804 804
 	 * @param bool $echo
805 805
 	 * @return string
806 806
 	 */
807
-	function espresso_organization_linkedin( $echo = TRUE ) {
808
-		if($echo){
809
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
807
+	function espresso_organization_linkedin($echo = TRUE) {
808
+		if ($echo) {
809
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
810 810
 			return '';
811 811
 		}
812
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
812
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
813 813
 	}
814 814
 }
815 815
 
816
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
816
+if ( ! function_exists('espresso_organization_pinterest')) {
817 817
 	/**
818 818
 	 * espresso_organization_pinterest
819 819
 	 * @param bool $echo
820 820
 	 * @return string
821 821
 	 */
822
-	function espresso_organization_pinterest( $echo = TRUE ) {
823
-		if($echo){
824
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
822
+	function espresso_organization_pinterest($echo = TRUE) {
823
+		if ($echo) {
824
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
825 825
 			return '';
826 826
 		}
827
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
827
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
828 828
 	}
829 829
 }
830 830
 
831
-if ( ! function_exists( 'espresso_organization_google' )) {
831
+if ( ! function_exists('espresso_organization_google')) {
832 832
 	/**
833 833
 	 * espresso_organization_google
834 834
 	 * @param bool $echo
835 835
 	 * @return string
836 836
 	 */
837
-	function espresso_organization_google( $echo = TRUE ) {
838
-		if($echo){
839
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
837
+	function espresso_organization_google($echo = TRUE) {
838
+		if ($echo) {
839
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
840 840
 			return '';
841 841
 		}
842
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
842
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
843 843
 	}
844 844
 }
845 845
 
846
-if ( ! function_exists( 'espresso_organization_instagram' )) {
846
+if ( ! function_exists('espresso_organization_instagram')) {
847 847
 	/**
848 848
 	 * espresso_organization_instagram
849 849
 	 * @param bool $echo
850 850
 	 * @return string
851 851
 	 */
852
-	function espresso_organization_instagram( $echo = TRUE ) {
853
-		if($echo){
854
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
852
+	function espresso_organization_instagram($echo = TRUE) {
853
+		if ($echo) {
854
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
855 855
 			return '';
856 856
 		}
857
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
857
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
858 858
 	}
859 859
 }
860 860
 
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 
865 865
 
866 866
 
867
-if ( ! function_exists( 'espresso_event_venues' )) {
867
+if ( ! function_exists('espresso_event_venues')) {
868 868
 	/**
869 869
 	 * espresso_event_venues
870 870
 	 *
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 
879 879
 
880 880
 
881
-if ( ! function_exists( 'espresso_venue_id' )) {
881
+if ( ! function_exists('espresso_venue_id')) {
882 882
 	/**
883 883
 	 *    espresso_venue_name
884 884
 	 *
@@ -886,15 +886,15 @@  discard block
 block discarded – undo
886 886
 	 * @param     int $EVT_ID
887 887
 	 * @return    string
888 888
 	 */
889
-	function espresso_venue_id( $EVT_ID = 0 ) {
890
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
889
+	function espresso_venue_id($EVT_ID = 0) {
890
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
891 891
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
892 892
 	}
893 893
 }
894 894
 
895 895
 
896 896
 
897
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
897
+if ( ! function_exists('espresso_is_venue_private')) {
898 898
 	/**
899 899
 	 * Return whether a venue is private or not.
900 900
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -903,45 +903,45 @@  discard block
 block discarded – undo
903 903
 	 *
904 904
 	 * @return bool | null
905 905
 	 */
906
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
907
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
906
+	function espresso_is_venue_private($VNU_ID = 0) {
907
+		return EEH_Venue_View::is_venue_private($VNU_ID);
908 908
 	}
909 909
 }
910 910
 
911 911
 
912 912
 
913
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
913
+if ( ! function_exists('espresso_venue_is_password_protected')) {
914 914
 	/**
915 915
 	 * returns true or false if a venue is password protected or not
916 916
 	 *
917 917
 	 * @param int     $VNU_ID optional, the venue id to check.
918 918
 	 * @return string
919 919
 	 */
920
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
921
-		EE_Registry::instance()->load_helper( 'Venue_View' );
922
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
920
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
921
+		EE_Registry::instance()->load_helper('Venue_View');
922
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
923 923
 	}
924 924
 }
925 925
 
926 926
 
927 927
 
928
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
928
+if ( ! function_exists('espresso_password_protected_venue_form')) {
929 929
 	/**
930 930
 	 * Returns a password form if venue is password protected.
931 931
 	 *
932 932
 	 * @param int     $VNU_ID optional, the venue id to check.
933 933
 	 * @return string
934 934
 	 */
935
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
936
-		EE_Registry::instance()->load_helper( 'Venue_View' );
937
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
935
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
936
+		EE_Registry::instance()->load_helper('Venue_View');
937
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
938 938
 	}
939 939
 }
940 940
 
941 941
 
942 942
 
943 943
 
944
-if ( ! function_exists( 'espresso_venue_name' )) {
944
+if ( ! function_exists('espresso_venue_name')) {
945 945
 	/**
946 946
 	 *    espresso_venue_name
947 947
 	 *
@@ -951,19 +951,19 @@  discard block
 block discarded – undo
951 951
 	 * @param bool   $echo
952 952
 	 * @return    string
953 953
 	 */
954
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
955
-		if($echo){
956
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
954
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
955
+		if ($echo) {
956
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
957 957
 			return '';
958 958
 		}
959
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
959
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
960 960
 	}
961 961
 }
962 962
 
963 963
 
964 964
 
965 965
 
966
-if ( ! function_exists( 'espresso_venue_link' )) {
966
+if ( ! function_exists('espresso_venue_link')) {
967 967
 	/**
968 968
 	 * 	espresso_venue_link
969 969
 	 *
@@ -972,14 +972,14 @@  discard block
 block discarded – undo
972 972
 	 *  @param 	string 	$text
973 973
 	 *  @return 	string
974 974
 	 */
975
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
976
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
975
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
976
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
977 977
 	}
978 978
 }
979 979
 
980 980
 
981 981
 
982
-if ( ! function_exists( 'espresso_venue_description' )) {
982
+if ( ! function_exists('espresso_venue_description')) {
983 983
 	/**
984 984
 	 *    espresso_venue_description
985 985
 	 *
@@ -988,17 +988,17 @@  discard block
 block discarded – undo
988 988
 	 * @param bool $echo
989 989
 	 * @return    string
990 990
 	 */
991
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
992
-		if($echo){
993
-			echo EEH_Venue_View::venue_description( $VNU_ID );
991
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
992
+		if ($echo) {
993
+			echo EEH_Venue_View::venue_description($VNU_ID);
994 994
 			return '';
995 995
 		}
996
-		return EEH_Venue_View::venue_description( $VNU_ID );
996
+		return EEH_Venue_View::venue_description($VNU_ID);
997 997
 	}
998 998
 }
999 999
 
1000 1000
 
1001
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
1001
+if ( ! function_exists('espresso_venue_excerpt')) {
1002 1002
 	/**
1003 1003
 	 *    espresso_venue_excerpt
1004 1004
 	 *
@@ -1007,18 +1007,18 @@  discard block
 block discarded – undo
1007 1007
 	 * @param bool $echo
1008 1008
 	 * @return    string
1009 1009
 	 */
1010
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
1011
-		if ( $echo ) {
1012
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
1010
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
1011
+		if ($echo) {
1012
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
1013 1013
 			return '';
1014 1014
 		}
1015
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
1015
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
1016 1016
 	}
1017 1017
 }
1018 1018
 
1019 1019
 
1020 1020
 
1021
-if ( ! function_exists( 'espresso_venue_categories' )) {
1021
+if ( ! function_exists('espresso_venue_categories')) {
1022 1022
 	/**
1023 1023
 	 * espresso_venue_categories
1024 1024
 	 * returns the terms associated with a venue
@@ -1028,17 +1028,17 @@  discard block
 block discarded – undo
1028 1028
 	 * @param bool $echo
1029 1029
 	 * @return string
1030 1030
 	 */
1031
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1032
-		if ( $echo ) {
1033
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1031
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1032
+		if ($echo) {
1033
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1034 1034
 			return '';
1035 1035
 		}
1036
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1036
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1037 1037
 	}
1038 1038
 }
1039 1039
 
1040 1040
 
1041
-if ( ! function_exists( 'espresso_venue_address' )) {
1041
+if ( ! function_exists('espresso_venue_address')) {
1042 1042
 	/**
1043 1043
 	 * espresso_venue_address
1044 1044
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1048,17 +1048,17 @@  discard block
 block discarded – undo
1048 1048
 	 * @param bool   $echo
1049 1049
 	 * @return string
1050 1050
 	 */
1051
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1052
-		if ( $echo ) {
1053
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1051
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1052
+		if ($echo) {
1053
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1054 1054
 			return '';
1055 1055
 		}
1056
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1056
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1057 1057
 	}
1058 1058
 }
1059 1059
 
1060 1060
 
1061
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1061
+if ( ! function_exists('espresso_venue_raw_address')) {
1062 1062
 	/**
1063 1063
 	 * espresso_venue_address
1064 1064
 	 * returns an UN-formatted string containing a venue's address
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 	 * @param bool     $echo
1069 1069
 	 * @return string
1070 1070
 	 */
1071
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1072
-		if ( $echo ) {
1073
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1071
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1072
+		if ($echo) {
1073
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1074 1074
 			return '';
1075 1075
 		}
1076
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1076
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1077 1077
 	}
1078 1078
 }
1079 1079
 
1080 1080
 
1081
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1081
+if ( ! function_exists('espresso_venue_has_address')) {
1082 1082
 	/**
1083 1083
 	 * espresso_venue_has_address
1084 1084
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1086,13 +1086,13 @@  discard block
 block discarded – undo
1086 1086
 	 * @param int $VNU_ID
1087 1087
 	 * @return bool
1088 1088
 	 */
1089
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1090
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1089
+	function espresso_venue_has_address($VNU_ID = 0) {
1090
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1091 1091
 	}
1092 1092
 }
1093 1093
 
1094 1094
 
1095
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1095
+if ( ! function_exists('espresso_venue_gmap')) {
1096 1096
 	/**
1097 1097
 	 * espresso_venue_gmap
1098 1098
 	 * returns a google map for the venue address
@@ -1103,17 +1103,17 @@  discard block
 block discarded – undo
1103 1103
 	 * @param bool     $echo
1104 1104
 	 * @return string
1105 1105
 	 */
1106
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1107
-		if ( $echo ) {
1108
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1106
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1107
+		if ($echo) {
1108
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1109 1109
 			return '';
1110 1110
 		}
1111
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1111
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1112 1112
 	}
1113 1113
 }
1114 1114
 
1115 1115
 
1116
-if ( ! function_exists( 'espresso_venue_phone' )) {
1116
+if ( ! function_exists('espresso_venue_phone')) {
1117 1117
 	/**
1118 1118
 	 * espresso_venue_phone
1119 1119
 	 *
@@ -1121,18 +1121,18 @@  discard block
 block discarded – undo
1121 1121
 	 * @param bool $echo
1122 1122
 	 * @return string
1123 1123
 	 */
1124
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1125
-		if ( $echo ) {
1126
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1124
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1125
+		if ($echo) {
1126
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1127 1127
 			return '';
1128 1128
 		}
1129
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1129
+		return EEH_Venue_View::venue_phone($VNU_ID);
1130 1130
 	}
1131 1131
 }
1132 1132
 
1133 1133
 
1134 1134
 
1135
-if ( ! function_exists( 'espresso_venue_website' )) {
1135
+if ( ! function_exists('espresso_venue_website')) {
1136 1136
 	/**
1137 1137
 	 * espresso_venue_website
1138 1138
 	 *
@@ -1140,18 +1140,18 @@  discard block
 block discarded – undo
1140 1140
 	 * @param bool $echo
1141 1141
 	 * @return string
1142 1142
 	 */
1143
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1144
-		if ( $echo ) {
1145
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1143
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1144
+		if ($echo) {
1145
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1146 1146
 			return '';
1147 1147
 		}
1148
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1148
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1149 1149
 	}
1150 1150
 }
1151 1151
 
1152 1152
 
1153 1153
 
1154
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1154
+if ( ! function_exists('espresso_edit_venue_link')) {
1155 1155
 	/**
1156 1156
 	 * espresso_edit_venue_link
1157 1157
 	 *
@@ -1159,12 +1159,12 @@  discard block
 block discarded – undo
1159 1159
 	 * @param bool $echo
1160 1160
 	 * @return string
1161 1161
 	 */
1162
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1163
-		if($echo){
1164
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1162
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1163
+		if ($echo) {
1164
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1165 1165
 			return '';
1166 1166
 		}
1167
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1167
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1168 1168
 	}
1169 1169
 }
1170 1170
 
Please login to merge, or discard this patch.
core/db_classes/EE_Registration.class.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	/**
922 922
 	 * Sets deleted
923 923
 	 * @param boolean $deleted
924
-	 * @return boolean
924
+	 * @return boolean|null
925 925
 	 */
926 926
 	public function set_deleted($deleted) {
927 927
 		$this->set( 'REG_deleted', $deleted );
@@ -965,6 +965,7 @@  discard block
 block discarded – undo
965 965
 	 *
966 966
 	 * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
967 967
 	 * @param bool   $check_approved   This is used to indicate whether the caller wants can_checkin to also consider registration status as well as datetime access.
968
+	 * @param EE_Base_Class $DTT_OR_ID
968 969
 	 *
969 970
 	 * @return bool
970 971
 	 */
@@ -1165,7 +1166,7 @@  discard block
 block discarded – undo
1165 1166
      * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1166 1167
      * "Latest" is defined by the `DTT_EVT_start` column.
1167 1168
      *
1168
-     * @return EE_Datetime|null
1169
+     * @return null|EE_Base_Class
1169 1170
      * @throws \EE_Error
1170 1171
      */
1171 1172
 	public function get_latest_related_datetime() {
@@ -1436,7 +1437,7 @@  discard block
 block discarded – undo
1436 1437
 	 * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1437 1438
 	 * Note: if there are no payments on the registration there will be no payment method returned.
1438 1439
 	 *
1439
-	 * @return EE_Payment_Method|null
1440
+	 * @return null|EE_Base_Class
1440 1441
 	 */
1441 1442
 	public function payment_method() {
1442 1443
 		return EEM_Payment_Method::instance()->get_last_used_for_registration( $this );
Please login to merge, or discard this patch.
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\exceptions\EntityNotFoundException;
2 2
 
3
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * EE_Registration class
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 *                             		    date_format and the second value is the time format
44 44
 	 * @return EE_Registration
45 45
 	 */
46
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
47
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
48
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
46
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
47
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
48
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
49 49
 	}
50 50
 
51 51
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 *                          		the website will be used.
57 57
 	 * @return EE_Registration
58 58
 	 */
59
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
60
-		return new self( $props_n_values, TRUE, $timezone );
59
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
60
+		return new self($props_n_values, TRUE, $timezone);
61 61
 	}
62 62
 
63 63
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @param        int $EVT_ID Event ID
69 69
 	 */
70
-	public function set_event( $EVT_ID = 0 ) {
71
-		$this->set( 'EVT_ID', $EVT_ID );
70
+	public function set_event($EVT_ID = 0) {
71
+		$this->set('EVT_ID', $EVT_ID);
72 72
 	}
73 73
 
74 74
 
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
 	 * @param mixed  $field_value
80 80
 	 * @param bool   $use_default
81 81
 	 */
82
-	public function set( $field_name, $field_value, $use_default = FALSE ) {
83
-		switch( $field_name ) {
82
+	public function set($field_name, $field_value, $use_default = FALSE) {
83
+		switch ($field_name) {
84 84
 			case 'REG_code' :
85
-				if ( ! empty( $field_value ) && $this->reg_code() == '' ) {
86
-					$this->set_reg_code( $field_value, $use_default );
85
+				if ( ! empty($field_value) && $this->reg_code() == '') {
86
+					$this->set_reg_code($field_value, $use_default);
87 87
 				}
88 88
 				break;
89 89
 			case 'STS_ID' :
90
-				$this->set_status( $field_value, $use_default );
90
+				$this->set_status($field_value, $use_default);
91 91
 				break;
92 92
 			default :
93
-				parent::set( $field_name, $field_value, $use_default );
93
+				parent::set($field_name, $field_value, $use_default);
94 94
 		}
95 95
 	}
96 96
 
@@ -107,42 +107,42 @@  discard block
 block discarded – undo
107 107
 	 * @return bool
108 108
 	 * @throws \EE_Error
109 109
 	 */
110
-	public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) {
110
+	public function set_status($new_STS_ID = NULL, $use_default = FALSE) {
111 111
 		// get current REG_Status
112 112
 		$old_STS_ID = $this->status_ID();
113 113
 		// if status has changed
114 114
 		if (
115 115
 			$this->ID() // ensure registration is in the db
116 116
 			&& $old_STS_ID != $new_STS_ID // and that status has actually changed
117
-			&& ! empty( $old_STS_ID ) // and that old status is actually set
118
-			&& ! empty( $new_STS_ID ) // as well as the new status
117
+			&& ! empty($old_STS_ID) // and that old status is actually set
118
+			&& ! empty($new_STS_ID) // as well as the new status
119 119
 		) {
120 120
 			// TO approved
121
-			if ( $new_STS_ID === EEM_Registration::status_id_approved ) {
121
+			if ($new_STS_ID === EEM_Registration::status_id_approved) {
122 122
 				// reserve a space by incrementing ticket and datetime sold values
123 123
 				$this->_reserve_registration_space();
124
-				do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID );
124
+				do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID);
125 125
 			// OR FROM  approved
126
-			} else if ( $old_STS_ID === EEM_Registration::status_id_approved ) {
126
+			} else if ($old_STS_ID === EEM_Registration::status_id_approved) {
127 127
 				// release a space by decrementing ticket and datetime sold values
128 128
 				$this->_release_registration_space();
129
-				do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID );
129
+				do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID);
130 130
 			}
131 131
 			// update status
132
-			parent::set( 'STS_ID', $new_STS_ID, $use_default );
132
+			parent::set('STS_ID', $new_STS_ID, $use_default);
133 133
 			/** @type EE_Registration_Processor $registration_processor */
134
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
134
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
135 135
 			/** @type EE_Transaction_Processor $transaction_processor */
136
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
136
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
137 137
 			/** @type EE_Transaction_Payments $transaction_payments */
138
-			$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
138
+			$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
139 139
 			// these reg statuses should not be considered in any calculations involving monies owing
140
-			$closed_reg_statuses = ! empty( $closed_reg_statuses )
140
+			$closed_reg_statuses = ! empty($closed_reg_statuses)
141 141
 				? $closed_reg_statuses
142 142
 				: EEM_Registration::closed_reg_statuses();
143 143
 			if (
144
-				in_array( $new_STS_ID, $closed_reg_statuses )
145
-				&& ! in_array( $old_STS_ID, $closed_reg_statuses )
144
+				in_array($new_STS_ID, $closed_reg_statuses)
145
+				&& ! in_array($old_STS_ID, $closed_reg_statuses)
146 146
 			) {
147 147
 				// cancelled or declined registration
148 148
 				$registration_processor->update_registration_after_being_canceled_or_declined(
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
155 155
 					false
156 156
 				);
157 157
 			} else if (
158
-				in_array( $old_STS_ID, $closed_reg_statuses )
159
-				&& ! in_array( $new_STS_ID, $closed_reg_statuses )
158
+				in_array($old_STS_ID, $closed_reg_statuses)
159
+				&& ! in_array($new_STS_ID, $closed_reg_statuses)
160 160
 			) {
161 161
 				// reinstating cancelled or declined registration
162 162
 				$registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
163 163
 					$this,
164 164
 					$closed_reg_statuses
165 165
 				);
166
-				$transaction_processor->update_transaction_after_reinstating_canceled_registration( $this );
166
+				$transaction_processor->update_transaction_after_reinstating_canceled_registration($this);
167 167
 			}
168
-			$transaction_payments->recalculate_transaction_total( $this->transaction(), false );
169
-			$this->transaction()->update_status_based_on_total_paid( true );
170
-			do_action( 'AHEE__EE_Registration__set_status__after_update', $this );
168
+			$transaction_payments->recalculate_transaction_total($this->transaction(), false);
169
+			$this->transaction()->update_status_based_on_total_paid(true);
170
+			do_action('AHEE__EE_Registration__set_status__after_update', $this);
171 171
 			return TRUE;
172 172
 		} else {
173 173
 			//even though the old value matches the new value, it's still good to
174 174
 			//allow the parent set method to have a say
175
-			parent::set( 'STS_ID', $new_STS_ID, $use_default );
175
+			parent::set('STS_ID', $new_STS_ID, $use_default);
176 176
 			return TRUE;
177 177
 		}
178 178
 	}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 *        get Status ID
184 184
 	 */
185 185
 	public function status_ID() {
186
-		return $this->get( 'STS_ID' );
186
+		return $this->get('STS_ID');
187 187
 	}
188 188
 
189 189
 
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 	 * @param boolean $include_archived whether to include archived tickets or not.
209 209
 	 * @return EE_Ticket
210 210
 	 */
211
-	public function ticket( $include_archived = TRUE ) {
211
+	public function ticket($include_archived = TRUE) {
212 212
 		$query_params = array();
213
-		if ( $include_archived ) {
214
-			$query_params[ 'default_where_conditions' ] = 'none';
213
+		if ($include_archived) {
214
+			$query_params['default_where_conditions'] = 'none';
215 215
 		}
216
-		return $this->get_first_related( 'Ticket', $query_params );
216
+		return $this->get_first_related('Ticket', $query_params);
217 217
 	}
218 218
 
219 219
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function wp_user() {
243 243
 		$event = $this->event();
244
-		if ( $event instanceof EE_Event ) {
244
+		if ($event instanceof EE_Event) {
245 245
 			return $event->wp_user();
246 246
 		}
247 247
 		return 0;
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param        int $ATT_ID Attendee ID
268 268
 	 */
269
-	public function set_attendee_id( $ATT_ID = 0 ) {
270
-		$this->set( 'ATT_ID', $ATT_ID );
269
+	public function set_attendee_id($ATT_ID = 0) {
270
+		$this->set('ATT_ID', $ATT_ID);
271 271
 	}
272 272
 
273 273
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 * @param        int $TXN_ID Transaction ID
279 279
 	 */
280
-	public function set_transaction_id( $TXN_ID = 0 ) {
281
-		$this->set( 'TXN_ID', $TXN_ID );
280
+	public function set_transaction_id($TXN_ID = 0) {
281
+		$this->set('TXN_ID', $TXN_ID);
282 282
 	}
283 283
 
284 284
 
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @param    string $REG_session PHP Session ID
290 290
 	 */
291
-	public function set_session( $REG_session = '' ) {
292
-		$this->set( 'REG_session', $REG_session );
291
+	public function set_session($REG_session = '') {
292
+		$this->set('REG_session', $REG_session);
293 293
 	}
294 294
 
295 295
 
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @param    string $REG_url_link Registration URL Link
301 301
 	 */
302
-	public function set_reg_url_link( $REG_url_link = '' ) {
303
-		$this->set( 'REG_url_link', $REG_url_link );
302
+	public function set_reg_url_link($REG_url_link = '') {
303
+		$this->set('REG_url_link', $REG_url_link);
304 304
 	}
305 305
 
306 306
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @param        int $REG_count Primary Attendee
312 312
 	 */
313
-	public function set_count( $REG_count = 1 ) {
314
-		$this->set( 'REG_count', $REG_count );
313
+	public function set_count($REG_count = 1) {
314
+		$this->set('REG_count', $REG_count);
315 315
 	}
316 316
 
317 317
 
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @param        boolean $REG_group_size Group Registration
323 323
 	 */
324
-	public function set_group_size( $REG_group_size = FALSE ) {
325
-		$this->set( 'REG_group_size', $REG_group_size );
324
+	public function set_group_size($REG_group_size = FALSE) {
325
+		$this->set('REG_group_size', $REG_group_size);
326 326
 	}
327 327
 
328 328
 
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 *
399 399
 	 * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date
400 400
 	 */
401
-	public function set_reg_date( $REG_date = FALSE ) {
402
-		$this->set( 'REG_date', $REG_date );
401
+	public function set_reg_date($REG_date = FALSE) {
402
+		$this->set('REG_date', $REG_date);
403 403
 	}
404 404
 
405 405
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 	 * @access    public
411 411
 	 * @param    float $REG_final_price
412 412
 	 */
413
-	public function set_final_price( $REG_final_price = 0.00 ) {
414
-		$this->set( 'REG_final_price', $REG_final_price );
413
+	public function set_final_price($REG_final_price = 0.00) {
414
+		$this->set('REG_final_price', $REG_final_price);
415 415
 	}
416 416
 
417 417
 
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	 * @access    public
423 423
 	 * @param    float $REG_paid
424 424
 	 */
425
-	public function set_paid( $REG_paid = 0.00 ) {
426
-		$this->set( 'REG_paid', $REG_paid );
425
+	public function set_paid($REG_paid = 0.00) {
426
+		$this->set('REG_paid', $REG_paid);
427 427
 	}
428 428
 
429 429
 
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 * @param        boolean $REG_att_is_going Attendee Is Going
435 435
 	 */
436
-	public function set_att_is_going( $REG_att_is_going = FALSE ) {
437
-		$this->set( 'REG_att_is_going', $REG_att_is_going );
436
+	public function set_att_is_going($REG_att_is_going = FALSE) {
437
+		$this->set('REG_att_is_going', $REG_att_is_going);
438 438
 	}
439 439
 
440 440
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * @return EE_Attendee
445 445
 	 */
446 446
 	public function attendee() {
447
-		return $this->get_first_related( 'Attendee' );
447
+		return $this->get_first_related('Attendee');
448 448
 	}
449 449
 
450 450
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 *        get Event ID
454 454
 	 */
455 455
 	public function event_ID() {
456
-		return $this->get( 'EVT_ID' );
456
+		return $this->get('EVT_ID');
457 457
 	}
458 458
 
459 459
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 	 */
464 464
 	public function event_name() {
465 465
 		$event = $this->event_obj();
466
-		if ( $event ) {
466
+		if ($event) {
467 467
 			return $event->name();
468 468
 		} else {
469 469
 			return NULL;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return EE_Event
478 478
 	 */
479 479
 	public function event_obj() {
480
-		return $this->get_first_related( 'Event' );
480
+		return $this->get_first_related('Event');
481 481
 	}
482 482
 
483 483
 
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 	 *        get Attendee ID
487 487
 	 */
488 488
 	public function attendee_ID() {
489
-		return $this->get( 'ATT_ID' );
489
+		return $this->get('ATT_ID');
490 490
 	}
491 491
 
492 492
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 *        get PHP Session ID
496 496
 	 */
497 497
 	public function session_ID() {
498
-		return $this->get( 'REG_session' );
498
+		return $this->get('REG_session');
499 499
 	}
500 500
 
501 501
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
506 506
 	 * @return string
507 507
 	 */
508
-	public function receipt_url( $messenger = 'html' ) {
508
+	public function receipt_url($messenger = 'html') {
509 509
 
510 510
 		/**
511 511
 		 * The below will be deprecated one version after this.  We check first if there is a custom receipt template already in use on old system.  If there is then we just return the standard url for it.
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
 		 * @since 4.5.0
514 514
 		 */
515 515
 		$template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
516
-		$has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE );
516
+		$has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE);
517 517
 
518
-		if ( $has_custom ) {
519
-			return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) );
518
+		if ($has_custom) {
519
+			return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
520 520
 		}
521
-		return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' );
521
+		return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
522 522
 	}
523 523
 
524 524
 
@@ -529,28 +529,28 @@  discard block
 block discarded – undo
529 529
 	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
530 530
 	 * @return string
531 531
 	 */
532
-	public function invoice_url( $messenger = 'html' ) {
532
+	public function invoice_url($messenger = 'html') {
533 533
 		/**
534 534
 		 * The below will be deprecated one version after this.  We check first if there is a custom invoice template already in use on old system.  If there is then we just return the standard url for it.
535 535
 		 *
536 536
 		 * @since 4.5.0
537 537
 		 */
538 538
 		$template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
539
-		$has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE );
539
+		$has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE);
540 540
 
541
-		if ( $has_custom ) {
542
-			if ( $messenger == 'html' ) {
543
-				return $this->invoice_url( 'launch' );
541
+		if ($has_custom) {
542
+			if ($messenger == 'html') {
543
+				return $this->invoice_url('launch');
544 544
 			}
545 545
 			$route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
546 546
 
547
-			$query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() );
548
-			if ( $messenger == 'html' ) {
547
+			$query_args = array('ee' => $route, 'id' => $this->reg_url_link());
548
+			if ($messenger == 'html') {
549 549
 				$query_args['html'] = TRUE;
550 550
 			}
551
-			return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) );
551
+			return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
552 552
 		}
553
-		return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' );
553
+		return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
554 554
 	}
555 555
 
556 556
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @throws \EE_Error
564 564
 	 */
565 565
 	public function reg_url_link() {
566
-		return (string)$this->get( 'REG_url_link' );
566
+		return (string) $this->get('REG_url_link');
567 567
 	}
568 568
 
569 569
 
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
 	 * @param string $type 'download','launch', or 'html' (default is 'launch')
574 574
 	 * @return void
575 575
 	 */
576
-	public function e_invoice_url( $type = 'launch' ) {
577
-		echo $this->invoice_url( $type );
576
+	public function e_invoice_url($type = 'launch') {
577
+		echo $this->invoice_url($type);
578 578
 	}
579 579
 
580 580
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	 * @return string
595 595
 	 */
596 596
 	public function payment_overview_url() {
597
-		return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() );
597
+		return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url());
598 598
 	}
599 599
 
600 600
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	 * @return string
606 606
 	 */
607 607
 	public function edit_attendee_information_url() {
608
-		return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() );
608
+		return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url());
609 609
 	}
610 610
 
611 611
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	 * @return string
616 616
 	 */
617 617
 	public function get_admin_edit_url() {
618
-		return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) );
618
+		return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php'));
619 619
 	}
620 620
 
621 621
 
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	 *    is_primary_registrant?
625 625
 	 */
626 626
 	public function is_primary_registrant() {
627
-		return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE;
627
+		return $this->get('REG_count') == 1 ? TRUE : FALSE;
628 628
 	}
629 629
 
630 630
 
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
 	 * This returns the primary registration object for this registration group (which may be this object).
634 634
 	 * @return EE_Registration
635 635
 	 */
636
-	public function get_primary_registration()  {
637
-		if ( $this->is_primary_registrant() )
636
+	public function get_primary_registration() {
637
+		if ($this->is_primary_registrant())
638 638
 			return $this;
639 639
 
640 640
 		//k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
641
-		$primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) );
641
+		$primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1)));
642 642
 		return $primary_registrant;
643 643
 	}
644 644
 
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 	* 		@access		public
650 650
 	*/
651 651
 	public function count() {
652
-		return $this->get( 'REG_count' );
652
+		return $this->get('REG_count');
653 653
 	}
654 654
 
655 655
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	 *        get Group Size
659 659
 	 */
660 660
 	public function group_size() {
661
-		return $this->get( 'REG_group_size' );
661
+		return $this->get('REG_group_size');
662 662
 	}
663 663
 
664 664
 
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 *        get Registration Date
668 668
 	 */
669 669
 	public function date() {
670
-		return $this->get( 'REG_date' );
670
+		return $this->get('REG_date');
671 671
 	}
672 672
 
673 673
 
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @param string $time_format
679 679
 	 * @return string
680 680
 	 */
681
-	public function pretty_date( $date_format = NULL, $time_format = NULL ) {
682
-		return $this->get_datetime( 'REG_date', $date_format, $time_format );
681
+	public function pretty_date($date_format = NULL, $time_format = NULL) {
682
+		return $this->get_datetime('REG_date', $date_format, $time_format);
683 683
 	}
684 684
 
685 685
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	 * @return    float
692 692
 	 */
693 693
 	public function final_price() {
694
-		return $this->get( 'REG_final_price' );
694
+		return $this->get('REG_final_price');
695 695
 	}
696 696
 
697 697
 
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 * @return string
703 703
 	 */
704 704
 	public function pretty_final_price() {
705
-		return $this->get_pretty( 'REG_final_price' );
705
+		return $this->get_pretty('REG_final_price');
706 706
 	}
707 707
 
708 708
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	 * @return 	float
713 713
 	 */
714 714
 	public function paid() {
715
-		return $this->get( 'REG_paid' );
715
+		return $this->get('REG_paid');
716 716
 	}
717 717
 
718 718
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 * @return 	float
723 723
 	 */
724 724
 	public function pretty_paid() {
725
-		return $this->get_pretty( 'REG_paid' );
725
+		return $this->get_pretty('REG_paid');
726 726
 	}
727 727
 
728 728
 
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
 	 * @param array $requires_payment
734 734
 	 * @return bool
735 735
 	 */
736
-	public function owes_monies_and_can_pay( $requires_payment = array()) {
736
+	public function owes_monies_and_can_pay($requires_payment = array()) {
737 737
 		// these reg statuses require payment (if event is not free)
738
-		$requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment();
738
+		$requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment();
739 739
 		if (
740
-			in_array( $this->status_ID(), $requires_payment ) &&
740
+			in_array($this->status_ID(), $requires_payment) &&
741 741
 			$this->final_price() != 0 &&
742 742
 			$this->final_price() != $this->paid()
743 743
 		) {
@@ -754,8 +754,8 @@  discard block
 block discarded – undo
754 754
 	 * @param bool $show_icons
755 755
 	 * @return void
756 756
 	 */
757
-	public function e_pretty_status( $show_icons = FALSE ) {
758
-		echo $this->pretty_status( $show_icons );
757
+	public function e_pretty_status($show_icons = FALSE) {
758
+		echo $this->pretty_status($show_icons);
759 759
 	}
760 760
 
761 761
 
@@ -766,10 +766,10 @@  discard block
 block discarded – undo
766 766
 	 * @param bool $show_icons
767 767
 	 * @return string
768 768
 	 */
769
-	public function pretty_status( $show_icons = FALSE ) {
770
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
769
+	public function pretty_status($show_icons = FALSE) {
770
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
771 771
 		$icon = '';
772
-		switch ( $this->status_ID() ) {
772
+		switch ($this->status_ID()) {
773 773
 			case EEM_Registration::status_id_approved:
774 774
 				$icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : '';
775 775
 				break;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 				$icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : '';
793 793
 				break;
794 794
 		}
795
-		return $icon . $status[ $this->status_ID() ];
795
+		return $icon.$status[$this->status_ID()];
796 796
 	}
797 797
 
798 798
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	 *        get Attendee Is Going
802 802
 	 */
803 803
 	public function att_is_going() {
804
-		return $this->get( 'REG_att_is_going' );
804
+		return $this->get('REG_att_is_going');
805 805
 	}
806 806
 
807 807
 
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 	 * @param array $query_params like EEM_Base::get_all
812 812
 	 * @return EE_Answer[]
813 813
 	 */
814
-	public function answers( $query_params = NULL ) {
815
-		return $this->get_many_related( 'Answer', $query_params );
814
+	public function answers($query_params = NULL) {
815
+		return $this->get_many_related('Answer', $query_params);
816 816
 	}
817 817
 
818 818
 
@@ -826,9 +826,9 @@  discard block
 block discarded – undo
826 826
 	 * (because the answer might be an array of answer values, so passing pretty_value=true
827 827
 	 * will convert it into some kind of string)
828 828
 	 */
829
-	public function answer_value_to_question( $question, $pretty_value=true ) {
829
+	public function answer_value_to_question($question, $pretty_value = true) {
830 830
 		$question_id = EEM_Question::instance()->ensure_is_ID($question);
831
-		return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value);
831
+		return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
832 832
 	}
833 833
 
834 834
 
@@ -841,13 +841,13 @@  discard block
 block discarded – undo
841 841
 	 */
842 842
 	public function question_groups() {
843 843
 		$question_groups = array();
844
-		if ( $this->event() instanceof EE_Event ) {
844
+		if ($this->event() instanceof EE_Event) {
845 845
 			$question_groups = $this->event()->question_groups(
846 846
 				array(
847 847
 					array(
848 848
 						'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false
849 849
 					),
850
-					'order_by' => array( 'QSG_order' => 'ASC' )
850
+					'order_by' => array('QSG_order' => 'ASC')
851 851
 				)
852 852
 			);
853 853
 		}
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	 */
865 865
 	public function count_question_groups() {
866 866
 		$qg_count = 0;
867
-		if ( $this->event() instanceof EE_Event ) {
867
+		if ($this->event() instanceof EE_Event) {
868 868
 			$qg_count = $this->event()->count_related(
869 869
 				'Question_Group',
870 870
 				array(
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 	 * @return string
886 886
 	 */
887 887
 	public function reg_date() {
888
-		return $this->get_datetime( 'REG_date' );
888
+		return $this->get_datetime('REG_date');
889 889
 	}
890 890
 
891 891
 
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 	 * @return EE_Datetime_Ticket
898 898
 	 */
899 899
 	public function datetime_ticket() {
900
-		return $this->get_first_related( 'Datetime_Ticket' );
900
+		return $this->get_first_related('Datetime_Ticket');
901 901
 	}
902 902
 
903 903
 
@@ -907,15 +907,15 @@  discard block
 block discarded – undo
907 907
 	 * @param EE_Datetime_Ticket $datetime_ticket
908 908
 	 * @return EE_Datetime_Ticket
909 909
 	 */
910
-	public function set_datetime_ticket( $datetime_ticket ) {
911
-		return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' );
910
+	public function set_datetime_ticket($datetime_ticket) {
911
+		return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
912 912
 	}
913 913
 	/**
914 914
 	 * Gets deleted
915 915
 	 * @return boolean
916 916
 	 */
917 917
 	public function deleted() {
918
-		return $this->get( 'REG_deleted' );
918
+		return $this->get('REG_deleted');
919 919
 	}
920 920
 
921 921
 	/**
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 	 * @return boolean
925 925
 	 */
926 926
 	public function set_deleted($deleted) {
927
-		$this->set( 'REG_deleted', $deleted );
927
+		$this->set('REG_deleted', $deleted);
928 928
 	}
929 929
 
930 930
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	 * @return EE_Status
935 935
 	 */
936 936
 	public function status_obj() {
937
-		return $this->get_first_related( 'Status' );
937
+		return $this->get_first_related('Status');
938 938
 	}
939 939
 
940 940
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 	 * @return int
946 946
 	 */
947 947
 	public function count_checkins() {
948
-		return $this->get_model()->count_related( $this, 'Checkin' );
948
+		return $this->get_model()->count_related($this, 'Checkin');
949 949
 	}
950 950
 
951 951
 
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 	 * @return int
956 956
 	 */
957 957
 	public function count_checkins_not_checkedout() {
958
-		return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) );
958
+		return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
959 959
 	}
960 960
 
961 961
 
@@ -968,24 +968,24 @@  discard block
 block discarded – undo
968 968
 	 *
969 969
 	 * @return bool
970 970
 	 */
971
-	public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) {
972
-		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID );
971
+	public function can_checkin($DTT_OR_ID, $check_approved = TRUE) {
972
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
973 973
 
974 974
 		//first check registration status
975
-		if (  ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) {
975
+		if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
976 976
 			return false;
977 977
 		}
978 978
 		//is there a datetime ticket that matches this dtt_ID?
979
-		if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) {
979
+		if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) {
980 980
 			return false;
981 981
 		}
982 982
 		
983 983
 		//final check is against TKT_uses
984
-		if ( ! $this->verify_can_checkin_against_TKT_uses( $DTT_ID ) ) {
984
+		if ( ! $this->verify_can_checkin_against_TKT_uses($DTT_ID)) {
985 985
 			return false;
986 986
 		}
987 987
 		
988
-		return apply_filters( 'FHEE__EE_Registration__can_checkin__can_checkin', TRUE, $this, $DTT_ID, $verify );
988
+		return apply_filters('FHEE__EE_Registration__can_checkin__can_checkin', TRUE, $this, $DTT_ID, $verify);
989 989
 	}
990 990
 
991 991
 
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 	 * @param int | EE_Datetime  $DTT_OR_ID  The datetime the registration is being checked against
999 999
 	 * @return bool   true means can checkin.  false means cannot checkin.
1000 1000
 	 */
1001
-	public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) {
1002
-		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID );
1001
+	public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) {
1002
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1003 1003
 
1004
-		if ( ! $DTT_ID ) {
1004
+		if ( ! $DTT_ID) {
1005 1005
 			return false;
1006 1006
 		}
1007 1007
 
@@ -1009,23 +1009,23 @@  discard block
 block discarded – undo
1009 1009
 
1010 1010
 		// if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in
1011 1011
 		// or not.
1012
-		if ( ! $max_uses || $max_uses === EE_INF ) {
1012
+		if ( ! $max_uses || $max_uses === EE_INF) {
1013 1013
 			return true;
1014 1014
 		}
1015 1015
 
1016 1016
 		//does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1017 1017
 		//go ahead and toggle.
1018
-		if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) {
1018
+		if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1019 1019
 			return true;
1020 1020
 		}
1021 1021
 
1022 1022
 		//made it here so the last check is whether the number of checkins per unique datetime on this registration
1023 1023
 		//disallows further check-ins.
1024
-		$count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true );
1024
+		$count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true);
1025 1025
 		// checkins have already reached their max number of uses
1026 1026
 		// so registrant can NOT checkin
1027
-		if ( $count_unique_dtt_checkins >= $max_uses ) {
1028
-			EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1027
+		if ($count_unique_dtt_checkins >= $max_uses) {
1028
+			EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1029 1029
 			return false;
1030 1030
 		}
1031 1031
 		return true;
@@ -1047,14 +1047,14 @@  discard block
 block discarded – undo
1047 1047
      * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1048 1048
      * @throws EE_Error
1049 1049
      */
1050
-	public function toggle_checkin_status( $DTT_ID = null, $verify = false ) {
1050
+	public function toggle_checkin_status($DTT_ID = null, $verify = false) {
1051 1051
 		
1052 1052
 		$ticket = $this->ticket();
1053 1053
 		
1054
-		if ( ! ($ticket instanceof EE_Ticket ) ) {
1054
+		if ( ! ($ticket instanceof EE_Ticket)) {
1055 1055
 			EE_Error::add_error(
1056 1056
 				sprintf(
1057
-					__( 'The given registration (ID:%1$d) can not be checked in because we are unable to access the Ticket', 'event_espresso'),
1057
+					__('The given registration (ID:%1$d) can not be checked in because we are unable to access the Ticket', 'event_espresso'),
1058 1058
 					$this->ID(),
1059 1059
 					$DTT_ID
1060 1060
 				),
@@ -1063,17 +1063,17 @@  discard block
 block discarded – undo
1063 1063
 			return false;
1064 1064
 		}
1065 1065
 		
1066
-		if ( empty( $DTT_ID ) ) {
1066
+		if (empty($DTT_ID)) {
1067 1067
 			$datetime = $this->get_latest_related_datetime();
1068 1068
 			$DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1069 1069
 		}
1070 1070
 		
1071 1071
 		$DTTs = $ticket->datetimes();
1072 1072
 		
1073
-		if ( ! isset( $DTTs[$DTT_ID] ) ) {
1073
+		if ( ! isset($DTTs[$DTT_ID])) {
1074 1074
 			EE_Error::add_error(
1075 1075
 				sprintf(
1076
-					__( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'),
1076
+					__('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'),
1077 1077
 					$this->ID(),
1078 1078
 					$DTT_ID
1079 1079
 				),
@@ -1082,16 +1082,16 @@  discard block
 block discarded – undo
1082 1082
 			return false;
1083 1083
 		}
1084 1084
 		
1085
-		if ( ! $ticket->get('TKT_full_checkin') ) {
1085
+		if ( ! $ticket->get('TKT_full_checkin')) {
1086 1086
 			$DTTs = array($DTT_ID => $DTTs[$DTT_ID]);
1087 1087
 		}
1088 1088
 		
1089 1089
 		//start by getting the current status so we know what status we'll be changing to.
1090
-		$DTT_ID_status = $this->check_in_status_for_datetime( $DTT_ID, NULL );
1090
+		$DTT_ID_status = $this->check_in_status_for_datetime($DTT_ID, NULL);
1091 1091
 		
1092 1092
 		// database only records true for checked IN or false for checked OUT
1093 1093
 		// no record ( null ) means checked in NEVER, but we obviously don't save that
1094
-		$status_to = (int) ( $DTT_ID_status !== EE_Registration::checkin_status_in );
1094
+		$status_to = (int) ($DTT_ID_status !== EE_Registration::checkin_status_in);
1095 1095
 		
1096 1096
 		// add relation - note Check-ins are always creating new rows
1097 1097
 		// because we are keeping track of Check-ins over time.
@@ -1101,44 +1101,44 @@  discard block
 block discarded – undo
1101 1101
 		
1102 1102
 		foreach ($DTTs as $DTT) {
1103 1103
 			// verify the registration can checkin for the given DTT_ID
1104
-			if ( $this->can_checkin( $DTT, $verify ) ) {
1104
+			if ($this->can_checkin($DTT, $verify)) {
1105 1105
 				$cur_ID = $DTT->ID();
1106
-				if ( ( $cur_ID != $DTT_ID ) ) {
1107
-					$cur_status = (int) ($this->check_in_status_for_datetime( $DTT_ID, NULL ) === EE_Registration::checkin_status_in);
1106
+				if (($cur_ID != $DTT_ID)) {
1107
+					$cur_status = (int) ($this->check_in_status_for_datetime($DTT_ID, NULL) === EE_Registration::checkin_status_in);
1108 1108
 					// If the DT is not checked in and the new status is to check out, skip
1109 1109
 					// If the DT is checked in, and the new status is to check in, skip
1110
-					if ( $status_to === $cur_status )
1110
+					if ($status_to === $cur_status)
1111 1111
 						continue;
1112 1112
 				}
1113 1113
 				
1114
-				$checkin = EE_Checkin::new_instance( array(
1114
+				$checkin = EE_Checkin::new_instance(array(
1115 1115
 					'REG_ID' => $this->ID(),
1116 1116
 					'DTT_ID' => $DTT->ID(),
1117 1117
 					'CHK_in' => $status_to
1118
-				) );
1118
+				));
1119 1119
 				
1120
-				if ( $checkin->save() !== 0 ) {
1120
+				if ($checkin->save() !== 0) {
1121 1121
 					// Maintain list of successful saves, so we can back them out if there is an error.
1122 1122
 					$checked_in[] = $checkin;
1123 1123
 				} else {
1124
-					if ( WP_DEBUG ) {
1124
+					if (WP_DEBUG) {
1125 1125
 						global $wpdb;
1126 1126
 						$error = sprintf(
1127
-							__( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ),
1127
+							__('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'),
1128 1128
 							'<br />',
1129 1129
 							$wpdb->last_error
1130 1130
 						);
1131 1131
 					} else {
1132
-						$error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' );
1132
+						$error = __('Registration check in update failed because of an unknown database error', 'event_espresso');
1133 1133
 					}
1134
-					EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ );
1134
+					EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1135 1135
 					$status_to = false;
1136 1136
 					break;
1137 1137
 				}
1138 1138
 			} else {
1139 1139
 				EE_Error::add_error(
1140 1140
 						sprintf(
1141
-							__( 'The given registration (ID:%1$d) can not be checked in because DTT_ID (%2$d) can not be checked in', 'event_espresso'),
1141
+							__('The given registration (ID:%1$d) can not be checked in because DTT_ID (%2$d) can not be checked in', 'event_espresso'),
1142 1142
 							$this->ID(),
1143 1143
 							$DTT->ID()
1144 1144
 						),
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			}
1150 1150
 		}
1151 1151
 		
1152
-		if ( $status_to === false ) {
1152
+		if ($status_to === false) {
1153 1153
 			// if a record could not be saved, back out existing, then return false
1154 1154
 			foreach ($checked_in as $checkin) {
1155 1155
 				$checkin->delete();
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 				array(
1175 1175
 					'Ticket.Registration.REG_ID' => $this->ID()
1176 1176
 				),
1177
-				'order_by' => array( 'DTT_EVT_start' => 'DESC' )
1177
+				'order_by' => array('DTT_EVT_start' => 'DESC')
1178 1178
 			)
1179 1179
 		);
1180 1180
 	}
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 				array(
1194 1194
 					'Ticket.Registration.REG_ID' => $this->ID()
1195 1195
 				),
1196
-				'order_by' => array( 'DTT_EVT_start' => 'ASC' )
1196
+				'order_by' => array('DTT_EVT_start' => 'ASC')
1197 1197
 			)
1198 1198
 		);
1199 1199
 	}
@@ -1212,21 +1212,21 @@  discard block
 block discarded – undo
1212 1212
      * @return int                Integer representing Check-in status.
1213 1213
      * @throws \EE_Error
1214 1214
      */
1215
-	public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = null ) {
1215
+	public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) {
1216 1216
 		$checkin_query_params = array(
1217
-			'order_by' => array( 'CHK_timestamp' => 'DESC' )
1217
+			'order_by' => array('CHK_timestamp' => 'DESC')
1218 1218
 		);
1219 1219
 
1220
-		if ( $DTT_ID > 0 ) {
1221
-			$checkin_query_params[0] = array( 'DTT_ID' => $DTT_ID );
1220
+		if ($DTT_ID > 0) {
1221
+			$checkin_query_params[0] = array('DTT_ID' => $DTT_ID);
1222 1222
 		}
1223 1223
 
1224 1224
 		//get checkin object (if exists)
1225 1225
 		$checkin = $checkin instanceof EE_Checkin
1226 1226
             ? $checkin
1227
-            : $this->get_first_related( 'Checkin', $checkin_query_params );
1228
-		if ( $checkin instanceof EE_Checkin ) {
1229
-			if ( $checkin->get( 'CHK_in' ) ) {
1227
+            : $this->get_first_related('Checkin', $checkin_query_params);
1228
+		if ($checkin instanceof EE_Checkin) {
1229
+			if ($checkin->get('CHK_in')) {
1230 1230
 				return EE_Registration::checkin_status_in; //checked in
1231 1231
 			}
1232 1232
 			return EE_Registration::checkin_status_out; //had checked in but is now checked out.
@@ -1242,28 +1242,28 @@  discard block
 block discarded – undo
1242 1242
 	 * @param bool $error  This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name.
1243 1243
 	 * @return string         internationalized message
1244 1244
 	 */
1245
-	public function get_checkin_msg( $DTT_ID, $error = FALSE ) {
1245
+	public function get_checkin_msg($DTT_ID, $error = FALSE) {
1246 1246
 		//let's get the attendee first so we can include the name of the attendee
1247
-		$attendee = $this->get_first_related( 'Attendee' );
1248
-		if ( $attendee instanceof EE_Attendee ) {
1249
-			if ( $error ) {
1250
-				return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() );
1247
+		$attendee = $this->get_first_related('Attendee');
1248
+		if ($attendee instanceof EE_Attendee) {
1249
+			if ($error) {
1250
+				return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name());
1251 1251
 			}
1252
-			$cur_status = $this->check_in_status_for_datetime( $DTT_ID );
1252
+			$cur_status = $this->check_in_status_for_datetime($DTT_ID);
1253 1253
 			//what is the status message going to be?
1254
-			switch ( $cur_status ) {
1254
+			switch ($cur_status) {
1255 1255
 				case EE_Registration::checkin_status_never :
1256
-					return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() );
1256
+					return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name());
1257 1257
 					break;
1258 1258
 				case EE_Registration::checkin_status_in :
1259
-					return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() );
1259
+					return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1260 1260
 					break;
1261 1261
 				case EE_Registration::checkin_status_out :
1262
-					return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() );
1262
+					return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1263 1263
 					break;
1264 1264
 			}
1265 1265
 		}
1266
-		return __( "The check-in status could not be determined.", "event_espresso" );
1266
+		return __("The check-in status could not be determined.", "event_espresso");
1267 1267
 	}
1268 1268
 
1269 1269
 
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 	 *        get Registration Code
1288 1288
 	 */
1289 1289
 	public function reg_code() {
1290
-		return $this->get( 'REG_code' );
1290
+		return $this->get('REG_code');
1291 1291
 	}
1292 1292
 
1293 1293
 
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 	 *        get Transaction ID
1297 1297
 	 */
1298 1298
 	public function transaction_ID() {
1299
-		return $this->get( 'TXN_ID' );
1299
+		return $this->get('TXN_ID');
1300 1300
 	}
1301 1301
 
1302 1302
 
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 	 * @return int
1306 1306
 	 */
1307 1307
 	public function ticket_ID() {
1308
-		return $this->get( 'TKT_ID' );
1308
+		return $this->get('TKT_ID');
1309 1309
 	}
1310 1310
 
1311 1311
 
@@ -1317,17 +1317,17 @@  discard block
 block discarded – undo
1317 1317
 	 * @param    string $REG_code Registration Code
1318 1318
 	 * @param	boolean $use_default
1319 1319
 	 */
1320
-	public function set_reg_code( $REG_code, $use_default = FALSE ) {
1321
-		if ( empty( $REG_code )) {
1322
-			EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1320
+	public function set_reg_code($REG_code, $use_default = FALSE) {
1321
+		if (empty($REG_code)) {
1322
+			EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1323 1323
 			return;
1324 1324
 		}
1325
-		if ( ! $this->reg_code() ) {
1326
-			parent::set( 'REG_code', $REG_code, $use_default );
1325
+		if ( ! $this->reg_code()) {
1326
+			parent::set('REG_code', $REG_code, $use_default);
1327 1327
 		} else {
1328 1328
 			EE_Error::doing_it_wrong(
1329
-				__CLASS__ . '::' . __FUNCTION__,
1330
-				__( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ),
1329
+				__CLASS__.'::'.__FUNCTION__,
1330
+				__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1331 1331
 				'4.6.0'
1332 1332
 			);
1333 1333
 		}
@@ -1347,17 +1347,17 @@  discard block
 block discarded – undo
1347 1347
 	 * @return EE_Registration[]  or empty array if this isn't a group registration.
1348 1348
 	 */
1349 1349
 	public function get_all_other_registrations_in_group() {
1350
-		if ( $this->group_size() < 2 ) {
1350
+		if ($this->group_size() < 2) {
1351 1351
 			return array();
1352 1352
 		}
1353 1353
 
1354 1354
 		$query[0] = array(
1355 1355
 			'TXN_ID' => $this->transaction_ID(),
1356
-			'REG_ID' => array( '!=', $this->ID() ),
1356
+			'REG_ID' => array('!=', $this->ID()),
1357 1357
 			'TKT_ID' => $this->ticket_ID()
1358 1358
 			);
1359 1359
 
1360
-		$registrations = $this->get_model()->get_all( $query );
1360
+		$registrations = $this->get_model()->get_all($query);
1361 1361
 		return $registrations;
1362 1362
 	}
1363 1363
 
@@ -1366,14 +1366,14 @@  discard block
 block discarded – undo
1366 1366
 	 * @return string
1367 1367
 	 */
1368 1368
 	public function get_admin_details_link() {
1369
-		EE_Registry::instance()->load_helper( 'URL' );
1369
+		EE_Registry::instance()->load_helper('URL');
1370 1370
 		return EEH_URL::add_query_args_and_nonce(
1371 1371
 			array(
1372 1372
 				'page' => 'espresso_registrations',
1373 1373
 				'action' => 'view_registration',
1374 1374
 				'_REG_ID' => $this->ID()
1375 1375
 			),
1376
-			admin_url( 'admin.php' )
1376
+			admin_url('admin.php')
1377 1377
 		);
1378 1378
 	}
1379 1379
 
@@ -1398,12 +1398,12 @@  discard block
 block discarded – undo
1398 1398
 	 * @return string
1399 1399
 	 */
1400 1400
 	public function get_admin_overview_link() {
1401
-		EE_Registry::instance()->load_helper( 'URL' );
1401
+		EE_Registry::instance()->load_helper('URL');
1402 1402
 		return EEH_URL::add_query_args_and_nonce(
1403 1403
 			array(
1404 1404
 				'page' => 'espresso_registrations'
1405 1405
 			),
1406
-			admin_url( 'admin.php' )
1406
+			admin_url('admin.php')
1407 1407
 		);
1408 1408
 	}
1409 1409
 
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 	 * @return \EE_Registration[]
1415 1415
 	 * @throws \EE_Error
1416 1416
 	 */
1417
-	public function payments( $query_params = array() ) {
1418
-		return $this->get_many_related( 'Payment', $query_params );
1417
+	public function payments($query_params = array()) {
1418
+		return $this->get_many_related('Payment', $query_params);
1419 1419
 	}
1420 1420
 
1421 1421
 
@@ -1425,8 +1425,8 @@  discard block
 block discarded – undo
1425 1425
 	 * @return \EE_Registration_Payment[]
1426 1426
 	 * @throws \EE_Error
1427 1427
 	 */
1428
-	public function registration_payments( $query_params = array() ) {
1429
-		return $this->get_many_related( 'Registration_Payment', $query_params );
1428
+	public function registration_payments($query_params = array()) {
1429
+		return $this->get_many_related('Registration_Payment', $query_params);
1430 1430
 	}
1431 1431
 
1432 1432
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 	 * @return EE_Payment_Method|null
1440 1440
 	 */
1441 1441
 	public function payment_method() {
1442
-		return EEM_Payment_Method::instance()->get_last_used_for_registration( $this );
1442
+		return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1443 1443
 	}
1444 1444
 
1445 1445
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -634,8 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @return EE_Registration
635 635
 	 */
636 636
 	public function get_primary_registration()  {
637
-		if ( $this->is_primary_registrant() )
638
-			return $this;
637
+		if ( $this->is_primary_registrant() ) {
638
+					return $this;
639
+		}
639 640
 
640 641
 		//k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
641 642
 		$primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) );
@@ -1107,8 +1108,9 @@  discard block
 block discarded – undo
1107 1108
 					$cur_status = (int) ($this->check_in_status_for_datetime( $DTT_ID, NULL ) === EE_Registration::checkin_status_in);
1108 1109
 					// If the DT is not checked in and the new status is to check out, skip
1109 1110
 					// If the DT is checked in, and the new status is to check in, skip
1110
-					if ( $status_to === $cur_status )
1111
-						continue;
1111
+					if ( $status_to === $cur_status ) {
1112
+											continue;
1113
+					}
1112 1114
 				}
1113 1115
 				
1114 1116
 				$checkin = EE_Checkin::new_instance( array(
Please login to merge, or discard this patch.
core/db_models/fields/EE_Class_Field.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@
 block discarded – undo
191 191
 	 * generates Business Report showing total revenue per event.
192 192
 	 *
193 193
 	 * @param string $period  The period (acceptable by PHP Datetime constructor) for which the report is generated.
194
-	 * @return int
194
+	 * @return string
195 195
 	 */
196 196
 	private function _revenue_per_event_report( $period = '-1 month' ) {
197 197
 
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
3 3
 class EE_Class_Field extends EE_Text_Field_Base {
4 4
     
5
-    const CSS_CLASS_REGEX = '/^-?([_a-z]|[\240-\377]|([0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|[^\r\n\f0-9a-f]))([_a-z0-9-]|[\240-\377]|([0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|[^\r\n\f0-9a-f]))*$/i';
5
+	const CSS_CLASS_REGEX = '/^-?([_a-z]|[\240-\377]|([0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|[^\r\n\f0-9a-f]))([_a-z0-9-]|[\240-\377]|([0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|[^\r\n\f0-9a-f]))*$/i';
6 6
     
7
-    /**
7
+	/**
8 8
 	 * When setting, just verify that the value being used is a valid CSS Class Name.
9 9
 	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default)
10 10
 	 * @param int $value_inputted_for_field_on_model_object
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
2
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
3 3
 class EE_Class_Field extends EE_Text_Field_Base {
4 4
     
5 5
     const CSS_CLASS_REGEX = '/^-?([_a-z]|[\240-\377]|([0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|[^\r\n\f0-9a-f]))([_a-z0-9-]|[\240-\377]|([0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|[^\r\n\f0-9a-f]))*$/i';
@@ -12,28 +12,28 @@  discard block
 block discarded – undo
12 12
 	 * @throws EE_Error
13 13
 	 */
14 14
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
15
-		if( (string) $value_inputted_for_field_on_model_object !== '') {
15
+		if ((string) $value_inputted_for_field_on_model_object !== '') {
16 16
 			$valid_classes = array();
17
-			foreach ( explode(' ', $value_inputted_for_field_on_model_object) as $i => $potential_class ) {
18
-				if ( ! preg_match(self::CSS_CLASS_REGEX, $potential_class, $dis ) ) {
19
-					if( defined( 'WP_DEBUG' ) && WP_DEBUG ){
17
+			foreach (explode(' ', $value_inputted_for_field_on_model_object) as $i => $potential_class) {
18
+				if ( ! preg_match(self::CSS_CLASS_REGEX, $potential_class, $dis)) {
19
+					if (defined('WP_DEBUG') && WP_DEBUG) {
20 20
 						$msg = sprintf(
21
-							__('System is assigning incompatible value "%1$s" to field "%2$s"','event_espresso'),
21
+							__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
22 22
 							$potential_class,
23 23
 							$this->_name
24 24
 						);
25 25
 						$msg2 = sprintf(
26
-							__('Values must be valid CSS Class names. You provided "%1$s"','event_espresso'),
26
+							__('Values must be valid CSS Class names. You provided "%1$s"', 'event_espresso'),
27 27
 							$potential_class
28 28
 						);
29
-						EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ );
29
+						EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
30 30
 					}
31 31
 				} else
32 32
 					$valid_classes[] = $potential_class;
33 33
 			}
34
-			if ( empty($valid_classes) )
34
+			if (empty($valid_classes))
35 35
 				$value_inputted_for_field_on_model_object = '';
36
-			elseif ( ! isset($valid_classes[1]) )
36
+			elseif ( ! isset($valid_classes[1]))
37 37
 				$value_inputted_for_field_on_model_object = $valid_classes[0];
38 38
 			else
39 39
 				$value_inputted_for_field_on_model_object = implode(' ', $valid_classes);
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,15 +28,17 @@
 block discarded – undo
28 28
 						);
29 29
 						EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ );
30 30
 					}
31
-				} else
32
-					$valid_classes[] = $potential_class;
31
+				} else {
32
+									$valid_classes[] = $potential_class;
33
+				}
34
+			}
35
+			if ( empty($valid_classes) ) {
36
+							$value_inputted_for_field_on_model_object = '';
37
+			} elseif ( ! isset($valid_classes[1]) ) {
38
+							$value_inputted_for_field_on_model_object = $valid_classes[0];
39
+			} else {
40
+							$value_inputted_for_field_on_model_object = implode(' ', $valid_classes);
33 41
 			}
34
-			if ( empty($valid_classes) )
35
-				$value_inputted_for_field_on_model_object = '';
36
-			elseif ( ! isset($valid_classes[1]) )
37
-				$value_inputted_for_field_on_model_object = $valid_classes[0];
38
-			else
39
-				$value_inputted_for_field_on_model_object = implode(' ', $valid_classes);
40 42
 		}
41 43
 		return parent::prepare_for_set($value_inputted_for_field_on_model_object);
42 44
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket.model.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Ticket.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Ticket.class.php');
26 26
 
27 27
 class EEM_Ticket extends EEM_Soft_Delete_Base {
28 28
 
@@ -35,38 +35,38 @@  discard block
 block discarded – undo
35 35
 	 *		@access private
36 36
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
37 37
 	 */
38
-	protected function __construct( $timezone ) {
39
-		$this->singular_item = __('Ticket','event_espresso');
40
-		$this->plural_item = __('Tickets','event_espresso');
38
+	protected function __construct($timezone) {
39
+		$this->singular_item = __('Ticket', 'event_espresso');
40
+		$this->plural_item = __('Tickets', 'event_espresso');
41 41
 
42 42
 		$this->_tables = array(
43 43
 			'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID')
44 44
 		);
45 45
 		$this->_fields = array(
46 46
 			'Ticket'=>array(
47
-				'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')),
48
-				'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'),
47
+				'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')),
48
+				'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'),
49 49
 				'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''),
50
-				'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ),
50
+				'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''),
51 51
 				'TKT_class'=>new EE_Class_Field('TKT_class', __('Ticket Class', 'event_espresso'), false, ''),
52
-				'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
53
-				'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
54
-				'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ),
55
-				'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ),
52
+				'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
53
+				'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
54
+				'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0),
55
+				'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF),
56 56
 				'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0),
57 57
 				'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0),
58
-				'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF),
59
-				'TKT_reserved'=>new EE_Integer_Field('TKT_reserved', __('Quantity of this ticket that is reserved, but not yet fully purchased','event_espresso'), false, 0 ),
60
-				'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ),
61
-				'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ),
62
-				'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false),
63
-				'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ),
64
-				'TKT_full_checkin'=>new EE_Boolean_Field('TKT_full_checkin', __('Flag indicating that checking in with this ticket checks in all associated DateTimes', 'event_espresso'), false, false ),
58
+				'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF),
59
+				'TKT_reserved'=>new EE_Integer_Field('TKT_reserved', __('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso'), false, 0),
60
+				'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF),
61
+				'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false),
62
+				'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false),
63
+				'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false),
64
+				'TKT_full_checkin'=>new EE_Boolean_Field('TKT_full_checkin', __('Flag indicating that checking in with this ticket checks in all associated DateTimes', 'event_espresso'), false, false),
65 65
 				'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0),
66
-				'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ),
66
+				'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0),
67 67
 				'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false),
68
-				'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ),
69
-				'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 )
68
+				'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE),
69
+				'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0)
70 70
 			));
71 71
 		$this->_model_relations = array(
72 72
 			'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'),
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 		);
79 79
 
80 80
 		//this model is generally available for reading
81
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event');
81
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event');
82 82
 		//account for default tickets in the caps
83
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' );
84
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' );
85
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' );
86
-		parent::__construct( $timezone );
83
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event');
84
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event');
85
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event');
86
+		parent::__construct($timezone);
87 87
 	}
88 88
 
89 89
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function get_all_default_tickets() {
96 96
 		/** @type EE_Ticket[] $tickets */
97
-		$tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) );
97
+		$tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')));
98 98
 		//we need to set the start date and end date to today's date and the start of the default dtt
99
-		return $this->_set_default_dates( $tickets );
99
+		return $this->_set_default_dates($tickets);
100 100
 	}
101 101
 
102 102
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 * @param EE_Ticket[] $tickets
107 107
 	 * @return EE_Ticket[]
108 108
 	 */
109
-	private function _set_default_dates( $tickets ) {
110
-		foreach ( $tickets as $ticket ) {
111
-			$ticket->set('TKT_start_date', (int)$this->current_time_for_query('TKT_start_date', true) );
112
-			$ticket->set('TKT_end_date', (int)$this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) );
113
-			$ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) );
109
+	private function _set_default_dates($tickets) {
110
+		foreach ($tickets as $ticket) {
111
+			$ticket->set('TKT_start_date', (int) $this->current_time_for_query('TKT_start_date', true));
112
+			$ticket->set('TKT_end_date', (int) $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30));
113
+			$ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone));
114 114
 		}
115 115
 
116 116
 		return $tickets;
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 	 * @param array $query_params
126 126
 	 * @return int
127 127
 	 */
128
-	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){
129
-		return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params );
128
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) {
129
+		return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params);
130 130
 	}
131 131
 
132 132
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 * @param EE_Ticket[] $tickets
137 137
 	 * @return void
138 138
 	 */
139
-	public function update_tickets_sold($tickets){
140
-		foreach($tickets as $ticket){
139
+	public function update_tickets_sold($tickets) {
140
+		foreach ($tickets as $ticket) {
141 141
 			/* @var  $ticket EE_Ticket */
142 142
 			$ticket->update_tickets_sold();
143 143
 		}
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_datetime_ticket_row.template.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 	<td class="ee-tkt-order-field"><span class="ee-status-strip-td ee-status-strip<?php echo $tkt_status_class; ?>"></span><input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_order]" class="edit-ticket-TKT_order" value ="<?php echo $TKT_order; ?>"></td>
4 4
 	<td><input maxlength="245" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_name]" class="edit-ticket-TKT_name ee-large-text-inp" placeholder="Ticket Title" value="<?php echo $TKT_name; ?>"></td>
5 5
 	<td>
6
-		<?php if ( $disabled ) : ?>
6
+		<?php if ($disabled) : ?>
7 7
 			<input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>"  name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" >
8 8
 			<input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled>
9 9
 		<?php else : ?>
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 		<?php endif; ?>
12 12
 	</td>
13 13
 	<td>
14
-		<?php if ( $disabled ) : ?>
14
+		<?php if ($disabled) : ?>
15 15
 			<input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>"  name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" >
16 16
 			<input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled>
17 17
 		<?php else : ?>
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		<?php endif; ?>
20 20
 	</td>
21 21
 	<td>
22
-		<?php if ( $disabled ) : ?>
22
+		<?php if ($disabled) : ?>
23 23
 			<input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>">
24 24
 			<input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled>
25 25
 		<?php else : ?>
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		<input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>">
29 29
 	</td>
30 30
 	<td>
31
-		<?php if ( $disabled ) : ?>
31
+		<?php if ($disabled) : ?>
32 32
 			<input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>">
33 33
 			<input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled>
34 34
 		<?php else : ?>
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 			<input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_ID]" class="edit-ticket-TKT_ID" value="<?php echo $TKT_ID; ?>">
50 50
 			<input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_row]" class="edit-ticket-TKT_row" value="<?php echo $tkt_row; ?>">
51 51
 
52
-			<!--<div class="total-price-container"><?php printf( esc_html__('Total Final Price: %s', 'event_espresso'), '<span class="ticket-price-amount">' . $TKT_price . '</span>'); ?> </div>-->
52
+			<!--<div class="total-price-container"><?php printf(esc_html__('Total Final Price: %s', 'event_espresso'), '<span class="ticket-price-amount">'.$TKT_price.'</span>'); ?> </div>-->
53 53
 			<textarea name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_description]" class="edit-ticket-TKT_description ee-full-textarea-inp" placeholder="Ticket Description"><?php echo $TKT_description; ?></textarea>
54 54
 
55
-			<?php do_action( 'AHEE__event_tickets_datetime_ticket_row_template_after_desc', $tkt_row, $TKT_ID ); ?>
55
+			<?php do_action('AHEE__event_tickets_datetime_ticket_row_template_after_desc', $tkt_row, $TKT_ID); ?>
56 56
 
57 57
 			<div class="basic-ticket-container">
58 58
 				<h4 class="tickets-heading"><?php esc_html_e('Ticket Details', 'event_espresso'); ?></h4>
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 					<tbody>
69 69
 						<tr>
70 70
 							<td>
71
-								<?php if ( $disabled ) : ?>
71
+								<?php if ($disabled) : ?>
72 72
 									<input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>">
73 73
 									<input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled>
74 74
 								<?php else : ?>
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 								<?php endif; ?>
77 77
 							</td>
78 78
 							<td>
79
-								<?php if ( $disabled ) : ?>
79
+								<?php if ($disabled) : ?>
80 80
 									<input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>">
81 81
 									<input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled>
82 82
 								<?php else: ?>
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 								<?php endif; ?>
85 85
 							</td>
86 86
 							<td>
87
-								<?php if ( $disabled ) : ?>
87
+								<?php if ($disabled) : ?>
88 88
 									<input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>">
89 89
 									<input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled>
90 90
 								<?php else : ?>
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 					<label for="edit-ticket-TKT_required"><?php esc_html_e('This ticket is required (will appear first in frontend ticket lists).', 'event_espresso'); ?></label>
103 103
 				</div>
104 104
 				<div class="ticket-is-taxable-container">
105
-					<?php if ( !empty($tax_rows) ) { ?>
106
-						<?php if ( $disabled ) : ?>
105
+					<?php if ( ! empty($tax_rows)) { ?>
106
+						<?php if ($disabled) : ?>
107 107
 							<?php
108
-								$tax_value = !empty( $TKT_taxable ) ? 1 : 0;
108
+								$tax_value = ! empty($TKT_taxable) ? 1 : 0;
109 109
 							?>
110
-							<input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>">
110
+							<input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>">
111 111
 							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled>
112 112
 						<?php else : ?>
113
-							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>>
113
+							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>>
114 114
 						<?php endif; ?>
115 115
 						<label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?>
116 116
 					<?php } //end tax_rows check ?>
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 					<tbody>
180 180
 						<tr>
181 181
 							<td>
182
-								<?php if ( $disabled ) : ?>
182
+								<?php if ($disabled) : ?>
183 183
 									<input type="hidden" class="edit-ticket-TKT_class ee-small-text-inp ee-text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_class]" value="<?php echo $TKT_class; ?>">
184 184
 									<input type="text" class="edit-ticket-TKT_class ee-small-text-inp ee-text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_class]" value="<?php echo $TKT_class; ?>" disabled>
185 185
 								<?php else : ?>
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 					<label for="edit-ticket-TKT_full_checkin-<?php echo $tkt_row; ?>"><?php esc_html_e('Ticket Checks-In/Out in Full.', 'event_espresso'); ?></label>
196 196
 				</div>
197 197
 			</div>
198
-			<?php do_action( 'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', $tkt_row, $TKT_ID ); ?>
198
+			<?php do_action('AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', $tkt_row, $TKT_ID); ?>
199 199
 			<div class="ee-editor-footer-container">
200 200
 				<div class="ee-editor-id-container">
201
-					<span class="ee-item-id"><?php echo $TKT_ID ? sprintf( esc_html__( 'Ticket ID: %d', 'event_espresso' ), $TKT_ID ) : ''; ?></span>
201
+					<span class="ee-item-id"><?php echo $TKT_ID ? sprintf(esc_html__('Ticket ID: %d', 'event_espresso'), $TKT_ID) : ''; ?></span>
202 202
 				</div>
203 203
 				<div class="save-cancel-button-container">
204 204
 					<label for="edit-ticket-TKT_is_default_selector"><?php esc_html_e('use this new ticket as a default ticket for any new events', 'event_espresso'); ?></label>
Please login to merge, or discard this patch.
Braces   +45 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,24 +6,33 @@  discard block
 block discarded – undo
6 6
 		<?php if ( $disabled ) : ?>
7 7
 			<input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>"  name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" >
8 8
 			<input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled>
9
-		<?php else : ?>
10
-			<input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date">
9
+		<?php else {
10
+	: ?>
11
+			<input id="edit-ticket-TKT_start_date-<?php echo $tkt_row;
12
+}
13
+?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date">
11 14
 		<?php endif; ?>
12 15
 	</td>
13 16
 	<td>
14 17
 		<?php if ( $disabled ) : ?>
15 18
 			<input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>"  name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" >
16 19
 			<input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled>
17
-		<?php else : ?>
18
-			<input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty">
20
+		<?php else {
21
+	: ?>
22
+			<input id="edit-ticket-TKT_end_date-<?php echo $tkt_row;
23
+}
24
+?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty">
19 25
 		<?php endif; ?>
20 26
 	</td>
21 27
 	<td>
22 28
 		<?php if ( $disabled ) : ?>
23 29
 			<input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>">
24 30
 			<input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled>
25
-		<?php else : ?>
26
-			<input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>">
31
+		<?php else {
32
+	: ?>
33
+			<input id="edit-ticket-TKT_base_price-<?php echo $tkt_row;
34
+}
35
+?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>">
27 36
 		<?php endif; ?>
28 37
 		<input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>">
29 38
 	</td>
@@ -31,8 +40,11 @@  discard block
 block discarded – undo
31 40
 		<?php if ( $disabled ) : ?>
32 41
 			<input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>">
33 42
 			<input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled>
34
-		<?php else : ?>
35
-			<input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; ?>"class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>">
43
+		<?php else {
44
+	: ?>
45
+			<input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row;
46
+}
47
+?>"class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>">
36 48
 		<?php endif; ?>
37 49
 	</td>
38 50
 	<!--<td><span class="ticket-display-row-TKT_price"><?php echo $TKT_price; ?></span></td>-->
@@ -71,24 +83,33 @@  discard block
 block discarded – undo
71 83
 								<?php if ( $disabled ) : ?>
72 84
 									<input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>">
73 85
 									<input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled>
74
-								<?php else : ?>
75
-									<input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>">
86
+								<?php else {
87
+	: ?>
88
+									<input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name;
89
+}
90
+?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>">
76 91
 								<?php endif; ?>
77 92
 							</td>
78 93
 							<td>
79 94
 								<?php if ( $disabled ) : ?>
80 95
 									<input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>">
81 96
 									<input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled>
82
-								<?php else: ?>
83
-									<input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>">
97
+								<?php else {
98
+	: ?>
99
+									<input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name;
100
+}
101
+?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>">
84 102
 								<?php endif; ?>
85 103
 							</td>
86 104
 							<td>
87 105
 								<?php if ( $disabled ) : ?>
88 106
 									<input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>">
89 107
 									<input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled>
90
-								<?php else : ?>
91
-									<input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>">
108
+								<?php else {
109
+	: ?>
110
+									<input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name;
111
+}
112
+?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>">
92 113
 								<?php endif; ?>
93 114
 							</td>
94 115
 						</tr>
@@ -109,8 +130,11 @@  discard block
 block discarded – undo
109 130
 							?>
110 131
 							<input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>">
111 132
 							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled>
112
-						<?php else : ?>
113
-							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>>
133
+						<?php else {
134
+	: ?>
135
+							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row;
136
+}
137
+?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>>
114 138
 						<?php endif; ?>
115 139
 						<label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?>
116 140
 					<?php } //end tax_rows check ?>
@@ -182,8 +206,11 @@  discard block
 block discarded – undo
182 206
 								<?php if ( $disabled ) : ?>
183 207
 									<input type="hidden" class="edit-ticket-TKT_class ee-small-text-inp ee-text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_class]" value="<?php echo $TKT_class; ?>">
184 208
 									<input type="text" class="edit-ticket-TKT_class ee-small-text-inp ee-text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_class]" value="<?php echo $TKT_class; ?>" disabled>
185
-								<?php else : ?>
186
-									<input type="text" class="edit-ticket-TKT_class ee-small-text-inp ee-text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_class]" value="<?php echo $TKT_class; ?>">
209
+								<?php else {
210
+	: ?>
211
+									<input type="text" class="edit-ticket-TKT_class ee-small-text-inp ee-text" name="<?php echo $edit_tickets_name;
212
+}
213
+?>[<?php echo $tkt_row; ?>][TKT_class]" value="<?php echo $TKT_class; ?>">
187 214
 								<?php endif; ?>
188 215
 							</td>
189 216
 						</tr>
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Indentation   +1410 added lines, -1410 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
 /**
@@ -31,1537 +31,1537 @@  discard block
 block discarded – undo
31 31
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
32 32
 {
33 33
     
34
-    /**
35
-     * This property is just used to hold the status of whether an event is currently being
36
-     * created (true) or edited (false)
37
-     * @access protected
38
-     * @var bool
39
-     */
40
-    protected $_is_creating_event;
34
+	/**
35
+	 * This property is just used to hold the status of whether an event is currently being
36
+	 * created (true) or edited (false)
37
+	 * @access protected
38
+	 * @var bool
39
+	 */
40
+	protected $_is_creating_event;
41 41
     
42 42
     
43
-    /**
44
-     * Used to contain the format strings for date and time that will be used for php date and
45
-     * time.
46
-     *
47
-     * Is set in the _set_hooks_properties() method.
48
-     *
49
-     * @var array
50
-     */
51
-    protected $_date_format_strings;
43
+	/**
44
+	 * Used to contain the format strings for date and time that will be used for php date and
45
+	 * time.
46
+	 *
47
+	 * Is set in the _set_hooks_properties() method.
48
+	 *
49
+	 * @var array
50
+	 */
51
+	protected $_date_format_strings;
52 52
     
53 53
     
54
-    protected function _set_hooks_properties()
55
-    {
56
-        $this->_name = 'pricing';
57
-        
58
-        //capability check
59
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices',
60
-            'advanced_ticket_datetime_metabox')
61
-        ) {
62
-            return;
63
-        }
64
-        
65
-        
66
-        //if we were going to add our own metaboxes we'd use the below.
67
-        $this->_metaboxes = array(
68
-            0 => array(
69
-                'page_route' => array('edit', 'create_new'),
70
-                'func'       => 'pricing_metabox',
71
-                'label'      => __('Event Tickets & Datetimes', 'event_espresso'),
72
-                'priority'   => 'high',
73
-                'context'    => 'normal'
74
-            ),
75
-        
76
-        );/**/
77
-        
78
-        $this->_remove_metaboxes = array(
79
-            0 => array(
80
-                'page_route' => array('edit', 'create_new'),
81
-                'id'         => 'espresso_event_editor_tickets',
82
-                'context'    => 'normal'
83
-            )
84
-        );
85
-        
86
-        /**
87
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
88
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
89
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
90
-         *
91
-         * @since 4.6.7
92
-         *
93
-         * @var array  Expected an array returned with 'date' and 'time' keys.
94
-         */
95
-        $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
96
-            array(
97
-                'date' => 'Y-m-d',
98
-                'time' => 'h:i a'
99
-            ));
100
-        
101
-        //validate
102
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
103
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
104
-        
105
-        //validate format strings
106
-        $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
107
-        if (is_array($format_validation)) {
108
-            $msg = '<p>' . sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:',
109
-                    'event_espresso'),
110
-                    $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']) . '</p><ul>';
111
-            foreach ($format_validation as $error) {
112
-                $msg .= '<li>' . $error . '</li>';
113
-            }
114
-            $msg .= '</ul></p><p>' . sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
115
-                    'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
116
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
117
-            $this->_date_format_strings = array(
118
-                'date' => 'Y-m-d',
119
-                'time' => 'h:i a'
120
-            );
121
-        }
122
-        
123
-        
124
-        $this->_scripts_styles = array(
125
-            'registers'   => array(
126
-                'ee-tickets-datetimes-css' => array(
127
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
128
-                    'type' => 'css'
129
-                ),
130
-                'ee-dtt-ticket-metabox'    => array(
131
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
132
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
133
-                )
134
-            ),
135
-            'deregisters' => array(
136
-                'event-editor-css'       => array('type' => 'css'),
137
-                'event-datetime-metabox' => array('type' => 'js')
138
-            ),
139
-            'enqueues'    => array(
140
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
141
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new')
142
-            ),
143
-            'localize'    => array(
144
-                'ee-dtt-ticket-metabox' => array(
145
-                    'DTT_TRASH_BLOCK'       => array(
146
-                        'main_warning'            => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
147
-                            'event_espresso'),
148
-                        'after_warning'           => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
149
-                            'event_espresso'),
150
-                        'cancel_button'           => '<button class="button-secondary ee-modal-cancel">' . __('Cancel',
151
-                                'event_espresso') . '</button>',
152
-                        'close_button'            => '<button class="button-secondary ee-modal-cancel">' . __('Close',
153
-                                'event_espresso') . '</button>',
154
-                        'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
155
-                            'event_espresso'),
156
-                        'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
157
-                            'event_espresso'),
158
-                        'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss',
159
-                                'event_espresso') . '</button>'
160
-                    ),
161
-                    'DTT_ERROR_MSG'         => array(
162
-                        'no_ticket_name' => __('General Admission', 'event_espresso'),
163
-                        'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss',
164
-                                'event_espresso') . '</button></div>'
165
-                    ),
166
-                    'DTT_OVERSELL_WARNING'  => array(
167
-                        'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
168
-                            'event_espresso'),
169
-                        'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
170
-                            'event_espresso')
171
-                    ),
172
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'],
173
-                        $this->_date_format_strings['time']),
174
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int)get_option('start_of_week'))
175
-                )
176
-            )
177
-        );
178
-        
179
-        
180
-        add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
181
-            array($this, 'autosave_handling'), 10);
182
-        add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
183
-            array($this, 'caf_updates'), 10);
184
-    }
54
+	protected function _set_hooks_properties()
55
+	{
56
+		$this->_name = 'pricing';
57
+        
58
+		//capability check
59
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices',
60
+			'advanced_ticket_datetime_metabox')
61
+		) {
62
+			return;
63
+		}
64
+        
65
+        
66
+		//if we were going to add our own metaboxes we'd use the below.
67
+		$this->_metaboxes = array(
68
+			0 => array(
69
+				'page_route' => array('edit', 'create_new'),
70
+				'func'       => 'pricing_metabox',
71
+				'label'      => __('Event Tickets & Datetimes', 'event_espresso'),
72
+				'priority'   => 'high',
73
+				'context'    => 'normal'
74
+			),
75
+        
76
+		);/**/
77
+        
78
+		$this->_remove_metaboxes = array(
79
+			0 => array(
80
+				'page_route' => array('edit', 'create_new'),
81
+				'id'         => 'espresso_event_editor_tickets',
82
+				'context'    => 'normal'
83
+			)
84
+		);
85
+        
86
+		/**
87
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
88
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
89
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
90
+		 *
91
+		 * @since 4.6.7
92
+		 *
93
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
94
+		 */
95
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
96
+			array(
97
+				'date' => 'Y-m-d',
98
+				'time' => 'h:i a'
99
+			));
100
+        
101
+		//validate
102
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
103
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
104
+        
105
+		//validate format strings
106
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
107
+		if (is_array($format_validation)) {
108
+			$msg = '<p>' . sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:',
109
+					'event_espresso'),
110
+					$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']) . '</p><ul>';
111
+			foreach ($format_validation as $error) {
112
+				$msg .= '<li>' . $error . '</li>';
113
+			}
114
+			$msg .= '</ul></p><p>' . sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
115
+					'event_espresso'), '<span style="color:#D54E21;">', '</span>') . '</p>';
116
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
117
+			$this->_date_format_strings = array(
118
+				'date' => 'Y-m-d',
119
+				'time' => 'h:i a'
120
+			);
121
+		}
122
+        
123
+        
124
+		$this->_scripts_styles = array(
125
+			'registers'   => array(
126
+				'ee-tickets-datetimes-css' => array(
127
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
128
+					'type' => 'css'
129
+				),
130
+				'ee-dtt-ticket-metabox'    => array(
131
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
132
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
133
+				)
134
+			),
135
+			'deregisters' => array(
136
+				'event-editor-css'       => array('type' => 'css'),
137
+				'event-datetime-metabox' => array('type' => 'js')
138
+			),
139
+			'enqueues'    => array(
140
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
141
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new')
142
+			),
143
+			'localize'    => array(
144
+				'ee-dtt-ticket-metabox' => array(
145
+					'DTT_TRASH_BLOCK'       => array(
146
+						'main_warning'            => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
147
+							'event_espresso'),
148
+						'after_warning'           => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
149
+							'event_espresso'),
150
+						'cancel_button'           => '<button class="button-secondary ee-modal-cancel">' . __('Cancel',
151
+								'event_espresso') . '</button>',
152
+						'close_button'            => '<button class="button-secondary ee-modal-cancel">' . __('Close',
153
+								'event_espresso') . '</button>',
154
+						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
155
+							'event_espresso'),
156
+						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
157
+							'event_espresso'),
158
+						'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss',
159
+								'event_espresso') . '</button>'
160
+					),
161
+					'DTT_ERROR_MSG'         => array(
162
+						'no_ticket_name' => __('General Admission', 'event_espresso'),
163
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss',
164
+								'event_espresso') . '</button></div>'
165
+					),
166
+					'DTT_OVERSELL_WARNING'  => array(
167
+						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
168
+							'event_espresso'),
169
+						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
170
+							'event_espresso')
171
+					),
172
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'],
173
+						$this->_date_format_strings['time']),
174
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int)get_option('start_of_week'))
175
+				)
176
+			)
177
+		);
178
+        
179
+        
180
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
181
+			array($this, 'autosave_handling'), 10);
182
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
183
+			array($this, 'caf_updates'), 10);
184
+	}
185 185
     
186 186
     
187
-    public function caf_updates($update_callbacks)
188
-    {
189
-        foreach ($update_callbacks as $key => $callback) {
190
-            if ($callback[1] == '_default_tickets_update') {
191
-                unset($update_callbacks[$key]);
192
-            }
193
-        }
194
-        
195
-        $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
196
-        
197
-        return $update_callbacks;
198
-    }
187
+	public function caf_updates($update_callbacks)
188
+	{
189
+		foreach ($update_callbacks as $key => $callback) {
190
+			if ($callback[1] == '_default_tickets_update') {
191
+				unset($update_callbacks[$key]);
192
+			}
193
+		}
194
+        
195
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
196
+        
197
+		return $update_callbacks;
198
+	}
199 199
     
200 200
     
201
-    /**
202
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
203
-     *
204
-     * @param  EE_Event $evtobj The Event object we're attaching data to
205
-     * @param  array    $data   The request data from the form
206
-     *
207
-     * @return bool             success or fail
208
-     */
209
-    public function dtt_and_tickets_caf_update($evtobj, $data)
210
-    {
211
-        //first we need to start with datetimes cause they are the "root" items attached to events.
212
-        $saved_dtts = $this->_update_dtts($evtobj, $data);
213
-        //next tackle the tickets (and prices?)
214
-        $this->_update_tkts($evtobj, $saved_dtts, $data);
215
-    }
201
+	/**
202
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
203
+	 *
204
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
205
+	 * @param  array    $data   The request data from the form
206
+	 *
207
+	 * @return bool             success or fail
208
+	 */
209
+	public function dtt_and_tickets_caf_update($evtobj, $data)
210
+	{
211
+		//first we need to start with datetimes cause they are the "root" items attached to events.
212
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
213
+		//next tackle the tickets (and prices?)
214
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
215
+	}
216 216
     
217 217
     
218
-    /**
219
-     * update event_datetimes
220
-     *
221
-     * @param  EE_Event $evt_obj Event being updated
222
-     * @param  array    $data    the request data from the form
223
-     *
224
-     * @return EE_Datetime[]
225
-     */
226
-    protected function _update_dtts($evt_obj, $data)
227
-    {
228
-        $timezone       = isset($data['timezone_string']) ? $data['timezone_string'] : null;
229
-        $saved_dtt_ids  = array();
230
-        $saved_dtt_objs = array();
231
-        
232
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
233
-            //trim all values to ensure any excess whitespace is removed.
234
-            $dtt                = array_map(
235
-                function ($datetime_data) {
236
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
237
-                },
238
-                $dtt
239
-            );
240
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
241
-            $datetime_values    = array(
242
-                'DTT_ID'          => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
243
-                'DTT_name'        => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
244
-                'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
245
-                'DTT_EVT_start'   => $dtt['DTT_EVT_start'],
246
-                'DTT_EVT_end'     => $dtt['DTT_EVT_end'],
247
-                'DTT_reg_limit'   => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
248
-                'DTT_order'       => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
249
-            );
218
+	/**
219
+	 * update event_datetimes
220
+	 *
221
+	 * @param  EE_Event $evt_obj Event being updated
222
+	 * @param  array    $data    the request data from the form
223
+	 *
224
+	 * @return EE_Datetime[]
225
+	 */
226
+	protected function _update_dtts($evt_obj, $data)
227
+	{
228
+		$timezone       = isset($data['timezone_string']) ? $data['timezone_string'] : null;
229
+		$saved_dtt_ids  = array();
230
+		$saved_dtt_objs = array();
231
+        
232
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
233
+			//trim all values to ensure any excess whitespace is removed.
234
+			$dtt                = array_map(
235
+				function ($datetime_data) {
236
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
237
+				},
238
+				$dtt
239
+			);
240
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
241
+			$datetime_values    = array(
242
+				'DTT_ID'          => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
243
+				'DTT_name'        => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
244
+				'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
245
+				'DTT_EVT_start'   => $dtt['DTT_EVT_start'],
246
+				'DTT_EVT_end'     => $dtt['DTT_EVT_end'],
247
+				'DTT_reg_limit'   => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
248
+				'DTT_order'       => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
249
+			);
250 250
             
251
-            //if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
251
+			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
252 252
             
253
-            if ( ! empty($dtt['DTT_ID'])) {
254
-                $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
253
+			if ( ! empty($dtt['DTT_ID'])) {
254
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
255 255
                 
256
-                //set date and time format according to what is set in this class.
257
-                $DTM->set_date_format($this->_date_format_strings['date']);
258
-                $DTM->set_time_format($this->_date_format_strings['time']);
256
+				//set date and time format according to what is set in this class.
257
+				$DTM->set_date_format($this->_date_format_strings['date']);
258
+				$DTM->set_time_format($this->_date_format_strings['time']);
259 259
                 
260
-                foreach ($datetime_values as $field => $value) {
261
-                    $DTM->set($field, $value);
262
-                }
260
+				foreach ($datetime_values as $field => $value) {
261
+					$DTM->set($field, $value);
262
+				}
263 263
                 
264
-                // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
265
-                // We need to do this so we dont' TRASH the parent DTT.(save the ID for both key and value to avoid duplications)
266
-                $saved_dtt_ids[$DTM->ID()] = $DTM->ID();
264
+				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
265
+				// We need to do this so we dont' TRASH the parent DTT.(save the ID for both key and value to avoid duplications)
266
+				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
267 267
                 
268
-            } else {
269
-                $DTM = EE_Registry::instance()->load_class(
270
-                    'Datetime',
271
-                    array(
272
-                        $datetime_values,
273
-                        $timezone,
274
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
275
-                    ),
276
-                    false,
277
-                    false
278
-                );
268
+			} else {
269
+				$DTM = EE_Registry::instance()->load_class(
270
+					'Datetime',
271
+					array(
272
+						$datetime_values,
273
+						$timezone,
274
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
275
+					),
276
+					false,
277
+					false
278
+				);
279 279
                 
280
-                foreach ($datetime_values as $field => $value) {
281
-                    $DTM->set($field, $value);
282
-                }
283
-            }
280
+				foreach ($datetime_values as $field => $value) {
281
+					$DTM->set($field, $value);
282
+				}
283
+			}
284 284
             
285 285
             
286
-            $DTM->save();
287
-            $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
288
-            $evt_obj->save();
286
+			$DTM->save();
287
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
288
+			$evt_obj->save();
289 289
             
290
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
291
-            if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
292
-                $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
293
-                $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
294
-                $DTM->save();
295
-            }
290
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
291
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
292
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
293
+				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
294
+				$DTM->save();
295
+			}
296 296
             
297
-            //	now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
298
-            // because it is possible there was a new one created for the autosave.
299
-            // (save the ID for both key and value to avoid duplications)
300
-            $saved_dtt_ids[$DTM->ID()] = $DTM->ID();
301
-            $saved_dtt_objs[$row]      = $DTM;
297
+			//	now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
298
+			// because it is possible there was a new one created for the autosave.
299
+			// (save the ID for both key and value to avoid duplications)
300
+			$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
301
+			$saved_dtt_objs[$row]      = $DTM;
302 302
             
303
-            //todo if ANY of these updates fail then we want the appropriate global error message.
304
-        }
305
-        
306
-        //now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
307
-        $old_datetimes = explode(',', $data['datetime_IDs']);
308
-        $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
309
-        
310
-        if (is_array($old_datetimes)) {
311
-            $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
312
-            foreach ($dtts_to_delete as $id) {
313
-                $id = absint($id);
314
-                if (empty($id)) {
315
-                    continue;
316
-                }
303
+			//todo if ANY of these updates fail then we want the appropriate global error message.
304
+		}
305
+        
306
+		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
307
+		$old_datetimes = explode(',', $data['datetime_IDs']);
308
+		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
309
+        
310
+		if (is_array($old_datetimes)) {
311
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
312
+			foreach ($dtts_to_delete as $id) {
313
+				$id = absint($id);
314
+				if (empty($id)) {
315
+					continue;
316
+				}
317 317
                 
318
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
318
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
319 319
                 
320
-                //remove tkt relationships.
321
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
322
-                foreach ($related_tickets as $tkt) {
323
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
324
-                }
320
+				//remove tkt relationships.
321
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
322
+				foreach ($related_tickets as $tkt) {
323
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
324
+				}
325 325
                 
326
-                $evt_obj->_remove_relation_to($id, 'Datetime');
327
-                $dtt_to_remove->refresh_cache_of_related_objects();
326
+				$evt_obj->_remove_relation_to($id, 'Datetime');
327
+				$dtt_to_remove->refresh_cache_of_related_objects();
328 328
                 
329
-            }
330
-        }
329
+			}
330
+		}
331 331
         
332
-        return $saved_dtt_objs;
333
-    }
332
+		return $saved_dtt_objs;
333
+	}
334 334
     
335 335
     
336
-    /**
337
-     * update tickets
338
-     *
339
-     * @param  EE_Event      $evtobj     Event object being updated
340
-     * @param  EE_Datetime[] $saved_dtts an array of datetime ids being updated
341
-     * @param  array         $data       incoming request data
342
-     *
343
-     * @return EE_Ticket[]
344
-     */
345
-    protected function _update_tkts($evtobj, $saved_dtts, $data)
346
-    {
347
-        
348
-        $new_tkt     = null;
349
-        $new_default = null;
350
-        //stripslashes because WP filtered the $_POST ($data) array to add slashes
351
-        $data          = stripslashes_deep($data);
352
-        $timezone      = isset($data['timezone_string']) ? $data['timezone_string'] : null;
353
-        $saved_tickets = $dtts_on_existing = array();
354
-        $old_tickets   = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
355
-        
356
-        //load money helper
357
-        
358
-        foreach ($data['edit_tickets'] as $row => $tkt) {
336
+	/**
337
+	 * update tickets
338
+	 *
339
+	 * @param  EE_Event      $evtobj     Event object being updated
340
+	 * @param  EE_Datetime[] $saved_dtts an array of datetime ids being updated
341
+	 * @param  array         $data       incoming request data
342
+	 *
343
+	 * @return EE_Ticket[]
344
+	 */
345
+	protected function _update_tkts($evtobj, $saved_dtts, $data)
346
+	{
347
+        
348
+		$new_tkt     = null;
349
+		$new_default = null;
350
+		//stripslashes because WP filtered the $_POST ($data) array to add slashes
351
+		$data          = stripslashes_deep($data);
352
+		$timezone      = isset($data['timezone_string']) ? $data['timezone_string'] : null;
353
+		$saved_tickets = $dtts_on_existing = array();
354
+		$old_tickets   = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
355
+        
356
+		//load money helper
357
+        
358
+		foreach ($data['edit_tickets'] as $row => $tkt) {
359 359
             
360
-            $update_prices = $create_new_TKT = false;
360
+			$update_prices = $create_new_TKT = false;
361 361
             
362
-            //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
362
+			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
363 363
             
364
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
365
-            $tkt_dtt_rows          = explode(',', $data['ticket_datetime_rows'][$row]);
366
-            $dtts_added            = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
367
-            $dtts_removed          = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
364
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
365
+			$tkt_dtt_rows          = explode(',', $data['ticket_datetime_rows'][$row]);
366
+			$dtts_added            = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
367
+			$dtts_removed          = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
368 368
             
369
-            // trim inputs to ensure any excess whitespace is removed.
370
-            $tkt = array_map(
371
-                function ($ticket_data) {
372
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
373
-                },
374
-                $tkt
375
-            );
369
+			// trim inputs to ensure any excess whitespace is removed.
370
+			$tkt = array_map(
371
+				function ($ticket_data) {
372
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
373
+				},
374
+				$tkt
375
+			);
376 376
             
377
-            //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
378
-            //note incoming ['TKT_price'] value is already in standard notation (via js).
379
-            $ticket_price = isset($tkt['TKT_price']) ? round((float)$tkt['TKT_price'], 3) : 0;
377
+			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
378
+			//note incoming ['TKT_price'] value is already in standard notation (via js).
379
+			$ticket_price = isset($tkt['TKT_price']) ? round((float)$tkt['TKT_price'], 3) : 0;
380 380
             
381
-            //note incoming base price needs converted from localized value.
382
-            $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
383
-            //if ticket price == 0 and $base_price != 0 then ticket price == base_price
384
-            $ticket_price  = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
385
-            $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
381
+			//note incoming base price needs converted from localized value.
382
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
383
+			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
384
+			$ticket_price  = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
385
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
386 386
             
387
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
387
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
388 388
             
389
-            $now = null;
390
-            if (empty($tkt['TKT_start_date'])) {
391
-                //lets' use now in the set timezone.
392
-                $now                   = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
393
-                $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
394
-            }
389
+			$now = null;
390
+			if (empty($tkt['TKT_start_date'])) {
391
+				//lets' use now in the set timezone.
392
+				$now                   = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
393
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
394
+			}
395 395
             
396
-            if (empty($tkt['TKT_end_date'])) {
397
-                /**
398
-                 * set the TKT_end_date to the first datetime attached to the ticket.
399
-                 */
400
-                $first_dtt           = $saved_dtts[reset($tkt_dtt_rows)];
401
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time']);
402
-            }
396
+			if (empty($tkt['TKT_end_date'])) {
397
+				/**
398
+				 * set the TKT_end_date to the first datetime attached to the ticket.
399
+				 */
400
+				$first_dtt           = $saved_dtts[reset($tkt_dtt_rows)];
401
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time']);
402
+			}
403 403
             
404
-            $TKT_values = array(
405
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
406
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
407
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
408
-                'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description',
409
-                    'event_espresso') ? $tkt['TKT_description'] : '',
410
-                'TKT_start_date'  => $tkt['TKT_start_date'],
411
-                'TKT_end_date'    => $tkt['TKT_end_date'],
412
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
413
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
414
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
415
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
416
-                'TKT_row'         => $row,
417
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
418
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
419
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
420
-                'TKT_price'       => $ticket_price,
421
-                'TKT_class'       => $tkt['TKT_class'],
422
-                'TKT_full_checkin'=> $tkt['TKT_full_checkin']
423
-            );
404
+			$TKT_values = array(
405
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
406
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
407
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
408
+				'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description',
409
+					'event_espresso') ? $tkt['TKT_description'] : '',
410
+				'TKT_start_date'  => $tkt['TKT_start_date'],
411
+				'TKT_end_date'    => $tkt['TKT_end_date'],
412
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
413
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
414
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
415
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
416
+				'TKT_row'         => $row,
417
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
418
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
419
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
420
+				'TKT_price'       => $ticket_price,
421
+				'TKT_class'       => $tkt['TKT_class'],
422
+				'TKT_full_checkin'=> $tkt['TKT_full_checkin']
423
+			);
424 424
             
425 425
             
426
-            //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
427
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
428
-                $TKT_values['TKT_ID']         = 0;
429
-                $TKT_values['TKT_is_default'] = 0;
430
-                $update_prices                = true;
431
-            }
426
+			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
427
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
428
+				$TKT_values['TKT_ID']         = 0;
429
+				$TKT_values['TKT_is_default'] = 0;
430
+				$update_prices                = true;
431
+			}
432 432
             
433
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
434
-            // we actually do our saves ahead of doing any add_relations to
435
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
436
-            // but DID have it's items modified.
437
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
438
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
439
-            if (absint($TKT_values['TKT_ID'])) {
440
-                $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
441
-                if ($TKT instanceof EE_Ticket) {
433
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
434
+			// we actually do our saves ahead of doing any add_relations to
435
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
436
+			// but DID have it's items modified.
437
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
438
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
439
+			if (absint($TKT_values['TKT_ID'])) {
440
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
441
+				if ($TKT instanceof EE_Ticket) {
442 442
                     
443
-                    $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
444
-                    // are there any registrations using this ticket ?
445
-                    $tickets_sold = $TKT->count_related(
446
-                        'Registration',
447
-                        array(
448
-                            array(
449
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
450
-                            )
451
-                        )
452
-                    );
453
-                    //set ticket formats
454
-                    $TKT->set_date_format($this->_date_format_strings['date']);
455
-                    $TKT->set_time_format($this->_date_format_strings['time']);
443
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
444
+					// are there any registrations using this ticket ?
445
+					$tickets_sold = $TKT->count_related(
446
+						'Registration',
447
+						array(
448
+							array(
449
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
450
+							)
451
+						)
452
+					);
453
+					//set ticket formats
454
+					$TKT->set_date_format($this->_date_format_strings['date']);
455
+					$TKT->set_time_format($this->_date_format_strings['time']);
456 456
                     
457
-                    // let's just check the total price for the existing ticket
458
-                    // and determine if it matches the new total price.
459
-                    // if they are different then we create a new ticket (if tkts sold)
460
-                    // if they aren't different then we go ahead and modify existing ticket.
461
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price != $TKT->price() && ! $TKT->deleted()
462
-                        ? true : false;
457
+					// let's just check the total price for the existing ticket
458
+					// and determine if it matches the new total price.
459
+					// if they are different then we create a new ticket (if tkts sold)
460
+					// if they aren't different then we go ahead and modify existing ticket.
461
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price != $TKT->price() && ! $TKT->deleted()
462
+						? true : false;
463 463
                     
464
-                    //set new values
465
-                    foreach ($TKT_values as $field => $value) {
466
-                        if ($field === 'TKT_qty') {
467
-                            $TKT->set_qty($value);
468
-                        } else {
469
-                            $TKT->set($field, $value);
470
-                        }
471
-                    }
464
+					//set new values
465
+					foreach ($TKT_values as $field => $value) {
466
+						if ($field === 'TKT_qty') {
467
+							$TKT->set_qty($value);
468
+						} else {
469
+							$TKT->set($field, $value);
470
+						}
471
+					}
472 472
                     
473
-                    //if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
474
-                    if ($create_new_TKT) {
475
-                        $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price,
476
-                            $base_price_id);
477
-                    }
478
-                }
473
+					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
474
+					if ($create_new_TKT) {
475
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price,
476
+							$base_price_id);
477
+					}
478
+				}
479 479
                 
480
-            } else {
481
-                // no TKT_id so a new TKT
482
-                $TKT = EE_Ticket::new_instance(
483
-                    $TKT_values,
484
-                    $timezone,
485
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
486
-                );
487
-                if ($TKT instanceof EE_Ticket) {
488
-                    // make sure ticket has an ID of setting relations won't work
489
-                    $TKT->save();
490
-                    $TKT           = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
491
-                    $update_prices = true;
492
-                }
493
-            }
494
-            //make sure any current values have been saved.
495
-            //$TKT->save();
480
+			} else {
481
+				// no TKT_id so a new TKT
482
+				$TKT = EE_Ticket::new_instance(
483
+					$TKT_values,
484
+					$timezone,
485
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
486
+				);
487
+				if ($TKT instanceof EE_Ticket) {
488
+					// make sure ticket has an ID of setting relations won't work
489
+					$TKT->save();
490
+					$TKT           = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
491
+					$update_prices = true;
492
+				}
493
+			}
494
+			//make sure any current values have been saved.
495
+			//$TKT->save();
496 496
             
497
-            //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
498
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
499
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
500
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
501
-            }
497
+			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
498
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
499
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
500
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
501
+			}
502 502
             
503
-            //let's make sure the base price is handled
504
-            $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price,
505
-                $base_price_id) : $TKT;
503
+			//let's make sure the base price is handled
504
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price,
505
+				$base_price_id) : $TKT;
506 506
             
507
-            //add/update price_modifiers
508
-            $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
507
+			//add/update price_modifiers
508
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
509 509
             
510
-            //need to make sue that the TKT_price is accurate after saving the prices.
511
-            $TKT->ensure_TKT_Price_correct();
510
+			//need to make sue that the TKT_price is accurate after saving the prices.
511
+			$TKT->ensure_TKT_Price_correct();
512 512
             
513
-            //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
514
-            if ( ! defined('DOING_AUTOSAVE')) {
515
-                if ( ! empty($tkt['TKT_is_default_selector'])) {
516
-                    $update_prices = true;
517
-                    $new_default   = clone $TKT;
518
-                    $new_default->set('TKT_ID', 0);
519
-                    $new_default->set('TKT_is_default', 1);
520
-                    $new_default->set('TKT_row', 1);
521
-                    $new_default->set('TKT_price', $ticket_price);
522
-                    //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
523
-                    $new_default->_remove_relations('Datetime');
524
-                    //todo we need to add the current attached prices as new prices to the new default ticket.
525
-                    $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
526
-                    //don't forget the base price!
527
-                    $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price,
528
-                        $base_price_id);
529
-                    $new_default->save();
530
-                    do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default,
531
-                        $row, $TKT, $data);
532
-                }
533
-            }
513
+			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
514
+			if ( ! defined('DOING_AUTOSAVE')) {
515
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
516
+					$update_prices = true;
517
+					$new_default   = clone $TKT;
518
+					$new_default->set('TKT_ID', 0);
519
+					$new_default->set('TKT_is_default', 1);
520
+					$new_default->set('TKT_row', 1);
521
+					$new_default->set('TKT_price', $ticket_price);
522
+					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
523
+					$new_default->_remove_relations('Datetime');
524
+					//todo we need to add the current attached prices as new prices to the new default ticket.
525
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
526
+					//don't forget the base price!
527
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price,
528
+						$base_price_id);
529
+					$new_default->save();
530
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default,
531
+						$row, $TKT, $data);
532
+				}
533
+			}
534 534
             
535 535
             
536
-            //DO ALL dtt relationships for both current tickets and any archived tickets for the given dtt that are related to the current ticket. TODO... not sure exactly how we're going to do this considering we don't know what current ticket the archived tickets are related to (and TKT_parent is used for autosaves so that's not a field we can reliably use).
536
+			//DO ALL dtt relationships for both current tickets and any archived tickets for the given dtt that are related to the current ticket. TODO... not sure exactly how we're going to do this considering we don't know what current ticket the archived tickets are related to (and TKT_parent is used for autosaves so that's not a field we can reliably use).
537 537
             
538 538
             
539
-            //let's assign any tickets that have been setup to the saved_tickets tracker
540
-            //save existing TKT
541
-            $TKT->save();
542
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
543
-                //save new TKT
544
-                $new_tkt->save();
545
-                //add new ticket to array
546
-                $saved_tickets[$new_tkt->ID()] = $new_tkt;
539
+			//let's assign any tickets that have been setup to the saved_tickets tracker
540
+			//save existing TKT
541
+			$TKT->save();
542
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
543
+				//save new TKT
544
+				$new_tkt->save();
545
+				//add new ticket to array
546
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
547 547
                 
548
-                do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
548
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
549 549
                 
550
-            } else {
551
-                //add tkt to saved tkts
552
-                $saved_tickets[$TKT->ID()] = $TKT;
550
+			} else {
551
+				//add tkt to saved tkts
552
+				$saved_tickets[$TKT->ID()] = $TKT;
553 553
                 
554
-                do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
555
-            }
554
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
555
+			}
556 556
             
557
-        }
558
-        
559
-        // now we need to handle tickets actually "deleted permanently".
560
-        // There are cases where we'd want this to happen
561
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
562
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
563
-        // No sense in keeping all the related data in the db!
564
-        $old_tickets     = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
565
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
566
-        
567
-        foreach ($tickets_removed as $id) {
568
-            $id = absint($id);
557
+		}
558
+        
559
+		// now we need to handle tickets actually "deleted permanently".
560
+		// There are cases where we'd want this to happen
561
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
562
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
563
+		// No sense in keeping all the related data in the db!
564
+		$old_tickets     = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
565
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
566
+        
567
+		foreach ($tickets_removed as $id) {
568
+			$id = absint($id);
569 569
             
570
-            //get the ticket for this id
571
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
570
+			//get the ticket for this id
571
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
572 572
             
573
-            //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
574
-            if ($tkt_to_remove->get('TKT_is_default')) {
575
-                continue;
576
-            }
573
+			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
574
+			if ($tkt_to_remove->get('TKT_is_default')) {
575
+				continue;
576
+			}
577 577
             
578
-            // if this tkt has any registrations attached so then we just ARCHIVE
579
-            // because we don't actually permanently delete these tickets.
580
-            if ($tkt_to_remove->count_related('Registration') > 0) {
581
-                $tkt_to_remove->delete();
582
-                continue;
583
-            }
578
+			// if this tkt has any registrations attached so then we just ARCHIVE
579
+			// because we don't actually permanently delete these tickets.
580
+			if ($tkt_to_remove->count_related('Registration') > 0) {
581
+				$tkt_to_remove->delete();
582
+				continue;
583
+			}
584 584
             
585
-            // need to get all the related datetimes on this ticket and remove from every single one of them
586
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
587
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
585
+			// need to get all the related datetimes on this ticket and remove from every single one of them
586
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
587
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
588 588
             
589
-            foreach ($dtts as $dtt) {
590
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
591
-            }
589
+			foreach ($dtts as $dtt) {
590
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
591
+			}
592 592
             
593
-            // need to do the same for prices (except these prices can also be deleted because again,
594
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
595
-            $tkt_to_remove->delete_related_permanently('Price');
593
+			// need to do the same for prices (except these prices can also be deleted because again,
594
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
595
+			$tkt_to_remove->delete_related_permanently('Price');
596 596
             
597
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
597
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
598 598
             
599
-            // finally let's delete this ticket
600
-            // (which should not be blocked at this point b/c we've removed all our relationships)
601
-            $tkt_to_remove->delete_permanently();
602
-        }
599
+			// finally let's delete this ticket
600
+			// (which should not be blocked at this point b/c we've removed all our relationships)
601
+			$tkt_to_remove->delete_permanently();
602
+		}
603 603
         
604
-        return $saved_tickets;
605
-    }
604
+		return $saved_tickets;
605
+	}
606 606
     
607 607
     
608
-    /**
609
-     *
610
-     * @access  protected
611
-     *
612
-     * @param \EE_Ticket     $ticket
613
-     * @param \EE_Datetime[] $saved_datetimes
614
-     * @param \EE_Datetime[] $added_datetimes
615
-     * @param \EE_Datetime[] $removed_datetimes
616
-     *
617
-     * @return \EE_Ticket
618
-     * @throws \EE_Error
619
-     */
620
-    protected function _update_ticket_datetimes(
621
-        EE_Ticket $ticket,
622
-        $saved_datetimes = array(),
623
-        $added_datetimes = array(),
624
-        $removed_datetimes = array()
625
-    ) {
626
-        
627
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
628
-        // and removing the ticket from datetimes it got removed from.
629
-        
630
-        // first let's add datetimes
631
-        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
632
-            foreach ($added_datetimes as $row_id) {
633
-                $row_id = (int)$row_id;
634
-                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
635
-                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
636
-                    // Is this an existing ticket (has an ID) and does it have any sold?
637
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
638
-                    if ($ticket->ID() && $ticket->sold() > 0) {
639
-                        $saved_datetimes[$row_id]->increase_sold($ticket->sold());
640
-                        $saved_datetimes[$row_id]->save();
641
-                    }
642
-                }
643
-            }
644
-        }
645
-        // then remove datetimes
646
-        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
647
-            foreach ($removed_datetimes as $row_id) {
648
-                $row_id = (int)$row_id;
649
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
650
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
651
-                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
652
-                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
653
-                    // Is this an existing ticket (has an ID) and does it have any sold?
654
-                    // If so, then we need to remove it's sold from the DTT_sold.
655
-                    if ($ticket->ID() && $ticket->sold() > 0) {
656
-                        $saved_datetimes[$row_id]->decrease_sold($ticket->sold());
657
-                        $saved_datetimes[$row_id]->save();
658
-                    }
659
-                }
660
-            }
661
-        }
662
-        // cap ticket qty by datetime reg limits
663
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
664
-        
665
-        return $ticket;
666
-    }
608
+	/**
609
+	 *
610
+	 * @access  protected
611
+	 *
612
+	 * @param \EE_Ticket     $ticket
613
+	 * @param \EE_Datetime[] $saved_datetimes
614
+	 * @param \EE_Datetime[] $added_datetimes
615
+	 * @param \EE_Datetime[] $removed_datetimes
616
+	 *
617
+	 * @return \EE_Ticket
618
+	 * @throws \EE_Error
619
+	 */
620
+	protected function _update_ticket_datetimes(
621
+		EE_Ticket $ticket,
622
+		$saved_datetimes = array(),
623
+		$added_datetimes = array(),
624
+		$removed_datetimes = array()
625
+	) {
626
+        
627
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
628
+		// and removing the ticket from datetimes it got removed from.
629
+        
630
+		// first let's add datetimes
631
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
632
+			foreach ($added_datetimes as $row_id) {
633
+				$row_id = (int)$row_id;
634
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
635
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
636
+					// Is this an existing ticket (has an ID) and does it have any sold?
637
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
638
+					if ($ticket->ID() && $ticket->sold() > 0) {
639
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
640
+						$saved_datetimes[$row_id]->save();
641
+					}
642
+				}
643
+			}
644
+		}
645
+		// then remove datetimes
646
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
647
+			foreach ($removed_datetimes as $row_id) {
648
+				$row_id = (int)$row_id;
649
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
650
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
651
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
652
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
653
+					// Is this an existing ticket (has an ID) and does it have any sold?
654
+					// If so, then we need to remove it's sold from the DTT_sold.
655
+					if ($ticket->ID() && $ticket->sold() > 0) {
656
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
657
+						$saved_datetimes[$row_id]->save();
658
+					}
659
+				}
660
+			}
661
+		}
662
+		// cap ticket qty by datetime reg limits
663
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
664
+        
665
+		return $ticket;
666
+	}
667 667
     
668 668
     
669
-    /**
670
-     *
671
-     * @access  protected
672
-     *
673
-     * @param \EE_Ticket $ticket
674
-     * @param array      $price_rows
675
-     * @param int        $ticket_price
676
-     * @param int        $base_price
677
-     * @param int        $base_price_id
678
-     *
679
-     * @return \EE_Ticket
680
-     * @throws \EE_Error
681
-     */
682
-    protected function _duplicate_ticket(
683
-        EE_Ticket $ticket,
684
-        $price_rows = array(),
685
-        $ticket_price = 0,
686
-        $base_price = 0,
687
-        $base_price_id = 0
688
-    ) {
689
-        
690
-        // create new ticket that's a copy of the existing
691
-        // except a new id of course (and not archived)
692
-        // AND has the new TKT_price associated with it.
693
-        $new_ticket = clone($ticket);
694
-        $new_ticket->set('TKT_ID', 0);
695
-        $new_ticket->set('TKT_deleted', 0);
696
-        $new_ticket->set('TKT_price', $ticket_price);
697
-        $new_ticket->set('TKT_sold', 0);
698
-        // let's get a new ID for this ticket
699
-        $new_ticket->save();
700
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
701
-        $datetimes_on_existing = $ticket->get_many_related('Datetime');
702
-        $new_ticket            = $this->_update_ticket_datetimes(
703
-            $new_ticket,
704
-            $datetimes_on_existing,
705
-            array_keys($datetimes_on_existing)
706
-        );
707
-        
708
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
709
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
710
-        // available.
711
-        if ($ticket->sold() > 0) {
712
-            $new_qty = $ticket->qty() - $ticket->sold();
713
-            $new_ticket->set_qty($new_qty);
714
-        }
715
-        //now we update the prices just for this ticket
716
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
717
-        //and we update the base price
718
-        $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
719
-        
720
-        return $new_ticket;
721
-    }
669
+	/**
670
+	 *
671
+	 * @access  protected
672
+	 *
673
+	 * @param \EE_Ticket $ticket
674
+	 * @param array      $price_rows
675
+	 * @param int        $ticket_price
676
+	 * @param int        $base_price
677
+	 * @param int        $base_price_id
678
+	 *
679
+	 * @return \EE_Ticket
680
+	 * @throws \EE_Error
681
+	 */
682
+	protected function _duplicate_ticket(
683
+		EE_Ticket $ticket,
684
+		$price_rows = array(),
685
+		$ticket_price = 0,
686
+		$base_price = 0,
687
+		$base_price_id = 0
688
+	) {
689
+        
690
+		// create new ticket that's a copy of the existing
691
+		// except a new id of course (and not archived)
692
+		// AND has the new TKT_price associated with it.
693
+		$new_ticket = clone($ticket);
694
+		$new_ticket->set('TKT_ID', 0);
695
+		$new_ticket->set('TKT_deleted', 0);
696
+		$new_ticket->set('TKT_price', $ticket_price);
697
+		$new_ticket->set('TKT_sold', 0);
698
+		// let's get a new ID for this ticket
699
+		$new_ticket->save();
700
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
701
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
702
+		$new_ticket            = $this->_update_ticket_datetimes(
703
+			$new_ticket,
704
+			$datetimes_on_existing,
705
+			array_keys($datetimes_on_existing)
706
+		);
707
+        
708
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
709
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
710
+		// available.
711
+		if ($ticket->sold() > 0) {
712
+			$new_qty = $ticket->qty() - $ticket->sold();
713
+			$new_ticket->set_qty($new_qty);
714
+		}
715
+		//now we update the prices just for this ticket
716
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
717
+		//and we update the base price
718
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
719
+        
720
+		return $new_ticket;
721
+	}
722 722
     
723 723
     
724
-    /**
725
-     * This attaches a list of given prices to a ticket.
726
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
727
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
728
-     * price info and prices are automatically "archived" via the ticket.
729
-     *
730
-     * @access  private
731
-     *
732
-     * @param array     $prices        Array of prices from the form.
733
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
734
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
735
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
736
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
737
-     *
738
-     * @return EE_Ticket
739
-     */
740
-    protected function _add_prices_to_ticket(
741
-        $prices = array(),
742
-        EE_Ticket $ticket,
743
-        $new_prices = false,
744
-        $base_price = false,
745
-        $base_price_id = false
746
-    ) {
747
-        
748
-        //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
749
-        $current_prices_on_ticket = $base_price !== false ? $ticket->base_price(true) : $ticket->price_modifiers();
750
-        
751
-        $updated_prices = array();
752
-        
753
-        // if $base_price ! FALSE then updating a base price.
754
-        if ($base_price !== false) {
755
-            $prices[1] = array(
756
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
757
-                'PRT_ID'     => 1,
758
-                'PRC_amount' => $base_price,
759
-                'PRC_name'   => $ticket->get('TKT_name'),
760
-                'PRC_desc'   => $ticket->get('TKT_description')
761
-            );
762
-        }
763
-        
764
-        //possibly need to save tkt
765
-        if ( ! $ticket->ID()) {
766
-            $ticket->save();
767
-        }
768
-        
769
-        foreach ($prices as $row => $prc) {
770
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
771
-            if (empty($prt_id)) {
772
-                continue;
773
-            } //prices MUST have a price type id.
774
-            $PRC_values = array(
775
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
776
-                'PRT_ID'         => $prt_id,
777
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
778
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
779
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
780
-                'PRC_is_default' => false,
781
-                //make sure we set PRC_is_default to false for all ticket saves from event_editor
782
-                'PRC_order'      => $row
783
-            );
784
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
785
-                $PRC_values['PRC_ID'] = 0;
786
-                $PRC                  = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
787
-            } else {
788
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
789
-                //update this price with new values
790
-                foreach ($PRC_values as $field => $newprc) {
791
-                    $PRC->set($field, $newprc);
792
-                }
793
-            }
794
-            $PRC->save();
795
-            $prcid                  = $PRC->ID();
796
-            $updated_prices[$prcid] = $PRC;
797
-            $ticket->_add_relation_to($PRC, 'Price');
798
-        }
799
-        
800
-        //now let's remove any prices that got removed from the ticket
801
-        if ( ! empty ($current_prices_on_ticket)) {
802
-            $current          = array_keys($current_prices_on_ticket);
803
-            $updated          = array_keys($updated_prices);
804
-            $prices_to_remove = array_diff($current, $updated);
805
-            if ( ! empty($prices_to_remove)) {
806
-                foreach ($prices_to_remove as $prc_id) {
807
-                    $p = $current_prices_on_ticket[$prc_id];
808
-                    $ticket->_remove_relation_to($p, 'Price');
724
+	/**
725
+	 * This attaches a list of given prices to a ticket.
726
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
727
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
728
+	 * price info and prices are automatically "archived" via the ticket.
729
+	 *
730
+	 * @access  private
731
+	 *
732
+	 * @param array     $prices        Array of prices from the form.
733
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
734
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
735
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
736
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
737
+	 *
738
+	 * @return EE_Ticket
739
+	 */
740
+	protected function _add_prices_to_ticket(
741
+		$prices = array(),
742
+		EE_Ticket $ticket,
743
+		$new_prices = false,
744
+		$base_price = false,
745
+		$base_price_id = false
746
+	) {
747
+        
748
+		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
749
+		$current_prices_on_ticket = $base_price !== false ? $ticket->base_price(true) : $ticket->price_modifiers();
750
+        
751
+		$updated_prices = array();
752
+        
753
+		// if $base_price ! FALSE then updating a base price.
754
+		if ($base_price !== false) {
755
+			$prices[1] = array(
756
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
757
+				'PRT_ID'     => 1,
758
+				'PRC_amount' => $base_price,
759
+				'PRC_name'   => $ticket->get('TKT_name'),
760
+				'PRC_desc'   => $ticket->get('TKT_description')
761
+			);
762
+		}
763
+        
764
+		//possibly need to save tkt
765
+		if ( ! $ticket->ID()) {
766
+			$ticket->save();
767
+		}
768
+        
769
+		foreach ($prices as $row => $prc) {
770
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
771
+			if (empty($prt_id)) {
772
+				continue;
773
+			} //prices MUST have a price type id.
774
+			$PRC_values = array(
775
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
776
+				'PRT_ID'         => $prt_id,
777
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
778
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
779
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
780
+				'PRC_is_default' => false,
781
+				//make sure we set PRC_is_default to false for all ticket saves from event_editor
782
+				'PRC_order'      => $row
783
+			);
784
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
785
+				$PRC_values['PRC_ID'] = 0;
786
+				$PRC                  = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
787
+			} else {
788
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
789
+				//update this price with new values
790
+				foreach ($PRC_values as $field => $newprc) {
791
+					$PRC->set($field, $newprc);
792
+				}
793
+			}
794
+			$PRC->save();
795
+			$prcid                  = $PRC->ID();
796
+			$updated_prices[$prcid] = $PRC;
797
+			$ticket->_add_relation_to($PRC, 'Price');
798
+		}
799
+        
800
+		//now let's remove any prices that got removed from the ticket
801
+		if ( ! empty ($current_prices_on_ticket)) {
802
+			$current          = array_keys($current_prices_on_ticket);
803
+			$updated          = array_keys($updated_prices);
804
+			$prices_to_remove = array_diff($current, $updated);
805
+			if ( ! empty($prices_to_remove)) {
806
+				foreach ($prices_to_remove as $prc_id) {
807
+					$p = $current_prices_on_ticket[$prc_id];
808
+					$ticket->_remove_relation_to($p, 'Price');
809 809
                     
810
-                    //delete permanently the price
811
-                    $p->delete_permanently();
812
-                }
813
-            }
814
-        }
815
-        
816
-        return $ticket;
817
-    }
810
+					//delete permanently the price
811
+					$p->delete_permanently();
812
+				}
813
+			}
814
+		}
815
+        
816
+		return $ticket;
817
+	}
818 818
     
819 819
     
820
-    public function autosave_handling($event_admin_obj)
821
-    {
822
-        return $event_admin_obj; //doing nothing for the moment.
823
-        //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
824
-        
825
-        /**
826
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
827
-         *
828
-         * 1. TKT_is_default_selector (visible)
829
-         * 2. TKT_is_default (hidden)
830
-         *
831
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want this ticket to be saved as a default.
832
-         *
833
-         * The tricky part is, on an initial display on create or edit (or after manually updating), the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true if this is a create.  However, after an autosave, users will want some sort of indicator that the TKT HAS been saved as a default.. in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
834
-         * On Autosave:
835
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements, then set the TKT_is_default to false.
836
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
837
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
838
-         */
839
-    }
820
+	public function autosave_handling($event_admin_obj)
821
+	{
822
+		return $event_admin_obj; //doing nothing for the moment.
823
+		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
824
+        
825
+		/**
826
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
827
+		 *
828
+		 * 1. TKT_is_default_selector (visible)
829
+		 * 2. TKT_is_default (hidden)
830
+		 *
831
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want this ticket to be saved as a default.
832
+		 *
833
+		 * The tricky part is, on an initial display on create or edit (or after manually updating), the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true if this is a create.  However, after an autosave, users will want some sort of indicator that the TKT HAS been saved as a default.. in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
834
+		 * On Autosave:
835
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements, then set the TKT_is_default to false.
836
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
837
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
838
+		 */
839
+	}
840 840
     
841 841
     
842
-    public function pricing_metabox()
843
-    {
844
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
845
-        
846
-        $evtobj = $this->_adminpage_obj->get_cpt_model_obj();
847
-        
848
-        //set is_creating_event property.
849
-        $evtID                    = $evtobj->ID();
850
-        $this->_is_creating_event = absint($evtID) != 0 ? false : true;
851
-        
852
-        //default main template args
853
-        $main_template_args = array(
854
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab',
855
-                $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
856
-            //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
857
-            'existing_datetime_ids'    => '',
858
-            'total_dtt_rows'           => 1,
859
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link('add_new_dtt_info',
860
-                $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
861
-            //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
862
-            'datetime_rows'            => '',
863
-            'show_tickets_container'   => '',
864
-            //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
865
-            'ticket_rows'              => '',
866
-            'existing_ticket_ids'      => '',
867
-            'total_ticket_rows'        => 1,
868
-            'ticket_js_structure'      => '',
869
-            'ee_collapsible_status'    => ' ee-collapsible-open'
870
-            //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
871
-        );
872
-        
873
-        $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : null;
874
-        
875
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
876
-        
877
-        /**
878
-         * 1. Start with retrieving Datetimes
879
-         * 2. For each datetime get related tickets
880
-         * 3. For each ticket get related prices
881
-         */
882
-        
883
-        $DTM   = EE_Registry::instance()->load_model('Datetime', array($timezone));
884
-        $times = $DTM->get_all_event_dates($evtID);
885
-        
886
-        
887
-        $main_template_args['total_dtt_rows'] = count($times);
888
-        
889
-        /** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */
890
-        $dttrow = 1;
891
-        foreach ($times as $time) {
892
-            $dttid = $time->get('DTT_ID');
893
-            $time->set('DTT_order', $dttrow);
894
-            $existing_datetime_ids[] = $dttid;
842
+	public function pricing_metabox()
843
+	{
844
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
845
+        
846
+		$evtobj = $this->_adminpage_obj->get_cpt_model_obj();
847
+        
848
+		//set is_creating_event property.
849
+		$evtID                    = $evtobj->ID();
850
+		$this->_is_creating_event = absint($evtID) != 0 ? false : true;
851
+        
852
+		//default main template args
853
+		$main_template_args = array(
854
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab',
855
+				$this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
856
+			//todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
857
+			'existing_datetime_ids'    => '',
858
+			'total_dtt_rows'           => 1,
859
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link('add_new_dtt_info',
860
+				$this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
861
+			//todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
862
+			'datetime_rows'            => '',
863
+			'show_tickets_container'   => '',
864
+			//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
865
+			'ticket_rows'              => '',
866
+			'existing_ticket_ids'      => '',
867
+			'total_ticket_rows'        => 1,
868
+			'ticket_js_structure'      => '',
869
+			'ee_collapsible_status'    => ' ee-collapsible-open'
870
+			//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
871
+		);
872
+        
873
+		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : null;
874
+        
875
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
876
+        
877
+		/**
878
+		 * 1. Start with retrieving Datetimes
879
+		 * 2. For each datetime get related tickets
880
+		 * 3. For each ticket get related prices
881
+		 */
882
+        
883
+		$DTM   = EE_Registry::instance()->load_model('Datetime', array($timezone));
884
+		$times = $DTM->get_all_event_dates($evtID);
885
+        
886
+        
887
+		$main_template_args['total_dtt_rows'] = count($times);
888
+        
889
+		/** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */
890
+		$dttrow = 1;
891
+		foreach ($times as $time) {
892
+			$dttid = $time->get('DTT_ID');
893
+			$time->set('DTT_order', $dttrow);
894
+			$existing_datetime_ids[] = $dttid;
895 895
             
896
-            //tickets attached
897
-            $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(
898
-                array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
899
-                'default_where_conditions' => 'none',
900
-                'order_by'                 => array('TKT_order' => 'ASC')
901
-            )) : array();
896
+			//tickets attached
897
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(
898
+				array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
899
+				'default_where_conditions' => 'none',
900
+				'order_by'                 => array('TKT_order' => 'ASC')
901
+			)) : array();
902 902
             
903
-            //if there are no related tickets this is likely a new event OR autodraft
904
-            // event so we need to generate the default tickets because dtts
905
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
906
-            // datetime on the event.
907
-            if (empty ($related_tickets) && count($times) < 2) {
908
-                $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
903
+			//if there are no related tickets this is likely a new event OR autodraft
904
+			// event so we need to generate the default tickets because dtts
905
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
906
+			// datetime on the event.
907
+			if (empty ($related_tickets) && count($times) < 2) {
908
+				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
909 909
                 
910
-                //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
911
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
910
+				//this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
911
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
912 912
                 
913
-                $main_default_ticket = reset($related_tickets);
914
-                if ($main_default_ticket instanceof EE_Ticket) {
915
-                    foreach ($default_prices as $default_price) {
916
-                        if ($default_price->is_base_price()) {
917
-                            continue;
918
-                        }
919
-                        $main_default_ticket->cache('Price', $default_price);
920
-                    }
921
-                }
922
-            }
913
+				$main_default_ticket = reset($related_tickets);
914
+				if ($main_default_ticket instanceof EE_Ticket) {
915
+					foreach ($default_prices as $default_price) {
916
+						if ($default_price->is_base_price()) {
917
+							continue;
918
+						}
919
+						$main_default_ticket->cache('Price', $default_price);
920
+					}
921
+				}
922
+			}
923 923
             
924 924
             
925
-            //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
925
+			//we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
926 926
             
927
-            //loop through and setup the ticket rows and make sure the order is set.
928
-            foreach ($related_tickets as $ticket) {
929
-                $tktid  = $ticket->get('TKT_ID');
930
-                $tktrow = $ticket->get('TKT_row');
931
-                //we only want unique tickets in our final display!!
932
-                if ( ! in_array($tktid, $existing_ticket_ids)) {
933
-                    $existing_ticket_ids[] = $tktid;
934
-                    $all_tickets[]         = $ticket;
935
-                }
927
+			//loop through and setup the ticket rows and make sure the order is set.
928
+			foreach ($related_tickets as $ticket) {
929
+				$tktid  = $ticket->get('TKT_ID');
930
+				$tktrow = $ticket->get('TKT_row');
931
+				//we only want unique tickets in our final display!!
932
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
933
+					$existing_ticket_ids[] = $tktid;
934
+					$all_tickets[]         = $ticket;
935
+				}
936 936
                 
937
-                //temporary cache of this ticket info for this datetime for later processing of datetime rows.
938
-                $datetime_tickets[$dttid][] = $tktrow;
937
+				//temporary cache of this ticket info for this datetime for later processing of datetime rows.
938
+				$datetime_tickets[$dttid][] = $tktrow;
939 939
                 
940
-                //temporary cache of this datetime info for this ticket for later processing of ticket rows.
941
-                if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) {
942
-                    $ticket_datetimes[$tktid][] = $dttrow;
943
-                }
944
-            }
945
-            $dttrow++;
946
-        }
947
-        
948
-        $main_template_args['total_ticket_rows']     = count($existing_ticket_ids);
949
-        $main_template_args['existing_ticket_ids']   = implode(',', $existing_ticket_ids);
950
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
951
-        
952
-        //sort $all_tickets by order
953
-        usort($all_tickets, function ($a, $b) {
954
-            $a_order = (int)$a->get('TKT_order');
955
-            $b_order = (int)$b->get('TKT_order');
956
-            if ($a_order == $b_order) {
957
-                return 0;
958
-            }
940
+				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
941
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) {
942
+					$ticket_datetimes[$tktid][] = $dttrow;
943
+				}
944
+			}
945
+			$dttrow++;
946
+		}
947
+        
948
+		$main_template_args['total_ticket_rows']     = count($existing_ticket_ids);
949
+		$main_template_args['existing_ticket_ids']   = implode(',', $existing_ticket_ids);
950
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
951
+        
952
+		//sort $all_tickets by order
953
+		usort($all_tickets, function ($a, $b) {
954
+			$a_order = (int)$a->get('TKT_order');
955
+			$b_order = (int)$b->get('TKT_order');
956
+			if ($a_order == $b_order) {
957
+				return 0;
958
+			}
959 959
             
960
-            return ($a_order < $b_order) ? -1 : 1;
961
-        });
962
-        
963
-        //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
964
-        $dttrow = 1;
965
-        foreach ($times as $time) {
966
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets,
967
-                $all_tickets, false, $times);
968
-            $dttrow++;
969
-        }
970
-        
971
-        //then loop through all tickets for the ticket rows.
972
-        $tktrow = 1;
973
-        foreach ($all_tickets as $ticket) {
974
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times,
975
-                false, $all_tickets);
976
-            $tktrow++;
977
-        }
978
-        
979
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
980
-        $template                                  = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
981
-        EEH_Template::display_template($template, $main_template_args);
982
-        
983
-        return;
984
-    }
960
+			return ($a_order < $b_order) ? -1 : 1;
961
+		});
962
+        
963
+		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
964
+		$dttrow = 1;
965
+		foreach ($times as $time) {
966
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets,
967
+				$all_tickets, false, $times);
968
+			$dttrow++;
969
+		}
970
+        
971
+		//then loop through all tickets for the ticket rows.
972
+		$tktrow = 1;
973
+		foreach ($all_tickets as $ticket) {
974
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times,
975
+				false, $all_tickets);
976
+			$tktrow++;
977
+		}
978
+        
979
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
980
+		$template                                  = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
981
+		EEH_Template::display_template($template, $main_template_args);
982
+        
983
+		return;
984
+	}
985 985
     
986 986
     
987
-    protected function _get_datetime_row(
988
-        $dttrow,
989
-        EE_Datetime $dtt,
990
-        $datetime_tickets,
991
-        $all_tickets,
992
-        $default = false,
993
-        $all_dtts = array()
994
-    ) {
995
-        
996
-        $dtt_display_template_args = array(
997
-            'dtt_edit_row'             => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
998
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets,
999
-                $all_tickets, $default),
1000
-            'dtt_row'                  => $default ? 'DTTNUM' : $dttrow
1001
-        );
1002
-        $template                  = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
1003
-        
1004
-        return EEH_Template::display_template($template, $dtt_display_template_args, true);
1005
-    }
987
+	protected function _get_datetime_row(
988
+		$dttrow,
989
+		EE_Datetime $dtt,
990
+		$datetime_tickets,
991
+		$all_tickets,
992
+		$default = false,
993
+		$all_dtts = array()
994
+	) {
995
+        
996
+		$dtt_display_template_args = array(
997
+			'dtt_edit_row'             => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
998
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets,
999
+				$all_tickets, $default),
1000
+			'dtt_row'                  => $default ? 'DTTNUM' : $dttrow
1001
+		);
1002
+		$template                  = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
1003
+        
1004
+		return EEH_Template::display_template($template, $dtt_display_template_args, true);
1005
+	}
1006 1006
     
1007 1007
     
1008
-    /**
1009
-     * This method is used to generate a dtt fields  edit row.
1010
-     * The same row is used to generate a row with valid DTT objects and the default row that is used as the
1011
-     * skeleton by the js.
1012
-     *
1013
-     * @param int           $dttrow                         The row number for the row being generated.
1014
-     * @param               mixed                           EE_Datetime|null $dtt      If not default row being
1015
-     *                                                                       generated, this must be a EE_Datetime
1016
-     *                                                                       object.
1017
-     * @param bool          $default                        Whether a default row is being generated or not.
1018
-     * @param EE_Datetime[] $all_dtts                       This is the array of all datetimes used in the editor.
1019
-     *
1020
-     * @return string Generated edit row.
1021
-     */
1022
-    protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts)
1023
-    {
1024
-        
1025
-        // if the incoming $dtt object is NOT an instance of EE_Datetime then force default to true.
1026
-        $default = ! $dtt instanceof EE_Datetime ? true : false;
1027
-        
1028
-        $template_args = array(
1029
-            'dtt_row'              => $default ? 'DTTNUM' : $dttrow,
1030
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1031
-            'edit_dtt_expanded'    => '',
1032
-            //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
1033
-            'DTT_ID'               => $default ? '' : $dtt->ID(),
1034
-            'DTT_name'             => $default ? '' : $dtt->name(),
1035
-            'DTT_description'      => $default ? '' : $dtt->description(),
1036
-            'DTT_EVT_start'        => $default ? '' : $dtt->start_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1037
-            'DTT_EVT_end'          => $default ? '' : $dtt->end_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1038
-            'DTT_reg_limit'        => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
1039
-            'DTT_order'            => $default ? 'DTTNUM' : $dttrow,
1040
-            'dtt_sold'             => $default ? '0' : $dtt->get('DTT_sold'),
1041
-            'clone_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
1042
-            'trash_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable',
1043
-            'reg_list_url'         => $default || ! $dtt->event() instanceof \EE_Event
1044
-                ? ''
1045
-                : EE_Admin_Page::add_query_args_and_nonce(
1046
-                    array('event_id' => $dtt->event()->ID(), 'datetime_id' => $dtt->ID()),
1047
-                    REG_ADMIN_URL
1048
-                )
1049
-        );
1050
-        
1051
-        $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
1052
-        
1053
-        //allow filtering of template args at this point.
1054
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1055
-            $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
1056
-        
1057
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
1058
-        
1059
-        return EEH_Template::display_template($template, $template_args, true);
1060
-    }
1008
+	/**
1009
+	 * This method is used to generate a dtt fields  edit row.
1010
+	 * The same row is used to generate a row with valid DTT objects and the default row that is used as the
1011
+	 * skeleton by the js.
1012
+	 *
1013
+	 * @param int           $dttrow                         The row number for the row being generated.
1014
+	 * @param               mixed                           EE_Datetime|null $dtt      If not default row being
1015
+	 *                                                                       generated, this must be a EE_Datetime
1016
+	 *                                                                       object.
1017
+	 * @param bool          $default                        Whether a default row is being generated or not.
1018
+	 * @param EE_Datetime[] $all_dtts                       This is the array of all datetimes used in the editor.
1019
+	 *
1020
+	 * @return string Generated edit row.
1021
+	 */
1022
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts)
1023
+	{
1024
+        
1025
+		// if the incoming $dtt object is NOT an instance of EE_Datetime then force default to true.
1026
+		$default = ! $dtt instanceof EE_Datetime ? true : false;
1027
+        
1028
+		$template_args = array(
1029
+			'dtt_row'              => $default ? 'DTTNUM' : $dttrow,
1030
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1031
+			'edit_dtt_expanded'    => '',
1032
+			//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
1033
+			'DTT_ID'               => $default ? '' : $dtt->ID(),
1034
+			'DTT_name'             => $default ? '' : $dtt->name(),
1035
+			'DTT_description'      => $default ? '' : $dtt->description(),
1036
+			'DTT_EVT_start'        => $default ? '' : $dtt->start_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1037
+			'DTT_EVT_end'          => $default ? '' : $dtt->end_date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1038
+			'DTT_reg_limit'        => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
1039
+			'DTT_order'            => $default ? 'DTTNUM' : $dttrow,
1040
+			'dtt_sold'             => $default ? '0' : $dtt->get('DTT_sold'),
1041
+			'clone_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
1042
+			'trash_icon'           => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable',
1043
+			'reg_list_url'         => $default || ! $dtt->event() instanceof \EE_Event
1044
+				? ''
1045
+				: EE_Admin_Page::add_query_args_and_nonce(
1046
+					array('event_id' => $dtt->event()->ID(), 'datetime_id' => $dtt->ID()),
1047
+					REG_ADMIN_URL
1048
+				)
1049
+		);
1050
+        
1051
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
1052
+        
1053
+		//allow filtering of template args at this point.
1054
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1055
+			$template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
1056
+        
1057
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
1058
+        
1059
+		return EEH_Template::display_template($template, $template_args, true);
1060
+	}
1061 1061
     
1062 1062
     
1063
-    protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default)
1064
-    {
1065
-        
1066
-        $template_args = array(
1067
-            'dtt_row'                           => $default ? 'DTTNUM' : $dttrow,
1068
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1069
-            'DTT_description'                   => $default ? '' : $dtt->description(),
1070
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1071
-            'show_tickets_row'                  => ' style="display:none;"',
1072
-            //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
1073
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime',
1074
-                $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
1075
-            //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1076
-            'DTT_ID'                            => $default ? '' : $dtt->ID()
1077
-        );
1078
-        
1079
-        //need to setup the list items (but only if this isnt' a default skeleton setup)
1080
-        if ( ! $default) {
1081
-            $tktrow = 1;
1082
-            foreach ($all_tickets as $ticket) {
1083
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow,
1084
-                    $dtt, $ticket, $datetime_tickets, $default);
1085
-                $tktrow++;
1086
-            }
1087
-        }
1088
-        
1089
-        //filter template args at this point
1090
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1091
-            $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
1092
-        
1093
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
1094
-        
1095
-        return EEH_Template::display_template($template, $template_args, true);
1096
-    }
1063
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default)
1064
+	{
1065
+        
1066
+		$template_args = array(
1067
+			'dtt_row'                           => $default ? 'DTTNUM' : $dttrow,
1068
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1069
+			'DTT_description'                   => $default ? '' : $dtt->description(),
1070
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1071
+			'show_tickets_row'                  => ' style="display:none;"',
1072
+			//$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
1073
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime',
1074
+				$this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), false, false),
1075
+			//todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1076
+			'DTT_ID'                            => $default ? '' : $dtt->ID()
1077
+		);
1078
+        
1079
+		//need to setup the list items (but only if this isnt' a default skeleton setup)
1080
+		if ( ! $default) {
1081
+			$tktrow = 1;
1082
+			foreach ($all_tickets as $ticket) {
1083
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow,
1084
+					$dtt, $ticket, $datetime_tickets, $default);
1085
+				$tktrow++;
1086
+			}
1087
+		}
1088
+        
1089
+		//filter template args at this point
1090
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1091
+			$template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
1092
+        
1093
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
1094
+        
1095
+		return EEH_Template::display_template($template, $template_args, true);
1096
+	}
1097 1097
     
1098 1098
     
1099
-    protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default)
1100
-    {
1101
-        $tktid    = ! empty($ticket) ? $ticket->ID() : 0;
1102
-        $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1103
-        
1104
-        $displayrow    = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1105
-        $template_args = array(
1106
-            'dtt_row'                 => $default ? 'DTTNUM' : $dttrow,
1107
-            'tkt_row'                 => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1108
-            'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1109
-            'ticket_selected'         => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1110
-            'TKT_name'                => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1111
-            'tkt_status_class'        => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1112
-        );
1113
-        
1114
-        //filter template args
1115
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1116
-            $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1117
-        
1118
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1119
-        
1120
-        return EEH_Template::display_template($template, $template_args, true);
1121
-    }
1099
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default)
1100
+	{
1101
+		$tktid    = ! empty($ticket) ? $ticket->ID() : 0;
1102
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1103
+        
1104
+		$displayrow    = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1105
+		$template_args = array(
1106
+			'dtt_row'                 => $default ? 'DTTNUM' : $dttrow,
1107
+			'tkt_row'                 => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1108
+			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1109
+			'ticket_selected'         => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1110
+			'TKT_name'                => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1111
+			'tkt_status_class'        => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1112
+		);
1113
+        
1114
+		//filter template args
1115
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1116
+			$template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1117
+        
1118
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1119
+        
1120
+		return EEH_Template::display_template($template, $template_args, true);
1121
+	}
1122 1122
     
1123 1123
     
1124
-    /**
1125
-     * This generates the ticket row for tickets.
1126
-     * This same method is used to generate both the actual rows and the js skeleton row (when default ==
1127
-     * true)
1128
-     *
1129
-     * @param int           $tktrow                          Represents the row number being generated.
1130
-     * @param               mixed                            null|EE_Ticket $ticket           If default then this will
1131
-     *                                                                      be null.
1132
-     * @param EE_Datetime[] $ticket_datetimes                Either an array of all datetimes on all tickets indexed by
1133
-     *                                                       each ticket or empty for  default
1134
-     * @param EE_Datetime[] $all_dtts                        All Datetimes on the event or empty for default.
1135
-     * @param bool          $default                         Whether default row being generated or not.
1136
-     * @param EE_Ticket[]   $all_tickets                     This is an array of all tickets attached to the event (or
1137
-     *                                                       empty in the case of defaults)
1138
-     *
1139
-     * @return [type] [description]
1140
-     */
1141
-    protected function _get_ticket_row(
1142
-        $tktrow,
1143
-        $ticket,
1144
-        $ticket_datetimes,
1145
-        $all_dtts,
1146
-        $default = false,
1147
-        $all_tickets = array()
1148
-    ) {
1149
-        
1150
-        //if $ticket is not an instance of EE_Ticket then force default to true.
1151
-        $default = ! $ticket instanceof EE_Ticket ? true : false;
1152
-        
1153
-        $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price',
1154
-            array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1155
-        
1156
-        //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1157
-        //the object.  This is done by not including any query_params.
1158
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1159
-            $prices = $ticket->get_many_related('Price');
1160
-        }
1161
-        
1162
-        // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1163
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? true : false;
1164
-        
1165
-        $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1166
-        
1167
-        $ticket_subtotal  = $default ? 0 : $ticket->get_ticket_subtotal();
1168
-        $base_price       = $default ? null : $ticket->base_price();
1169
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1170
-        
1171
-        //breaking out complicated condition for ticket_status
1172
-        if ($default) {
1173
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1174
-        } else {
1175
-            $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1176
-        }
1177
-        
1178
-        //breaking out complicated condition for TKT_taxable
1179
-        if ($default) {
1180
-            $TKT_taxable = '';
1181
-        } else {
1182
-            $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
1183
-        }
1124
+	/**
1125
+	 * This generates the ticket row for tickets.
1126
+	 * This same method is used to generate both the actual rows and the js skeleton row (when default ==
1127
+	 * true)
1128
+	 *
1129
+	 * @param int           $tktrow                          Represents the row number being generated.
1130
+	 * @param               mixed                            null|EE_Ticket $ticket           If default then this will
1131
+	 *                                                                      be null.
1132
+	 * @param EE_Datetime[] $ticket_datetimes                Either an array of all datetimes on all tickets indexed by
1133
+	 *                                                       each ticket or empty for  default
1134
+	 * @param EE_Datetime[] $all_dtts                        All Datetimes on the event or empty for default.
1135
+	 * @param bool          $default                         Whether default row being generated or not.
1136
+	 * @param EE_Ticket[]   $all_tickets                     This is an array of all tickets attached to the event (or
1137
+	 *                                                       empty in the case of defaults)
1138
+	 *
1139
+	 * @return [type] [description]
1140
+	 */
1141
+	protected function _get_ticket_row(
1142
+		$tktrow,
1143
+		$ticket,
1144
+		$ticket_datetimes,
1145
+		$all_dtts,
1146
+		$default = false,
1147
+		$all_tickets = array()
1148
+	) {
1149
+        
1150
+		//if $ticket is not an instance of EE_Ticket then force default to true.
1151
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1152
+        
1153
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price',
1154
+			array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1155
+        
1156
+		//if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1157
+		//the object.  This is done by not including any query_params.
1158
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1159
+			$prices = $ticket->get_many_related('Price');
1160
+		}
1161
+        
1162
+		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1163
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? true : false;
1164
+        
1165
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1166
+        
1167
+		$ticket_subtotal  = $default ? 0 : $ticket->get_ticket_subtotal();
1168
+		$base_price       = $default ? null : $ticket->base_price();
1169
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1170
+        
1171
+		//breaking out complicated condition for ticket_status
1172
+		if ($default) {
1173
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1174
+		} else {
1175
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1176
+		}
1177
+        
1178
+		//breaking out complicated condition for TKT_taxable
1179
+		if ($default) {
1180
+			$TKT_taxable = '';
1181
+		} else {
1182
+			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
1183
+		}
1184 1184
 
1185 1185
         
1186
-        $template_args = array(
1187
-            'tkt_row'                       => $default ? 'TICKETNUM' : $tktrow,
1188
-            'TKT_order'                     => $default ? 'TICKETNUM' : $tktrow,
1189
-            //on initial page load this will always be the correct order.
1190
-            'tkt_status_class'              => $ticket_status_class,
1191
-            'display_edit_tkt_row'          => ' style="display:none;"',
1192
-            'edit_tkt_expanded'             => '',
1193
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1194
-            'TKT_name'                      => $default ? '' : $ticket->get('TKT_name'),
1195
-            'TKT_class'                     => $default ? '' : $ticket->get('TKT_class'),
1196
-            'TKT_full_checkin'              => $default ? '' : $ticket->get('TKT_full_checkin'),
1197
-            'TKT_start_date'                => $default ? '' : $ticket->get_date('TKT_start_date',
1198
-                $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1199
-            'TKT_end_date'                  => $default ? '' : $ticket->get_date('TKT_end_date',
1200
-                $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1201
-            'TKT_status'                    => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1202
-                'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1203
-                'sentence') : $ticket->ticket_status(true),
1204
-            'TKT_price'                     => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(),
1205
-                false, false),
1206
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1207
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1208
-            'TKT_qty'                       => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1209
-            'TKT_qty_for_input'             => $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1210
-            'TKT_uses'                      => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1211
-            'TKT_min'                       => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1212
-            'TKT_max'                       => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1213
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1214
-            'TKT_registrations'             => $default ? 0 : $ticket->count_registrations(array(
1215
-                array(
1216
-                    'STS_ID' => array(
1217
-                        '!=',
1218
-                        EEM_Registration::status_id_incomplete
1219
-                    )
1220
-                )
1221
-            )),
1222
-            'TKT_ID'                        => $default ? 0 : $ticket->get('TKT_ID'),
1223
-            'TKT_description'               => $default ? '' : $ticket->get('TKT_description'),
1224
-            'TKT_is_default'                => $default ? 0 : $ticket->get('TKT_is_default'),
1225
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1226
-            'TKT_is_default_selector'       => '',
1227
-            'ticket_price_rows'             => '',
1228
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount',
1229
-                'localized_float'),
1230
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1231
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1232
-            'show_price_mod_button'         => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1233
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1234
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1235
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1236
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_dtts),
1237
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1238
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1239
-            'TKT_taxable'                   => $TKT_taxable,
1240
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1241
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1242
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency($ticket_subtotal, false, false),
1243
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1244
-            'tax_rows'                      => $this->_get_tax_rows($tktrow, $ticket),
1245
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? true : false,
1246
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1247
-            'trash_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1248
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1249
-        );
1250
-        
1251
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1252
-        
1253
-        //handle rows that should NOT be empty
1254
-        if (empty($template_args['TKT_start_date'])) {
1255
-            //if empty then the start date will be now.
1256
-            $template_args['TKT_start_date']   = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1257
-                current_time('timestamp'));
1258
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1259
-        }
1260
-        
1261
-        if (empty($template_args['TKT_end_date'])) {
1186
+		$template_args = array(
1187
+			'tkt_row'                       => $default ? 'TICKETNUM' : $tktrow,
1188
+			'TKT_order'                     => $default ? 'TICKETNUM' : $tktrow,
1189
+			//on initial page load this will always be the correct order.
1190
+			'tkt_status_class'              => $ticket_status_class,
1191
+			'display_edit_tkt_row'          => ' style="display:none;"',
1192
+			'edit_tkt_expanded'             => '',
1193
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1194
+			'TKT_name'                      => $default ? '' : $ticket->get('TKT_name'),
1195
+			'TKT_class'                     => $default ? '' : $ticket->get('TKT_class'),
1196
+			'TKT_full_checkin'              => $default ? '' : $ticket->get('TKT_full_checkin'),
1197
+			'TKT_start_date'                => $default ? '' : $ticket->get_date('TKT_start_date',
1198
+				$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1199
+			'TKT_end_date'                  => $default ? '' : $ticket->get_date('TKT_end_date',
1200
+				$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']),
1201
+			'TKT_status'                    => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1202
+				'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, false,
1203
+				'sentence') : $ticket->ticket_status(true),
1204
+			'TKT_price'                     => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(),
1205
+				false, false),
1206
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1207
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1208
+			'TKT_qty'                       => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1209
+			'TKT_qty_for_input'             => $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1210
+			'TKT_uses'                      => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1211
+			'TKT_min'                       => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1212
+			'TKT_max'                       => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1213
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1214
+			'TKT_registrations'             => $default ? 0 : $ticket->count_registrations(array(
1215
+				array(
1216
+					'STS_ID' => array(
1217
+						'!=',
1218
+						EEM_Registration::status_id_incomplete
1219
+					)
1220
+				)
1221
+			)),
1222
+			'TKT_ID'                        => $default ? 0 : $ticket->get('TKT_ID'),
1223
+			'TKT_description'               => $default ? '' : $ticket->get('TKT_description'),
1224
+			'TKT_is_default'                => $default ? 0 : $ticket->get('TKT_is_default'),
1225
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1226
+			'TKT_is_default_selector'       => '',
1227
+			'ticket_price_rows'             => '',
1228
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount',
1229
+				'localized_float'),
1230
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1231
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1232
+			'show_price_mod_button'         => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1233
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1234
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1235
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1236
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_dtts),
1237
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1238
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1239
+			'TKT_taxable'                   => $TKT_taxable,
1240
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1241
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1242
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency($ticket_subtotal, false, false),
1243
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1244
+			'tax_rows'                      => $this->_get_tax_rows($tktrow, $ticket),
1245
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? true : false,
1246
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1247
+			'trash_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1248
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1249
+		);
1250
+        
1251
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1252
+        
1253
+		//handle rows that should NOT be empty
1254
+		if (empty($template_args['TKT_start_date'])) {
1255
+			//if empty then the start date will be now.
1256
+			$template_args['TKT_start_date']   = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1257
+				current_time('timestamp'));
1258
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1259
+		}
1260
+        
1261
+		if (empty($template_args['TKT_end_date'])) {
1262 1262
             
1263
-            //get the earliest datetime (if present);
1264
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime',
1265
-                array('order_by' => array('DTT_EVT_start' => 'ASC'))) : null;
1263
+			//get the earliest datetime (if present);
1264
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime',
1265
+				array('order_by' => array('DTT_EVT_start' => 'ASC'))) : null;
1266 1266
             
1267
-            if ( ! empty($earliest_dtt)) {
1268
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start',
1269
-                    $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
1270
-            } else {
1271
-                //default so let's just use what's been set for the default date-time which is 30 days from now.
1272
-                $template_args['TKT_end_date'] = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1273
-                    mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1274
-            }
1275
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1276
-        }
1277
-        
1278
-        //generate ticket_datetime items
1279
-        if ( ! $default) {
1280
-            $dttrow = 1;
1281
-            foreach ($all_dtts as $dtt) {
1282
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt,
1283
-                    $ticket, $ticket_datetimes, $default);
1284
-                $dttrow++;
1285
-            }
1286
-        }
1287
-        
1288
-        $prcrow = 1;
1289
-        foreach ($prices as $price) {
1290
-            if ($price->is_base_price()) {
1291
-                $prcrow++;
1292
-                continue;
1293
-            }
1294
-            $show_trash  = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? false : true;
1295
-            $show_create = count($prices) > 1 && count($prices) !== $prcrow ? false : true;
1296
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default,
1297
-                $ticket, $show_trash, $show_create);
1298
-            $prcrow++;
1299
-        }
1300
-        
1301
-        //filter $template_args
1302
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1303
-            $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets,
1304
-            $this->_is_creating_event);
1305
-        
1306
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1307
-        
1308
-        return EEH_Template::display_template($template, $template_args, true);
1309
-    }
1267
+			if ( ! empty($earliest_dtt)) {
1268
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start',
1269
+					$this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']);
1270
+			} else {
1271
+				//default so let's just use what's been set for the default date-time which is 30 days from now.
1272
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'],
1273
+					mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1274
+			}
1275
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1276
+		}
1277
+        
1278
+		//generate ticket_datetime items
1279
+		if ( ! $default) {
1280
+			$dttrow = 1;
1281
+			foreach ($all_dtts as $dtt) {
1282
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt,
1283
+					$ticket, $ticket_datetimes, $default);
1284
+				$dttrow++;
1285
+			}
1286
+		}
1287
+        
1288
+		$prcrow = 1;
1289
+		foreach ($prices as $price) {
1290
+			if ($price->is_base_price()) {
1291
+				$prcrow++;
1292
+				continue;
1293
+			}
1294
+			$show_trash  = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? false : true;
1295
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? false : true;
1296
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default,
1297
+				$ticket, $show_trash, $show_create);
1298
+			$prcrow++;
1299
+		}
1300
+        
1301
+		//filter $template_args
1302
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1303
+			$template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets,
1304
+			$this->_is_creating_event);
1305
+        
1306
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1307
+        
1308
+		return EEH_Template::display_template($template, $template_args, true);
1309
+	}
1310 1310
     
1311 1311
     
1312
-    protected function _get_tax_rows($tktrow, $ticket)
1313
-    {
1314
-        $tax_rows      = '';
1315
-        $template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1316
-        $template_args = array();
1317
-        $taxes         = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1318
-        foreach ($taxes as $tax) {
1319
-            $tax_added     = $this->_get_tax_added($tax, $ticket);
1320
-            $template_args = array(
1321
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1322
-                'tax_id'            => $tax->ID(),
1323
-                'tkt_row'           => $tktrow,
1324
-                'tax_label'         => $tax->get('PRC_name'),
1325
-                'tax_added'         => $tax_added,
1326
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1327
-                'tax_amount'        => $tax->get('PRC_amount')
1328
-            );
1329
-            $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1330
-                $template_args, $tktrow, $ticket, $this->_is_creating_event);
1331
-            $tax_rows .= EEH_Template::display_template($template, $template_args, true);
1332
-        }
1333
-        
1334
-        
1335
-        return $tax_rows;
1336
-    }
1312
+	protected function _get_tax_rows($tktrow, $ticket)
1313
+	{
1314
+		$tax_rows      = '';
1315
+		$template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1316
+		$template_args = array();
1317
+		$taxes         = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1318
+		foreach ($taxes as $tax) {
1319
+			$tax_added     = $this->_get_tax_added($tax, $ticket);
1320
+			$template_args = array(
1321
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1322
+				'tax_id'            => $tax->ID(),
1323
+				'tkt_row'           => $tktrow,
1324
+				'tax_label'         => $tax->get('PRC_name'),
1325
+				'tax_added'         => $tax_added,
1326
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1327
+				'tax_amount'        => $tax->get('PRC_amount')
1328
+			);
1329
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1330
+				$template_args, $tktrow, $ticket, $this->_is_creating_event);
1331
+			$tax_rows .= EEH_Template::display_template($template, $template_args, true);
1332
+		}
1333
+        
1334
+        
1335
+		return $tax_rows;
1336
+	}
1337 1337
     
1338 1338
     
1339
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1340
-    {
1341
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1339
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1340
+	{
1341
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1342 1342
         
1343
-        return $subtotal * $tax->get('PRC_amount') / 100;
1344
-    }
1343
+		return $subtotal * $tax->get('PRC_amount') / 100;
1344
+	}
1345 1345
     
1346 1346
     
1347
-    protected function _get_ticket_price_row(
1348
-        $tktrow,
1349
-        $prcrow,
1350
-        $price,
1351
-        $default,
1352
-        $ticket,
1353
-        $show_trash = true,
1354
-        $show_create = true
1355
-    ) {
1356
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false;
1357
-        $template_args = array(
1358
-            'tkt_row'               => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1359
-            'PRC_order'             => $default && empty($price) ? 'PRICENUM' : $prcrow,
1360
-            'edit_prices_name'      => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1361
-            'price_type_selector'   => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow,
1362
-                $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1363
-            'PRC_ID'                => $default && empty($price) ? 0 : $price->ID(),
1364
-            'PRC_is_default'        => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1365
-            'PRC_name'              => $default && empty($price) ? '' : $price->get('PRC_name'),
1366
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1367
-            'show_plus_or_minus'    => $default && empty($price) ? '' : ' style="display:none;"',
1368
-            'show_plus'             => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1369
-            'show_minus'            => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1370
-            'show_currency_symbol'  => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1371
-            'PRC_amount'            => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount',
1372
-                'localized_float'),
1373
-            'show_percentage'       => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1374
-            'show_trash_icon'       => $show_trash ? '' : ' style="display:none;"',
1375
-            'show_create_button'    => $show_create ? '' : ' style="display:none;"',
1376
-            'PRC_desc'              => $default && empty($price) ? '' : $price->get('PRC_desc'),
1377
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false
1378
-        );
1379
-        
1380
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1381
-            $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create,
1382
-            $this->_is_creating_event);
1383
-        
1384
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1385
-        
1386
-        return EEH_Template::display_template($template, $template_args, true);
1387
-    }
1347
+	protected function _get_ticket_price_row(
1348
+		$tktrow,
1349
+		$prcrow,
1350
+		$price,
1351
+		$default,
1352
+		$ticket,
1353
+		$show_trash = true,
1354
+		$show_create = true
1355
+	) {
1356
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false;
1357
+		$template_args = array(
1358
+			'tkt_row'               => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1359
+			'PRC_order'             => $default && empty($price) ? 'PRICENUM' : $prcrow,
1360
+			'edit_prices_name'      => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1361
+			'price_type_selector'   => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow,
1362
+				$price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1363
+			'PRC_ID'                => $default && empty($price) ? 0 : $price->ID(),
1364
+			'PRC_is_default'        => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1365
+			'PRC_name'              => $default && empty($price) ? '' : $price->get('PRC_name'),
1366
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1367
+			'show_plus_or_minus'    => $default && empty($price) ? '' : ' style="display:none;"',
1368
+			'show_plus'             => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1369
+			'show_minus'            => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1370
+			'show_currency_symbol'  => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1371
+			'PRC_amount'            => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount',
1372
+				'localized_float'),
1373
+			'show_percentage'       => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1374
+			'show_trash_icon'       => $show_trash ? '' : ' style="display:none;"',
1375
+			'show_create_button'    => $show_create ? '' : ' style="display:none;"',
1376
+			'PRC_desc'              => $default && empty($price) ? '' : $price->get('PRC_desc'),
1377
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted') ? true : false
1378
+		);
1379
+        
1380
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1381
+			$template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create,
1382
+			$this->_is_creating_event);
1383
+        
1384
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1385
+        
1386
+		return EEH_Template::display_template($template, $template_args, true);
1387
+	}
1388 1388
     
1389 1389
     
1390
-    protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = false)
1391
-    {
1392
-        if ($price->is_base_price()) {
1393
-            return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1394
-        } else {
1395
-            return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1396
-        }
1397
-        
1398
-    }
1390
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = false)
1391
+	{
1392
+		if ($price->is_base_price()) {
1393
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1394
+		} else {
1395
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1396
+		}
1397
+        
1398
+	}
1399 1399
     
1400 1400
     
1401
-    protected function _get_base_price_template($tktrow, $prcrow, $price, $default)
1402
-    {
1403
-        $template_args = array(
1404
-            'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1405
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1406
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1407
-            'PRT_name'                  => __('Price', 'event_espresso'),
1408
-            'price_selected_operator'   => '+',
1409
-            'price_selected_is_percent' => 0
1410
-        );
1411
-        $template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1412
-        
1413
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1414
-            $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1415
-        
1416
-        return EEH_Template::display_template($template, $template_args, true);
1417
-    }
1401
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default)
1402
+	{
1403
+		$template_args = array(
1404
+			'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1405
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1406
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1407
+			'PRT_name'                  => __('Price', 'event_espresso'),
1408
+			'price_selected_operator'   => '+',
1409
+			'price_selected_is_percent' => 0
1410
+		);
1411
+		$template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1412
+        
1413
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1414
+			$template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1415
+        
1416
+		return EEH_Template::display_template($template, $template_args, true);
1417
+	}
1418 1418
     
1419 1419
     
1420
-    protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = false)
1421
-    {
1422
-        $select_name                = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1423
-        $price_types                = EE_Registry::instance()->load_model('Price_Type')->get_all(array(
1424
-            array(
1425
-                'OR' => array(
1426
-                    'PBT_ID'  => '2',
1427
-                    'PBT_ID*' => '3'
1428
-                )
1429
-            )
1430
-        ));
1431
-        $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1432
-        $all_price_types            = $default && empty($price) ? array(
1433
-            array(
1434
-                'id'   => 0,
1435
-                'text' => __('Select Modifier', 'event_espresso')
1436
-            )
1437
-        ) : array();
1438
-        $selected_price_type_id     = $default && empty($price) ? 0 : $price->type();
1439
-        $price_option_spans         = '';
1440
-        //setup pricetypes for selector
1441
-        foreach ($price_types as $price_type) {
1442
-            $all_price_types[] = array(
1443
-                'id'   => $price_type->ID(),
1444
-                'text' => $price_type->get('PRT_name'),
1445
-            );
1420
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = false)
1421
+	{
1422
+		$select_name                = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1423
+		$price_types                = EE_Registry::instance()->load_model('Price_Type')->get_all(array(
1424
+			array(
1425
+				'OR' => array(
1426
+					'PBT_ID'  => '2',
1427
+					'PBT_ID*' => '3'
1428
+				)
1429
+			)
1430
+		));
1431
+		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1432
+		$all_price_types            = $default && empty($price) ? array(
1433
+			array(
1434
+				'id'   => 0,
1435
+				'text' => __('Select Modifier', 'event_espresso')
1436
+			)
1437
+		) : array();
1438
+		$selected_price_type_id     = $default && empty($price) ? 0 : $price->type();
1439
+		$price_option_spans         = '';
1440
+		//setup pricetypes for selector
1441
+		foreach ($price_types as $price_type) {
1442
+			$all_price_types[] = array(
1443
+				'id'   => $price_type->ID(),
1444
+				'text' => $price_type->get('PRT_name'),
1445
+			);
1446 1446
             
1447
-            //while we're in the loop let's setup the option spans used by js
1448
-            $spanargs = array(
1449
-                'PRT_ID'         => $price_type->ID(),
1450
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1451
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1452
-            );
1453
-            $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, true);
1454
-        }
1455
-        
1456
-        $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1457
-        $main_name     = $select_name;
1458
-        $select_name   = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1459
-        
1460
-        $template_args = array(
1461
-            'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1462
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1463
-            'price_modifier_selector'   => EEH_Form_Fields::select_input($select_name, $all_price_types,
1464
-                $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1465
-            'main_name'                 => $main_name,
1466
-            'selected_price_type_id'    => $selected_price_type_id,
1467
-            'price_option_spans'        => $price_option_spans,
1468
-            'price_selected_operator'   => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1469
-            'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1470
-            'disabled'                  => $disabled
1471
-        );
1472
-        
1473
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1474
-            $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1475
-        
1476
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1477
-        
1478
-        return EEH_Template::display_template($template, $template_args, true);
1479
-    }
1447
+			//while we're in the loop let's setup the option spans used by js
1448
+			$spanargs = array(
1449
+				'PRT_ID'         => $price_type->ID(),
1450
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1451
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1452
+			);
1453
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, true);
1454
+		}
1455
+        
1456
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1457
+		$main_name     = $select_name;
1458
+		$select_name   = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1459
+        
1460
+		$template_args = array(
1461
+			'tkt_row'                   => $default ? 'TICKETNUM' : $tktrow,
1462
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $prcrow,
1463
+			'price_modifier_selector'   => EEH_Form_Fields::select_input($select_name, $all_price_types,
1464
+				$selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1465
+			'main_name'                 => $main_name,
1466
+			'selected_price_type_id'    => $selected_price_type_id,
1467
+			'price_option_spans'        => $price_option_spans,
1468
+			'price_selected_operator'   => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1469
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1470
+			'disabled'                  => $disabled
1471
+		);
1472
+        
1473
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1474
+			$template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1475
+        
1476
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1477
+        
1478
+		return EEH_Template::display_template($template, $template_args, true);
1479
+	}
1480 1480
     
1481 1481
     
1482
-    protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default)
1483
-    {
1484
-        $tkt_dtts      = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1485
-        $template_args = array(
1486
-            'dtt_row'                  => $default && ! $dtt instanceof EE_Datetime ? 'DTTNUM' : $dttrow,
1487
-            'tkt_row'                  => $default ? 'TICKETNUM' : $tktrow,
1488
-            'ticket_datetime_selected' => in_array($dttrow, $tkt_dtts) ? ' ticket-selected' : '',
1489
-            'ticket_datetime_checked'  => in_array($dttrow, $tkt_dtts) ? ' checked="checked"' : '',
1490
-            'DTT_name'                 => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(true),
1491
-            'tkt_status_class'         => '',
1492
-        );
1493
-        
1494
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
1495
-            $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1496
-        $template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1497
-        
1498
-        return EEH_Template::display_template($template, $template_args, true);
1499
-    }
1482
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default)
1483
+	{
1484
+		$tkt_dtts      = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1485
+		$template_args = array(
1486
+			'dtt_row'                  => $default && ! $dtt instanceof EE_Datetime ? 'DTTNUM' : $dttrow,
1487
+			'tkt_row'                  => $default ? 'TICKETNUM' : $tktrow,
1488
+			'ticket_datetime_selected' => in_array($dttrow, $tkt_dtts) ? ' ticket-selected' : '',
1489
+			'ticket_datetime_checked'  => in_array($dttrow, $tkt_dtts) ? ' checked="checked"' : '',
1490
+			'DTT_name'                 => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(true),
1491
+			'tkt_status_class'         => '',
1492
+		);
1493
+        
1494
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
1495
+			$template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1496
+		$template      = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1497
+        
1498
+		return EEH_Template::display_template($template, $template_args, true);
1499
+	}
1500 1500
     
1501 1501
     
1502
-    protected function _get_ticket_js_structure($all_dtts, $all_tickets)
1503
-    {
1504
-        $template_args = array(
1505
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row('DTTNUM', null, true, $all_dtts),
1506
-            'default_ticket_row'                       => $this->_get_ticket_row('TICKETNUM', null, array(), array(),
1507
-                true),
1508
-            'default_price_row'                        => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', null,
1509
-                true, null),
1510
-            'default_price_rows'                       => '',
1511
-            'default_base_price_amount'                => 0,
1512
-            'default_base_price_name'                  => '',
1513
-            'default_base_price_description'           => '',
1514
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM',
1515
-                null, true),
1516
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row('DTTNUM', null, array(),
1517
-                array(), true),
1518
-            'existing_available_datetime_tickets_list' => '',
1519
-            'existing_available_ticket_datetimes_list' => '',
1520
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM',
1521
-                null, null, array(), true),
1522
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM',
1523
-                null, null, array(), true)
1524
-        );
1525
-        
1526
-        $tktrow = 1;
1527
-        foreach ($all_tickets as $ticket) {
1528
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM',
1529
-                $tktrow, null, $ticket, array(), true);
1530
-            $tktrow++;
1531
-        }
1532
-        
1533
-        
1534
-        $dttrow = 1;
1535
-        foreach ($all_dtts as $dtt) {
1536
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow,
1537
-                'TICKETNUM', $dtt, null, array(), true);
1538
-            $dttrow++;
1539
-        }
1540
-        
1541
-        $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1542
-        $prcrow         = 1;
1543
-        foreach ($default_prices as $price) {
1544
-            if ($price->is_base_price()) {
1545
-                $template_args['default_base_price_amount']      = $price->get_pretty('PRC_amount', 'localized_float');
1546
-                $template_args['default_base_price_name']        = $price->get('PRC_name');
1547
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
1548
-                $prcrow++;
1549
-                continue;
1550
-            }
1551
-            $show_trash  = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? false : true;
1552
-            $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? false : true;
1553
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, true,
1554
-                null, $show_trash, $show_create);
1555
-            $prcrow++;
1556
-        }
1557
-        
1558
-        $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
1559
-            $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1560
-        
1561
-        $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1562
-        
1563
-        return EEH_Template::display_template($template, $template_args, true);
1564
-    }
1502
+	protected function _get_ticket_js_structure($all_dtts, $all_tickets)
1503
+	{
1504
+		$template_args = array(
1505
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row('DTTNUM', null, true, $all_dtts),
1506
+			'default_ticket_row'                       => $this->_get_ticket_row('TICKETNUM', null, array(), array(),
1507
+				true),
1508
+			'default_price_row'                        => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', null,
1509
+				true, null),
1510
+			'default_price_rows'                       => '',
1511
+			'default_base_price_amount'                => 0,
1512
+			'default_base_price_name'                  => '',
1513
+			'default_base_price_description'           => '',
1514
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM',
1515
+				null, true),
1516
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row('DTTNUM', null, array(),
1517
+				array(), true),
1518
+			'existing_available_datetime_tickets_list' => '',
1519
+			'existing_available_ticket_datetimes_list' => '',
1520
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM',
1521
+				null, null, array(), true),
1522
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM',
1523
+				null, null, array(), true)
1524
+		);
1525
+        
1526
+		$tktrow = 1;
1527
+		foreach ($all_tickets as $ticket) {
1528
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM',
1529
+				$tktrow, null, $ticket, array(), true);
1530
+			$tktrow++;
1531
+		}
1532
+        
1533
+        
1534
+		$dttrow = 1;
1535
+		foreach ($all_dtts as $dtt) {
1536
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow,
1537
+				'TICKETNUM', $dtt, null, array(), true);
1538
+			$dttrow++;
1539
+		}
1540
+        
1541
+		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1542
+		$prcrow         = 1;
1543
+		foreach ($default_prices as $price) {
1544
+			if ($price->is_base_price()) {
1545
+				$template_args['default_base_price_amount']      = $price->get_pretty('PRC_amount', 'localized_float');
1546
+				$template_args['default_base_price_name']        = $price->get('PRC_name');
1547
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1548
+				$prcrow++;
1549
+				continue;
1550
+			}
1551
+			$show_trash  = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? false : true;
1552
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? false : true;
1553
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, true,
1554
+				null, $show_trash, $show_create);
1555
+			$prcrow++;
1556
+		}
1557
+        
1558
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
1559
+			$template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1560
+        
1561
+		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1562
+        
1563
+		return EEH_Template::display_template($template, $template_args, true);
1564
+	}
1565 1565
     
1566 1566
     
1567 1567
 } //end class espresso_events_Pricing_Hooks
Please login to merge, or discard this patch.
modules/ticket_selector/templates/ticket_selector_chart.template.php 2 patches
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
 
12 12
 $row = 1;
13 13
 $max = 1;
14
-$ticket_count = count( $tickets );
14
+$ticket_count = count($tickets);
15 15
 $ticket_status_display = '';
16
-if ( ! $ticket_count ) {
16
+if ( ! $ticket_count) {
17 17
 	return;
18 18
 }
19 19
 
20 20
 $required_ticket_sold_out = FALSE;
21
-$template_settings = isset ( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector )
21
+$template_settings = isset (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
22 22
 	? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
23 23
 	: new EE_Ticket_Selector_Config();
24 24
 
25
-$tax_settings = isset ( EE_Registry::instance()->CFG->tax_settings )
25
+$tax_settings = isset (EE_Registry::instance()->CFG->tax_settings)
26 26
 	? EE_Registry::instance()->CFG->tax_settings
27 27
 	: new EE_Tax_Config();
28 28
 
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
 
32 32
 ob_start();
33 33
 
34
-foreach ( $tickets as $TKT_ID => $ticket ) {
35
-	if ( $ticket instanceof EE_Ticket ) {
34
+foreach ($tickets as $TKT_ID => $ticket) {
35
+	if ($ticket instanceof EE_Ticket) {
36 36
 		$cols = 2;
37 37
 		$max = $ticket->max();
38 38
 		$min = 0;
39 39
 		$remaining = $ticket->remaining();
40
-		if ( $ticket->is_on_sale() && $ticket->is_remaining() ) {
40
+		if ($ticket->is_on_sale() && $ticket->is_remaining()) {
41 41
 			// offer the number of $tickets_remaining or $max_atndz, whichever is smaller
42
-			$max = min( $remaining, $max_atndz );
42
+			$max = min($remaining, $max_atndz);
43 43
 			// but... we also want to restrict the number of tickets by the ticket max setting,
44 44
 			// however, the max still can't be higher than what was just set above
45
-			$max = $ticket->max() > 0 ? min( $ticket->max(), $max ) : $max;
45
+			$max = $ticket->max() > 0 ? min($ticket->max(), $max) : $max;
46 46
 			// and we also want to restrict the minimum number of tickets by the ticket min setting
47 47
 			$min = $ticket->min() > 0 ? $ticket->min() : 0;
48 48
 			// and if the ticket is required, then make sure that min qty is at least 1
49
-			$min = $ticket->required() ? max( $min, 1 ) : $min;
49
+			$min = $ticket->required() ? max($min, 1) : $min;
50 50
 		} else {
51 51
 			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
52 52
 			$required_ticket_sold_out = $ticket->required() && ! $remaining ? $ticket->start_date() : $required_ticket_sold_out;
@@ -58,42 +58,42 @@  discard block
 block discarded – undo
58 58
 		$taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
59 59
 		$ticket_bundle = FALSE;
60 60
 		// for ticket bundles, set min and max qty the same
61
-		if ( $ticket->min() !== 0 && $ticket->min() === $ticket->max() ) {
61
+		if ($ticket->min() !== 0 && $ticket->min() === $ticket->max()) {
62 62
 			$ticket_price *= $ticket->min();
63 63
 			$ticket_bundle = TRUE;
64 64
 		}
65
-		$ticket_price = apply_filters( 'FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket );
65
+		$ticket_price = apply_filters('FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket);
66 66
 		$is_remaining = $remaining > 0 ? true : false;
67 67
 		// if a previous required ticket with the same sale start date is sold out, then mark this ticket as sold out as well.
68 68
 		// tickets that go on sale at a later date than the required ticket  will NOT be affected
69
-		$tkt_status = $required_ticket_sold_out !== FALSE && $required_ticket_sold_out === $ticket->start_date() ? EE_Ticket::sold_out : $ticket->ticket_status( false, $is_remaining );
69
+		$tkt_status = $required_ticket_sold_out !== FALSE && $required_ticket_sold_out === $ticket->start_date() ? EE_Ticket::sold_out : $ticket->ticket_status(false, $is_remaining);
70 70
 		$tkt_status = $event_status === EE_Datetime::sold_out ? EE_Ticket::sold_out : $tkt_status;
71 71
 		// check ticket status
72
-		switch ( $tkt_status ) {
72
+		switch ($tkt_status) {
73 73
 			// sold_out
74 74
 			case EE_Ticket::sold_out :
75
-				$ticket_status = '<span class="ticket-sales-sold-out">' . $ticket->ticket_status( TRUE, $is_remaining ) . '</span>';
75
+				$ticket_status = '<span class="ticket-sales-sold-out">'.$ticket->ticket_status(TRUE, $is_remaining).'</span>';
76 76
 				$status_class = 'ticket-sales-sold-out lt-grey-text';
77 77
 			break;
78 78
 			// expired
79 79
 			case EE_Ticket::expired :
80
-				$ticket_status = '<span class="ticket-sales-expired">' . $ticket->ticket_status( true, $is_remaining ) . '</span>';
80
+				$ticket_status = '<span class="ticket-sales-expired">'.$ticket->ticket_status(true, $is_remaining).'</span>';
81 81
 				$status_class = 'ticket-sales-expired lt-grey-text';
82 82
 			break;
83 83
 			// archived
84 84
 			case EE_Ticket::archived :
85
-				$ticket_status = '<span class="archived-ticket">' . $ticket->ticket_status( true, $is_remaining ) . '</span>';
85
+				$ticket_status = '<span class="archived-ticket">'.$ticket->ticket_status(true, $is_remaining).'</span>';
86 86
 				$status_class = 'archived-ticket hidden';
87 87
 			break;
88 88
 			// pending
89 89
 			case EE_Ticket::pending :
90
-				$ticket_status = '<span class="ticket-pending">' . $ticket->ticket_status( true, $is_remaining ) . '</span>';
90
+				$ticket_status = '<span class="ticket-pending">'.$ticket->ticket_status(true, $is_remaining).'</span>';
91 91
 				$status_class = 'ticket-pending';
92 92
 			break;
93 93
 			// onsale
94 94
 			case EE_Ticket::onsale :
95 95
 			default :
96
-				$ticket_status = '<span class="ticket-on-sale">' . $ticket->ticket_status( true, $is_remaining ) . '</span>';
96
+				$ticket_status = '<span class="ticket-on-sale">'.$ticket->ticket_status(true, $is_remaining).'</span>';
97 97
 				$status_class = 'ticket-on-sale';
98 98
 			break;
99 99
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             "tckt-slctr-tkt-details-{$EVT_ID}-{$TKT_ID}"
134 134
         );
135 135
 	?>
136
-				<tr class="tckt-slctr-tbl-tr <?php if ($ticket->get('TKT_class')) echo strip_tags($ticket->get('TKT_class').' ');?> <?php echo $status_class . ' ' . espresso_get_object_css_class( $ticket ); ?>">
136
+				<tr class="tckt-slctr-tbl-tr <?php if ($ticket->get('TKT_class')) echo strip_tags($ticket->get('TKT_class').' '); ?> <?php echo $status_class.' '.espresso_get_object_css_class($ticket); ?>">
137 137
 		<?php
138 138
 		/**
139 139
 		 * Allow plugins to hook in and abort the generation and display of the contents of this
@@ -145,24 +145,24 @@  discard block
 block discarded – undo
145 145
 		 *
146 146
 		 * @var string|bool
147 147
 		 */
148
-		if ( false !== ( $new_row_cells_content = apply_filters( 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class ) ) ) {
148
+		if (false !== ($new_row_cells_content = apply_filters('FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class))) {
149 149
 			echo $new_row_cells_content;
150 150
 			echo '</tr>';
151 151
 			continue;
152 152
 		}
153 153
 		?>
154 154
 					<td class="tckt-slctr-tbl-td-name">
155
-						<b><?php echo $ticket->get_pretty('TKT_name');?></b>
156
-						<?php if ( $template_settings->show_ticket_details ) : ?>
157
-							<a id="display-<?php echo $ticket_details_css_id; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __( 'click to show additional ticket details', 'event_espresso' )) ); ?>">
158
-								<?php echo sprintf( __( 'show%1$sdetails%1$s+', 'event_espresso' ), '&nbsp;' ); ?>
155
+						<b><?php echo $ticket->get_pretty('TKT_name'); ?></b>
156
+						<?php if ($template_settings->show_ticket_details) : ?>
157
+							<a id="display-<?php echo $ticket_details_css_id; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __('click to show additional ticket details', 'event_espresso'))); ?>">
158
+								<?php echo sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), '&nbsp;'); ?>
159 159
 							</a>
160
-							<a id="hide-<?php echo $ticket_details_css_id; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __( 'click to hide additional ticket details', 'event_espresso' )) ); ?>" style="display:none;">
161
-								<?php echo sprintf( __( 'hide%1$sdetails%1$s-', 'event_espresso' ), '&nbsp;' ); ?>
160
+							<a id="hide-<?php echo $ticket_details_css_id; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="<?php echo $ticket_details_css_id; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __('click to hide additional ticket details', 'event_espresso'))); ?>" style="display:none;">
161
+								<?php echo sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'); ?>
162 162
 							</a>
163 163
 						<?php endif; //end show details check ?>
164
-					<?php if ( $ticket->required() ) { ?>
165
-						<p class="ticket-required-pg"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_required_message', __( 'This ticket is required and must be purchased.', 'event_espresso' )); ?></p>
164
+					<?php if ($ticket->required()) { ?>
165
+						<p class="ticket-required-pg"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_required_message', __('This ticket is required and must be purchased.', 'event_espresso')); ?></p>
166 166
 					<?php } ?>
167 167
 					<?php
168 168
 //	echo '<br/><b>$max_atndz : ' . $max_atndz . '</b>';
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
 					</td>
179 179
 					<?php
180 180
 					if (
181
-						apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE )
181
+						apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)
182 182
 					) { ?>
183 183
 					<td class="tckt-slctr-tbl-td-price jst-rght"><?php
184
-						echo EEH_Template::format_currency( $ticket_price );
184
+						echo EEH_Template::format_currency($ticket_price);
185 185
 						echo $ticket->taxable() ? '<span class="taxable-tickets-asterisk grey-text">*</span>' : '';
186 186
 						?>&nbsp;<span class="smaller-text no-bold"><?php
187
-						if ( $ticket_bundle ) {
188
-							echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __( ' / bundle', 'event_espresso' ));
187
+						if ($ticket_bundle) {
188
+							echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __(' / bundle', 'event_espresso'));
189 189
 						} else {
190
-							echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_text', __( '', 'event_espresso' ));
190
+							echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_text', __('', 'event_espresso'));
191 191
 						}?></span>&nbsp;</td>
192 192
 						<?php $cols++; ?>
193 193
 					<?php } ?>
@@ -195,28 +195,28 @@  discard block
 block discarded – undo
195 195
 					<?php
196 196
 					$hidden_input_qty = $max_atndz > 1 ? TRUE : FALSE;
197 197
 					$ticket_status_display = '';
198
-					if ( $max_atndz === 0 ) {
198
+					if ($max_atndz === 0) {
199 199
 						// registration is CLOSED because admin set max attendees to ZERO
200
-						$ticket_status_display = '<span class="sold-out">' . apply_filters(
200
+						$ticket_status_display = '<span class="sold-out">'.apply_filters(
201 201
 													 'FHEE__ticket_selector_chart_template__ticket_closed_msg',
202
-													 __( 'Closed', 'event_espresso' )
203
-												 ) . '</span>';
204
-					} else if ( $tkt_status === EE_Ticket::sold_out || $remaining === 0 ) {
202
+													 __('Closed', 'event_espresso')
203
+												 ).'</span>';
204
+					} else if ($tkt_status === EE_Ticket::sold_out || $remaining === 0) {
205 205
 						// SOLD OUT - no tickets remaining
206
-						$ticket_status_display = '<span class="sold-out">' . apply_filters(
206
+						$ticket_status_display = '<span class="sold-out">'.apply_filters(
207 207
 													'FHEE__ticket_selector_chart_template__ticket_sold_out_msg',
208
-													__( 'Sold&nbsp;Out', 'event_espresso' )
209
-												) . '</span>';
210
-					} else if ( $tkt_status === EE_Ticket::expired || $tkt_status === EE_Ticket::archived ) {
208
+													__('Sold&nbsp;Out', 'event_espresso')
209
+												).'</span>';
210
+					} else if ($tkt_status === EE_Ticket::expired || $tkt_status === EE_Ticket::archived) {
211 211
 						// expired or archived ticket
212 212
 						$ticket_status_display = $ticket_status;
213
-					} else if ( $tkt_status === EE_Ticket::pending ) {
213
+					} else if ($tkt_status === EE_Ticket::pending) {
214 214
 						// ticket not on sale yet
215 215
 						$ticket_status_display = '<span class="ticket-pending-pg">
216 216
 						<span class="ticket-pending">'
217 217
 						. apply_filters(
218 218
 							'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg',
219
-							__( 'Goes&nbsp;On&nbsp;Sale', 'event_espresso' )
219
+							__('Goes&nbsp;On&nbsp;Sale', 'event_espresso')
220 220
 						 )
221 221
 					. '</span><br/>
222 222
 						<span class="small-text">'
@@ -229,36 +229,36 @@  discard block
 block discarded – undo
229 229
 						)
230 230
 					. '</span>
231 231
 					</span>';
232
-					} else if ( $ticket->min() > $remaining ) {
232
+					} else if ($ticket->min() > $remaining) {
233 233
 						// min qty purchasable is less than tickets available
234 234
 						$ticket_status_display = '
235 235
 					<div class="archived-ticket-pg">
236 236
 						<span class="archived-ticket small-text">'
237
-						 . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', __( 'Not Available', 'event_espresso' ))
237
+						 . apply_filters('FHEE__ticket_selector_chart_template__ticket_not_available_msg', __('Not Available', 'event_espresso'))
238 238
 					 . '</span><br/>
239 239
 					</div>';
240
-					} else if ( $max_atndz  === 1 ) {
240
+					} else if ($max_atndz === 1) {
241 241
 						// only ONE attendee is allowed to register at a time
242 242
 						// display submit button since we have tickets available
243
-						add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
243
+						add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
244 244
 					?>
245
-						<input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row . '-'; ?>1" <?php echo $row === 1 ? ' checked="checked"' : ''; ?>  title=""/>
245
+						<input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row.'-'; ?>1" <?php echo $row === 1 ? ' checked="checked"' : ''; ?>  title=""/>
246 246
 					<?php
247 247
 						$hidden_input_qty = FALSE;
248 248
 
249
-					} else if ( $max > 0 ) {
249
+					} else if ($max > 0) {
250 250
 						// display submit button since we have tickets available
251
-						add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
251
+						add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
252 252
 					?>
253
-					<select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" title="">
253
+					<select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" title="">
254 254
 					<?php
255 255
 						// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
256
-						if ( ! $ticket->required() && $min !== 0 ) {
256
+						if ( ! $ticket->required() && $min !== 0) {
257 257
 					?>
258 258
 						<option value="0">&nbsp;0&nbsp;</option>
259 259
 					<?php }
260 260
 						// offer ticket quantities from the min to the max
261
-						for ( $i = $min; $i <= $max; $i++) {
261
+						for ($i = $min; $i <= $max; $i++) {
262 262
 					?>
263 263
 						<option value="<?php echo $i; ?>">&nbsp;<?php echo $i; ?>&nbsp;</option>
264 264
 					<?php } ?>
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 					}
270 270
 					echo $ticket_status_display;
271 271
 					// depending on group reg we need to change the format for qty
272
-					if ( $hidden_input_qty ) {
272
+					if ($hidden_input_qty) {
273 273
 					?>
274 274
 					<input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="0" />
275 275
 					<?php
@@ -279,33 +279,33 @@  discard block
 block discarded – undo
279 279
 
280 280
 					</td>
281 281
 				</tr>
282
-				<?php if ( $template_settings->show_ticket_details ) : ?>
283
-					<tr class="tckt-slctr-tkt-details-tr <?php if ($ticket->get('TKT_class')) echo strip_tags($ticket->get('TKT_class').' ');?>  <?php echo espresso_get_object_css_class( $ticket, '', 'details' );?>">
282
+				<?php if ($template_settings->show_ticket_details) : ?>
283
+					<tr class="tckt-slctr-tkt-details-tr <?php if ($ticket->get('TKT_class')) echo strip_tags($ticket->get('TKT_class').' '); ?>  <?php echo espresso_get_object_css_class($ticket, '', 'details'); ?>">
284 284
 						<td class="tckt-slctr-tkt-details-td" colspan="<?php echo $cols; ?>" >
285 285
 							<div id="<?php echo $ticket_details_css_id; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;">
286 286
 
287 287
 								<section class="tckt-slctr-tkt-details-sctn">
288
-									<h3><?php _e( 'Details', 'event_espresso' ); ?></h3>
288
+									<h3><?php _e('Details', 'event_espresso'); ?></h3>
289 289
 									<p><?php echo $ticket->description(); ?></p>
290 290
 
291
-									<?php if ( $ticket_price !== 0 && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?>
291
+									<?php if ($ticket_price !== 0 && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
292 292
 									<section class="tckt-slctr-tkt-price-sctn">
293
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __( 'Price', 'event_espresso' )); ?></h5>
293
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __('Price', 'event_espresso')); ?></h5>
294 294
 										<div class="tckt-slctr-tkt-details-tbl-wrap-dv">
295 295
 											<table class="tckt-slctr-tkt-details-tbl">
296 296
 												<thead>
297 297
 													<tr>
298
-														<th class="ee-third-width"><span class="small-text"><?php _e( 'Name', 'event_espresso' ); ?></span></th>
299
-														<th class="jst-cntr"><span class="small-text"><?php _e( 'Description', 'event_espresso' ); ?></span></th>
300
-														<th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e( 'Amount', 'event_espresso' ); ?></span></th>
298
+														<th class="ee-third-width"><span class="small-text"><?php _e('Name', 'event_espresso'); ?></span></th>
299
+														<th class="jst-cntr"><span class="small-text"><?php _e('Description', 'event_espresso'); ?></span></th>
300
+														<th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e('Amount', 'event_espresso'); ?></span></th>
301 301
 													</tr>
302 302
 												</thead>
303 303
 												<tbody>
304
-										<?php if ( $ticket->base_price() instanceof EE_Price ) { ?>
304
+										<?php if ($ticket->base_price() instanceof EE_Price) { ?>
305 305
 													<tr>
306
-														<td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td>
307
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td>
308
-														<td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td>
306
+														<td data-th="<?php _e('Name', 'event_espresso'); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td>
307
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td>
308
+														<td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td>
309 309
 													</tr>
310 310
 													<?php
311 311
 															$running_total = $ticket->base_price()->amount();
@@ -313,44 +313,44 @@  discard block
 block discarded – undo
313 313
 															$running_total = 0;
314 314
 														}
315 315
 														// now add price modifiers
316
-														foreach ( $ticket->price_modifiers() as $price_mod ) { ?>
316
+														foreach ($ticket->price_modifiers() as $price_mod) { ?>
317 317
 													<tr>
318
-														<td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td>
319
-													<?php if ( $price_mod->is_percent() ) { ?>
320
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td>
318
+														<td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td>
319
+													<?php if ($price_mod->is_percent()) { ?>
320
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td>
321 321
 														<?php
322
-															$new_sub_total = $running_total * ( $price_mod->amount() / 100 );
322
+															$new_sub_total = $running_total * ($price_mod->amount() / 100);
323 323
 															$new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total;
324 324
 														?>
325 325
 													<?php } else { ?>
326 326
 														<?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?>
327
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td>
327
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td>
328 328
 														<?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?>
329 329
 													<?php } ?>
330
-														<td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $new_sub_total ); ?></td>
330
+														<td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($new_sub_total); ?></td>
331 331
 														<?php $running_total += $new_sub_total; ?>
332 332
 													</tr>
333 333
 												<?php } ?>
334
-												<?php if ( $ticket->taxable() ) { ?>
334
+												<?php if ($ticket->taxable()) { ?>
335 335
 													<?php //$ticket_subtotal =$ticket->get_ticket_subtotal(); ?>
336 336
 													<tr>
337
-														<td colspan="2" class="jst-rght small-text sbttl"><b><?php _e( 'subtotal', 'event_espresso' ); ?></b></td>
338
-														<td data-th="<?php _e( 'subtotal', 'event_espresso' ); ?>" class="jst-rght small-text"><b><?php echo  EEH_Template::format_currency( $running_total ); ?></b></td>
337
+														<td colspan="2" class="jst-rght small-text sbttl"><b><?php _e('subtotal', 'event_espresso'); ?></b></td>
338
+														<td data-th="<?php _e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text"><b><?php echo  EEH_Template::format_currency($running_total); ?></b></td>
339 339
 													</tr>
340 340
 
341
-													<?php foreach ( $ticket->get_ticket_taxes_for_admin() as $tax ) { ?>
341
+													<?php foreach ($ticket->get_ticket_taxes_for_admin() as $tax) { ?>
342 342
 													<tr>
343
-														<td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td>
344
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td>
345
-														<?php $tax_amount = $running_total * ( $tax->amount() / 100 ); ?>
346
-														<td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $tax_amount ); ?></td>
343
+														<td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td>
344
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td>
345
+														<?php $tax_amount = $running_total * ($tax->amount() / 100); ?>
346
+														<td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($tax_amount); ?></td>
347 347
 														<?php $running_total += $tax_amount; ?>
348 348
 													</tr>
349 349
 													<?php } ?>
350 350
 												<?php } ?>
351 351
 													<tr>
352
-														<td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?></b></td>
353
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency( $running_total ); ?></b></td>
352
+														<td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?></b></td>
353
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency($running_total); ?></b></td>
354 354
 													</tr>
355 355
 												</tbody>
356 356
 											</table>
@@ -360,110 +360,110 @@  discard block
 block discarded – undo
360 360
 									<?php } ?>
361 361
 
362 362
 									<section class="tckt-slctr-tkt-sale-dates-sctn">
363
-										<h5 class="tckt-slctr-tkt-sale-dates-hdr"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __( 'Sale Dates', 'event_espresso' )); ?></h5>
364
-										<span class="tckt-slctr-tkt-sale-dates-desc drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __( 'The dates when this option is available for purchase.', 'event_espresso' )); ?></span>
363
+										<h5 class="tckt-slctr-tkt-sale-dates-hdr"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __('Sale Dates', 'event_espresso')); ?></h5>
364
+										<span class="tckt-slctr-tkt-sale-dates-desc drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __('The dates when this option is available for purchase.', 'event_espresso')); ?></span>
365 365
 										<span class="tckt-slctr-tkt-sale-dates-start">
366
-											<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __( 'Goes On Sale:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><span class="ee-date-start"><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $date_format) . ' &nbsp; '; ?></span><span class="dashicons dashicons-clock"></span><span class="ee-time-start"><?php echo $ticket->get_i18n_datetime( 'TKT_start_date',  $time_format ) ; ?></span>
366
+											<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __('Goes On Sale:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><span class="ee-date-start"><?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format).' &nbsp; '; ?></span><span class="dashicons dashicons-clock"></span><span class="ee-time-start"><?php echo $ticket->get_i18n_datetime('TKT_start_date', $time_format); ?></span>
367 367
 										</span>
368 368
 										<span clacc="tckt-slctr-tkt-sale-dates-end">
369
-											<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', __( 'Sales End:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><span class="ee-date-end"><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $date_format ) . ' &nbsp; '; ?></span><span class="dashicons dashicons-clock"></span><span class="ee-time-end"><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $time_format ) ; ?></span>
369
+											<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_end', __('Sales End:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><span class="ee-date-end"><?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format).' &nbsp; '; ?></span><span class="dashicons dashicons-clock"></span><span class="ee-time-end"><?php echo $ticket->get_i18n_datetime('TKT_end_date', $time_format); ?></span>
370 370
 										</span>
371 371
 									</section>
372 372
 									<br/>
373 373
 
374
-									<?php do_action( 'AHEE__ticket_selector_chart_template__after_ticket_date', $ticket ); ?>
374
+									<?php do_action('AHEE__ticket_selector_chart_template__after_ticket_date', $ticket); ?>
375 375
 
376
-									<?php if ( $ticket->min() && $ticket->max() ) { ?>
376
+									<?php if ($ticket->min() && $ticket->max()) { ?>
377 377
 									<section class="tckt-slctr-tkt-quantities-sctn">
378
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __( 'Purchasable Quantities', 'event_espresso' )); ?></h5>
379
-										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __( 'The number of tickets that can be purchased per transaction (if available).', 'event_espresso' )); ?></span><br/>
380
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __( 'Minimum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?>
381
-										<?php if ( $ticket->min() > $remaining ) { ?> &nbsp; <span class="important-notice small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __( 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso' )); ?></span><?php } ?><br/>
378
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __('Purchasable Quantities', 'event_espresso')); ?></h5>
379
+										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __('The number of tickets that can be purchased per transaction (if available).', 'event_espresso')); ?></span><br/>
380
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __('Minimum Qty:', 'event_espresso')); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?>
381
+										<?php if ($ticket->min() > $remaining) { ?> &nbsp; <span class="important-notice small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __('The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso')); ?></span><?php } ?><br/>
382 382
 										<?php //$max = min( $max, $max_atndz );?>
383
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __( 'Maximum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->max() === EE_INF ? __( 'no limit', 'event_espresso' ) : max( $ticket->max(), 1 ); ?><br/>
383
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __('Maximum Qty:', 'event_espresso')); ?></span><?php echo $ticket->max() === EE_INF ? __('no limit', 'event_espresso') : max($ticket->max(), 1); ?><br/>
384 384
 									</section>
385 385
 									<br/>
386 386
 									<?php } ?>
387 387
 
388
-									<?php if ( $ticket->uses() !== EE_INF && ( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE )) { ?>
388
+									<?php if ($ticket->uses() !== EE_INF && ( ! defined('EE_DECAF') || EE_DECAF !== TRUE)) { ?>
389 389
 									<section class="tckt-slctr-tkt-uses-sctn">
390
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __( 'Event Date Ticket Uses', 'event_espresso' )); ?></h5>
390
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __('Event Date Ticket Uses', 'event_espresso')); ?></h5>
391 391
 										<span class="drk-grey-text small-text no-bold"> - <?php
392 392
 											echo apply_filters(
393 393
 												'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message',
394 394
 												sprintf(
395
-													__( 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso' ),
395
+													__('The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso'),
396 396
 													'<br/>',
397 397
 													'<strong>',
398 398
 													'</strong>'
399 399
 												)
400 400
 											);
401 401
 											?></span><br/>
402
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __( '# Datetimes:', 'event_espresso' )); ?></span><?php  echo $ticket->uses();?><br/>
402
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __('# Datetimes:', 'event_espresso')); ?></span><?php  echo $ticket->uses(); ?><br/>
403 403
 									</section>
404 404
 									<?php } ?>
405 405
 
406 406
 									<?php
407
-									$datetimes = $ticket->datetimes_ordered( $event_is_expired, FALSE );
407
+									$datetimes = $ticket->datetimes_ordered($event_is_expired, FALSE);
408 408
 									$chart_column_width = $template_settings->show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
409
-									if ( ! empty( $datetimes )) { ?>
409
+									if ( ! empty($datetimes)) { ?>
410 410
 									<section class="tckt-slctr-tkt-datetimes-sctn">
411
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __( 'Access', 'event_espresso' )); ?></h5>
412
-										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __( 'This option allows access to the following dates and times.', 'event_espresso' )); ?></span>
411
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __('Access', 'event_espresso')); ?></h5>
412
+										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __('This option allows access to the following dates and times.', 'event_espresso')); ?></span>
413 413
 										<div class="tckt-slctr-tkt-details-tbl-wrap-dv">
414 414
 											<table class="tckt-slctr-tkt-details-tbl">
415 415
 												<thead>
416 416
 													<tr>
417 417
 														<th class="tckt-slctr-tkt-details-date-th">
418
-															<span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Date ', 'event_espresso' )); ?></span>
418
+															<span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Date ', 'event_espresso')); ?></span>
419 419
 														</th>
420 420
 														<th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>">
421
-															<span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e( 'Time ', 'event_espresso' ); ?></span>
421
+															<span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e('Time ', 'event_espresso'); ?></span>
422 422
 														</th>
423
-														<?php if ( $template_settings->show_ticket_sale_columns ) : ?>
423
+														<?php if ($template_settings->show_ticket_sale_columns) : ?>
424 424
 															<th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr">
425
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf( __( 'Sold', 'event_espresso' ), '<br/>' )); ?></span>
425
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf(__('Sold', 'event_espresso'), '<br/>')); ?></span>
426 426
 															</th>
427 427
 															<th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr">
428
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf( __( 'Remaining', 'event_espresso' ), '<br/>' )); ?></span>
428
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf(__('Remaining', 'event_espresso'), '<br/>')); ?></span>
429 429
 															</th>
430 430
 															<th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr">
431
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf( __( 'Total%sSold', 'event_espresso' ), '<br/>' )); ?></span>
431
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf(__('Total%sSold', 'event_espresso'), '<br/>')); ?></span>
432 432
 															</th>
433 433
 															<th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr">
434
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf( __( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' )); ?></span>
434
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf(__('Total Spaces%sLeft', 'event_espresso'), '<br/>')); ?></span>
435 435
 															</th>
436 436
 														<?php endif; //end $template_settings->show_ticket_sale_columns conditional ?>
437 437
 													</tr>
438 438
 												</thead>
439 439
 												<tbody>
440 440
 											<?php
441
-												foreach ( $datetimes as $datetime ) {
442
-													if ( $datetime instanceof EE_Datetime ) {
441
+												foreach ($datetimes as $datetime) {
442
+													if ($datetime instanceof EE_Datetime) {
443 443
 											?>
444 444
 
445 445
 												<tr>
446
-													<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Event Date ', 'event_espresso' )); ?>" class="small-text tckt-slctr-tkt-details-date">
446
+													<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Event Date ', 'event_espresso')); ?>" class="small-text tckt-slctr-tkt-details-date">
447 447
 														<?php $datetime_name = $datetime->name(); ?>
448
-														<?php echo ! empty( $datetime_name ) ? '<b>' . $datetime_name . '</b><br/>' : ''; ?>
449
-														<?php echo $datetime->date_range( $date_format, __( ' to  ', 'event_espresso' )); ?>
448
+														<?php echo ! empty($datetime_name) ? '<b>'.$datetime_name.'</b><br/>' : ''; ?>
449
+														<?php echo $datetime->date_range($date_format, __(' to  ', 'event_espresso')); ?>
450 450
 													</td>
451
-													<td data-th="<?php _e( 'Time ', 'event_espresso' ); ?>" class="cntr small-text tckt-slctr-tkt-details-time">
452
-														<?php echo $datetime->time_range( $time_format, __( ' to  ', 'event_espresso' )); ?>
451
+													<td data-th="<?php _e('Time ', 'event_espresso'); ?>" class="cntr small-text tckt-slctr-tkt-details-time">
452
+														<?php echo $datetime->time_range($time_format, __(' to  ', 'event_espresso')); ?>
453 453
 													</td>
454
-													<?php if ( $template_settings->show_ticket_sale_columns ) : ?>
455
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __( 'Sold', 'event_espresso' )); ?>" class="cntr small-text tckt-slctr-tkt-details-this-ticket-sold">
454
+													<?php if ($template_settings->show_ticket_sale_columns) : ?>
455
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __('Sold', 'event_espresso')); ?>" class="cntr small-text tckt-slctr-tkt-details-this-ticket-sold">
456 456
 															<?php echo $ticket->sold(); ?>
457 457
 														</td>
458
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __( 'Remaining', 'event_espresso' )); ?>" class="cntr small-text tckt-slctr-tkt-details-this-ticket-left">
459
-															<?php echo $remaining === EE_INF ? '<span class="smaller-text">' .  __( 'unlimited ', 'event_espresso' ) . '</span>' : $remaining; ?>
458
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __('Remaining', 'event_espresso')); ?>" class="cntr small-text tckt-slctr-tkt-details-this-ticket-left">
459
+															<?php echo $remaining === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $remaining; ?>
460 460
 														</td>
461
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __( 'Total Sold', 'event_espresso' )); ?>" class="cntr small-text tckt-slctr-tkt-details-tickets-sold">
461
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __('Total Sold', 'event_espresso')); ?>" class="cntr small-text tckt-slctr-tkt-details-tickets-sold">
462 462
 															<?php echo $datetime->sold(); ?>
463 463
 														</td>
464
-												<?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">' . __( 'Sold&nbsp;Out', 'event_espresso' ) . '</span>' : $datetime->spaces_remaining(); ?>
465
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __( 'Total Spaces Left', 'event_espresso' )); ?>" class="cntr small-text tckt-slctr-tkt-details-tickets-left">
466
-															<?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' .  __( 'unlimited ', 'event_espresso' ) . '</span>' : $tkts_left; ?>
464
+												<?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">'.__('Sold&nbsp;Out', 'event_espresso').'</span>' : $datetime->spaces_remaining(); ?>
465
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __('Total Spaces Left', 'event_espresso')); ?>" class="cntr small-text tckt-slctr-tkt-details-tickets-left">
466
+															<?php echo $tkts_left === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $tkts_left; ?>
467 467
 														</td>
468 468
 													<?php endif; //end $template_settings->show_ticket_sale_columns conditional ?>
469 469
 												</tr>
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 							</div>
482 482
 						</td>
483 483
 					</tr>
484
-				<?php endif;  //end template_settings->show_ticket_details check?>
484
+				<?php endif; //end template_settings->show_ticket_details check?>
485 485
 	<?php
486 486
 			$row++;
487 487
 		}
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 $ticket_row_html = ob_get_clean();
491 491
 // if there is only ONE ticket with a max qty of ONE, and it is free... then not much need for the ticket selector
492 492
 $hide_ticket_selector = $ticket_count === 1 && $max_atndz === 1 && $ticket->is_free() ? true : false;
493
-$hide_ticket_selector = apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID );
494
-remove_all_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector' );
493
+$hide_ticket_selector = apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID);
494
+remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
495 495
 // EEH_Debug_Tools::printr( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ), 'display submit', __FILE__, __LINE__ );
496 496
 // EEH_Debug_Tools::printr( (string) $ticket_count, '$ticket_count', __FILE__, __LINE__ );
497 497
 // EEH_Debug_Tools::printr( (string) $max, '$max', __FILE__, __LINE__ );
@@ -505,20 +505,20 @@  discard block
 block discarded – undo
505 505
 * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
506 506
 * @param int $EVT_ID The Event ID
507 507
 */
508
-$anchor_id = apply_filters( 'FHEE__EE_Ticket_Selector__redirect_anchor_id', '#tkt-slctr-tbl-' . $EVT_ID, $EVT_ID );
509
-if ( ! $hide_ticket_selector ) {
508
+$anchor_id = apply_filters('FHEE__EE_Ticket_Selector__redirect_anchor_id', '#tkt-slctr-tbl-'.$EVT_ID, $EVT_ID);
509
+if ( ! $hide_ticket_selector) {
510 510
 ?>
511 511
 <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv">
512 512
 
513
-	<?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?>
513
+	<?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?>
514 514
 
515 515
 	<table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl">
516 516
 		<thead>
517 517
 			<tr>
518 518
 				<th scope="col" class="ee-ticket-selector-ticket-details-th">
519
-					<?php echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID ) ); ?>
519
+					<?php echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID)); ?>
520 520
 				</th>
521
-				<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?>
521
+				<?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
522 522
 				<th scope="col" class="ee-ticket-selector-ticket-price-th cntr">
523 523
 					<?php
524 524
 						/**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 						 * @param string 'Price' The translatable text to display in the table header for price
530 530
 						 * @param int $EVT_ID The Event ID
531 531
 						 */
532
-						echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_price', __( 'Price', 'event_espresso' ), $EVT_ID ) );
532
+						echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_price', __('Price', 'event_espresso'), $EVT_ID));
533 533
 					?>
534 534
 				</th>
535 535
 				<?php } ?>
@@ -543,77 +543,77 @@  discard block
 block discarded – undo
543 543
 						* @param string 'Qty' The translatable text to display in the table header for the Quantity of tickets
544 544
 						* @param int $EVT_ID The Event ID
545 545
 						*/
546
-						echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_qty', __( 'Qty', 'event_espresso' ), $EVT_ID ) );
546
+						echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_qty', __('Qty', 'event_espresso'), $EVT_ID));
547 547
 					?>
548 548
 				</th>
549 549
 			</tr>
550 550
 		</thead>
551 551
 		<tbody>
552
-			<?php echo $ticket_row_html;?>
552
+			<?php echo $ticket_row_html; ?>
553 553
 		</tbody>
554 554
 	</table>
555 555
 	<?php
556
-	if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) {
557
-		if ( $tax_settings->prices_displayed_including_taxes ) {
558
-			$ticket_price_includes_taxes = __( '* price includes taxes', 'event_espresso' );
556
+	if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
557
+		if ($tax_settings->prices_displayed_including_taxes) {
558
+			$ticket_price_includes_taxes = __('* price includes taxes', 'event_espresso');
559 559
 		} else {
560
-			$ticket_price_includes_taxes = __( '* price does not include taxes', 'event_espresso' );
560
+			$ticket_price_includes_taxes = __('* price does not include taxes', 'event_espresso');
561 561
 		}
562
-		echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>';
562
+		echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>';
563 563
 	}
564 564
 	?>
565 565
 
566 566
 	<input type="hidden" name="noheader" value="true" />
567
-	<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>" />
567
+	<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>" />
568 568
 	<input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>" />
569 569
 	<input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>" />
570 570
 	<input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>" />
571 571
 
572 572
 <?php
573
-if ( $max_atndz > 0 ) {
573
+if ($max_atndz > 0) {
574 574
 	echo apply_filters(
575 575
 		'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote',
576 576
 		''
577 577
 	);
578 578
 }
579
-if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
580
-	add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' );
579
+if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
580
+	add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true');
581 581
 }
582
-do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
582
+do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event);
583 583
 ?>
584 584
 
585 585
 <?php
586
-} else if ( isset( $TKT_ID ) ) {
587
-	add_filter( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', '__return_true' );
586
+} else if (isset($TKT_ID)) {
587
+	add_filter('FHEE__EE_Ticket_Selector__hide_ticket_selector', '__return_true');
588 588
 ?>
589 589
 
590 590
 <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/>
591 591
 <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/>
592 592
 <input type="hidden" name="noheader" value="true"/>
593
-<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>"/>
593
+<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>"/>
594 594
 <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>"/>
595 595
 <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>"/>
596 596
 <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>"/>
597 597
 <?php
598
-	if ( $ticket instanceof EE_Ticket ) {
599
-		do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event );
598
+	if ($ticket instanceof EE_Ticket) {
599
+		do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event);
600 600
 		$ticket_description = $ticket->description();
601
-		$ticket_description .= ! empty( $ticket_description )
602
-			? '<br />' . $ticket_status_display
601
+		$ticket_description .= ! empty($ticket_description)
602
+			? '<br />'.$ticket_status_display
603 603
 			: $ticket_status_display;
604
-		if ( ! strpos( $ticket_description, '<div' ) ) {
604
+		if ( ! strpos($ticket_description, '<div')) {
605 605
 			$ticket_description = "<p>{$ticket_description}</p>";
606 606
 		}
607 607
 ?>
608 608
 <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv">
609 609
 	<div class="no-tkt-slctr-ticket-content-dv">
610 610
 		<h5><?php echo $ticket->name(); ?></h5>
611
-		<?php if ( ! empty( $ticket_description ) ) { ?>
611
+		<?php if ( ! empty($ticket_description)) { ?>
612 612
 		<?php echo $ticket_description; ?>
613 613
 		<?php } ?>
614 614
 	</div>
615 615
 <?php
616
-		do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
616
+		do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event);
617 617
 	}
618 618
 }
619 619
 ?>
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -133,7 +133,10 @@  discard block
 block discarded – undo
133 133
             "tckt-slctr-tkt-details-{$EVT_ID}-{$TKT_ID}"
134 134
         );
135 135
 	?>
136
-				<tr class="tckt-slctr-tbl-tr <?php if ($ticket->get('TKT_class')) echo strip_tags($ticket->get('TKT_class').' ');?> <?php echo $status_class . ' ' . espresso_get_object_css_class( $ticket ); ?>">
136
+				<tr class="tckt-slctr-tbl-tr <?php if ($ticket->get('TKT_class')) {
137
+	echo strip_tags($ticket->get('TKT_class').' ');
138
+}
139
+?> <?php echo $status_class . ' ' . espresso_get_object_css_class( $ticket ); ?>">
137 140
 		<?php
138 141
 		/**
139 142
 		 * Allow plugins to hook in and abort the generation and display of the contents of this
@@ -280,7 +283,10 @@  discard block
 block discarded – undo
280 283
 					</td>
281 284
 				</tr>
282 285
 				<?php if ( $template_settings->show_ticket_details ) : ?>
283
-					<tr class="tckt-slctr-tkt-details-tr <?php if ($ticket->get('TKT_class')) echo strip_tags($ticket->get('TKT_class').' ');?>  <?php echo espresso_get_object_css_class( $ticket, '', 'details' );?>">
286
+					<tr class="tckt-slctr-tkt-details-tr <?php if ($ticket->get('TKT_class')) {
287
+	echo strip_tags($ticket->get('TKT_class').' ');
288
+}
289
+?>  <?php echo espresso_get_object_css_class( $ticket, '', 'details' );?>">
284 290
 						<td class="tckt-slctr-tkt-details-td" colspan="<?php echo $cols; ?>" >
285 291
 							<div id="<?php echo $ticket_details_css_id; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;">
286 292
 
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +1205 added lines, -1205 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
 
@@ -14,1216 +14,1216 @@  discard block
 block discarded – undo
14 14
 class EED_Ticket_Selector extends EED_Module
15 15
 {
16 16
 
17
-    const debug = false;    //	true false
18
-
19
-    /**
20
-     * event that ticket selector is being generated for
21
-     *
22
-     * @access protected
23
-     * @var \EE_Event
24
-     */
25
-    protected static $_event;
26
-
27
-    /**
28
-     * array of datetimes and the spaces available for them
29
-     *
30
-     * @access private
31
-     * @var array
32
-     */
33
-    private static $_available_spaces = array();
34
-
35
-    /**
36
-     * max attendees that can register for event at one time
37
-     *
38
-     * @access private
39
-     * @var int
40
-     */
41
-    private static $_max_atndz = EE_INF;
42
-
43
-
44
-
45
-    /**
46
-     * Used to flag when the ticket selector is being called from an external iframe.
47
-     *
48
-     * @var bool
49
-     */
50
-    protected static $_in_iframe = false;
51
-
52
-
53
-
54
-    /**
55
-     * @return EED_Ticket_Selector
56
-     */
57
-    public static function instance()
58
-    {
59
-        return parent::get_instance(__CLASS__);
60
-    }
61
-
62
-
63
-
64
-    protected function set_config()
65
-    {
66
-        $this->set_config_section('template_settings');
67
-        $this->set_config_class('EE_Ticket_Selector_Config');
68
-        $this->set_config_name('EED_Ticket_Selector');
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     *    set_hooks - for hooking into EE Core, other modules, etc
75
-     *
76
-     * @access    public
77
-     * @return    void
78
-     */
79
-    public static function set_hooks()
80
-    {
81
-        // routing
82
-        EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
83
-        EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
84
-        EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
85
-        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
86
-        add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
87
-        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
94
-     *
95
-     * @access    public
96
-     * @return    void
97
-     */
98
-    public static function set_hooks_admin()
99
-    {
100
-        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
101
-        //add button for iframe code to event editor.
102
-        add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 2);
103
-        add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     *    set_definitions
110
-     *
111
-     * @access    public
112
-     * @return    void
113
-     */
114
-    public static function set_definitions()
115
-    {
116
-        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
117
-        define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
118
-        //if config is not set, initialize
119
-        //If config is not set, set it.
120
-        if (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector === null) {
121
-            EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
122
-        }
123
-        EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     *    gets the ball rolling
130
-     *
131
-     * @access public
132
-     * @param    WP $WP
133
-     * @return void
134
-     */
135
-    public function run($WP)
136
-    {
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     * ticket_selector_iframe
143
-     *
144
-     * @access    public
145
-     * @return    void
146
-     * @throws \EE_Error
147
-     */
148
-    public function ticket_selector_iframe()
149
-    {
150
-        self::$_in_iframe = true;
151
-        /** @type EEM_Event $EEM_Event */
152
-        $EEM_Event = EE_Registry::instance()->load_model('Event');
153
-        $event = $EEM_Event->get_one_by_ID(
154
-            EE_Registry::instance()->REQ->get('event', 0)
155
-        );
156
-        EE_Registry::instance()->REQ->set_espresso_page(true);
157
-        $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
158
-        $template_args['css'] = apply_filters(
159
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
160
-            array(
161
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
162
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
163
-                includes_url('css/dashicons.min.css?ver=' . $GLOBALS['wp_version']),
164
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
165
-            )
166
-        );
167
-        EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
168
-        EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = esc_html__('Please choose at least one ticket before continuing.',
169
-            'event_espresso');
170
-        $template_args['eei18n'] = apply_filters(
171
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
172
-            EE_Registry::localize_i18n_js_strings()
173
-        );
174
-        $template_args['js'] = apply_filters(
175
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
176
-            array(
177
-                includes_url('js/jquery/jquery.js?ver=' . $GLOBALS['wp_version']),
178
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
179
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION,
180
-            )
181
-        );
182
-        $template_args['notices'] = EEH_Template::display_template(
183
-            EE_TEMPLATES . 'espresso-ajax-notices.template.php',
184
-            array(),
185
-            true
186
-        );
187
-        EEH_Template::display_template(
188
-            TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
189
-            $template_args
190
-        );
191
-        exit;
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     * Adds an iframe embed code button to the Event editor.
198
-     *
199
-     * @param string $permalink_string The current html string for the permalink section.
200
-     * @param int    $id               The post id for the event.
201
-     * @return string The new html string for the permalink area.
202
-     */
203
-    public static function iframe_code_button($permalink_string, $id )
204
-    {
205
-        //make sure this is ONLY when editing and the event id has been set.
206
-        if ( ! empty($id)) {
207
-            $post = get_post($id);
208
-            //if NOT event then let's get out.
209
-            if ($post->post_type !== 'espresso_events') {
210
-                return $permalink_string;
211
-            }
212
-            $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'
213
-                                 . __('Embed', 'event_espresso')
214
-                                 . '</a> ';
215
-            $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
216
-            $iframe_string = esc_html(
217
-                '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>'
218
-            );
219
-            $permalink_string .= '
17
+	const debug = false;    //	true false
18
+
19
+	/**
20
+	 * event that ticket selector is being generated for
21
+	 *
22
+	 * @access protected
23
+	 * @var \EE_Event
24
+	 */
25
+	protected static $_event;
26
+
27
+	/**
28
+	 * array of datetimes and the spaces available for them
29
+	 *
30
+	 * @access private
31
+	 * @var array
32
+	 */
33
+	private static $_available_spaces = array();
34
+
35
+	/**
36
+	 * max attendees that can register for event at one time
37
+	 *
38
+	 * @access private
39
+	 * @var int
40
+	 */
41
+	private static $_max_atndz = EE_INF;
42
+
43
+
44
+
45
+	/**
46
+	 * Used to flag when the ticket selector is being called from an external iframe.
47
+	 *
48
+	 * @var bool
49
+	 */
50
+	protected static $_in_iframe = false;
51
+
52
+
53
+
54
+	/**
55
+	 * @return EED_Ticket_Selector
56
+	 */
57
+	public static function instance()
58
+	{
59
+		return parent::get_instance(__CLASS__);
60
+	}
61
+
62
+
63
+
64
+	protected function set_config()
65
+	{
66
+		$this->set_config_section('template_settings');
67
+		$this->set_config_class('EE_Ticket_Selector_Config');
68
+		$this->set_config_name('EED_Ticket_Selector');
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 *    set_hooks - for hooking into EE Core, other modules, etc
75
+	 *
76
+	 * @access    public
77
+	 * @return    void
78
+	 */
79
+	public static function set_hooks()
80
+	{
81
+		// routing
82
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
83
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
84
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
85
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
86
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
87
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
94
+	 *
95
+	 * @access    public
96
+	 * @return    void
97
+	 */
98
+	public static function set_hooks_admin()
99
+	{
100
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
101
+		//add button for iframe code to event editor.
102
+		add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 2);
103
+		add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 *    set_definitions
110
+	 *
111
+	 * @access    public
112
+	 * @return    void
113
+	 */
114
+	public static function set_definitions()
115
+	{
116
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
117
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
118
+		//if config is not set, initialize
119
+		//If config is not set, set it.
120
+		if (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector === null) {
121
+			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
122
+		}
123
+		EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 *    gets the ball rolling
130
+	 *
131
+	 * @access public
132
+	 * @param    WP $WP
133
+	 * @return void
134
+	 */
135
+	public function run($WP)
136
+	{
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 * ticket_selector_iframe
143
+	 *
144
+	 * @access    public
145
+	 * @return    void
146
+	 * @throws \EE_Error
147
+	 */
148
+	public function ticket_selector_iframe()
149
+	{
150
+		self::$_in_iframe = true;
151
+		/** @type EEM_Event $EEM_Event */
152
+		$EEM_Event = EE_Registry::instance()->load_model('Event');
153
+		$event = $EEM_Event->get_one_by_ID(
154
+			EE_Registry::instance()->REQ->get('event', 0)
155
+		);
156
+		EE_Registry::instance()->REQ->set_espresso_page(true);
157
+		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
158
+		$template_args['css'] = apply_filters(
159
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
160
+			array(
161
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
162
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
163
+				includes_url('css/dashicons.min.css?ver=' . $GLOBALS['wp_version']),
164
+				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
165
+			)
166
+		);
167
+		EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
168
+		EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = esc_html__('Please choose at least one ticket before continuing.',
169
+			'event_espresso');
170
+		$template_args['eei18n'] = apply_filters(
171
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
172
+			EE_Registry::localize_i18n_js_strings()
173
+		);
174
+		$template_args['js'] = apply_filters(
175
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
176
+			array(
177
+				includes_url('js/jquery/jquery.js?ver=' . $GLOBALS['wp_version']),
178
+				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
179
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION,
180
+			)
181
+		);
182
+		$template_args['notices'] = EEH_Template::display_template(
183
+			EE_TEMPLATES . 'espresso-ajax-notices.template.php',
184
+			array(),
185
+			true
186
+		);
187
+		EEH_Template::display_template(
188
+			TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
189
+			$template_args
190
+		);
191
+		exit;
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 * Adds an iframe embed code button to the Event editor.
198
+	 *
199
+	 * @param string $permalink_string The current html string for the permalink section.
200
+	 * @param int    $id               The post id for the event.
201
+	 * @return string The new html string for the permalink area.
202
+	 */
203
+	public static function iframe_code_button($permalink_string, $id )
204
+	{
205
+		//make sure this is ONLY when editing and the event id has been set.
206
+		if ( ! empty($id)) {
207
+			$post = get_post($id);
208
+			//if NOT event then let's get out.
209
+			if ($post->post_type !== 'espresso_events') {
210
+				return $permalink_string;
211
+			}
212
+			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'
213
+								 . __('Embed', 'event_espresso')
214
+								 . '</a> ';
215
+			$ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
216
+			$iframe_string = esc_html(
217
+				'<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>'
218
+			);
219
+			$permalink_string .= '
220 220
 <div id="js-ts-iframe" style="display:none">
221 221
 	<div style="width:100%; height: 500px;">
222 222
 		' . $iframe_string . '
223 223
 	</div>
224 224
 </div>';
225
-        }
226
-        return $permalink_string;
227
-    }
228
-
229
-
230
-
231
-    /**
232
-     *    finds and sets the EE_Event object for use throughout class
233
-     *
234
-     * @access    public
235
-     * @param    mixed $event
236
-     * @return    bool
237
-     */
238
-    protected static function set_event($event = null)
239
-    {
240
-        if ($event === null) {
241
-            global $post;
242
-            $event = $post;
243
-        }
244
-        if ($event instanceof EE_Event) {
245
-            self::$_event = $event;
246
-        } else if ($event instanceof WP_Post ) {
247
-            if ( isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
248
-                self::$_event = $event->EE_Event;
249
-            } else if ( $event->post_type === 'espresso_events') {
250
-                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
251
-                self::$_event = $event->EE_Event;
252
-            }
253
-        } else {
254
-            $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
255
-            $dev_msg = $user_msg
256
-                       . __('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
257
-                    'event_espresso');
258
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
259
-            return false;
260
-        }
261
-        return true;
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     * creates buttons for selecting number of attendees for an event
268
-     *
269
-     * @access public
270
-     * @param EE_Event $event
271
-     * @param bool     $view_details
272
-     * @return string
273
-     * @throws \EE_Error
274
-     */
275
-    public static function display_ticket_selector($event = null, $view_details = false)
276
-    {
277
-        // reset filter for displaying submit button
278
-        remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
279
-        // poke and prod incoming event till it tells us what it is
280
-        if ( ! EED_Ticket_Selector::set_event($event)) {
281
-            return false;
282
-        }
283
-        $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
284
-        // grab event status
285
-        $_event_active_status = self::$_event->get_active_status();
286
-        if (
287
-            ! is_admin()
288
-            && (
289
-                ! self::$_event->display_ticket_selector()
290
-                || $view_details
291
-                || post_password_required($event_post)
292
-                || (
293
-                    $_event_active_status !== EE_Datetime::active
294
-                    && $_event_active_status !== EE_Datetime::upcoming
295
-                    && $_event_active_status !== EE_Datetime::sold_out
296
-                    && ! (
297
-                        $_event_active_status === EE_Datetime::inactive
298
-                        && is_user_logged_in()
299
-                    )
300
-                )
301
-            )
302
-        ) {
303
-            return ! is_single() ? EED_Ticket_Selector::display_view_details_btn() : '';
304
-        }
305
-        $template_args = array();
306
-        $template_args['event_status'] = $_event_active_status;
307
-        $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
308
-            get_option('date_format'));
309
-        $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
310
-            get_option('time_format'));
311
-        $template_args['EVT_ID'] = self::$_event->ID();
312
-        $template_args['event'] = self::$_event;
313
-        // is the event expired ?
314
-        $template_args['event_is_expired'] = self::$_event->is_expired();
315
-        if ($template_args['event_is_expired']) {
316
-            return '<div class="ee-event-expired-notice"><span class="important-notice">'
317
-                   . __('We\'re sorry, but all tickets sales have ended because the event is expired.',
318
-                'event_espresso')
319
-                   . '</span></div>';
320
-        }
321
-        $ticket_query_args = array(
322
-            array('Datetime.EVT_ID' => self::$_event->ID()),
323
-            'order_by' => array(
324
-                'TKT_order'              => 'ASC',
325
-                'TKT_required'           => 'DESC',
326
-                'TKT_start_date'         => 'ASC',
327
-                'TKT_end_date'           => 'ASC',
328
-                'Datetime.DTT_EVT_start' => 'DESC',
329
-            ),
330
-        );
331
-        if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
332
-            //use the correct applicable time query depending on what version of core is being run.
333
-            $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time()
334
-                : current_time('timestamp');
335
-            $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
336
-        }
337
-        // get all tickets for this event ordered by the datetime
338
-        $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
339
-        if (count($template_args['tickets']) < 1) {
340
-            return '<div class="ee-event-expired-notice"><span class="important-notice">'
341
-                   . __('We\'re sorry, but all ticket sales have ended.', 'event_espresso')
342
-                   . '</span></div>';
343
-        }
344
-        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
345
-        \EED_Ticket_Selector::$_max_atndz = apply_filters(
346
-            'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
347
-            self::$_event->additional_limit()
348
-        );
349
-        $template_args['max_atndz'] = \EED_Ticket_Selector::$_max_atndz;
350
-        if ($template_args['max_atndz'] < 1) {
351
-            $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
352
-                'event_espresso');
353
-            if (current_user_can('edit_post', self::$_event->ID())) {
354
-                $sales_closed_msg .= sprintf(
355
-                    __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
356
-                        'event_espresso'),
357
-                    '<div class="ee-attention" style="text-align: left;"><b>',
358
-                    '</b><br />',
359
-                    $link = '<span class="edit-link"><a class="post-edit-link" href="'
360
-                            . get_edit_post_link(self::$_event->ID())
361
-                            . '">',
362
-                    '</a></span></div>'
363
-                );
364
-            }
365
-            return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
366
-        }
367
-        $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
368
-        $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',
369
-            $templates['ticket_selector'], self::$_event);
370
-        // redirecting to another site for registration ??
371
-        $external_url = self::$_event->external_url() !== null || self::$_event->external_url() !== ''
372
-            ? self::$_event->external_url() : false;
373
-        // if not redirecting to another site for registration
374
-        if ( ! $external_url) {
375
-            // then display the ticket selector
376
-            $ticket_selector = EEH_Template::locate_template($templates['ticket_selector'], $template_args);
377
-        } else {
378
-            // if not we still need to trigger the display of the submit button
379
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
380
-            //display notice to admin that registration is external
381
-            $ticket_selector = ! is_admin() ? ''
382
-                : __('Registration is at an external URL for this event.', 'event_espresso');
383
-        }
384
-        // now set up the form (but not for the admin)
385
-        $ticket_selector = ! is_admin()
386
-            ? EED_Ticket_Selector::ticket_selector_form_open(
387
-                self::$_event->ID(),
388
-                $external_url
389
-            ) . $ticket_selector
390
-            : $ticket_selector;
391
-        // submit button and form close tag
392
-        $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit($external_url) : '';
393
-        // set no cache headers and constants
394
-        EE_System::do_not_cache();
395
-        return $ticket_selector;
396
-    }
397
-
398
-
399
-
400
-    /**
401
-     *    ticket_selector_form_open
402
-     *
403
-     * @access        public
404
-     * @param        int    $ID
405
-     * @param        string $external_url
406
-     * @return        string
407
-     */
408
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
409
-    {
410
-        // if redirecting, we don't need any anything else
411
-        if ($external_url) {
412
-            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '">';
413
-            $query_args = (array)EEH_URL::get_query_string($external_url);
414
-            foreach ($query_args as $query_arg => $value) {
415
-                $html .= '
225
+		}
226
+		return $permalink_string;
227
+	}
228
+
229
+
230
+
231
+	/**
232
+	 *    finds and sets the EE_Event object for use throughout class
233
+	 *
234
+	 * @access    public
235
+	 * @param    mixed $event
236
+	 * @return    bool
237
+	 */
238
+	protected static function set_event($event = null)
239
+	{
240
+		if ($event === null) {
241
+			global $post;
242
+			$event = $post;
243
+		}
244
+		if ($event instanceof EE_Event) {
245
+			self::$_event = $event;
246
+		} else if ($event instanceof WP_Post ) {
247
+			if ( isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
248
+				self::$_event = $event->EE_Event;
249
+			} else if ( $event->post_type === 'espresso_events') {
250
+				$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
251
+				self::$_event = $event->EE_Event;
252
+			}
253
+		} else {
254
+			$user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
255
+			$dev_msg = $user_msg
256
+					   . __('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
257
+					'event_espresso');
258
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
259
+			return false;
260
+		}
261
+		return true;
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 * creates buttons for selecting number of attendees for an event
268
+	 *
269
+	 * @access public
270
+	 * @param EE_Event $event
271
+	 * @param bool     $view_details
272
+	 * @return string
273
+	 * @throws \EE_Error
274
+	 */
275
+	public static function display_ticket_selector($event = null, $view_details = false)
276
+	{
277
+		// reset filter for displaying submit button
278
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
279
+		// poke and prod incoming event till it tells us what it is
280
+		if ( ! EED_Ticket_Selector::set_event($event)) {
281
+			return false;
282
+		}
283
+		$event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
284
+		// grab event status
285
+		$_event_active_status = self::$_event->get_active_status();
286
+		if (
287
+			! is_admin()
288
+			&& (
289
+				! self::$_event->display_ticket_selector()
290
+				|| $view_details
291
+				|| post_password_required($event_post)
292
+				|| (
293
+					$_event_active_status !== EE_Datetime::active
294
+					&& $_event_active_status !== EE_Datetime::upcoming
295
+					&& $_event_active_status !== EE_Datetime::sold_out
296
+					&& ! (
297
+						$_event_active_status === EE_Datetime::inactive
298
+						&& is_user_logged_in()
299
+					)
300
+				)
301
+			)
302
+		) {
303
+			return ! is_single() ? EED_Ticket_Selector::display_view_details_btn() : '';
304
+		}
305
+		$template_args = array();
306
+		$template_args['event_status'] = $_event_active_status;
307
+		$template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
308
+			get_option('date_format'));
309
+		$template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
310
+			get_option('time_format'));
311
+		$template_args['EVT_ID'] = self::$_event->ID();
312
+		$template_args['event'] = self::$_event;
313
+		// is the event expired ?
314
+		$template_args['event_is_expired'] = self::$_event->is_expired();
315
+		if ($template_args['event_is_expired']) {
316
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'
317
+				   . __('We\'re sorry, but all tickets sales have ended because the event is expired.',
318
+				'event_espresso')
319
+				   . '</span></div>';
320
+		}
321
+		$ticket_query_args = array(
322
+			array('Datetime.EVT_ID' => self::$_event->ID()),
323
+			'order_by' => array(
324
+				'TKT_order'              => 'ASC',
325
+				'TKT_required'           => 'DESC',
326
+				'TKT_start_date'         => 'ASC',
327
+				'TKT_end_date'           => 'ASC',
328
+				'Datetime.DTT_EVT_start' => 'DESC',
329
+			),
330
+		);
331
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
332
+			//use the correct applicable time query depending on what version of core is being run.
333
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time()
334
+				: current_time('timestamp');
335
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
336
+		}
337
+		// get all tickets for this event ordered by the datetime
338
+		$template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
339
+		if (count($template_args['tickets']) < 1) {
340
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'
341
+				   . __('We\'re sorry, but all ticket sales have ended.', 'event_espresso')
342
+				   . '</span></div>';
343
+		}
344
+		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
345
+		\EED_Ticket_Selector::$_max_atndz = apply_filters(
346
+			'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
347
+			self::$_event->additional_limit()
348
+		);
349
+		$template_args['max_atndz'] = \EED_Ticket_Selector::$_max_atndz;
350
+		if ($template_args['max_atndz'] < 1) {
351
+			$sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
352
+				'event_espresso');
353
+			if (current_user_can('edit_post', self::$_event->ID())) {
354
+				$sales_closed_msg .= sprintf(
355
+					__('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
356
+						'event_espresso'),
357
+					'<div class="ee-attention" style="text-align: left;"><b>',
358
+					'</b><br />',
359
+					$link = '<span class="edit-link"><a class="post-edit-link" href="'
360
+							. get_edit_post_link(self::$_event->ID())
361
+							. '">',
362
+					'</a></span></div>'
363
+				);
364
+			}
365
+			return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
366
+		}
367
+		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
368
+		$templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',
369
+			$templates['ticket_selector'], self::$_event);
370
+		// redirecting to another site for registration ??
371
+		$external_url = self::$_event->external_url() !== null || self::$_event->external_url() !== ''
372
+			? self::$_event->external_url() : false;
373
+		// if not redirecting to another site for registration
374
+		if ( ! $external_url) {
375
+			// then display the ticket selector
376
+			$ticket_selector = EEH_Template::locate_template($templates['ticket_selector'], $template_args);
377
+		} else {
378
+			// if not we still need to trigger the display of the submit button
379
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
380
+			//display notice to admin that registration is external
381
+			$ticket_selector = ! is_admin() ? ''
382
+				: __('Registration is at an external URL for this event.', 'event_espresso');
383
+		}
384
+		// now set up the form (but not for the admin)
385
+		$ticket_selector = ! is_admin()
386
+			? EED_Ticket_Selector::ticket_selector_form_open(
387
+				self::$_event->ID(),
388
+				$external_url
389
+			) . $ticket_selector
390
+			: $ticket_selector;
391
+		// submit button and form close tag
392
+		$ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit($external_url) : '';
393
+		// set no cache headers and constants
394
+		EE_System::do_not_cache();
395
+		return $ticket_selector;
396
+	}
397
+
398
+
399
+
400
+	/**
401
+	 *    ticket_selector_form_open
402
+	 *
403
+	 * @access        public
404
+	 * @param        int    $ID
405
+	 * @param        string $external_url
406
+	 * @return        string
407
+	 */
408
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
409
+	{
410
+		// if redirecting, we don't need any anything else
411
+		if ($external_url) {
412
+			$html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '">';
413
+			$query_args = (array)EEH_URL::get_query_string($external_url);
414
+			foreach ($query_args as $query_arg => $value) {
415
+				$html .= '
416 416
 				<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
417
-            }
418
-            return $html;
419
-        }
420
-        // if there is no submit button, then don't start building a form
421
-        // because the "View Details" button will build its own form
422
-        if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
423
-            return '';
424
-        }
425
-        $checkout_url = EEH_Event_View::event_link_url($ID);
426
-        if ( ! $checkout_url) {
427
-            EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
428
-                __FILE__, __FUNCTION__, __LINE__);
429
-        }
430
-        $extra_params = self::$_in_iframe ? ' target="_blank"' : '';
431
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
432
-        $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false);
433
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
434
-        $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
435
-        return $html;
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * display_ticket_selector_submit
442
-     *
443
-     * @param        string $external_url
444
-     * @return        string
445
-     * @throws \EE_Error
446
-     */
447
-    public static function display_ticket_selector_submit($external_url = '')
448
-    {
449
-        $html = '';
450
-        if ( ! is_admin()) {
451
-            // standard TS displayed with submit button, ie: "Register Now"
452
-            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
453
-                $html .= \EED_Ticket_Selector::display_register_now_button();
454
-                $html .= empty($external_url) ?
455
-                    \EED_Ticket_Selector::no_tkt_slctr_end_dv()
456
-                    : \EED_Ticket_Selector::clear_tkt_slctr();
457
-                $html .= '<br/>' . \EED_Ticket_Selector::ticket_selector_form_close();
458
-            } else if ( EED_Ticket_Selector::$_max_atndz === 1 ) {
459
-                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
460
-                if ( EED_Ticket_Selector::$_event->is_sold_out() ) {
461
-                    // then instead of a View Details or Submit button, just display a "Sold Out" message
462
-                    $html .= apply_filters(
463
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
464
-                        sprintf(
465
-                            __(
466
-                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
467
-                                'event_espresso'
468
-                            ),
469
-                            '<p class="no-ticket-selector-msg clear-float">',
470
-                            EED_Ticket_Selector::$_event->name(),
471
-                            '</p>',
472
-                            '<br />'
473
-                        ),
474
-                        EED_Ticket_Selector::$_event
475
-                    );
476
-                    if (
477
-                        apply_filters(
478
-                            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
479
-                            false,
480
-                            EED_Ticket_Selector::$_event
481
-                        )
482
-                    ) {
483
-                        $html .= \EED_Ticket_Selector::display_register_now_button();
484
-                    }
485
-                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
486
-                    $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
487
-                } else if (
488
-                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
489
-                    && ! is_single()
490
-                ) {
491
-                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
492
-                    // but no tickets are available, so display event's "View Details" button.
493
-                    // it is being viewed via somewhere other than a single post
494
-                    $html .= EED_Ticket_Selector::display_view_details_btn(true);
495
-                }
496
-            } else if (is_archive()) {
497
-                // event list, no tickets available so display event's "View Details" button
498
-                $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
499
-                $html .= EED_Ticket_Selector::display_view_details_btn();
500
-            } else {
501
-                if (
502
-                    apply_filters(
503
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
504
-                        false,
505
-                        EED_Ticket_Selector::$_event
506
-                    )
507
-                ) {
508
-                    $html .= \EED_Ticket_Selector::display_register_now_button();
509
-                }
510
-                // no submit or view details button, and no additional content
511
-                $html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
512
-            }
513
-            if ( ! is_archive()) {
514
-                $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
515
-            }
516
-        }
517
-        return $html;
518
-    }
519
-
520
-
521
-
522
-    /**
523
-     * @return string
524
-     */
525
-    public static function clear_tkt_slctr()
526
-    {
527
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
528
-        return '<div class="clear"></div>';
529
-    }
530
-
531
-
532
-
533
-    /**
534
-     * @deprecated 4.9.13
535
-     * @return string
536
-     */
537
-    public static function tkt_slctr_end_dv()
538
-    {
539
-        return \EED_Ticket_Selector::clear_tkt_slctr();
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * @return string
546
-     */
547
-    public static function no_tkt_slctr_end_dv()
548
-    {
549
-        // DWMTS event, no TS, appears after a "Register Now" or "view Details" button
550
-        return '<div class="clear"></div></div>';
551
-    }
552
-
553
-
554
-
555
-    /**
556
-     *    ticket_selector_form_close
557
-     *
558
-     * @access        public
559
-     * @access        public
560
-     * @return        string
561
-     */
562
-    public static function ticket_selector_form_close()
563
-    {
564
-        return '</form>';
565
-    }
566
-
567
-
568
-
569
-    /**
570
-     * @return string
571
-     * @throws \EE_Error
572
-     */
573
-    public static function display_register_now_button()
574
-    {
575
-        $btn_text = apply_filters(
576
-            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
577
-            __('Register Now', 'event_espresso'),
578
-            EED_Ticket_Selector::$_event
579
-        );
580
-        $external_url = EED_Ticket_Selector::$_event->external_url();
581
-        $html = '<input id="ticket-selector-submit-' . EED_Ticket_Selector::$_event->ID() . '-btn"';
582
-        $html .= ' class="ticket-selector-submit-btn ';
583
-        $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
584
-        $html .= ' type="submit" value="' . $btn_text . '" />';
585
-        $html .= apply_filters(
586
-            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
587
-            '',
588
-            EED_Ticket_Selector::$_event
589
-        );
590
-        return $html;
591
-    }
592
-
593
-
594
-    /**
595
-     * display_view_details_btn
596
-     *
597
-     * @access public
598
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
599
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
600
-     *                    either because they are sold out, expired, or not yet on sale.
601
-     *                    In this case, we need to close the form BEFORE adding any closing divs
602
-     * @return string
603
-     * @throws \EE_Error
604
-     */
605
-    public static function display_view_details_btn($DWMTS = false)
606
-    {
607
-        if ( ! self::$_event->get_permalink()) {
608
-            EE_Error::add_error(
609
-                __('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
610
-                __FILE__, __FUNCTION__, __LINE__
611
-            );
612
-        }
613
-        $view_details_btn = '<form method="POST" action="';
614
-        $view_details_btn .= apply_filters(
615
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
616
-            self::$_event->get_permalink(),
617
-            self::$_event
618
-        );
619
-        $view_details_btn .= '">';
620
-        $btn_text = apply_filters(
621
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
622
-            __('View Details', 'event_espresso'),
623
-            self::$_event
624
-        );
625
-        $view_details_btn .= '<input id="ticket-selector-submit-'
626
-                             . self::$_event->ID()
627
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
628
-                             . $btn_text
629
-                             . '" />';
630
-        $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
631
-        if ($DWMTS) {
632
-            $view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close();
633
-            $view_details_btn .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
634
-            $view_details_btn .= '<br/>';
635
-        } else {
636
-            $view_details_btn .= \EED_Ticket_Selector::clear_tkt_slctr();
637
-            $view_details_btn .= '<br/>';
638
-            $view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close();
639
-        }
640
-        return $view_details_btn;
641
-    }
642
-
643
-
644
-
645
-    /**
646
-     *    cancel_ticket_selections
647
-     *
648
-     * @access        public
649
-     * @access        public
650
-     * @return        string
651
-     */
652
-    public static function cancel_ticket_selections()
653
-    {
654
-        // check nonce
655
-        if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('cancel_ticket_selections')) {
656
-            return false;
657
-        }
658
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
659
-        if (EE_Registry::instance()->REQ->is_set('event_id')) {
660
-            wp_safe_redirect(
661
-                EEH_Event_View::event_link_url(
662
-                    EE_Registry::instance()->REQ->get('event_id')
663
-                )
664
-            );
665
-        } else {
666
-            wp_safe_redirect(
667
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
668
-            );
669
-        }
670
-        die();
671
-    }
672
-
673
-
674
-
675
-    /**
676
-     *    process_ticket_selector_nonce
677
-     *
678
-     * @access public
679
-     * @param  string $nonce_name
680
-     * @param string  $id
681
-     * @return bool
682
-     */
683
-    public static function process_ticket_selector_nonce($nonce_name, $id = '')
684
-    {
685
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
686
-        if (
687
-            ! is_admin()
688
-            && (
689
-                ! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
690
-                || ! wp_verify_nonce(
691
-                    EE_Registry::instance()->REQ->get($nonce_name_with_id),
692
-                    $nonce_name
693
-                )
694
-            )
695
-        ) {
696
-            EE_Error::add_error(
697
-                sprintf(
698
-                    __(
699
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
700
-                        'event_espresso'
701
-                    ),
702
-                    '<br/>'
703
-                ),
704
-                __FILE__,
705
-                __FUNCTION__,
706
-                __LINE__
707
-            );
708
-            return false;
709
-        }
710
-        return true;
711
-    }
712
-
713
-
714
-
715
-    /**
716
-     *    process_ticket_selections
717
-     *
718
-     * @access public
719
-     * @return array|boolean
720
-     * @throws \EE_Error
721
-     */
722
-    public function process_ticket_selections()
723
-    {
724
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
725
-        // do we have an event id?
726
-        if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
727
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
728
-            EE_Error::add_error(
729
-                sprintf(
730
-                    __(
731
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
732
-                        'event_espresso'
733
-                    ),
734
-                    '<br/>'
735
-                ),
736
-                __FILE__,
737
-                __FUNCTION__,
738
-                __LINE__
739
-            );
740
-        }
741
-        //if event id is valid
742
-        $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
743
-        // check nonce
744
-        if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('process_ticket_selections', $id)) {
745
-            return false;
746
-        }
747
-        //		d( EE_Registry::instance()->REQ );
748
-        self::$_available_spaces = array(
749
-            'tickets'   => array(),
750
-            'datetimes' => array(),
751
-        );
752
-        //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
753
-        // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
754
-        EE_Registry::instance()->load_core('Session');
755
-        // unless otherwise requested, clear the session
756
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
757
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
758
-        }
759
-        //d( EE_Registry::instance()->SSN );
760
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
761
-        // validate/sanitize data
762
-        $valid = self::_validate_post_data($id);
763
-        //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
764
-        //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
765
-        //EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
766
-        //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
767
-        //check total tickets ordered vs max number of attendees that can register
768
-        if ($valid['total_tickets'] > $valid['max_atndz']) {
769
-            // ordering too many tickets !!!
770
-            $total_tickets_string = _n('You have attempted to purchase %s ticket.',
771
-                'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso');
772
-            $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
773
-            // dev only message
774
-            $max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
775
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
776
-                $valid['max_atndz'], 'event_espresso');
777
-            $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
778
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
779
-        } elseif ( apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid) ) {
780
-            // all data appears to be valid
781
-            $tckts_slctd = false;
782
-            $tickets_added = 0;
783
-            $valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid);
784
-            if ($valid['total_tickets'] > 0) {
785
-                // load cart
786
-                EE_Registry::instance()->load_core('Cart');
787
-                // cycle thru the number of data rows sent from the event listing
788
-                for ($x = 0; $x < $valid['rows']; $x++) {
789
-                    // does this row actually contain a ticket quantity?
790
-                    if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
791
-                        // YES we have a ticket quantity
792
-                        $tckts_slctd = true;
793
-                        //						d( $valid['ticket_obj'][$x] );
794
-                        if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
795
-                            // then add ticket to cart
796
-                            $tickets_added += self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
797
-                            if (EE_Error::has_error()) {
798
-                                break;
799
-                            }
800
-                        } else {
801
-                            // nothing added to cart retrieved
802
-                            EE_Error::add_error(
803
-                                sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
804
-                                    'event_espresso'), '<br/>'),
805
-                                __FILE__, __FUNCTION__, __LINE__
806
-                            );
807
-                        }
808
-                    }
809
-                }
810
-            }
811
-            do_action(
812
-                'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
813
-                EE_Registry::instance()->CART,
814
-                $this
815
-            );
816
-            //d( EE_Registry::instance()->CART );
817
-            //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
818
-            if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
819
-                if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
820
-                    do_action(
821
-                        'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
822
-                        EE_Registry::instance()->CART,
823
-                        $this
824
-                    );
825
-                    EE_Registry::instance()->CART->recalculate_all_cart_totals();
826
-                    EE_Registry::instance()->CART->save_cart(false);
827
-                    // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
828
-                    // just return TRUE for registrations being made from admin
829
-                    if (is_admin()) {
830
-                        return true;
831
-                    }
832
-                    EE_Error::get_notices(false, true);
833
-                    wp_safe_redirect(
834
-                        apply_filters(
835
-                            'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
836
-                            EE_Registry::instance()->CFG->core->reg_page_url()
837
-                        )
838
-                    );
839
-                    exit();
840
-                } else {
841
-                    if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
842
-                        // nothing added to cart
843
-                        EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__,
844
-                            __FUNCTION__, __LINE__);
845
-                    }
846
-                }
847
-            } else {
848
-                // no ticket quantities were selected
849
-                EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
850
-                    'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
851
-            }
852
-        } else {
853
-            if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
854
-                // nothing added to cart
855
-                EE_Error::add_attention(__('There was an error adding your tickets to the cart', 'event_espresso'), __FILE__,
856
-                    __FUNCTION__, __LINE__);
857
-            }
858
-        }
859
-        //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
860
-        // at this point, just return if registration is being made from admin
861
-        if (is_admin()) {
862
-            return false;
863
-        }
864
-        if ($valid['return_url']) {
865
-            EE_Error::get_notices(false, true);
866
-            wp_safe_redirect($valid['return_url']);
867
-            exit();
868
-        } elseif (isset($event_to_add['id'])) {
869
-            EE_Error::get_notices(false, true);
870
-            wp_safe_redirect(get_permalink($event_to_add['id']));
871
-            exit();
872
-        } else {
873
-            echo EE_Error::get_notices();
874
-        }
875
-        return false;
876
-    }
877
-
878
-
879
-
880
-    /**
881
-     *    validate_post_data
882
-     *
883
-     * @access        private
884
-     * @param int $id
885
-     * @return array|FALSE
886
-     */
887
-    private static function _validate_post_data($id = 0)
888
-    {
889
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
890
-        if ( ! $id) {
891
-            EE_Error::add_error(
892
-                __('The event id provided was not valid.', 'event_espresso'),
893
-                __FILE__,
894
-                __FUNCTION__,
895
-                __LINE__
896
-            );
897
-            return false;
898
-        }
899
-        // start with an empty array()
900
-        $valid_data = array();
901
-        // grab valid id
902
-        $valid_data['id'] = $id;
903
-        // grab and sanitize return-url
904
-        $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-' . $id));
905
-        // array of other form names
906
-        $inputs_to_clean = array(
907
-            'event_id'   => 'tkt-slctr-event-id',
908
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
909
-            'rows'       => 'tkt-slctr-rows-',
910
-            'qty'        => 'tkt-slctr-qty-',
911
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
912
-            'return_url' => 'tkt-slctr-return-url-',
913
-        );
914
-        // let's track the total number of tickets ordered.'
915
-        $valid_data['total_tickets'] = 0;
916
-        // cycle through $inputs_to_clean array
917
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
918
-            // check for POST data
919
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
920
-                // grab value
921
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
922
-                switch ($what) {
923
-                    // integers
924
-                    case 'event_id':
925
-                        $valid_data[$what] = absint($input_value);
926
-                        // get event via the event id we put in the form
927
-                        $valid_data['event'] = EE_Registry::instance()
928
-                                                          ->load_model('Event')
929
-                                                          ->get_one_by_ID($valid_data['event_id']);
930
-                        break;
931
-                    case 'rows':
932
-                    case 'max_atndz':
933
-                        $valid_data[$what] = absint($input_value);
934
-                        break;
935
-                    // arrays of integers
936
-                    case 'qty':
937
-                        /** @var array $row_qty */
938
-                        $row_qty = $input_value;
939
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
940
-                        if ( ! is_array($row_qty)) {
941
-                            // get number of rows
942
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
943
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
944
-                                : 1;
945
-                            // explode ints by the dash
946
-                            $row_qty = explode('-', $row_qty);
947
-                            $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
948
-                            $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
949
-                            $row_qty = array($row => $qty);
950
-                            //								 d( $row_qty );
951
-                            for ($x = 1; $x <= $rows; $x++) {
952
-                                if ( ! isset($row_qty[$x])) {
953
-                                    $row_qty[$x] = 0;
954
-                                }
955
-                            }
956
-                        }
957
-                        ksort($row_qty);
958
-                        //							 d( $row_qty );
959
-                        // cycle thru values
960
-                        foreach ($row_qty as $qty) {
961
-                            $qty = absint($qty);
962
-                            // sanitize as integers
963
-                            $valid_data[$what][] = $qty;
964
-                            $valid_data['total_tickets'] += $qty;
965
-                        }
966
-                        break;
967
-                    // array of integers
968
-                    case 'ticket_id':
969
-                        $value_array = array();
970
-                        // cycle thru values
971
-                        foreach ((array)$input_value as $key => $value) {
972
-                            // allow only numbers, letters,  spaces, commas and dashes
973
-                            $value_array[$key] = wp_strip_all_tags($value);
974
-                            // get ticket via the ticket id we put in the form
975
-                            $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
976
-                            $valid_data['ticket_obj'][$key] = $ticket_obj;
977
-                        }
978
-                        $valid_data[$what] = $value_array;
979
-                        break;
980
-                    case 'return_url' :
981
-                        // grab and sanitize return-url
982
-                        $valid_data[$what] = esc_url_raw($input_value);
983
-                        break;
984
-                }    // end switch $what
985
-            }
986
-        }    // end foreach $inputs_to_clean
987
-        //		d( $valid_data );
988
-        //		die();
989
-        return $valid_data;
990
-    }
991
-
992
-
993
-
994
-    /**
995
-     *    adds a ticket to the cart
996
-     *
997
-     * @access   private
998
-     * @param EE_Ticket $ticket
999
-     * @param int       $qty
1000
-     * @return TRUE on success, FALSE on fail
1001
-     * @throws \EE_Error
1002
-     */
1003
-    private static function _add_ticket_to_cart(EE_Ticket $ticket = null, $qty = 1)
1004
-    {
1005
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1006
-        // get the number of spaces left for this datetime ticket
1007
-        $available_spaces = self::_ticket_datetime_availability($ticket);
1008
-        // compare available spaces against the number of tickets being purchased
1009
-        if ($available_spaces >= $qty) {
1010
-            // allow addons to prevent a ticket from being added to cart
1011
-            if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket,
1012
-                $qty, $available_spaces)
1013
-            ) {
1014
-                return false;
1015
-            }
1016
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
1017
-            // add event to cart
1018
-            if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
1019
-                self::_recalculate_ticket_datetime_availability($ticket, $qty);
1020
-                return true;
1021
-            } else {
1022
-                return false;
1023
-            }
1024
-        } else {
1025
-            // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
1026
-            $available_spaces = self::_ticket_datetime_availability($ticket, true);
1027
-            // greedy greedy greedy eh?
1028
-            if ($available_spaces > 0) {
1029
-                if (
1030
-                apply_filters(
1031
-                    'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
1032
-                    true,
1033
-                    $ticket,
1034
-                    $qty,
1035
-                    $available_spaces
1036
-                )
1037
-                ) {
1038
-                    EED_Ticket_Selector::_display_availability_error($available_spaces);
1039
-                }
1040
-            } else {
1041
-                EE_Error::add_error(
1042
-                    __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
1043
-                        'event_espresso'),
1044
-                    __FILE__, __FUNCTION__, __LINE__
1045
-                );
1046
-            }
1047
-            return false;
1048
-        }
1049
-    }
1050
-
1051
-
1052
-
1053
-    /**
1054
-     *  _display_availability_error
1055
-     *
1056
-     * @access    private
1057
-     * @param int $available_spaces
1058
-     * @throws \EE_Error
1059
-     */
1060
-    private static function _display_availability_error($available_spaces = 1)
1061
-    {
1062
-        // add error messaging - we're using the _n function that will generate
1063
-        // the appropriate singular or plural message based on the number of $available_spaces
1064
-        if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
1065
-            $msg = sprintf(
1066
-                _n(
1067
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
1068
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
1069
-                    $available_spaces,
1070
-                    'event_espresso'
1071
-                ),
1072
-                $available_spaces,
1073
-                '<br />'
1074
-            );
1075
-        } else {
1076
-            $msg = sprintf(
1077
-                _n(
1078
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
1079
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
1080
-                    $available_spaces,
1081
-                    'event_espresso'
1082
-                ),
1083
-                $available_spaces,
1084
-                '<br />'
1085
-            );
1086
-        }
1087
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1088
-    }
1089
-
1090
-
1091
-
1092
-    /**
1093
-     * _ticket_datetime_availability
1094
-     * creates an array of tickets plus all of the datetimes available to each ticket
1095
-     * and tracks the spaces remaining for each of those datetimes
1096
-     *
1097
-     * @access private
1098
-     * @param EE_Ticket $ticket - selected ticket
1099
-     * @param bool      $get_original_ticket_spaces
1100
-     * @return int
1101
-     * @throws \EE_Error
1102
-     */
1103
-    private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
1104
-    {
1105
-        // if the $_available_spaces array has not been set up yet...
1106
-        if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1107
-            self::_set_initial_ticket_datetime_availability($ticket);
1108
-        }
1109
-        $available_spaces = $ticket->qty() - $ticket->sold();
1110
-        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1111
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
1112
-            foreach ((array)self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1113
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
1114
-                if ($get_original_ticket_spaces) {
1115
-                    // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
1116
-                    $available_spaces = min($available_spaces,
1117
-                        self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
1118
-                } else {
1119
-                    // we want the updated ticket availability as stored in the "datetimes" array
1120
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
1121
-                }
1122
-            }
1123
-        }
1124
-        return $available_spaces;
1125
-    }
1126
-
1127
-
1128
-
1129
-    /**
1130
-     * _set_initial_ticket_datetime_availability
1131
-     *
1132
-     * @access private
1133
-     * @param EE_Ticket $ticket
1134
-     * @return void
1135
-     * @throws \EE_Error
1136
-     */
1137
-    private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket)
1138
-    {
1139
-        // first, get all of the datetimes that are available to this ticket
1140
-        $datetimes = $ticket->get_many_related(
1141
-            'Datetime',
1142
-            array(
1143
-                array(
1144
-                    'DTT_EVT_end' => array(
1145
-                        '>=',
1146
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
1147
-                    ),
1148
-                ),
1149
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
1150
-            )
1151
-        );
1152
-        if ( ! empty($datetimes)) {
1153
-            // now loop thru all of the datetimes
1154
-            foreach ($datetimes as $datetime) {
1155
-                if ($datetime instanceof EE_Datetime) {
1156
-                    // the number of spaces available for the datetime without considering individual ticket quantities
1157
-                    $spaces_remaining = $datetime->spaces_remaining();
1158
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key
1159
-                    self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
1160
-                        $ticket->qty() - $ticket->sold(),
1161
-                        $spaces_remaining
1162
-                    );
1163
-                    // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
1164
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
1165
-                    self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()])
1166
-                        ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
1167
-                        : $spaces_remaining;
1168
-                }
1169
-            }
1170
-        }
1171
-    }
1172
-
1173
-
1174
-
1175
-    /**
1176
-     *    _recalculate_ticket_datetime_availability
1177
-     *
1178
-     * @access    private
1179
-     * @param    EE_Ticket $ticket
1180
-     * @param    int       $qty
1181
-     * @return    void
1182
-     */
1183
-    private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0)
1184
-    {
1185
-        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1186
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
1187
-            foreach ((array)self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1188
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
1189
-                self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
1190
-            }
1191
-        }
1192
-    }
1193
-
1194
-
1195
-
1196
-    /**
1197
-     *    load js
1198
-     *
1199
-     * @access        public
1200
-     * @return        void
1201
-     */
1202
-    public static function load_tckt_slctr_assets()
1203
-    {
1204
-        // add some style
1205
-        if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
1206
-            wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
1207
-            wp_enqueue_style('ticket_selector');
1208
-            // make it dance
1209
-            // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
1210
-            // wp_enqueue_script('ticket_selector');
1211
-        }
1212
-    }
1213
-
1214
-
1215
-
1216
-    public static function load_tckt_slctr_assets_admin()
1217
-    {
1218
-        //iframe button js on admin event editor page
1219
-        if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
1220
-            && EE_Registry::instance()->REQ->get('action') === 'edit'
1221
-        ) {
1222
-            wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js',
1223
-                array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1224
-            wp_enqueue_script('ticket_selector_embed');
1225
-        }
1226
-    }
417
+			}
418
+			return $html;
419
+		}
420
+		// if there is no submit button, then don't start building a form
421
+		// because the "View Details" button will build its own form
422
+		if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
423
+			return '';
424
+		}
425
+		$checkout_url = EEH_Event_View::event_link_url($ID);
426
+		if ( ! $checkout_url) {
427
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
428
+				__FILE__, __FUNCTION__, __LINE__);
429
+		}
430
+		$extra_params = self::$_in_iframe ? ' target="_blank"' : '';
431
+		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
432
+		$html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false);
433
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
434
+		$html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
435
+		return $html;
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * display_ticket_selector_submit
442
+	 *
443
+	 * @param        string $external_url
444
+	 * @return        string
445
+	 * @throws \EE_Error
446
+	 */
447
+	public static function display_ticket_selector_submit($external_url = '')
448
+	{
449
+		$html = '';
450
+		if ( ! is_admin()) {
451
+			// standard TS displayed with submit button, ie: "Register Now"
452
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
453
+				$html .= \EED_Ticket_Selector::display_register_now_button();
454
+				$html .= empty($external_url) ?
455
+					\EED_Ticket_Selector::no_tkt_slctr_end_dv()
456
+					: \EED_Ticket_Selector::clear_tkt_slctr();
457
+				$html .= '<br/>' . \EED_Ticket_Selector::ticket_selector_form_close();
458
+			} else if ( EED_Ticket_Selector::$_max_atndz === 1 ) {
459
+				// its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
460
+				if ( EED_Ticket_Selector::$_event->is_sold_out() ) {
461
+					// then instead of a View Details or Submit button, just display a "Sold Out" message
462
+					$html .= apply_filters(
463
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
464
+						sprintf(
465
+							__(
466
+								'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
467
+								'event_espresso'
468
+							),
469
+							'<p class="no-ticket-selector-msg clear-float">',
470
+							EED_Ticket_Selector::$_event->name(),
471
+							'</p>',
472
+							'<br />'
473
+						),
474
+						EED_Ticket_Selector::$_event
475
+					);
476
+					if (
477
+						apply_filters(
478
+							'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
479
+							false,
480
+							EED_Ticket_Selector::$_event
481
+						)
482
+					) {
483
+						$html .= \EED_Ticket_Selector::display_register_now_button();
484
+					}
485
+					// sold out DWMTS event, no TS, no submit or view details button, but has additional content
486
+					$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
487
+				} else if (
488
+					apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
489
+					&& ! is_single()
490
+				) {
491
+					// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
492
+					// but no tickets are available, so display event's "View Details" button.
493
+					// it is being viewed via somewhere other than a single post
494
+					$html .= EED_Ticket_Selector::display_view_details_btn(true);
495
+				}
496
+			} else if (is_archive()) {
497
+				// event list, no tickets available so display event's "View Details" button
498
+				$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
499
+				$html .= EED_Ticket_Selector::display_view_details_btn();
500
+			} else {
501
+				if (
502
+					apply_filters(
503
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
504
+						false,
505
+						EED_Ticket_Selector::$_event
506
+					)
507
+				) {
508
+					$html .= \EED_Ticket_Selector::display_register_now_button();
509
+				}
510
+				// no submit or view details button, and no additional content
511
+				$html .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
512
+			}
513
+			if ( ! is_archive()) {
514
+				$html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
515
+			}
516
+		}
517
+		return $html;
518
+	}
519
+
520
+
521
+
522
+	/**
523
+	 * @return string
524
+	 */
525
+	public static function clear_tkt_slctr()
526
+	{
527
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
528
+		return '<div class="clear"></div>';
529
+	}
530
+
531
+
532
+
533
+	/**
534
+	 * @deprecated 4.9.13
535
+	 * @return string
536
+	 */
537
+	public static function tkt_slctr_end_dv()
538
+	{
539
+		return \EED_Ticket_Selector::clear_tkt_slctr();
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * @return string
546
+	 */
547
+	public static function no_tkt_slctr_end_dv()
548
+	{
549
+		// DWMTS event, no TS, appears after a "Register Now" or "view Details" button
550
+		return '<div class="clear"></div></div>';
551
+	}
552
+
553
+
554
+
555
+	/**
556
+	 *    ticket_selector_form_close
557
+	 *
558
+	 * @access        public
559
+	 * @access        public
560
+	 * @return        string
561
+	 */
562
+	public static function ticket_selector_form_close()
563
+	{
564
+		return '</form>';
565
+	}
566
+
567
+
568
+
569
+	/**
570
+	 * @return string
571
+	 * @throws \EE_Error
572
+	 */
573
+	public static function display_register_now_button()
574
+	{
575
+		$btn_text = apply_filters(
576
+			'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
577
+			__('Register Now', 'event_espresso'),
578
+			EED_Ticket_Selector::$_event
579
+		);
580
+		$external_url = EED_Ticket_Selector::$_event->external_url();
581
+		$html = '<input id="ticket-selector-submit-' . EED_Ticket_Selector::$_event->ID() . '-btn"';
582
+		$html .= ' class="ticket-selector-submit-btn ';
583
+		$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
584
+		$html .= ' type="submit" value="' . $btn_text . '" />';
585
+		$html .= apply_filters(
586
+			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
587
+			'',
588
+			EED_Ticket_Selector::$_event
589
+		);
590
+		return $html;
591
+	}
592
+
593
+
594
+	/**
595
+	 * display_view_details_btn
596
+	 *
597
+	 * @access public
598
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
599
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
600
+	 *                    either because they are sold out, expired, or not yet on sale.
601
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
602
+	 * @return string
603
+	 * @throws \EE_Error
604
+	 */
605
+	public static function display_view_details_btn($DWMTS = false)
606
+	{
607
+		if ( ! self::$_event->get_permalink()) {
608
+			EE_Error::add_error(
609
+				__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
610
+				__FILE__, __FUNCTION__, __LINE__
611
+			);
612
+		}
613
+		$view_details_btn = '<form method="POST" action="';
614
+		$view_details_btn .= apply_filters(
615
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
616
+			self::$_event->get_permalink(),
617
+			self::$_event
618
+		);
619
+		$view_details_btn .= '">';
620
+		$btn_text = apply_filters(
621
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
622
+			__('View Details', 'event_espresso'),
623
+			self::$_event
624
+		);
625
+		$view_details_btn .= '<input id="ticket-selector-submit-'
626
+							 . self::$_event->ID()
627
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
628
+							 . $btn_text
629
+							 . '" />';
630
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
631
+		if ($DWMTS) {
632
+			$view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close();
633
+			$view_details_btn .= \EED_Ticket_Selector::no_tkt_slctr_end_dv();
634
+			$view_details_btn .= '<br/>';
635
+		} else {
636
+			$view_details_btn .= \EED_Ticket_Selector::clear_tkt_slctr();
637
+			$view_details_btn .= '<br/>';
638
+			$view_details_btn .= \EED_Ticket_Selector::ticket_selector_form_close();
639
+		}
640
+		return $view_details_btn;
641
+	}
642
+
643
+
644
+
645
+	/**
646
+	 *    cancel_ticket_selections
647
+	 *
648
+	 * @access        public
649
+	 * @access        public
650
+	 * @return        string
651
+	 */
652
+	public static function cancel_ticket_selections()
653
+	{
654
+		// check nonce
655
+		if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('cancel_ticket_selections')) {
656
+			return false;
657
+		}
658
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
659
+		if (EE_Registry::instance()->REQ->is_set('event_id')) {
660
+			wp_safe_redirect(
661
+				EEH_Event_View::event_link_url(
662
+					EE_Registry::instance()->REQ->get('event_id')
663
+				)
664
+			);
665
+		} else {
666
+			wp_safe_redirect(
667
+				site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
668
+			);
669
+		}
670
+		die();
671
+	}
672
+
673
+
674
+
675
+	/**
676
+	 *    process_ticket_selector_nonce
677
+	 *
678
+	 * @access public
679
+	 * @param  string $nonce_name
680
+	 * @param string  $id
681
+	 * @return bool
682
+	 */
683
+	public static function process_ticket_selector_nonce($nonce_name, $id = '')
684
+	{
685
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
686
+		if (
687
+			! is_admin()
688
+			&& (
689
+				! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
690
+				|| ! wp_verify_nonce(
691
+					EE_Registry::instance()->REQ->get($nonce_name_with_id),
692
+					$nonce_name
693
+				)
694
+			)
695
+		) {
696
+			EE_Error::add_error(
697
+				sprintf(
698
+					__(
699
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
700
+						'event_espresso'
701
+					),
702
+					'<br/>'
703
+				),
704
+				__FILE__,
705
+				__FUNCTION__,
706
+				__LINE__
707
+			);
708
+			return false;
709
+		}
710
+		return true;
711
+	}
712
+
713
+
714
+
715
+	/**
716
+	 *    process_ticket_selections
717
+	 *
718
+	 * @access public
719
+	 * @return array|boolean
720
+	 * @throws \EE_Error
721
+	 */
722
+	public function process_ticket_selections()
723
+	{
724
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
725
+		// do we have an event id?
726
+		if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
727
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
728
+			EE_Error::add_error(
729
+				sprintf(
730
+					__(
731
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
732
+						'event_espresso'
733
+					),
734
+					'<br/>'
735
+				),
736
+				__FILE__,
737
+				__FUNCTION__,
738
+				__LINE__
739
+			);
740
+		}
741
+		//if event id is valid
742
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
743
+		// check nonce
744
+		if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('process_ticket_selections', $id)) {
745
+			return false;
746
+		}
747
+		//		d( EE_Registry::instance()->REQ );
748
+		self::$_available_spaces = array(
749
+			'tickets'   => array(),
750
+			'datetimes' => array(),
751
+		);
752
+		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
753
+		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
754
+		EE_Registry::instance()->load_core('Session');
755
+		// unless otherwise requested, clear the session
756
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
757
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
758
+		}
759
+		//d( EE_Registry::instance()->SSN );
760
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
761
+		// validate/sanitize data
762
+		$valid = self::_validate_post_data($id);
763
+		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
764
+		//EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
765
+		//EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
766
+		//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
767
+		//check total tickets ordered vs max number of attendees that can register
768
+		if ($valid['total_tickets'] > $valid['max_atndz']) {
769
+			// ordering too many tickets !!!
770
+			$total_tickets_string = _n('You have attempted to purchase %s ticket.',
771
+				'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso');
772
+			$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
773
+			// dev only message
774
+			$max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
775
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
776
+				$valid['max_atndz'], 'event_espresso');
777
+			$limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
778
+			EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
779
+		} elseif ( apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid) ) {
780
+			// all data appears to be valid
781
+			$tckts_slctd = false;
782
+			$tickets_added = 0;
783
+			$valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid);
784
+			if ($valid['total_tickets'] > 0) {
785
+				// load cart
786
+				EE_Registry::instance()->load_core('Cart');
787
+				// cycle thru the number of data rows sent from the event listing
788
+				for ($x = 0; $x < $valid['rows']; $x++) {
789
+					// does this row actually contain a ticket quantity?
790
+					if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
791
+						// YES we have a ticket quantity
792
+						$tckts_slctd = true;
793
+						//						d( $valid['ticket_obj'][$x] );
794
+						if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
795
+							// then add ticket to cart
796
+							$tickets_added += self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
797
+							if (EE_Error::has_error()) {
798
+								break;
799
+							}
800
+						} else {
801
+							// nothing added to cart retrieved
802
+							EE_Error::add_error(
803
+								sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
804
+									'event_espresso'), '<br/>'),
805
+								__FILE__, __FUNCTION__, __LINE__
806
+							);
807
+						}
808
+					}
809
+				}
810
+			}
811
+			do_action(
812
+				'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
813
+				EE_Registry::instance()->CART,
814
+				$this
815
+			);
816
+			//d( EE_Registry::instance()->CART );
817
+			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
818
+			if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
819
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
820
+					do_action(
821
+						'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
822
+						EE_Registry::instance()->CART,
823
+						$this
824
+					);
825
+					EE_Registry::instance()->CART->recalculate_all_cart_totals();
826
+					EE_Registry::instance()->CART->save_cart(false);
827
+					// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
828
+					// just return TRUE for registrations being made from admin
829
+					if (is_admin()) {
830
+						return true;
831
+					}
832
+					EE_Error::get_notices(false, true);
833
+					wp_safe_redirect(
834
+						apply_filters(
835
+							'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
836
+							EE_Registry::instance()->CFG->core->reg_page_url()
837
+						)
838
+					);
839
+					exit();
840
+				} else {
841
+					if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
842
+						// nothing added to cart
843
+						EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__,
844
+							__FUNCTION__, __LINE__);
845
+					}
846
+				}
847
+			} else {
848
+				// no ticket quantities were selected
849
+				EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
850
+					'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
851
+			}
852
+		} else {
853
+			if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
854
+				// nothing added to cart
855
+				EE_Error::add_attention(__('There was an error adding your tickets to the cart', 'event_espresso'), __FILE__,
856
+					__FUNCTION__, __LINE__);
857
+			}
858
+		}
859
+		//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
860
+		// at this point, just return if registration is being made from admin
861
+		if (is_admin()) {
862
+			return false;
863
+		}
864
+		if ($valid['return_url']) {
865
+			EE_Error::get_notices(false, true);
866
+			wp_safe_redirect($valid['return_url']);
867
+			exit();
868
+		} elseif (isset($event_to_add['id'])) {
869
+			EE_Error::get_notices(false, true);
870
+			wp_safe_redirect(get_permalink($event_to_add['id']));
871
+			exit();
872
+		} else {
873
+			echo EE_Error::get_notices();
874
+		}
875
+		return false;
876
+	}
877
+
878
+
879
+
880
+	/**
881
+	 *    validate_post_data
882
+	 *
883
+	 * @access        private
884
+	 * @param int $id
885
+	 * @return array|FALSE
886
+	 */
887
+	private static function _validate_post_data($id = 0)
888
+	{
889
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
890
+		if ( ! $id) {
891
+			EE_Error::add_error(
892
+				__('The event id provided was not valid.', 'event_espresso'),
893
+				__FILE__,
894
+				__FUNCTION__,
895
+				__LINE__
896
+			);
897
+			return false;
898
+		}
899
+		// start with an empty array()
900
+		$valid_data = array();
901
+		// grab valid id
902
+		$valid_data['id'] = $id;
903
+		// grab and sanitize return-url
904
+		$valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-' . $id));
905
+		// array of other form names
906
+		$inputs_to_clean = array(
907
+			'event_id'   => 'tkt-slctr-event-id',
908
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
909
+			'rows'       => 'tkt-slctr-rows-',
910
+			'qty'        => 'tkt-slctr-qty-',
911
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
912
+			'return_url' => 'tkt-slctr-return-url-',
913
+		);
914
+		// let's track the total number of tickets ordered.'
915
+		$valid_data['total_tickets'] = 0;
916
+		// cycle through $inputs_to_clean array
917
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
918
+			// check for POST data
919
+			if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
920
+				// grab value
921
+				$input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
922
+				switch ($what) {
923
+					// integers
924
+					case 'event_id':
925
+						$valid_data[$what] = absint($input_value);
926
+						// get event via the event id we put in the form
927
+						$valid_data['event'] = EE_Registry::instance()
928
+														  ->load_model('Event')
929
+														  ->get_one_by_ID($valid_data['event_id']);
930
+						break;
931
+					case 'rows':
932
+					case 'max_atndz':
933
+						$valid_data[$what] = absint($input_value);
934
+						break;
935
+					// arrays of integers
936
+					case 'qty':
937
+						/** @var array $row_qty */
938
+						$row_qty = $input_value;
939
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
940
+						if ( ! is_array($row_qty)) {
941
+							// get number of rows
942
+							$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
943
+								? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
944
+								: 1;
945
+							// explode ints by the dash
946
+							$row_qty = explode('-', $row_qty);
947
+							$row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
948
+							$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
949
+							$row_qty = array($row => $qty);
950
+							//								 d( $row_qty );
951
+							for ($x = 1; $x <= $rows; $x++) {
952
+								if ( ! isset($row_qty[$x])) {
953
+									$row_qty[$x] = 0;
954
+								}
955
+							}
956
+						}
957
+						ksort($row_qty);
958
+						//							 d( $row_qty );
959
+						// cycle thru values
960
+						foreach ($row_qty as $qty) {
961
+							$qty = absint($qty);
962
+							// sanitize as integers
963
+							$valid_data[$what][] = $qty;
964
+							$valid_data['total_tickets'] += $qty;
965
+						}
966
+						break;
967
+					// array of integers
968
+					case 'ticket_id':
969
+						$value_array = array();
970
+						// cycle thru values
971
+						foreach ((array)$input_value as $key => $value) {
972
+							// allow only numbers, letters,  spaces, commas and dashes
973
+							$value_array[$key] = wp_strip_all_tags($value);
974
+							// get ticket via the ticket id we put in the form
975
+							$ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
976
+							$valid_data['ticket_obj'][$key] = $ticket_obj;
977
+						}
978
+						$valid_data[$what] = $value_array;
979
+						break;
980
+					case 'return_url' :
981
+						// grab and sanitize return-url
982
+						$valid_data[$what] = esc_url_raw($input_value);
983
+						break;
984
+				}    // end switch $what
985
+			}
986
+		}    // end foreach $inputs_to_clean
987
+		//		d( $valid_data );
988
+		//		die();
989
+		return $valid_data;
990
+	}
991
+
992
+
993
+
994
+	/**
995
+	 *    adds a ticket to the cart
996
+	 *
997
+	 * @access   private
998
+	 * @param EE_Ticket $ticket
999
+	 * @param int       $qty
1000
+	 * @return TRUE on success, FALSE on fail
1001
+	 * @throws \EE_Error
1002
+	 */
1003
+	private static function _add_ticket_to_cart(EE_Ticket $ticket = null, $qty = 1)
1004
+	{
1005
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1006
+		// get the number of spaces left for this datetime ticket
1007
+		$available_spaces = self::_ticket_datetime_availability($ticket);
1008
+		// compare available spaces against the number of tickets being purchased
1009
+		if ($available_spaces >= $qty) {
1010
+			// allow addons to prevent a ticket from being added to cart
1011
+			if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket,
1012
+				$qty, $available_spaces)
1013
+			) {
1014
+				return false;
1015
+			}
1016
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
1017
+			// add event to cart
1018
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
1019
+				self::_recalculate_ticket_datetime_availability($ticket, $qty);
1020
+				return true;
1021
+			} else {
1022
+				return false;
1023
+			}
1024
+		} else {
1025
+			// tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
1026
+			$available_spaces = self::_ticket_datetime_availability($ticket, true);
1027
+			// greedy greedy greedy eh?
1028
+			if ($available_spaces > 0) {
1029
+				if (
1030
+				apply_filters(
1031
+					'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
1032
+					true,
1033
+					$ticket,
1034
+					$qty,
1035
+					$available_spaces
1036
+				)
1037
+				) {
1038
+					EED_Ticket_Selector::_display_availability_error($available_spaces);
1039
+				}
1040
+			} else {
1041
+				EE_Error::add_error(
1042
+					__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
1043
+						'event_espresso'),
1044
+					__FILE__, __FUNCTION__, __LINE__
1045
+				);
1046
+			}
1047
+			return false;
1048
+		}
1049
+	}
1050
+
1051
+
1052
+
1053
+	/**
1054
+	 *  _display_availability_error
1055
+	 *
1056
+	 * @access    private
1057
+	 * @param int $available_spaces
1058
+	 * @throws \EE_Error
1059
+	 */
1060
+	private static function _display_availability_error($available_spaces = 1)
1061
+	{
1062
+		// add error messaging - we're using the _n function that will generate
1063
+		// the appropriate singular or plural message based on the number of $available_spaces
1064
+		if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
1065
+			$msg = sprintf(
1066
+				_n(
1067
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
1068
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
1069
+					$available_spaces,
1070
+					'event_espresso'
1071
+				),
1072
+				$available_spaces,
1073
+				'<br />'
1074
+			);
1075
+		} else {
1076
+			$msg = sprintf(
1077
+				_n(
1078
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
1079
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
1080
+					$available_spaces,
1081
+					'event_espresso'
1082
+				),
1083
+				$available_spaces,
1084
+				'<br />'
1085
+			);
1086
+		}
1087
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1088
+	}
1089
+
1090
+
1091
+
1092
+	/**
1093
+	 * _ticket_datetime_availability
1094
+	 * creates an array of tickets plus all of the datetimes available to each ticket
1095
+	 * and tracks the spaces remaining for each of those datetimes
1096
+	 *
1097
+	 * @access private
1098
+	 * @param EE_Ticket $ticket - selected ticket
1099
+	 * @param bool      $get_original_ticket_spaces
1100
+	 * @return int
1101
+	 * @throws \EE_Error
1102
+	 */
1103
+	private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
1104
+	{
1105
+		// if the $_available_spaces array has not been set up yet...
1106
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1107
+			self::_set_initial_ticket_datetime_availability($ticket);
1108
+		}
1109
+		$available_spaces = $ticket->qty() - $ticket->sold();
1110
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1111
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
1112
+			foreach ((array)self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1113
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
1114
+				if ($get_original_ticket_spaces) {
1115
+					// then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
1116
+					$available_spaces = min($available_spaces,
1117
+						self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
1118
+				} else {
1119
+					// we want the updated ticket availability as stored in the "datetimes" array
1120
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
1121
+				}
1122
+			}
1123
+		}
1124
+		return $available_spaces;
1125
+	}
1126
+
1127
+
1128
+
1129
+	/**
1130
+	 * _set_initial_ticket_datetime_availability
1131
+	 *
1132
+	 * @access private
1133
+	 * @param EE_Ticket $ticket
1134
+	 * @return void
1135
+	 * @throws \EE_Error
1136
+	 */
1137
+	private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket)
1138
+	{
1139
+		// first, get all of the datetimes that are available to this ticket
1140
+		$datetimes = $ticket->get_many_related(
1141
+			'Datetime',
1142
+			array(
1143
+				array(
1144
+					'DTT_EVT_end' => array(
1145
+						'>=',
1146
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
1147
+					),
1148
+				),
1149
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
1150
+			)
1151
+		);
1152
+		if ( ! empty($datetimes)) {
1153
+			// now loop thru all of the datetimes
1154
+			foreach ($datetimes as $datetime) {
1155
+				if ($datetime instanceof EE_Datetime) {
1156
+					// the number of spaces available for the datetime without considering individual ticket quantities
1157
+					$spaces_remaining = $datetime->spaces_remaining();
1158
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key
1159
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
1160
+						$ticket->qty() - $ticket->sold(),
1161
+						$spaces_remaining
1162
+					);
1163
+					// if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
1164
+					// else just take the datetime spaces remaining, and assign to the datetimes array
1165
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()])
1166
+						? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
1167
+						: $spaces_remaining;
1168
+				}
1169
+			}
1170
+		}
1171
+	}
1172
+
1173
+
1174
+
1175
+	/**
1176
+	 *    _recalculate_ticket_datetime_availability
1177
+	 *
1178
+	 * @access    private
1179
+	 * @param    EE_Ticket $ticket
1180
+	 * @param    int       $qty
1181
+	 * @return    void
1182
+	 */
1183
+	private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0)
1184
+	{
1185
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1186
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
1187
+			foreach ((array)self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1188
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
1189
+				self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
1190
+			}
1191
+		}
1192
+	}
1193
+
1194
+
1195
+
1196
+	/**
1197
+	 *    load js
1198
+	 *
1199
+	 * @access        public
1200
+	 * @return        void
1201
+	 */
1202
+	public static function load_tckt_slctr_assets()
1203
+	{
1204
+		// add some style
1205
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
1206
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
1207
+			wp_enqueue_style('ticket_selector');
1208
+			// make it dance
1209
+			// wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
1210
+			// wp_enqueue_script('ticket_selector');
1211
+		}
1212
+	}
1213
+
1214
+
1215
+
1216
+	public static function load_tckt_slctr_assets_admin()
1217
+	{
1218
+		//iframe button js on admin event editor page
1219
+		if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
1220
+			&& EE_Registry::instance()->REQ->get('action') === 'edit'
1221
+		) {
1222
+			wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js',
1223
+				array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1224
+			wp_enqueue_script('ticket_selector_embed');
1225
+		}
1226
+	}
1227 1227
 
1228 1228
 
1229 1229
 
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 class EED_Ticket_Selector extends EED_Module
15 15
 {
16 16
 
17
-    const debug = false;    //	true false
17
+    const debug = false; //	true false
18 18
 
19 19
     /**
20 20
      * event that ticket selector is being generated for
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public static function set_definitions()
115 115
     {
116
-        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
117
-        define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
116
+        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
117
+        define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
118 118
         //if config is not set, initialize
119 119
         //If config is not set, set it.
120 120
         if (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector === null) {
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
         $template_args['css'] = apply_filters(
159 159
             'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
160 160
             array(
161
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
162
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
163
-                includes_url('css/dashicons.min.css?ver=' . $GLOBALS['wp_version']),
164
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
161
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION,
162
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION,
163
+                includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']),
164
+                EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
165 165
             )
166 166
         );
167 167
         EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
         $template_args['js'] = apply_filters(
175 175
             'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
176 176
             array(
177
-                includes_url('js/jquery/jquery.js?ver=' . $GLOBALS['wp_version']),
178
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
179
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION,
177
+                includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']),
178
+                EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
179
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION,
180 180
             )
181 181
         );
182 182
         $template_args['notices'] = EEH_Template::display_template(
183
-            EE_TEMPLATES . 'espresso-ajax-notices.template.php',
183
+            EE_TEMPLATES.'espresso-ajax-notices.template.php',
184 184
             array(),
185 185
             true
186 186
         );
187 187
         EEH_Template::display_template(
188
-            TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
188
+            TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php',
189 189
             $template_args
190 190
         );
191 191
         exit;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      * @param int    $id               The post id for the event.
201 201
      * @return string The new html string for the permalink area.
202 202
      */
203
-    public static function iframe_code_button($permalink_string, $id )
203
+    public static function iframe_code_button($permalink_string, $id)
204 204
     {
205 205
         //make sure this is ONLY when editing and the event id has been set.
206 206
         if ( ! empty($id)) {
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
                                  . '</a> ';
215 215
             $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
216 216
             $iframe_string = esc_html(
217
-                '<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>'
217
+                '<iframe src="'.$ticket_selector_url.'" width="100%" height="100%"></iframe>'
218 218
             );
219 219
             $permalink_string .= '
220 220
 <div id="js-ts-iframe" style="display:none">
221 221
 	<div style="width:100%; height: 500px;">
222
-		' . $iframe_string . '
222
+		' . $iframe_string.'
223 223
 	</div>
224 224
 </div>';
225 225
         }
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
         }
244 244
         if ($event instanceof EE_Event) {
245 245
             self::$_event = $event;
246
-        } else if ($event instanceof WP_Post ) {
247
-            if ( isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
246
+        } else if ($event instanceof WP_Post) {
247
+            if (isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
248 248
                 self::$_event = $event->EE_Event;
249
-            } else if ( $event->post_type === 'espresso_events') {
249
+            } else if ($event->post_type === 'espresso_events') {
250 250
                 $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
251 251
                 self::$_event = $event->EE_Event;
252 252
             }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             $dev_msg = $user_msg
256 256
                        . __('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
257 257
                     'event_espresso');
258
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
258
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
259 259
             return false;
260 260
         }
261 261
         return true;
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
                     '</a></span></div>'
363 363
                 );
364 364
             }
365
-            return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
365
+            return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
366 366
         }
367
-        $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
367
+        $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php';
368 368
         $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',
369 369
             $templates['ticket_selector'], self::$_event);
370 370
         // redirecting to another site for registration ??
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
             ? EED_Ticket_Selector::ticket_selector_form_open(
387 387
                 self::$_event->ID(),
388 388
                 $external_url
389
-            ) . $ticket_selector
389
+            ).$ticket_selector
390 390
             : $ticket_selector;
391 391
         // submit button and form close tag
392 392
         $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit($external_url) : '';
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
     {
410 410
         // if redirecting, we don't need any anything else
411 411
         if ($external_url) {
412
-            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '">';
413
-            $query_args = (array)EEH_URL::get_query_string($external_url);
412
+            $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">';
413
+            $query_args = (array) EEH_URL::get_query_string($external_url);
414 414
             foreach ($query_args as $query_arg => $value) {
415 415
                 $html .= '
416
-				<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
416
+				<input type="hidden" name="' . $query_arg.'" value="'.$value.'">';
417 417
             }
418 418
             return $html;
419 419
         }
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
                 __FILE__, __FUNCTION__, __LINE__);
429 429
         }
430 430
         $extra_params = self::$_in_iframe ? ' target="_blank"' : '';
431
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
432
-        $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false);
431
+        $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
432
+        $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false);
433 433
         $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
434 434
         $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
435 435
         return $html;
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
                 $html .= empty($external_url) ?
455 455
                     \EED_Ticket_Selector::no_tkt_slctr_end_dv()
456 456
                     : \EED_Ticket_Selector::clear_tkt_slctr();
457
-                $html .= '<br/>' . \EED_Ticket_Selector::ticket_selector_form_close();
458
-            } else if ( EED_Ticket_Selector::$_max_atndz === 1 ) {
457
+                $html .= '<br/>'.\EED_Ticket_Selector::ticket_selector_form_close();
458
+            } else if (EED_Ticket_Selector::$_max_atndz === 1) {
459 459
                 // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
460
-                if ( EED_Ticket_Selector::$_event->is_sold_out() ) {
460
+                if (EED_Ticket_Selector::$_event->is_sold_out()) {
461 461
                     // then instead of a View Details or Submit button, just display a "Sold Out" message
462 462
                     $html .= apply_filters(
463 463
                         'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
             EED_Ticket_Selector::$_event
579 579
         );
580 580
         $external_url = EED_Ticket_Selector::$_event->external_url();
581
-        $html = '<input id="ticket-selector-submit-' . EED_Ticket_Selector::$_event->ID() . '-btn"';
581
+        $html = '<input id="ticket-selector-submit-'.EED_Ticket_Selector::$_event->ID().'-btn"';
582 582
         $html .= ' class="ticket-selector-submit-btn ';
583 583
         $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
584
-        $html .= ' type="submit" value="' . $btn_text . '" />';
584
+        $html .= ' type="submit" value="'.$btn_text.'" />';
585 585
         $html .= apply_filters(
586 586
             'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
587 587
             '',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
             );
665 665
         } else {
666 666
             wp_safe_redirect(
667
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
667
+                site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/')
668 668
             );
669 669
         }
670 670
         die();
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
                 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
776 776
                 $valid['max_atndz'], 'event_espresso');
777 777
             $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
778
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
779
-        } elseif ( apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid) ) {
778
+            EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
779
+        } elseif (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid)) {
780 780
             // all data appears to be valid
781 781
             $tckts_slctd = false;
782 782
             $tickets_added = 0;
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
         // grab valid id
902 902
         $valid_data['id'] = $id;
903 903
         // grab and sanitize return-url
904
-        $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-' . $id));
904
+        $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id));
905 905
         // array of other form names
906 906
         $inputs_to_clean = array(
907 907
             'event_id'   => 'tkt-slctr-event-id',
@@ -916,9 +916,9 @@  discard block
 block discarded – undo
916 916
         // cycle through $inputs_to_clean array
917 917
         foreach ($inputs_to_clean as $what => $input_to_clean) {
918 918
             // check for POST data
919
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
919
+            if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
920 920
                 // grab value
921
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
921
+                $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
922 922
                 switch ($what) {
923 923
                     // integers
924 924
                     case 'event_id':
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
940 940
                         if ( ! is_array($row_qty)) {
941 941
                             // get number of rows
942
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
943
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
942
+                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id)
943
+                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id))
944 944
                                 : 1;
945 945
                             // explode ints by the dash
946 946
                             $row_qty = explode('-', $row_qty);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
                     case 'ticket_id':
969 969
                         $value_array = array();
970 970
                         // cycle thru values
971
-                        foreach ((array)$input_value as $key => $value) {
971
+                        foreach ((array) $input_value as $key => $value) {
972 972
                             // allow only numbers, letters,  spaces, commas and dashes
973 973
                             $value_array[$key] = wp_strip_all_tags($value);
974 974
                             // get ticket via the ticket id we put in the form
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
         $available_spaces = $ticket->qty() - $ticket->sold();
1110 1110
         if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1111 1111
             // loop thru tickets, which will ALSO include individual ticket records AND a total
1112
-            foreach ((array)self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1112
+            foreach ((array) self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1113 1113
                 // if we want the original datetime availability BEFORE we started subtracting tickets ?
1114 1114
                 if ($get_original_ticket_spaces) {
1115 1115
                     // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
     {
1185 1185
         if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1186 1186
             // loop thru tickets, which will ALSO include individual ticket records AND a total
1187
-            foreach ((array)self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1187
+            foreach ((array) self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1188 1188
                 // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
1189 1189
                 self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
1190 1190
             }
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
     {
1204 1204
         // add some style
1205 1205
         if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
1206
-            wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
1206
+            wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
1207 1207
             wp_enqueue_style('ticket_selector');
1208 1208
             // make it dance
1209 1209
             // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
         if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
1220 1220
             && EE_Registry::instance()->REQ->get('action') === 'edit'
1221 1221
         ) {
1222
-            wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js',
1222
+            wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js',
1223 1223
                 array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1224 1224
             wp_enqueue_script('ticket_selector_embed');
1225 1225
         }
Please login to merge, or discard this patch.