Completed
Branch BUG-8698-ticket-sellouts (bcf7c9)
by
unknown
127:27 queued 110:31
created
core/db_classes/EE_Datetime.class.php 2 patches
Doc Comments   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * Sets qty of reserved tickets for this datetime
247 247
 	 *
248 248
 	 * @param int $reserved
249
-	 * @return boolean
249
+	 * @return boolean|null
250 250
 	 */
251 251
 	function set_reserved( $reserved ) {
252 252
 		// reserved can not go below zero
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * increments reserved by amount passed by $qty
261 261
 	 *
262 262
 	 * @param int $qty
263
-	 * @return boolean
263
+	 * @return boolean|null
264 264
 	 */
265 265
 	function increase_reserved( $qty = 1 ) {
266 266
 		$reserved = $this->reserved() + absint( $qty );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * decrements (subtracts) reserved by amount passed by $qty
274 274
 	 *
275 275
 	 * @param int $qty
276
-	 * @return boolean
276
+	 * @return boolean|null
277 277
 	 */
278 278
 	function decrease_reserved( $qty = 1 ) {
279 279
 		$reserved = $this->reserved() - absint( $qty );
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 	/**
297 297
 	 * returns the datetime name
298
-	 * @return string
298
+	 * @return boolean
299 299
 	 */
300 300
 	public function name() {
301 301
 		return $this->get( 'DTT_name' );
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
 	/**
307 307
 	 * returns the datetime description
308
-	 * @return string
308
+	 * @return boolean
309 309
 	 */
310 310
 	public function description() {
311 311
 		return $this->get( 'DTT_description' );
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 	/**
327 327
 	 * This helper simply returns the order for the datetime
328
-	 * @return int         The order of the datetime for this event.
328
+	 * @return boolean         The order of the datetime for this event.
329 329
 	 */
330 330
 	public function order() {
331 331
 		return $this->get( 'DTT_order' );
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
 	/**
337 337
 	 * This helper simply returns the parent id for the datetime
338
-	 * @return int
338
+	 * @return boolean
339 339
 	 */
340 340
 	public function parent() {
341 341
 		return $this->get( 'DTT_parent' );
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @param    string $dt_frmt
353 353
 	 * @param    string $tm_frmt
354 354
 	 * @param    bool   $echo         - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats)
355
-	 * @return    string|bool|void  string on success, FALSE on fail
355
+	 * @return    string|boolean  string on success, FALSE on fail
356 356
 	 */
357 357
 	private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) {
358 358
 		$field_name = "DTT_EVT_{$start_or_end}";
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	 * last-used format, or '' to use the default date format
371 371
 	 *
372 372
 	 * @access        public
373
-	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
374
-	 * @return        mixed        string on success, FALSE on fail
373
+	 * @param string $dt_frmt - string representation of date format defaults to 'F j, Y'
374
+	 * @return        string|boolean        string on success, FALSE on fail
375 375
 	 */
376 376
 	public function start_date( $dt_frmt = NULL ) {
377 377
 		return $this->_show_datetime( 'D', 'start', $dt_frmt );
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * last-used format, or '' to use the default date format
395 395
 	 *
396 396
 	 * @access        public
397
-	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
398
-	 * @return        mixed        string on success, FALSE on fail
397
+	 * @param string $dt_frmt - string representation of date format defaults to 'F j, Y'
398
+	 * @return        string|boolean        string on success, FALSE on fail
399 399
 	 */
400 400
 	public function end_date( $dt_frmt = NULL ) {
401 401
 		return $this->_show_datetime( 'D', 'end', $dt_frmt );
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @access        public
420 420
 	 * @param null          $dt_frmt - string representation of date format defaults to WP settings
421 421
 	 * @param        string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
422
-	 * @return        mixed        string on success, FALSE on fail
422
+	 * @return        string        string on success, FALSE on fail
423 423
 	 */
424 424
 	public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
425 425
 		$dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 *
446 446
 	 * @access        public
447 447
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
448
-	 * @return        mixed        string on success, FALSE on fail
448
+	 * @return        string|boolean        string on success, FALSE on fail
449 449
 	 */
450 450
 	public function start_time( $tm_format = NULL ) {
451 451
 		return $this->_show_datetime( 'T', 'start', NULL, $tm_format );
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @access        public
469 469
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
470
-	 * @return        mixed        string on success, FALSE on fail
470
+	 * @return        string|boolean        string on success, FALSE on fail
471 471
 	 */
472 472
 	public function end_time( $tm_format = NULL ) {
473 473
 		return $this->_show_datetime( 'T', 'end', NULL, $tm_format );
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 * @access        public
491 491
 	 * @param        string $tm_format   - string representation of time format defaults to 'g:i a'
492 492
 	 * @param        string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
493
-	 * @return        mixed        string on success, FALSE on fail
493
+	 * @return        string        string on success, FALSE on fail
494 494
 	 */
495 495
 	public function time_range( $tm_format = NULL, $conjunction = ' - ' ) {
496 496
 		$tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	 * @access        public
519 519
 	 * @param 	string 	$dt_format - string representation of date format defaults to 'F j, Y'
520 520
 	 * @param 	string 	$tm_format - string representation of time format defaults to 'g:i a'
521
-	 * @return 	mixed 	string on success, FALSE on fail
521
+	 * @return 	string|boolean 	string on success, FALSE on fail
522 522
 	 */
523 523
 	public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) {
524 524
 		return $this->_show_datetime( '', 'start', $dt_format, $tm_format );
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	 * @access        public
579 579
 	 * @param bool | string 	$dt_frmt- string representation of date format defaults to 'F j, Y'
580 580
 	 * @param bool | string 	$tm_format - string representation of time format defaults to 'g:i a'
581
-	 * @return 	mixed        		string on success, FALSE on fail
581
+	 * @return 	string|boolean        		string on success, FALSE on fail
582 582
 	 */
583 583
 	public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
584 584
 		return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format );
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 *                             		    date_format and the second value is the time format
75 75
 	 * @return EE_Datetime
76 76
 	 */
77
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
78
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
79
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
77
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
78
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
79
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
80 80
 	}
81 81
 
82 82
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *                          		the website will be used.
88 88
 	 * @return EE_Datetime
89 89
 	 */
90
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
91
-		return new self( $props_n_values, TRUE, $timezone );
90
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
91
+		return new self($props_n_values, TRUE, $timezone);
92 92
 	}
93 93
 
94 94
 
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	/**
97 97
 	 * @param $name
98 98
 	 */
99
-	public function set_name( $name ) {
100
-		$this->set( 'DTT_name', $name );
99
+	public function set_name($name) {
100
+		$this->set('DTT_name', $name);
101 101
 	}
102 102
 
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @param $description
107 107
 	 */
108
-	public function set_description( $description ) {
109
-		$this->set( 'DTT_description', $description );
108
+	public function set_description($description) {
109
+		$this->set('DTT_description', $description);
110 110
 	}
111 111
 
112 112
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @access        public
120 120
 	 * @param        string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
121 121
 	 */
122
-	public function set_start_date( $date ) {
123
-		$this->_set_date_for( $date, 'DTT_EVT_start' );
122
+	public function set_start_date($date) {
123
+		$this->_set_date_for($date, 'DTT_EVT_start');
124 124
 	}
125 125
 
126 126
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @access        public
134 134
 	 * @param        string $time a string representation of the event time ex:  9am  or  7:30 PM
135 135
 	 */
136
-	public function set_start_time( $time ) {
137
-		$this->_set_time_for( $time, 'DTT_EVT_start' );
136
+	public function set_start_time($time) {
137
+		$this->_set_time_for($time, 'DTT_EVT_start');
138 138
 	}
139 139
 
140 140
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 * @access        public
148 148
 	 * @param        string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
149 149
 	 */
150
-	public function set_end_date( $date ) {
151
-		$this->_set_date_for( $date, 'DTT_EVT_end' );
150
+	public function set_end_date($date) {
151
+		$this->_set_date_for($date, 'DTT_EVT_end');
152 152
 	}
153 153
 
154 154
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @access        public
162 162
 	 * @param        string $time a string representation of the event time ex:  9am  or  7:30 PM
163 163
 	 */
164
-	public function set_end_time( $time ) {
165
-		$this->_set_time_for( $time, 'DTT_EVT_end' );
164
+	public function set_end_time($time) {
165
+		$this->_set_time_for($time, 'DTT_EVT_end');
166 166
 	}
167 167
 
168 168
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @access        public
176 176
 	 * @param        int $reg_limit
177 177
 	 */
178
-	public function set_reg_limit( $reg_limit ) {
179
-		$this->set( 'DTT_reg_limit', $reg_limit );
178
+	public function set_reg_limit($reg_limit) {
179
+		$this->set('DTT_reg_limit', $reg_limit);
180 180
 	}
181 181
 
182 182
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @return        mixed        int on success, FALSE on fail
189 189
 	 */
190 190
 	public function sold() {
191
-		return $this->get_raw( 'DTT_sold' );
191
+		return $this->get_raw('DTT_sold');
192 192
 	}
193 193
 
194 194
 
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @access        public
200 200
 	 * @param        int $sold
201 201
 	 */
202
-	public function set_sold( $sold ) {
202
+	public function set_sold($sold) {
203 203
 		// sold can not go below zero
204
-		$sold = max( 0, $sold );
205
-		$this->set( 'DTT_sold', $sold );
204
+		$sold = max(0, $sold);
205
+		$this->set('DTT_sold', $sold);
206 206
 	}
207 207
 
208 208
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * increments sold by amount passed by $qty
212 212
 	 * @param int $qty
213 213
 	 */
214
-	function increase_sold( $qty = 1 ) {
214
+	function increase_sold($qty = 1) {
215 215
 		$sold = $this->sold() + $qty;
216 216
 		// remove ticket reservation
217
-		$this->decrease_reserved( $qty );
218
-		$this->set_sold( $sold );
217
+		$this->decrease_reserved($qty);
218
+		$this->set_sold($sold);
219 219
 	}
220 220
 
221 221
 
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * decrements (subtracts) sold amount passed by $qty
225 225
 	 * @param int $qty
226 226
 	 */
227
-	function decrease_sold( $qty = 1 ) {
227
+	function decrease_sold($qty = 1) {
228 228
 		$sold = $this->sold() - $qty;
229
-		$this->set_sold( $sold );
229
+		$this->set_sold($sold);
230 230
 	}
231 231
 
232 232
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 * @return int
238 238
 	 */
239 239
 	function reserved() {
240
-		return $this->get_raw( 'DTT_reserved' );
240
+		return $this->get_raw('DTT_reserved');
241 241
 	}
242 242
 
243 243
 
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 	 * @param int $reserved
249 249
 	 * @return boolean
250 250
 	 */
251
-	function set_reserved( $reserved ) {
251
+	function set_reserved($reserved) {
252 252
 		// reserved can not go below zero
253
-		$reserved = max( 0, intval( $reserved ) );
254
-		$this->set( 'DTT_reserved', $reserved );
253
+		$reserved = max(0, intval($reserved));
254
+		$this->set('DTT_reserved', $reserved);
255 255
 	}
256 256
 
257 257
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	 * @param int $qty
263 263
 	 * @return boolean
264 264
 	 */
265
-	function increase_reserved( $qty = 1 ) {
266
-		$reserved = $this->reserved() + absint( $qty );
267
-		return $this->set_reserved( $reserved );
265
+	function increase_reserved($qty = 1) {
266
+		$reserved = $this->reserved() + absint($qty);
267
+		return $this->set_reserved($reserved);
268 268
 	}
269 269
 
270 270
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 * @param int $qty
276 276
 	 * @return boolean
277 277
 	 */
278
-	function decrease_reserved( $qty = 1 ) {
279
-		$reserved = $this->reserved() - absint( $qty );
280
-		return $this->set_reserved( $reserved );
278
+	function decrease_reserved($qty = 1) {
279
+		$reserved = $this->reserved() - absint($qty);
280
+		return $this->set_reserved($reserved);
281 281
 	}
282 282
 
283 283
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @return string
299 299
 	 */
300 300
 	public function name() {
301
-		return $this->get( 'DTT_name' );
301
+		return $this->get('DTT_name');
302 302
 	}
303 303
 
304 304
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return string
309 309
 	 */
310 310
 	public function description() {
311
-		return $this->get( 'DTT_description' );
311
+		return $this->get('DTT_description');
312 312
 	}
313 313
 
314 314
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @return boolean          TRUE if is primary, FALSE if not.
319 319
 	 */
320 320
 	public function is_primary() {
321
-		return $this->get( 'DTT_is_primary' );
321
+		return $this->get('DTT_is_primary');
322 322
 	}
323 323
 
324 324
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @return int         The order of the datetime for this event.
329 329
 	 */
330 330
 	public function order() {
331
-		return $this->get( 'DTT_order' );
331
+		return $this->get('DTT_order');
332 332
 	}
333 333
 
334 334
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 * @return int
339 339
 	 */
340 340
 	public function parent() {
341
-		return $this->get( 'DTT_parent' );
341
+		return $this->get('DTT_parent');
342 342
 	}
343 343
 
344 344
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 	 * @param    bool   $echo         - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats)
355 355
 	 * @return    string|bool|void  string on success, FALSE on fail
356 356
 	 */
357
-	private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) {
357
+	private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) {
358 358
 		$field_name = "DTT_EVT_{$start_or_end}";
359
-		$dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo );
360
-		if ( ! $echo ) {
359
+		$dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo);
360
+		if ( ! $echo) {
361 361
 			return $dtt;
362 362
 		}
363 363
 		return '';
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
374 374
 	 * @return        mixed        string on success, FALSE on fail
375 375
 	 */
376
-	public function start_date( $dt_frmt = NULL ) {
377
-		return $this->_show_datetime( 'D', 'start', $dt_frmt );
376
+	public function start_date($dt_frmt = NULL) {
377
+		return $this->_show_datetime('D', 'start', $dt_frmt);
378 378
 	}
379 379
 
380 380
 
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 	 * Echoes start_date()
384 384
 	 * @param string $dt_frmt
385 385
 	 */
386
-	public function e_start_date( $dt_frmt = NULL ) {
387
-		$this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE );
386
+	public function e_start_date($dt_frmt = NULL) {
387
+		$this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE);
388 388
 	}
389 389
 
390 390
 
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 	 * @param null $dt_frmt - string representation of date format defaults to 'F j, Y'
398 398
 	 * @return        mixed        string on success, FALSE on fail
399 399
 	 */
400
-	public function end_date( $dt_frmt = NULL ) {
401
-		return $this->_show_datetime( 'D', 'end', $dt_frmt );
400
+	public function end_date($dt_frmt = NULL) {
401
+		return $this->_show_datetime('D', 'end', $dt_frmt);
402 402
 	}
403 403
 
404 404
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 * Echoes the end date. See end_date()
408 408
 	 * @param string $dt_frmt
409 409
 	 */
410
-	public function e_end_date( $dt_frmt = NULL ) {
411
-		$this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE );
410
+	public function e_end_date($dt_frmt = NULL) {
411
+		$this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE);
412 412
 	}
413 413
 
414 414
 
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	 * @param        string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
422 422
 	 * @return        mixed        string on success, FALSE on fail
423 423
 	 */
424
-	public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
425
-		$dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt;
426
-		$start = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) );
427
-		$end = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) );
428
-		return $start != $end ? $start . $conjunction . $end : $start;
424
+	public function date_range($dt_frmt = NULL, $conjunction = ' - ') {
425
+		$dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
426
+		$start = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt));
427
+		$end = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt));
428
+		return $start != $end ? $start.$conjunction.$end : $start;
429 429
 	}
430 430
 
431 431
 
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 	 * @param null   $dt_frmt
435 435
 	 * @param string $conjunction
436 436
 	 */
437
-	public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
438
-		echo $this->date_range( $dt_frmt, $conjunction );
437
+	public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') {
438
+		echo $this->date_range($dt_frmt, $conjunction);
439 439
 	}
440 440
 
441 441
 
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
448 448
 	 * @return        mixed        string on success, FALSE on fail
449 449
 	 */
450
-	public function start_time( $tm_format = NULL ) {
451
-		return $this->_show_datetime( 'T', 'start', NULL, $tm_format );
450
+	public function start_time($tm_format = NULL) {
451
+		return $this->_show_datetime('T', 'start', NULL, $tm_format);
452 452
 	}
453 453
 
454 454
 
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	/**
457 457
 	 * @param null $tm_format
458 458
 	 */
459
-	public function e_start_time( $tm_format = NULL ) {
460
-		$this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE );
459
+	public function e_start_time($tm_format = NULL) {
460
+		$this->_show_datetime('T', 'start', NULL, $tm_format, TRUE);
461 461
 	}
462 462
 
463 463
 
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
470 470
 	 * @return        mixed        string on success, FALSE on fail
471 471
 	 */
472
-	public function end_time( $tm_format = NULL ) {
473
-		return $this->_show_datetime( 'T', 'end', NULL, $tm_format );
472
+	public function end_time($tm_format = NULL) {
473
+		return $this->_show_datetime('T', 'end', NULL, $tm_format);
474 474
 	}
475 475
 
476 476
 
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	/**
479 479
 	 * @param null $tm_format
480 480
 	 */
481
-	public function e_end_time( $tm_format = NULL ) {
482
-		$this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE );
481
+	public function e_end_time($tm_format = NULL) {
482
+		$this->_show_datetime('T', 'end', NULL, $tm_format, TRUE);
483 483
 	}
484 484
 
485 485
 
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
 	 * @param        string $conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
493 493
 	 * @return        mixed        string on success, FALSE on fail
494 494
 	 */
495
-	public function time_range( $tm_format = NULL, $conjunction = ' - ' ) {
496
-		$tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt;
495
+	public function time_range($tm_format = NULL, $conjunction = ' - ') {
496
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
497 497
 
498
-		$start = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) );
499
-		$end = str_replace( ' ', '&nbsp;', $this->get_i18n_datetime( 'DTT_EVT_end',  $tm_format ) );
500
-		return $start != $end ? $start . $conjunction . $end : $start;
498
+		$start = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_start', $tm_format));
499
+		$end = str_replace(' ', '&nbsp;', $this->get_i18n_datetime('DTT_EVT_end', $tm_format));
500
+		return $start != $end ? $start.$conjunction.$end : $start;
501 501
 	}
502 502
 
503 503
 
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	 * @param null   $tm_format
507 507
 	 * @param string $conjunction
508 508
 	 */
509
-	public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) {
510
-		echo $this->time_range( $tm_format, $conjunction );
509
+	public function e_time_range($tm_format = NULL, $conjunction = ' - ') {
510
+		echo $this->time_range($tm_format, $conjunction);
511 511
 	}
512 512
 
513 513
 
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
 	 * @param 	string 	$tm_format - string representation of time format defaults to 'g:i a'
521 521
 	 * @return 	mixed 	string on success, FALSE on fail
522 522
 	 */
523
-	public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) {
524
-		return $this->_show_datetime( '', 'start', $dt_format, $tm_format );
523
+	public function start_date_and_time($dt_format = NULL, $tm_format = NULL) {
524
+		return $this->_show_datetime('', 'start', $dt_format, $tm_format);
525 525
 	}
526 526
 
527 527
 
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
 	 * @param null $dt_frmt
531 531
 	 * @param null $tm_format
532 532
 	 */
533
-	public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) {
534
-		$this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE );
533
+	public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) {
534
+		$this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE);
535 535
 	}
536 536
 
537 537
 
@@ -545,11 +545,11 @@  discard block
 block discarded – undo
545 545
 	 * @param bool   $round_up
546 546
 	 * @return float|int|mixed
547 547
 	 */
548
-	public function length( $units = 'seconds', $round_up = FALSE ) {
549
-		$start = $this->get_raw( 'DTT_EVT_start' );
550
-		$end = $this->get_raw( 'DTT_EVT_end' );
548
+	public function length($units = 'seconds', $round_up = FALSE) {
549
+		$start = $this->get_raw('DTT_EVT_start');
550
+		$end = $this->get_raw('DTT_EVT_end');
551 551
 		$length_in_units = $end - $start;
552
-		switch ( $units ) {
552
+		switch ($units) {
553 553
 			//NOTE: We purposefully don't use "break;" in order to chain the divisions
554 554
 			/** @noinspection PhpMissingBreakStatementInspection */
555 555
 			case 'days':
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
 				$length_in_units /= 60;
563 563
 			case 'seconds':
564 564
 			default:
565
-				$length_in_units = ceil( $length_in_units );
565
+				$length_in_units = ceil($length_in_units);
566 566
 		}
567
-		if ( $round_up ) {
568
-			$length_in_units = max( $length_in_units, 1 );
567
+		if ($round_up) {
568
+			$length_in_units = max($length_in_units, 1);
569 569
 		}
570 570
 		return $length_in_units;
571 571
 	}
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @param bool | string 	$tm_format - string representation of time format defaults to 'g:i a'
581 581
 	 * @return 	mixed        		string on success, FALSE on fail
582 582
 	 */
583
-	public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
584
-		return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format );
583
+	public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
584
+		return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
585 585
 	}
586 586
 
587 587
 
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @param bool $dt_frmt
591 591
 	 * @param bool $tm_format
592 592
 	 */
593
-	public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
594
-		$this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE );
593
+	public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
594
+		$this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE);
595 595
 	}
596 596
 
597 597
 
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	 * @return        int
604 604
 	 */
605 605
 	public function start() {
606
-		return $this->get_raw( 'DTT_EVT_start' );
606
+		return $this->get_raw('DTT_EVT_start');
607 607
 	}
608 608
 
609 609
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	 * @return        int
616 616
 	 */
617 617
 	public function end() {
618
-		return $this->get_raw( 'DTT_EVT_end' );
618
+		return $this->get_raw('DTT_EVT_end');
619 619
 	}
620 620
 
621 621
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	 * @return        mixed        int on success, FALSE on fail
628 628
 	 */
629 629
 	public function reg_limit() {
630
-		return $this->get_raw( 'DTT_reg_limit' );
630
+		return $this->get_raw('DTT_reg_limit');
631 631
 	}
632 632
 
633 633
 
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 	 * 																	the spaces remaining for this particular datetime, hence the flag.
657 657
 	 * @return 	int
658 658
 	 */
659
-	public function spaces_remaining( $consider_tickets = FALSE ) {
659
+	public function spaces_remaining($consider_tickets = FALSE) {
660 660
 		// tickets remaining available for purchase
661 661
 		//no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
662 662
 		$dtt_remaining = $this->reg_limit() - $this->sold();
663
-		if ( ! $consider_tickets ) {
663
+		if ( ! $consider_tickets) {
664 664
 			return $dtt_remaining;
665 665
 		}
666 666
 		$tickets_remaining = $this->tickets_remaining();
667
-		return min( $dtt_remaining, $tickets_remaining );
667
+		return min($dtt_remaining, $tickets_remaining);
668 668
 	}
669 669
 
670 670
 
@@ -675,19 +675,19 @@  discard block
 block discarded – undo
675 675
 	 * @param array $query_params like EEM_Base::get_all's
676 676
 	 * @return int
677 677
 	 */
678
-	public function tickets_remaining( $query_params = array() ) {
678
+	public function tickets_remaining($query_params = array()) {
679 679
 		$sum = 0;
680
-		$tickets = $this->tickets( $query_params );
681
-		if ( ! empty( $tickets ) ) {
682
-			foreach ( $tickets as $ticket ) {
683
-				if ( $ticket instanceof EE_Ticket ) {
680
+		$tickets = $this->tickets($query_params);
681
+		if ( ! empty($tickets)) {
682
+			foreach ($tickets as $ticket) {
683
+				if ($ticket instanceof EE_Ticket) {
684 684
 					// get the actual amount of tickets that can be sold
685
-					$qty = $ticket->qty( 'saleable' );
686
-					if ( $qty === EE_INF ) {
685
+					$qty = $ticket->qty('saleable');
686
+					if ($qty === EE_INF) {
687 687
 						return EE_INF;
688 688
 					}
689 689
 					// no negative ticket quantities plz
690
-					if ( $qty > 0 ) {
690
+					if ($qty > 0) {
691 691
 						$sum += $qty;
692 692
 					}
693 693
 				}
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 	 * @param array $query_params like EEM_Base::get_all's
705 705
 	 * @return int
706 706
 	 */
707
-	public function sum_tickets_initially_available( $query_params = array() ) {
708
-		return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' );
707
+	public function sum_tickets_initially_available($query_params = array()) {
708
+		return $this->sum_related('Ticket', $query_params, 'TKT_qty');
709 709
 	}
710 710
 
711 711
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 	 * @return int
718 718
 	 */
719 719
 	public function total_tickets_available_at_this_datetime() {
720
-		return $this->spaces_remaining( true );
720
+		return $this->spaces_remaining(true);
721 721
 	}
722 722
 
723 723
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	 * @return boolean
729 729
 	 */
730 730
 	public function is_upcoming() {
731
-		return ( $this->get_raw( 'DTT_EVT_start' ) > time() );
731
+		return ($this->get_raw('DTT_EVT_start') > time());
732 732
 	}
733 733
 
734 734
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 * @return boolean
739 739
 	 */
740 740
 	public function is_active() {
741
-		return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() );
741
+		return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
742 742
 	}
743 743
 
744 744
 
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 	 * @return boolean
749 749
 	 */
750 750
 	public function is_expired() {
751
-		return ( $this->get_raw( 'DTT_EVT_end' ) < time() );
751
+		return ($this->get_raw('DTT_EVT_end') < time());
752 752
 	}
753 753
 
754 754
 
@@ -759,16 +759,16 @@  discard block
 block discarded – undo
759 759
 	 */
760 760
 	public function get_active_status() {
761 761
 		$total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
762
-		if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) {
762
+		if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) {
763 763
 			return EE_Datetime::sold_out;
764 764
 		}
765
-		if ( $this->is_expired() ) {
765
+		if ($this->is_expired()) {
766 766
 			return EE_Datetime::expired;
767 767
 		}
768
-		if ( $this->is_upcoming() ) {
768
+		if ($this->is_upcoming()) {
769 769
 			return EE_Datetime::upcoming;
770 770
 		}
771
-		if ( $this->is_active() ) {
771
+		if ($this->is_active()) {
772 772
 			return EE_Datetime::active;
773 773
 		}
774 774
 		return NULL;
@@ -782,24 +782,24 @@  discard block
 block discarded – undo
782 782
 	 * @param  boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
783 783
 	 * @return string
784 784
 	 */
785
-	public function get_dtt_display_name( $use_dtt_name = FALSE ) {
786
-		if ( $use_dtt_name ) {
785
+	public function get_dtt_display_name($use_dtt_name = FALSE) {
786
+		if ($use_dtt_name) {
787 787
 			$dtt_name = $this->name();
788
-			if ( !empty( $dtt_name ) ) {
788
+			if ( ! empty($dtt_name)) {
789 789
 				return $dtt_name;
790 790
 			}
791 791
 		}
792 792
 		//first condition is to see if the months are different
793
-		if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) {
794
-			$display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' );
793
+		if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) {
794
+			$display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a');
795 795
 			//next condition is if its the same month but different day
796 796
 		}
797 797
 		else {
798
-			if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) {
799
-				$display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' );
798
+			if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) {
799
+				$display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y');
800 800
 			}
801 801
 			else {
802
-				$display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' );
802
+				$display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a');
803 803
 			}
804 804
 		}
805 805
 		return $display_date;
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 *@param array $query_params see EEM_Base::get_all()
814 814
 	 * @return EE_Ticket[]
815 815
 	 */
816
-	public function tickets( $query_params = array() ) {
817
-		return $this->get_many_related( 'Ticket', $query_params );
816
+	public function tickets($query_params = array()) {
817
+		return $this->get_many_related('Ticket', $query_params);
818 818
 	}
819 819
 
820 820
 
@@ -824,21 +824,21 @@  discard block
 block discarded – undo
824 824
 	 * @param array $query_params like EEM_Base::get_all's
825 825
 	 * @return EE_Ticket[]
826 826
 	 */
827
-	public function ticket_types_available_for_purchase( $query_params = array() ) {
827
+	public function ticket_types_available_for_purchase($query_params = array()) {
828 828
 		// first check if datetime is valid
829
-		if ( !( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) {
829
+		if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) {
830 830
 			return array();
831 831
 		}
832
-		if ( empty( $query_params ) ) {
832
+		if (empty($query_params)) {
833 833
 			$query_params = array(
834 834
 				array(
835
-					'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ),
836
-					'TKT_end_date'   => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ),
835
+					'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')),
836
+					'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
837 837
 					'TKT_deleted'    => false
838 838
 				)
839 839
 			);
840 840
 		}
841
-		return $this->tickets( $query_params );
841
+		return $this->tickets($query_params);
842 842
 	}
843 843
 
844 844
 
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 	 * @return EE_Event
849 849
 	 */
850 850
 	public function event() {
851
-		return $this->get_first_related( 'Event' );
851
+		return $this->get_first_related('Event');
852 852
 	}
853 853
 
854 854
 
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 	 */
861 861
 	public function update_sold() {
862 862
 		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
863
-			array( array(
863
+			array(array(
864 864
 				'STS_ID' 					=> EEM_Registration::status_id_approved,
865 865
 				'REG_deleted' 				=> 0,
866 866
 				'Ticket.Datetime.DTT_ID' 	=> $this->ID(),
867
-			) )
867
+			))
868 868
 		);
869
-		$this->set( 'DTT_sold', $count_regs_for_this_datetime );
869
+		$this->set('DTT_sold', $count_regs_for_this_datetime);
870 870
 		$this->save();
871 871
 		return $count_regs_for_this_datetime;
872 872
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Ticket.class.php 2 patches
Doc Comments   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
 	/**
180 180
 	 * Gets min
181
-	 * @return int
181
+	 * @return boolean
182 182
 	 */
183 183
 	function min() {
184 184
 		return $this->get( 'TKT_min' );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * This returns the chronologically last datetime that this ticket is associated with
221 221
 	 * @param string 	$dt_frmt
222 222
 	 * @param string 	$conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
223
-	 * @return array
223
+	 * @return string
224 224
 	 */
225 225
 	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
226 226
 		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	/**
362 362
 	 * Gets all the ticket applicabilities (ie, relations between datetimes and tickets)
363 363
 	 * @param array $query_params see EEM_Base::get_all()
364
-	 * @return EE_Datetime_Ticket
364
+	 * @return EE_Base_Class[]
365 365
 	 */
366 366
 	public function datetime_tickets( $query_params = array() ) {
367 367
 		return $this->get_many_related( 'Datetime_Ticket', $query_params );
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
 	/**
385 385
 	 * Gets ID
386
-	 * @return string
386
+	 * @return boolean
387 387
 	 */
388 388
 	function ID() {
389 389
 		return $this->get( 'TKT_ID' );
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 *
398 398
 	 * @since 4.5.0
399 399
 	 *
400
-	 * @return int
400
+	 * @return boolean
401 401
 	 */
402 402
 	public function wp_user() {
403 403
 		return $this->get('TKT_wp_user');
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	/**
496 496
 	 * Sets name
497 497
 	 * @param string $name
498
-	 * @return boolean
498
+	 * @return boolean|null
499 499
 	 */
500 500
 	function set_name( $name ) {
501 501
 		$this->set( 'TKT_name', $name );
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
 	/**
507 507
 	 * Gets description
508
-	 * @return string
508
+	 * @return boolean
509 509
 	 */
510 510
 	function description() {
511 511
 		return $this->get( 'TKT_description' );
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	/**
517 517
 	 * Sets description
518 518
 	 * @param string $description
519
-	 * @return boolean
519
+	 * @return boolean|null
520 520
 	 */
521 521
 	function set_description( $description ) {
522 522
 		$this->set( 'TKT_description', $description );
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	/**
587 587
 	 * Sets min
588 588
 	 * @param int $min
589
-	 * @return boolean
589
+	 * @return boolean|null
590 590
 	 */
591 591
 	function set_min( $min ) {
592 592
 		$this->set( 'TKT_min', $min );
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 
597 597
 	/**
598 598
 	 * Gets max
599
-	 * @return int
599
+	 * @return boolean
600 600
 	 */
601 601
 	function max() {
602 602
 		return $this->get( 'TKT_max' );
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	/**
608 608
 	 * Sets max
609 609
 	 * @param int $max
610
-	 * @return boolean
610
+	 * @return boolean|null
611 611
 	 */
612 612
 	function set_max( $max ) {
613 613
 		$this->set( 'TKT_max', $max );
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	/**
619 619
 	 * Sets price
620 620
 	 * @param float $price
621
-	 * @return boolean
621
+	 * @return boolean|null
622 622
 	 */
623 623
 	function set_price( $price ) {
624 624
 		$this->set( 'TKT_price', $price );
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	/**
640 640
 	 * Sets sold
641 641
 	 * @param int $sold
642
-	 * @return boolean
642
+	 * @return boolean|null
643 643
 	 */
644 644
 	function set_sold( $sold ) {
645 645
 		// sold can not go below zero
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	/**
653 653
 	 * increments sold by amount passed by $qty
654 654
 	 * @param int $qty
655
-	 * @return boolean
655
+	 * @return boolean|null
656 656
 	 */
657 657
 	function increase_sold( $qty = 1 ) {
658 658
 		$sold = $this->sold() + $qty;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 	/**
669 669
 	 * Increases sold on related datetimes
670 670
 	 * @param int $qty
671
-	 * @return boolean
671
+	 * @return boolean|null
672 672
 	 */
673 673
 	protected function _increase_sold_for_datetimes( $qty = 1 ) {
674 674
 		$datetimes = $this->datetimes();
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 	/**
688 688
 	 * decrements (subtracts) sold by amount passed by $qty
689 689
 	 * @param int $qty
690
-	 * @return boolean
690
+	 * @return boolean|null
691 691
 	 */
692 692
 	function decrease_sold( $qty = 1 ) {
693 693
 		$sold = $this->sold() - $qty;
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	* Decreases sold on related datetimes
702 702
 	*
703 703
 	* @param int $qty
704
-	* @return boolean
704
+	* @return boolean|null
705 705
 	*/
706 706
 	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
707 707
 		$datetimes = $this->datetimes();
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	/**
731 731
 	 * Sets reserved
732 732
 	 * @param int $reserved
733
-	 * @return boolean
733
+	 * @return boolean|null
734 734
 	 */
735 735
 	function set_reserved( $reserved ) {
736 736
 		// reserved can not go below zero
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 	/**
744 744
 	 * increments reserved by amount passed by $qty
745 745
 	 * @param int $qty
746
-	 * @return boolean
746
+	 * @return boolean|null
747 747
 	 */
748 748
 	function increase_reserved( $qty = 1 ) {
749 749
 		$qty = absint( $qty );
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 	 * Increases sold on related datetimes
759 759
 	 *
760 760
 	 * @param int $qty
761
-	 * @return boolean
761
+	 * @return boolean|null
762 762
 	 */
763 763
 	protected function _increase_reserved_for_datetimes( $qty = 1 ) {
764 764
 		$datetimes = $this->datetimes();
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	 *
780 780
 	 * @param int  $qty
781 781
 	 * @param bool $adjust_datetimes
782
-	 * @return bool
782
+	 * @return boolean|null
783 783
 	 */
784 784
 	function decrease_reserved( $qty = 1, $adjust_datetimes = true ) {
785 785
 		$reserved = $this->reserved() - absint( $qty );
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	 * Increases sold on related datetimes
796 796
 	 *
797 797
 	 * @param int $qty
798
-	 * @return boolean
798
+	 * @return boolean|null
799 799
 	 */
800 800
 	protected function _decrease_reserved_for_datetimes( $qty = 1 ) {
801 801
 		$datetimes = $this->datetimes();
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 	 * Sets qty - IMPORTANT!!! Does NOT allow QTY to be set higher than the lowest reg limit of any related datetimes
917 917
 	 *
918 918
 	 * @param int  $qty
919
-	 * @return bool
919
+	 * @return boolean|null
920 920
 	 * @throws \EE_Error
921 921
 	 */
922 922
 	function set_qty( $qty ) {
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 
934 934
 	/**
935 935
 	 * Gets uses
936
-	 * @return int
936
+	 * @return boolean
937 937
 	 */
938 938
 	function uses() {
939 939
 		return $this->get( 'TKT_uses' );
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	/**
945 945
 	 * Sets uses
946 946
 	 * @param int $uses
947
-	 * @return boolean
947
+	 * @return boolean|null
948 948
 	 */
949 949
 	function set_uses( $uses ) {
950 950
 		$this->set( 'TKT_uses', $uses );
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 	/**
966 966
 	 * sets the TKT_required property
967 967
 	 * @param boolean $required
968
-	 * @return boolean
968
+	 * @return boolean|null
969 969
 	 */
970 970
 	public function set_required( $required ) {
971 971
 		$this->set( 'TKT_required', $required );
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 	/**
987 987
 	 * Sets taxable
988 988
 	 * @param boolean $taxable
989
-	 * @return boolean
989
+	 * @return boolean|null
990 990
 	 */
991 991
 	function set_taxable( $taxable ) {
992 992
 		$this->set( 'TKT_taxable', $taxable );
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 	/**
1008 1008
 	 * Sets is_default
1009 1009
 	 * @param boolean $is_default
1010
-	 * @return boolean
1010
+	 * @return boolean|null
1011 1011
 	 */
1012 1012
 	function set_is_default( $is_default ) {
1013 1013
 		$this->set( 'TKT_is_default', $is_default );
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 
1018 1018
 	/**
1019 1019
 	 * Gets order
1020
-	 * @return int
1020
+	 * @return boolean
1021 1021
 	 */
1022 1022
 	function order() {
1023 1023
 		return $this->get( 'TKT_order' );
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 	/**
1029 1029
 	 * Sets order
1030 1030
 	 * @param int $order
1031
-	 * @return boolean
1031
+	 * @return boolean|null
1032 1032
 	 */
1033 1033
 	function set_order( $order ) {
1034 1034
 		$this->set( 'TKT_order', $order );
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 
1039 1039
 	/**
1040 1040
 	 * Gets row
1041
-	 * @return int
1041
+	 * @return boolean
1042 1042
 	 */
1043 1043
 	function row() {
1044 1044
 		return $this->get( 'TKT_row' );
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	/**
1050 1050
 	 * Sets row
1051 1051
 	 * @param int $row
1052
-	 * @return boolean
1052
+	 * @return boolean|null
1053 1053
 	 */
1054 1054
 	function set_row( $row ) {
1055 1055
 		$this->set( 'TKT_row', $row );
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	/**
1071 1071
 	 * Sets deleted
1072 1072
 	 * @param boolean $deleted
1073
-	 * @return boolean
1073
+	 * @return boolean|null
1074 1074
 	 */
1075 1075
 	function set_deleted( $deleted ) {
1076 1076
 		$this->set( 'TKT_deleted', $deleted );
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
 	/**
1082 1082
 	 * Gets parent
1083
-	 * @return int
1083
+	 * @return boolean
1084 1084
 	 */
1085 1085
 	function parent_ID() {
1086 1086
 		return $this->get( 'TKT_parent' );
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 	/**
1092 1092
 	 * Sets parent
1093 1093
 	 * @param int $parent
1094
-	 * @return boolean
1094
+	 * @return boolean|null
1095 1095
 	 */
1096 1096
 	function set_parent_ID( $parent ) {
1097 1097
 		$this->set( 'TKT_parent', $parent );
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 	/**
1117 1117
 	 * Gets name
1118
-	 * @return string
1118
+	 * @return boolean
1119 1119
 	 */
1120 1120
 	function name() {
1121 1121
 		return $this->get( 'TKT_name' );
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 
1126 1126
 	/**
1127 1127
 	 * Gets price
1128
-	 * @return float
1128
+	 * @return boolean
1129 1129
 	 */
1130 1130
 	function price() {
1131 1131
 		return $this->get( 'TKT_price' );
Please login to merge, or discard this patch.
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 *                             		    date_format and the second value is the time format
67 67
 	 * @return EE_Ticket
68 68
 	 */
69
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
70
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
71
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
69
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
70
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
71
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
72 72
 	}
73 73
 
74 74
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 *                          		the website will be used.
80 80
 	 * @return EE_Ticket
81 81
 	 */
82
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
83
-		return new self( $props_n_values, TRUE, $timezone );
82
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
83
+		return new self($props_n_values, TRUE, $timezone);
84 84
 	}
85 85
 
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return bool
90 90
 	 */
91 91
 	public function parent() {
92
-		return $this->get( 'TKT_parent' );
92
+		return $this->get('TKT_parent');
93 93
 	}
94 94
 
95 95
 
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @param  int $DTT_ID the primary key for a particular datetime
100 100
 	 * @return boolean
101 101
 	 */
102
-	public function available( $DTT_ID = 0 ) {
102
+	public function available($DTT_ID = 0) {
103 103
 		// are we checking availability for a particular datetime ?
104
-		if ( $DTT_ID ) {
104
+		if ($DTT_ID) {
105 105
 			// get that datetime object
106
-			$datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
106
+			$datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
107 107
 			// if  ticket sales for this datetime have exceeded the reg limit...
108
-			if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) {
108
+			if ($datetime instanceof EE_Datetime && $datetime->sold_out()) {
109 109
 				return FALSE;
110 110
 			}
111 111
 		}
@@ -121,22 +121,22 @@  discard block
 block discarded – undo
121 121
 	 * @param bool | null $remaining  if it is already known that tickets are available, then simply pass a bool to save further processing
122 122
 	 * @return mixed status int if the display string isn't requested
123 123
 	 */
124
-	public function ticket_status( $display = FALSE, $remaining = null ) {
125
-		$remaining = is_bool( $remaining ) ? $remaining : $this->is_remaining();
126
-		if ( ! $remaining ) {
127
-			return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out;
124
+	public function ticket_status($display = FALSE, $remaining = null) {
125
+		$remaining = is_bool($remaining) ? $remaining : $this->is_remaining();
126
+		if ( ! $remaining) {
127
+			return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out;
128 128
 		}
129
-		if ( $this->get( 'TKT_deleted' ) ) {
130
-			return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived;
129
+		if ($this->get('TKT_deleted')) {
130
+			return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived;
131 131
 		}
132
-		if ( $this->is_expired() ) {
133
-			return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired;
132
+		if ($this->is_expired()) {
133
+			return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired;
134 134
 		}
135
-		if ( $this->is_pending() ) {
136
-			return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending;
135
+		if ($this->is_pending()) {
136
+			return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending;
137 137
 		}
138
-		if ( $this->is_on_sale() ) {
139
-			return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale;
138
+		if ($this->is_on_sale()) {
139
+			return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale;
140 140
 		}
141 141
 		return '';
142 142
 	}
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 	 * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
151 151
 	 * @return boolean         true = tickets remaining, false not.
152 152
 	 */
153
-	public function is_remaining( $DTT_ID = 0 ) {
154
-		$num_remaining = $this->remaining( $DTT_ID );
155
-		if ( $num_remaining === 0 ) {
153
+	public function is_remaining($DTT_ID = 0) {
154
+		$num_remaining = $this->remaining($DTT_ID);
155
+		if ($num_remaining === 0) {
156 156
 			return FALSE;
157 157
 		}
158
-		if ( $num_remaining > 0 && $num_remaining < $this->min() ) {
158
+		if ($num_remaining > 0 && $num_remaining < $this->min()) {
159 159
 			return FALSE;
160 160
 		}
161 161
 		return TRUE;
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 *                     set to 0 for all related datetimes
171 171
 	 * @return int
172 172
 	 */
173
-	public function remaining( $DTT_ID = 0 ) {
174
-		return $this->real_quantity_on_ticket('saleable', $DTT_ID );
173
+	public function remaining($DTT_ID = 0) {
174
+		return $this->real_quantity_on_ticket('saleable', $DTT_ID);
175 175
 	}
176 176
 
177 177
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return int
182 182
 	 */
183 183
 	function min() {
184
-		return $this->get( 'TKT_min' );
184
+		return $this->get('TKT_min');
185 185
 	}
186 186
 
187 187
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @return boolean
192 192
 	 */
193 193
 	public function is_expired() {
194
-		return ( $this->get_raw( 'TKT_end_date' ) < time() );
194
+		return ($this->get_raw('TKT_end_date') < time());
195 195
 	}
196 196
 
197 197
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @return boolean
202 202
 	 */
203 203
 	public function is_pending() {
204
-		return ( $this->get_raw( 'TKT_start_date' ) > time() );
204
+		return ($this->get_raw('TKT_start_date') > time());
205 205
 	}
206 206
 
207 207
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 * @return boolean
212 212
 	 */
213 213
 	public function is_on_sale() {
214
-		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
214
+		return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time());
215 215
 	}
216 216
 
217 217
 
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 * @param string 	$conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
223 223
 	 * @return array
224 224
 	 */
225
-	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
226
-		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
227
-		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
225
+	public function date_range($dt_frmt = '', $conjunction = ' - ') {
226
+		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : '';
227
+		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : '';
228 228
 
229
-		return $first_date && $last_date ? $first_date . $conjunction  . $last_date : '';
229
+		return $first_date && $last_date ? $first_date.$conjunction.$last_date : '';
230 230
 	}
231 231
 
232 232
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * @return EE_Datetime
237 237
 	 */
238 238
 	public function first_datetime() {
239
-		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
240
-		return reset( $datetimes );
239
+		$datetimes = $this->datetimes(array('limit' => 1));
240
+		return reset($datetimes);
241 241
 	}
242 242
 
243 243
 
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 	 * @param array $query_params see EEM_Base::get_all()
249 249
 	 * @return EE_Datetime[]
250 250
 	 */
251
-	public function datetimes( $query_params = array() ) {
252
-		if ( ! isset( $query_params[ 'order_by' ] ) ) {
253
-			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
251
+	public function datetimes($query_params = array()) {
252
+		if ( ! isset($query_params['order_by'])) {
253
+			$query_params['order_by']['DTT_order'] = 'ASC';
254 254
 		}
255
-		return $this->get_many_related( 'Datetime', $query_params );
255
+		return $this->get_many_related('Datetime', $query_params);
256 256
 	}
257 257
 
258 258
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * @return EE_Datetime
263 263
 	 */
264 264
 	public function last_datetime() {
265
-		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
266
-		return end( $datetimes );
265
+		$datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC')));
266
+		return end($datetimes);
267 267
 	}
268 268
 
269 269
 
@@ -277,22 +277,22 @@  discard block
 block discarded – undo
277 277
 	 * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
278 278
 	 * @return mixed (array|int)          how many tickets have sold
279 279
 	 */
280
-	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
280
+	public function tickets_sold($what = 'ticket', $dtt_id = NULL) {
281 281
 		$total = 0;
282 282
 		$tickets_sold = $this->_all_tickets_sold();
283
-		switch ( $what ) {
283
+		switch ($what) {
284 284
 			case 'ticket' :
285
-				return $tickets_sold[ 'ticket' ];
285
+				return $tickets_sold['ticket'];
286 286
 				break;
287 287
 			case 'datetime' :
288
-				if ( empty( $tickets_sold[ 'datetime' ] ) ) {
288
+				if (empty($tickets_sold['datetime'])) {
289 289
 					return $total;
290 290
 				}
291
-				if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) {
292
-					EE_Error::add_error( __( "You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
291
+				if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) {
292
+					EE_Error::add_error(__("You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
293 293
 					return $total;
294 294
 				}
295
-				return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ];
295
+				return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id];
296 296
 				break;
297 297
 			default:
298 298
 				return $total;
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
 	 * @return EE_Ticket[]
307 307
 	 */
308 308
 	protected function _all_tickets_sold() {
309
-		$datetimes = $this->get_many_related( 'Datetime' );
309
+		$datetimes = $this->get_many_related('Datetime');
310 310
 		$tickets_sold = array();
311
-		if ( ! empty( $datetimes ) ) {
312
-			foreach ( $datetimes as $datetime ) {
313
-				$tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' );
311
+		if ( ! empty($datetimes)) {
312
+			foreach ($datetimes as $datetime) {
313
+				$tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold');
314 314
 			}
315 315
 		}
316 316
 		//Tickets sold
317
-		$tickets_sold[ 'ticket' ] = $this->sold();
317
+		$tickets_sold['ticket'] = $this->sold();
318 318
 		return $tickets_sold;
319 319
 	}
320 320
 
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 	 * @param  bool $return_array whether to return as an array indexed by price id or just the object.
328 328
 	 * @return EE_Price
329 329
 	 */
330
-	public function base_price( $return_array = FALSE ) {
331
-		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
332
-		return $return_array ? $this->get_many_related( 'Price', array( $_where ) ) : $this->get_first_related( 'Price', array( $_where ) );
330
+	public function base_price($return_array = FALSE) {
331
+		$_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price);
332
+		return $return_array ? $this->get_many_related('Price', array($_where)) : $this->get_first_related('Price', array($_where));
333 333
 	}
334 334
 
335 335
 
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 * @return EE_Price[]
342 342
 	 */
343 343
 	public function price_modifiers() {
344
-		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
345
-		return $this->prices( $query_params );
344
+		$query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax))));
345
+		return $this->prices($query_params);
346 346
 	}
347 347
 
348 348
 
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 * @param array $query_params like EEM_Base::get_all
353 353
 	 * @return EE_Price[]
354 354
 	 */
355
-	public function prices( $query_params = array() ) {
356
-		return $this->get_many_related( 'Price', $query_params );
355
+	public function prices($query_params = array()) {
356
+		return $this->get_many_related('Price', $query_params);
357 357
 	}
358 358
 
359 359
 
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	 * @param array $query_params see EEM_Base::get_all()
364 364
 	 * @return EE_Datetime_Ticket
365 365
 	 */
366
-	public function datetime_tickets( $query_params = array() ) {
367
-		return $this->get_many_related( 'Datetime_Ticket', $query_params );
366
+	public function datetime_tickets($query_params = array()) {
367
+		return $this->get_many_related('Datetime_Ticket', $query_params);
368 368
 	}
369 369
 
370 370
 
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param boolean $show_deleted
376 376
 	 * @return EE_Datetime[]
377 377
 	 */
378
-	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
379
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
378
+	public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) {
379
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted);
380 380
 	}
381 381
 
382 382
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * @return string
387 387
 	 */
388 388
 	function ID() {
389
-		return $this->get( 'TKT_ID' );
389
+		return $this->get('TKT_ID');
390 390
 	}
391 391
 
392 392
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @return EE_Ticket_Template
411 411
 	 */
412 412
 	public function template() {
413
-		return $this->get_first_related( 'Ticket_Template' );
413
+		return $this->get_first_related('Ticket_Template');
414 414
 	}
415 415
 
416 416
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @return bool
430 430
 	 */
431 431
 	public function ticket_price() {
432
-		return $this->get( 'TKT_price' );
432
+		return $this->get('TKT_price');
433 433
 	}
434 434
 
435 435
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	 * @return mixed
439 439
 	 */
440 440
 	public function pretty_price() {
441
-		return $this->get_pretty( 'TKT_price' );
441
+		return $this->get_pretty('TKT_price');
442 442
 	}
443 443
 
444 444
 
@@ -457,17 +457,17 @@  discard block
 block discarded – undo
457 457
 	 * @param bool $no_cache
458 458
 	 * @return float
459 459
 	 */
460
-	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
461
-		if ( ! isset( $this->_ticket_total_with_taxes ) || $no_cache ) {
460
+	public function get_ticket_total_with_taxes($no_cache = FALSE) {
461
+		if ( ! isset($this->_ticket_total_with_taxes) || $no_cache) {
462 462
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
463 463
 		}
464
-		return (float)$this->_ticket_total_with_taxes;
464
+		return (float) $this->_ticket_total_with_taxes;
465 465
 	}
466 466
 
467 467
 
468 468
 
469 469
 	public function ensure_TKT_Price_correct() {
470
-		$this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) );
470
+		$this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this));
471 471
 		$this->save();
472 472
 	}
473 473
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return float
478 478
 	 */
479 479
 	public function get_ticket_subtotal() {
480
-		return EE_Taxes::get_subtotal_for_admin( $this );
480
+		return EE_Taxes::get_subtotal_for_admin($this);
481 481
 	}
482 482
 
483 483
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	 * @return float
488 488
 	 */
489 489
 	public function get_ticket_taxes_total_for_admin() {
490
-		return EE_Taxes::get_total_taxes_for_admin( $this );
490
+		return EE_Taxes::get_total_taxes_for_admin($this);
491 491
 	}
492 492
 
493 493
 
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
 	 * @param string $name
498 498
 	 * @return boolean
499 499
 	 */
500
-	function set_name( $name ) {
501
-		$this->set( 'TKT_name', $name );
500
+	function set_name($name) {
501
+		$this->set('TKT_name', $name);
502 502
 	}
503 503
 
504 504
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 	 * @return string
509 509
 	 */
510 510
 	function description() {
511
-		return $this->get( 'TKT_description' );
511
+		return $this->get('TKT_description');
512 512
 	}
513 513
 
514 514
 
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 	 * @param string $description
519 519
 	 * @return boolean
520 520
 	 */
521
-	function set_description( $description ) {
522
-		$this->set( 'TKT_description', $description );
521
+	function set_description($description) {
522
+		$this->set('TKT_description', $description);
523 523
 	}
524 524
 
525 525
 
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
 	 * @param string $tm_frmt
531 531
 	 * @return string
532 532
 	 */
533
-	function start_date( $dt_frmt = '', $tm_frmt = '' ) {
534
-		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
533
+	function start_date($dt_frmt = '', $tm_frmt = '') {
534
+		return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt);
535 535
 	}
536 536
 
537 537
 
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 	 * @param string $start_date
542 542
 	 * @return void
543 543
 	 */
544
-	function set_start_date( $start_date ) {
545
-		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
544
+	function set_start_date($start_date) {
545
+		$this->_set_date_time('B', $start_date, 'TKT_start_date');
546 546
 	}
547 547
 
548 548
 
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 	 * @param string $tm_frmt
554 554
 	 * @return string
555 555
 	 */
556
-	function end_date( $dt_frmt = '', $tm_frmt = '' ) {
557
-		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
556
+	function end_date($dt_frmt = '', $tm_frmt = '') {
557
+		return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt);
558 558
 	}
559 559
 
560 560
 
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
 	 * @param string $end_date
565 565
 	 * @return void
566 566
 	 */
567
-	function set_end_date( $end_date ) {
568
-		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
567
+	function set_end_date($end_date) {
568
+		$this->_set_date_time('B', $end_date, 'TKT_end_date');
569 569
 	}
570 570
 
571 571
 
@@ -577,8 +577,8 @@  discard block
 block discarded – undo
577 577
 	 *
578 578
 	 * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
579 579
 	 */
580
-	function set_end_time( $time ) {
581
-		$this->_set_time_for( $time, 'TKT_end_date' );
580
+	function set_end_time($time) {
581
+		$this->_set_time_for($time, 'TKT_end_date');
582 582
 	}
583 583
 
584 584
 
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 	 * @param int $min
589 589
 	 * @return boolean
590 590
 	 */
591
-	function set_min( $min ) {
592
-		$this->set( 'TKT_min', $min );
591
+	function set_min($min) {
592
+		$this->set('TKT_min', $min);
593 593
 	}
594 594
 
595 595
 
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	 * @return int
600 600
 	 */
601 601
 	function max() {
602
-		return $this->get( 'TKT_max' );
602
+		return $this->get('TKT_max');
603 603
 	}
604 604
 
605 605
 
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	 * @param int $max
610 610
 	 * @return boolean
611 611
 	 */
612
-	function set_max( $max ) {
613
-		$this->set( 'TKT_max', $max );
612
+	function set_max($max) {
613
+		$this->set('TKT_max', $max);
614 614
 	}
615 615
 
616 616
 
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
 	 * @param float $price
621 621
 	 * @return boolean
622 622
 	 */
623
-	function set_price( $price ) {
624
-		$this->set( 'TKT_price', $price );
623
+	function set_price($price) {
624
+		$this->set('TKT_price', $price);
625 625
 	}
626 626
 
627 627
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	 * @return int
632 632
 	 */
633 633
 	function sold() {
634
-		return $this->get_raw( 'TKT_sold' );
634
+		return $this->get_raw('TKT_sold');
635 635
 	}
636 636
 
637 637
 
@@ -641,10 +641,10 @@  discard block
 block discarded – undo
641 641
 	 * @param int $sold
642 642
 	 * @return boolean
643 643
 	 */
644
-	function set_sold( $sold ) {
644
+	function set_sold($sold) {
645 645
 		// sold can not go below zero
646
-		$sold = max( 0, $sold );
647
-		$this->set( 'TKT_sold', $sold );
646
+		$sold = max(0, $sold);
647
+		$this->set('TKT_sold', $sold);
648 648
 	}
649 649
 
650 650
 
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 	 * @param int $qty
655 655
 	 * @return boolean
656 656
 	 */
657
-	function increase_sold( $qty = 1 ) {
657
+	function increase_sold($qty = 1) {
658 658
 		$sold = $this->sold() + $qty;
659 659
 		// remove ticket reservation, but don't adjust datetime reservations,  because that will happen
660 660
 		// via \EE_Datetime::increase_sold() when \EE_Ticket::_increase_sold_for_datetimes() is called
661
-		$this->decrease_reserved( $qty, false );
662
-		$this->_increase_sold_for_datetimes( $qty );
663
-		return $this->set_sold( $sold );
661
+		$this->decrease_reserved($qty, false);
662
+		$this->_increase_sold_for_datetimes($qty);
663
+		return $this->set_sold($sold);
664 664
 	}
665 665
 
666 666
 
@@ -670,12 +670,12 @@  discard block
 block discarded – undo
670 670
 	 * @param int $qty
671 671
 	 * @return boolean
672 672
 	 */
673
-	protected function _increase_sold_for_datetimes( $qty = 1 ) {
673
+	protected function _increase_sold_for_datetimes($qty = 1) {
674 674
 		$datetimes = $this->datetimes();
675
-		if ( is_array( $datetimes ) ) {
676
-			foreach ( $datetimes as $datetime ) {
677
-				if ( $datetime instanceof EE_Datetime ) {
678
-					$datetime->increase_sold( $qty );
675
+		if (is_array($datetimes)) {
676
+			foreach ($datetimes as $datetime) {
677
+				if ($datetime instanceof EE_Datetime) {
678
+					$datetime->increase_sold($qty);
679 679
 					$datetime->save();
680 680
 				}
681 681
 			}
@@ -689,10 +689,10 @@  discard block
 block discarded – undo
689 689
 	 * @param int $qty
690 690
 	 * @return boolean
691 691
 	 */
692
-	function decrease_sold( $qty = 1 ) {
692
+	function decrease_sold($qty = 1) {
693 693
 		$sold = $this->sold() - $qty;
694
-		$this->_decrease_sold_for_datetimes( $qty );
695
-		return $this->set_sold( $sold );
694
+		$this->_decrease_sold_for_datetimes($qty);
695
+		return $this->set_sold($sold);
696 696
 	}
697 697
 
698 698
 
@@ -703,12 +703,12 @@  discard block
 block discarded – undo
703 703
 	* @param int $qty
704 704
 	* @return boolean
705 705
 	*/
706
-	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
706
+	protected function _decrease_sold_for_datetimes($qty = 1) {
707 707
 		$datetimes = $this->datetimes();
708
-		if ( is_array( $datetimes ) ) {
709
-			foreach ( $datetimes as $datetime ) {
710
-				if ( $datetime instanceof EE_Datetime ) {
711
-					$datetime->decrease_sold( $qty );
708
+		if (is_array($datetimes)) {
709
+			foreach ($datetimes as $datetime) {
710
+				if ($datetime instanceof EE_Datetime) {
711
+					$datetime->decrease_sold($qty);
712 712
 					$datetime->save();
713 713
 				}
714 714
 			}
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 * @return int
723 723
 	 */
724 724
 	function reserved() {
725
-		return $this->get_raw( 'TKT_reserved' );
725
+		return $this->get_raw('TKT_reserved');
726 726
 	}
727 727
 
728 728
 
@@ -732,10 +732,10 @@  discard block
 block discarded – undo
732 732
 	 * @param int $reserved
733 733
 	 * @return boolean
734 734
 	 */
735
-	function set_reserved( $reserved ) {
735
+	function set_reserved($reserved) {
736 736
 		// reserved can not go below zero
737
-		$reserved = max( 0, intval( $reserved ) );
738
-		$this->set( 'TKT_reserved', $reserved );
737
+		$reserved = max(0, intval($reserved));
738
+		$this->set('TKT_reserved', $reserved);
739 739
 	}
740 740
 
741 741
 
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 	 * @param int $qty
746 746
 	 * @return boolean
747 747
 	 */
748
-	function increase_reserved( $qty = 1 ) {
749
-		$qty = absint( $qty );
748
+	function increase_reserved($qty = 1) {
749
+		$qty = absint($qty);
750 750
 		$reserved = $this->reserved() + $qty;
751
-		$this->_increase_reserved_for_datetimes( $qty );
752
-		return $this->set_reserved( $reserved );
751
+		$this->_increase_reserved_for_datetimes($qty);
752
+		return $this->set_reserved($reserved);
753 753
 	}
754 754
 
755 755
 
@@ -760,12 +760,12 @@  discard block
 block discarded – undo
760 760
 	 * @param int $qty
761 761
 	 * @return boolean
762 762
 	 */
763
-	protected function _increase_reserved_for_datetimes( $qty = 1 ) {
763
+	protected function _increase_reserved_for_datetimes($qty = 1) {
764 764
 		$datetimes = $this->datetimes();
765
-		if ( is_array( $datetimes ) ) {
766
-			foreach ( $datetimes as $datetime ) {
767
-				if ( $datetime instanceof EE_Datetime ) {
768
-					$datetime->increase_reserved( $qty );
765
+		if (is_array($datetimes)) {
766
+			foreach ($datetimes as $datetime) {
767
+				if ($datetime instanceof EE_Datetime) {
768
+					$datetime->increase_reserved($qty);
769 769
 					$datetime->save();
770 770
 				}
771 771
 			}
@@ -781,12 +781,12 @@  discard block
 block discarded – undo
781 781
 	 * @param bool $adjust_datetimes
782 782
 	 * @return bool
783 783
 	 */
784
-	function decrease_reserved( $qty = 1, $adjust_datetimes = true ) {
785
-		$reserved = $this->reserved() - absint( $qty );
786
-		if ( $adjust_datetimes ) {
787
-			$this->_decrease_reserved_for_datetimes( $qty );
784
+	function decrease_reserved($qty = 1, $adjust_datetimes = true) {
785
+		$reserved = $this->reserved() - absint($qty);
786
+		if ($adjust_datetimes) {
787
+			$this->_decrease_reserved_for_datetimes($qty);
788 788
 		}
789
-		return $this->set_reserved( $reserved );
789
+		return $this->set_reserved($reserved);
790 790
 	}
791 791
 
792 792
 
@@ -797,12 +797,12 @@  discard block
 block discarded – undo
797 797
 	 * @param int $qty
798 798
 	 * @return boolean
799 799
 	 */
800
-	protected function _decrease_reserved_for_datetimes( $qty = 1 ) {
800
+	protected function _decrease_reserved_for_datetimes($qty = 1) {
801 801
 		$datetimes = $this->datetimes();
802
-		if ( is_array( $datetimes ) ) {
803
-			foreach ( $datetimes as $datetime ) {
804
-				if ( $datetime instanceof EE_Datetime ) {
805
-					$datetime->decrease_reserved( $qty );
802
+		if (is_array($datetimes)) {
803
+			foreach ($datetimes as $datetime) {
804
+				if ($datetime instanceof EE_Datetime) {
805
+					$datetime->decrease_reserved($qty);
806 806
 					$datetime->save();
807 807
 				}
808 808
 			}
@@ -823,14 +823,14 @@  discard block
 block discarded – undo
823 823
 	 *
824 824
 	 * @return int
825 825
 	 */
826
-	function qty( $context = '' ) {
827
-		switch ( $context ) {
826
+	function qty($context = '') {
827
+		switch ($context) {
828 828
 			case 'reg_limit' :
829 829
 				return $this->real_quantity_on_ticket();
830 830
 			case 'saleable' :
831
-				return $this->real_quantity_on_ticket( 'saleable' );
831
+				return $this->real_quantity_on_ticket('saleable');
832 832
 			default:
833
-				return $this->get_raw( 'TKT_qty' );
833
+				return $this->get_raw('TKT_qty');
834 834
 		}
835 835
 	}
836 836
 
@@ -849,15 +849,15 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return int
851 851
 	 */
852
-	function real_quantity_on_ticket( $context = 'reg_limit', $DTT_ID = 0 ) {
853
-		$raw = $this->get_raw( 'TKT_qty' );
852
+	function real_quantity_on_ticket($context = 'reg_limit', $DTT_ID = 0) {
853
+		$raw = $this->get_raw('TKT_qty');
854 854
 		// return immediately if it's zero
855
-		if ( $raw === 0 ) {
855
+		if ($raw === 0) {
856 856
 			return $raw;
857 857
 		}
858 858
 		//echo "\n\n<br />Ticket: " . $this->name() . '<br />';
859 859
 		// ensure qty doesn't exceed raw value for THIS ticket
860
-		$qty = min( EE_INF, $raw );
860
+		$qty = min(EE_INF, $raw);
861 861
 		//echo "\n . qty: " . $qty . '<br />';
862 862
 		// calculate this ticket's total sales and reservations
863 863
 		$sold_and_reserved_for_this_ticket = $this->sold() + $this->reserved();
@@ -866,23 +866,23 @@  discard block
 block discarded – undo
866 866
 		//echo "\n . sold_and_reserved_for_this_ticket: " . $sold_and_reserved_for_this_ticket . '<br />';
867 867
 		// first we need to calculate the maximum number of tickets available for the datetime
868 868
 		// do we want data for one datetime or all of them ?
869
-		$query_params = $DTT_ID ? array( array( 'DTT_ID' => $DTT_ID ) ) : array();
870
-		$datetimes = $this->datetimes( $query_params );
871
-		if ( is_array( $datetimes ) && ! empty( $datetimes ) ) {
872
-			foreach ( $datetimes as $datetime ) {
873
-				if ( $datetime instanceof EE_Datetime ) {
869
+		$query_params = $DTT_ID ? array(array('DTT_ID' => $DTT_ID)) : array();
870
+		$datetimes = $this->datetimes($query_params);
871
+		if (is_array($datetimes) && ! empty($datetimes)) {
872
+			foreach ($datetimes as $datetime) {
873
+				if ($datetime instanceof EE_Datetime) {
874 874
 					$datetime->refresh_from_db();
875 875
 					//echo "\n . . datetime name: " . $datetime->name() . '<br />';
876 876
 					//echo "\n . . datetime ID: " . $datetime->ID() . '<br />';
877 877
 					// initialize with no restrictions for each datetime
878 878
 					// but adjust datetime qty based on datetime reg limit
879
-					$datetime_qty = min( EE_INF, $datetime->reg_limit() );
879
+					$datetime_qty = min(EE_INF, $datetime->reg_limit());
880 880
 					//echo "\n . . . datetime reg_limit: " . $datetime->reg_limit() . '<br />';
881 881
 					//echo "\n . . . datetime_qty: " . $datetime_qty . '<br />';
882 882
 					// if we want the actual saleable amount, then we need to consider OTHER ticket sales
883 883
 					// and reservations for this datetime, that do NOT include sales and reservations
884 884
 					// for this ticket (so we add $this->sold() and $this->reserved() back in)
885
-					if ( $context == 'saleable' ) {
885
+					if ($context == 'saleable') {
886 886
 						$datetime_qty = max(
887 887
 							$datetime_qty - $datetime->sold_and_reserved() + $sold_and_reserved_for_this_ticket,
888 888
 							0
@@ -894,16 +894,16 @@  discard block
 block discarded – undo
894 894
 						$datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0;
895 895
 						//echo "\n . . . datetime_qty: " . $datetime_qty . '<br />';
896 896
 					}
897
-					$qty = min( $datetime_qty, $qty );
897
+					$qty = min($datetime_qty, $qty);
898 898
 					//echo "\n . . qty: " . $qty . '<br />';
899 899
 				}
900 900
 			}
901 901
 		}
902 902
 		// NOW that we know the  maximum number of tickets available for the datetime
903 903
 		// we can finally factor in the details for this specific ticket
904
-		if ( $qty > 0 && $context == 'saleable' ) {
904
+		if ($qty > 0 && $context == 'saleable') {
905 905
 			// and subtract the sales for THIS ticket
906
-			$qty = max( $qty - $sold_and_reserved_for_this_ticket, 0 );
906
+			$qty = max($qty - $sold_and_reserved_for_this_ticket, 0);
907 907
 			//echo "\n . qty: " . $qty . '<br />';
908 908
 		}
909 909
 		//echo "\nFINAL QTY: " . $qty . "<br /><br />";
@@ -919,14 +919,14 @@  discard block
 block discarded – undo
919 919
 	 * @return bool
920 920
 	 * @throws \EE_Error
921 921
 	 */
922
-	function set_qty( $qty ) {
922
+	function set_qty($qty) {
923 923
 		$datetimes = $this->datetimes();
924
-		foreach ( $datetimes as $datetime ) {
925
-			if ( $datetime instanceof EE_Datetime ) {
926
-				$qty = min( $qty, $datetime->reg_limit() );
924
+		foreach ($datetimes as $datetime) {
925
+			if ($datetime instanceof EE_Datetime) {
926
+				$qty = min($qty, $datetime->reg_limit());
927 927
 			}
928 928
 		}
929
-		$this->set( 'TKT_qty', $qty );
929
+		$this->set('TKT_qty', $qty);
930 930
 	}
931 931
 
932 932
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	 * @return int
937 937
 	 */
938 938
 	function uses() {
939
-		return $this->get( 'TKT_uses' );
939
+		return $this->get('TKT_uses');
940 940
 	}
941 941
 
942 942
 
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @param int $uses
947 947
 	 * @return boolean
948 948
 	 */
949
-	function set_uses( $uses ) {
950
-		$this->set( 'TKT_uses', $uses );
949
+	function set_uses($uses) {
950
+		$this->set('TKT_uses', $uses);
951 951
 	}
952 952
 
953 953
 
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 	 * @return boolean
958 958
 	 */
959 959
 	public function required() {
960
-		return $this->get( 'TKT_required' );
960
+		return $this->get('TKT_required');
961 961
 	}
962 962
 
963 963
 
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 	 * @param boolean $required
968 968
 	 * @return boolean
969 969
 	 */
970
-	public function set_required( $required ) {
971
-		$this->set( 'TKT_required', $required );
970
+	public function set_required($required) {
971
+		$this->set('TKT_required', $required);
972 972
 	}
973 973
 
974 974
 
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 	 * @return boolean
979 979
 	 */
980 980
 	function taxable() {
981
-		return $this->get( 'TKT_taxable' );
981
+		return $this->get('TKT_taxable');
982 982
 	}
983 983
 
984 984
 
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
 	 * @param boolean $taxable
989 989
 	 * @return boolean
990 990
 	 */
991
-	function set_taxable( $taxable ) {
992
-		$this->set( 'TKT_taxable', $taxable );
991
+	function set_taxable($taxable) {
992
+		$this->set('TKT_taxable', $taxable);
993 993
 	}
994 994
 
995 995
 
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 	 * @return boolean
1000 1000
 	 */
1001 1001
 	function is_default() {
1002
-		return $this->get( 'TKT_is_default' );
1002
+		return $this->get('TKT_is_default');
1003 1003
 	}
1004 1004
 
1005 1005
 
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @param boolean $is_default
1010 1010
 	 * @return boolean
1011 1011
 	 */
1012
-	function set_is_default( $is_default ) {
1013
-		$this->set( 'TKT_is_default', $is_default );
1012
+	function set_is_default($is_default) {
1013
+		$this->set('TKT_is_default', $is_default);
1014 1014
 	}
1015 1015
 
1016 1016
 
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 	 * @return int
1021 1021
 	 */
1022 1022
 	function order() {
1023
-		return $this->get( 'TKT_order' );
1023
+		return $this->get('TKT_order');
1024 1024
 	}
1025 1025
 
1026 1026
 
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
 	 * @param int $order
1031 1031
 	 * @return boolean
1032 1032
 	 */
1033
-	function set_order( $order ) {
1034
-		$this->set( 'TKT_order', $order );
1033
+	function set_order($order) {
1034
+		$this->set('TKT_order', $order);
1035 1035
 	}
1036 1036
 
1037 1037
 
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 	 * @return int
1042 1042
 	 */
1043 1043
 	function row() {
1044
-		return $this->get( 'TKT_row' );
1044
+		return $this->get('TKT_row');
1045 1045
 	}
1046 1046
 
1047 1047
 
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @param int $row
1052 1052
 	 * @return boolean
1053 1053
 	 */
1054
-	function set_row( $row ) {
1055
-		$this->set( 'TKT_row', $row );
1054
+	function set_row($row) {
1055
+		$this->set('TKT_row', $row);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 	 * @return boolean
1063 1063
 	 */
1064 1064
 	function deleted() {
1065
-		return $this->get( 'TKT_deleted' );
1065
+		return $this->get('TKT_deleted');
1066 1066
 	}
1067 1067
 
1068 1068
 
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
 	 * @param boolean $deleted
1073 1073
 	 * @return boolean
1074 1074
 	 */
1075
-	function set_deleted( $deleted ) {
1076
-		$this->set( 'TKT_deleted', $deleted );
1075
+	function set_deleted($deleted) {
1076
+		$this->set('TKT_deleted', $deleted);
1077 1077
 	}
1078 1078
 
1079 1079
 
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 	 * @return int
1084 1084
 	 */
1085 1085
 	function parent_ID() {
1086
-		return $this->get( 'TKT_parent' );
1086
+		return $this->get('TKT_parent');
1087 1087
 	}
1088 1088
 
1089 1089
 
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	 * @param int $parent
1094 1094
 	 * @return boolean
1095 1095
 	 */
1096
-	function set_parent_ID( $parent ) {
1097
-		$this->set( 'TKT_parent', $parent );
1096
+	function set_parent_ID($parent) {
1097
+		$this->set('TKT_parent', $parent);
1098 1098
 	}
1099 1099
 
1100 1100
 
@@ -1105,10 +1105,10 @@  discard block
 block discarded – undo
1105 1105
 	 */
1106 1106
 	function name_and_info() {
1107 1107
 		$times = array();
1108
-		foreach ( $this->datetimes() as $datetime ) {
1108
+		foreach ($this->datetimes() as $datetime) {
1109 1109
 			$times[] = $datetime->start_date_and_time();
1110 1110
 		}
1111
-		return $this->name() . " @ " . implode( ", ", $times ) . " for " . $this->price();
1111
+		return $this->name()." @ ".implode(", ", $times)." for ".$this->price();
1112 1112
 	}
1113 1113
 
1114 1114
 
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 	 * @return string
1119 1119
 	 */
1120 1120
 	function name() {
1121
-		return $this->get( 'TKT_name' );
1121
+		return $this->get('TKT_name');
1122 1122
 	}
1123 1123
 
1124 1124
 
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 	 * @return float
1129 1129
 	 */
1130 1130
 	function price() {
1131
-		return $this->get( 'TKT_price' );
1131
+		return $this->get('TKT_price');
1132 1132
 	}
1133 1133
 
1134 1134
 
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 	 * @param array $query_params like EEM_Base::get_all's
1139 1139
 	 * @return EE_Registration[]
1140 1140
 	 */
1141
-	public function registrations( $query_params = array() ) {
1142
-		return $this->get_many_related( 'Registration', $query_params );
1141
+	public function registrations($query_params = array()) {
1142
+		return $this->get_many_related('Registration', $query_params);
1143 1143
 	}
1144 1144
 
1145 1145
 
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
 	 * @return int
1151 1151
 	 */
1152 1152
 	public function update_tickets_sold() {
1153
-		$count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) );
1154
-		$this->set_sold( $count_regs_for_this_ticket );
1153
+		$count_regs_for_this_ticket = $this->count_registrations(array(array('STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0)));
1154
+		$this->set_sold($count_regs_for_this_ticket);
1155 1155
 		$this->save();
1156 1156
 		return $count_regs_for_this_ticket;
1157 1157
 	}
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 	 * @param array $query_params like EEM_Base::get_all's
1164 1164
 	 * @return int
1165 1165
 	 */
1166
-	public function count_registrations( $query_params = array() ) {
1166
+	public function count_registrations($query_params = array()) {
1167 1167
 		return $this->count_related('Registration', $query_params);
1168 1168
 	}
1169 1169
 
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 	public function get_related_event() {
1189 1189
 		//get one datetime to use for getting the event
1190 1190
 		$datetime = $this->first_datetime();
1191
-		if ( $datetime instanceof EE_Datetime ) {
1191
+		if ($datetime instanceof EE_Datetime) {
1192 1192
 			return $datetime->event();
1193 1193
 		}
1194 1194
 		return null;
Please login to merge, or discard this patch.
modules/ticket_sales_monitor/EED_Ticket_Sales_Monitor.module.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @access 	protected
228 228
 	 * @param 	\EE_Ticket   $ticket
229
-	 * @return 	bool
229
+	 * @return 	boolean|null
230 230
 	 * @throws \EE_Error
231 231
 	 */
232 232
 	protected function _ticket_sold_out( EE_Ticket $ticket ) {
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @access    protected
247 247
 	 * @param    \EE_Ticket $ticket
248
-	 * @return bool
248
+	 * @return boolean|null
249 249
 	 */
250 250
 	protected function _ticket_quantity_decremented( EE_Ticket $ticket ) {
251 251
 		if ( self::debug ) {
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EED_Ticket_Sales_Monitor
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class EED_Ticket_Sales_Monitor extends EED_Module {
19 19
 
20
-	const debug = false; 	//	true false
20
+	const debug = false; //	true false
21 21
 
22 22
 	/**
23 23
 	 * an array of raw ticket data from EED_Ticket_Selector
@@ -59,46 +59,46 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// check ticket reserves AFTER MER does it's check (hence priority 20)
62
-		add_filter( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty',
63
-			array( 'EED_Ticket_Sales_Monitor', 'validate_ticket_sale' ),
62
+		add_filter('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty',
63
+			array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'),
64 64
 			20, 3
65 65
 		);
66 66
 		// add notices for sold out tickets
67
-		add_action( 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
68
-			array( 'EED_Ticket_Sales_Monitor', 'post_notices' ),
67
+		add_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
68
+			array('EED_Ticket_Sales_Monitor', 'post_notices'),
69 69
 			10
70 70
 		);
71 71
 		// handle emptied carts
72 72
 		add_action(
73 73
 			'AHEE__EE_Session__reset_cart__before_reset',
74
-			array( 'EED_Ticket_Sales_Monitor', 'session_cart_reset' ),
74
+			array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
75 75
 			10, 1
76 76
 		);
77 77
 		add_action(
78 78
 			'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart',
79
-			array( 'EED_Ticket_Sales_Monitor', 'session_cart_reset' ),
79
+			array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
80 80
 			10, 1
81 81
 		);
82 82
 		// handle cancelled registrations
83 83
 		add_action(
84 84
 			'AHEE__EE_Session__reset_checkout__before_reset',
85
-			array( 'EED_Ticket_Sales_Monitor', 'session_checkout_reset' ),
85
+			array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'),
86 86
 			10, 1
87 87
 		);
88 88
 		// cron tasks
89 89
 		add_action(
90 90
 			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction',
91
-			array( 'EED_Ticket_Sales_Monitor', 'process_abandoned_transactions' ),
91
+			array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
92 92
 			10, 1
93 93
 		);
94 94
 		add_action(
95 95
 			'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
96
-			array( 'EED_Ticket_Sales_Monitor', 'process_abandoned_transactions' ),
96
+			array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
97 97
 			10, 1
98 98
 		);
99 99
 		add_action(
100 100
 			'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
101
-			array( 'EED_Ticket_Sales_Monitor', 'process_failed_transactions' ),
101
+			array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'),
102 102
 			10, 1
103 103
 		);
104 104
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @return EED_Ticket_Sales_Monitor
123 123
 	 */
124 124
 	public static function instance() {
125
-		return parent::get_instance( __CLASS__ );
125
+		return parent::get_instance(__CLASS__);
126 126
 	}
127 127
 
128 128
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param WP_Query $WP_Query
135 135
 	 * @return    void
136 136
 	 */
137
-	public function run( $WP_Query ) {
137
+	public function run($WP_Query) {
138 138
 	}
139 139
 
140 140
 
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 	 * @param \EE_Ticket $ticket
153 153
 	 * @return bool
154 154
 	 */
155
-	public static function validate_ticket_sale( $qty = 1, EE_Ticket $ticket  ) {
156
-		$qty = absint( $qty );
157
-		if ( $qty > 0 ) {
158
-			$qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale( $ticket, $qty );
155
+	public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) {
156
+		$qty = absint($qty);
157
+		if ($qty > 0) {
158
+			$qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty);
159 159
 		}
160
-		if ( self::debug ) {
161
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
162
-			echo "\n qty: " . $qty;
160
+		if (self::debug) {
161
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
162
+			echo "\n qty: ".$qty;
163 163
 		}
164 164
 		return $qty;
165 165
 	}
@@ -175,45 +175,45 @@  discard block
 block discarded – undo
175 175
 	 * @param int          $qty
176 176
 	 * @return int
177 177
 	 */
178
-	protected function _validate_ticket_sale( EE_Ticket $ticket, $qty = 1 ) {
179
-		if ( self::debug ) {
180
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
178
+	protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) {
179
+		if (self::debug) {
180
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
181 181
 		}
182
-		if ( ! $ticket instanceof EE_Ticket ) {
182
+		if ( ! $ticket instanceof EE_Ticket) {
183 183
 			return 0;
184 184
 		}
185
-		if ( self::debug ) {
186
-			echo "\n . ticket->ID: " . $ticket->ID() . '<br />';
187
-			echo "\n . original ticket->reserved: " . $ticket->reserved() . '<br />';
185
+		if (self::debug) {
186
+			echo "\n . ticket->ID: ".$ticket->ID().'<br />';
187
+			echo "\n . original ticket->reserved: ".$ticket->reserved().'<br />';
188 188
 		}
189 189
 		$ticket->refresh_from_db();
190 190
 		// first let's determine the ticket availability based on sales
191
-		$available = $ticket->qty( 'saleable' );
192
-		if ( self::debug ) {
193
-			echo "\n . . . ticket->qty: " . $ticket->qty() . '<br />';
194
-			echo "\n . . . ticket->sold: " . $ticket->sold() . '<br />';
195
-			echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />';
196
-			echo "\n . . . ticket->qty(saleable): " . $ticket->qty( 'saleable' ) . '<br />';
197
-			echo "\n . . . available: " . $available . '<br />';
198
-		}
199
-		if ( $available < 1 ) {
200
-			$this->_ticket_sold_out( $ticket );
191
+		$available = $ticket->qty('saleable');
192
+		if (self::debug) {
193
+			echo "\n . . . ticket->qty: ".$ticket->qty().'<br />';
194
+			echo "\n . . . ticket->sold: ".$ticket->sold().'<br />';
195
+			echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />';
196
+			echo "\n . . . ticket->qty(saleable): ".$ticket->qty('saleable').'<br />';
197
+			echo "\n . . . available: ".$available.'<br />';
198
+		}
199
+		if ($available < 1) {
200
+			$this->_ticket_sold_out($ticket);
201 201
 			return 0;
202 202
 		}
203
-		if ( self::debug ) {
204
-			echo "\n . . . qty: " . $qty . '<br />';
203
+		if (self::debug) {
204
+			echo "\n . . . qty: ".$qty.'<br />';
205 205
 		}
206
-		if ( $available < $qty ) {
206
+		if ($available < $qty) {
207 207
 			$qty = $available;
208
-			if ( self::debug ) {
209
-				echo "\n . . . QTY ADJUSTED: " . $qty . '<br />';
208
+			if (self::debug) {
209
+				echo "\n . . . QTY ADJUSTED: ".$qty.'<br />';
210 210
 			}
211
-			$this->_ticket_quantity_decremented( $ticket );
211
+			$this->_ticket_quantity_decremented($ticket);
212 212
 		}
213
-		if ( self::debug ) {
214
-			echo "\n\n . . . INCREASE RESERVED: " . $qty . '<br/><br/>';
213
+		if (self::debug) {
214
+			echo "\n\n . . . INCREASE RESERVED: ".$qty.'<br/><br/>';
215 215
 		}
216
-		$ticket->increase_reserved( $qty );
216
+		$ticket->increase_reserved($qty);
217 217
 		$ticket->save();
218 218
 		return $qty;
219 219
 	}
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 	 * @return 	bool
230 230
 	 * @throws \EE_Error
231 231
 	 */
232
-	protected function _ticket_sold_out( EE_Ticket $ticket ) {
233
-		if ( self::debug ) {
234
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
235
-			echo "\n . . ticket->name: " . $this->_get_ticket_and_event_name( $ticket ) . '<br />';
232
+	protected function _ticket_sold_out(EE_Ticket $ticket) {
233
+		if (self::debug) {
234
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
235
+			echo "\n . . ticket->name: ".$this->_get_ticket_and_event_name($ticket).'<br />';
236 236
 		}
237
-		$this->sold_out_tickets[] = $this->_get_ticket_and_event_name( $ticket );
237
+		$this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket);
238 238
 	}
239 239
 
240 240
 
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 	 * @param    \EE_Ticket $ticket
248 248
 	 * @return bool
249 249
 	 */
250
-	protected function _ticket_quantity_decremented( EE_Ticket $ticket ) {
251
-		if ( self::debug ) {
252
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
253
-			echo "\n . . ticket->name: " . $this->_get_ticket_and_event_name( $ticket ) . '<br />';
250
+	protected function _ticket_quantity_decremented(EE_Ticket $ticket) {
251
+		if (self::debug) {
252
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
253
+			echo "\n . . ticket->name: ".$this->_get_ticket_and_event_name($ticket).'<br />';
254 254
 		}
255
-		$this->decremented_tickets[] = $this->_get_ticket_and_event_name( $ticket );
255
+		$this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket);
256 256
 	}
257 257
 
258 258
 
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 	 * @param    \EE_Ticket $ticket
266 266
 	 * @return string
267 267
 	 */
268
-	protected function _get_ticket_and_event_name( EE_Ticket $ticket ) {
268
+	protected function _get_ticket_and_event_name(EE_Ticket $ticket) {
269 269
 		$event = $ticket->get_related_event();
270
-		if ( $event instanceof EE_Event ) {
270
+		if ($event instanceof EE_Event) {
271 271
 			$ticket_name = sprintf(
272
-				_x( '%1$s for %2$s', 'ticket name for event name', 'event_espresso' ),
272
+				_x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'),
273 273
 				$ticket->name(),
274 274
 				$event->name()
275 275
 			);
@@ -304,34 +304,34 @@  discard block
 block discarded – undo
304 304
 	 * @return    void
305 305
 	 */
306 306
 	protected function _post_notices() {
307
-		if ( self::debug ) {
308
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
307
+		if (self::debug) {
308
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
309 309
 		}
310
-		if ( ! empty( $this->sold_out_tickets ) ) {
310
+		if ( ! empty($this->sold_out_tickets)) {
311 311
 			EE_Error::add_attention(
312 312
 				sprintf(
313 313
 					apply_filters(
314 314
 						'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice',
315
-						__( 'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso' )
315
+						__('We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso')
316 316
 					),
317 317
 					'<br />',
318
-					implode( '<br />', $this->sold_out_tickets )
318
+					implode('<br />', $this->sold_out_tickets)
319 319
 				)
320 320
 			);
321 321
 			// alter code flow in the Ticket Selector for better UX
322
-			add_filter( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true' );
323
-			add_filter( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false' );
322
+			add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true');
323
+			add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false');
324 324
 			$this->sold_out_tickets = array();
325 325
 		}
326
-		if ( ! empty( $this->decremented_tickets ) ) {
326
+		if ( ! empty($this->decremented_tickets)) {
327 327
 			EE_Error::add_attention(
328 328
 				sprintf(
329 329
 					apply_filters(
330 330
 						'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice',
331
-						__( 'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso' )
331
+						__('We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso')
332 332
 					),
333 333
 					'<br />',
334
-					implode( '<br />', $this->decremented_tickets )
334
+					implode('<br />', $this->decremented_tickets)
335 335
 				)
336 336
 			);
337 337
 			$this->decremented_tickets = array();
@@ -353,27 +353,27 @@  discard block
 block discarded – undo
353 353
 	 * @param 	EE_Transaction 	$transaction
354 354
 	 * @return int
355 355
 	 */
356
-	protected function _release_all_reserved_tickets_for_transaction( EE_Transaction $transaction ) {
357
-		if ( self::debug ) {
358
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
359
-			echo "\n . transaction->ID: " . $transaction->ID() . '<br />';
356
+	protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) {
357
+		if (self::debug) {
358
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
359
+			echo "\n . transaction->ID: ".$transaction->ID().'<br />';
360 360
 		}
361 361
 		/** @type EE_Transaction_Processor $transaction_processor */
362
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
362
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
363 363
 		// check if 'finalize_registration' step has been completed...
364
-		$finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' );
365
-		if ( self::debug ) {
364
+		$finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration');
365
+		if (self::debug) {
366 366
 			// DEBUG LOG
367 367
 			EEH_Debug_Tools::log(
368 368
 				__CLASS__, __FUNCTION__, __LINE__,
369
-				array( 'finalized' => $finalized ),
370
-				false, 'EE_Transaction: ' . $transaction->ID()
369
+				array('finalized' => $finalized),
370
+				false, 'EE_Transaction: '.$transaction->ID()
371 371
 			);
372 372
 		}
373 373
 		// how many tickets were released
374 374
 		$count = 0;
375
-		if ( self::debug ) {
376
-			echo "\n . . . finalized: " . $finalized . '<br />';
375
+		if (self::debug) {
376
+			echo "\n . . . finalized: ".$finalized.'<br />';
377 377
 		}
378 378
 		$release_tickets_with_TXN_status = array(
379 379
 			EEM_Transaction::failed_status_code,
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 			EEM_Transaction::incomplete_status_code,
382 382
 		);
383 383
 		// if the session is getting cleared BEFORE the TXN has been finalized
384
-		if ( ! $finalized || in_array( $transaction->status_ID(), $release_tickets_with_TXN_status ) ) {
384
+		if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status)) {
385 385
 			// let's cancel any reserved tickets
386 386
 			$registrations = $transaction->registrations();
387
-			if ( ! empty( $registrations ) ) {
388
-				foreach ( $registrations as $registration ) {
389
-					if ( $registration instanceof EE_Registration ) {
390
-						$count += $this->_release_reserved_ticket_for_registration( $registration, $transaction );
387
+			if ( ! empty($registrations)) {
388
+				foreach ($registrations as $registration) {
389
+					if ($registration instanceof EE_Registration) {
390
+						$count += $this->_release_reserved_ticket_for_registration($registration, $transaction);
391 391
 					}
392 392
 				}
393 393
 			}
@@ -408,12 +408,12 @@  discard block
 block discarded – undo
408 408
 	 * @return 	int
409 409
 	 * @throws 	\EE_Error
410 410
 	 */
411
-	protected function _release_reserved_ticket_for_registration( EE_Registration $registration, EE_Transaction $transaction ) {
412
-		if ( self::debug ) {
413
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
414
-			echo "\n . . registration->ID: " . $registration->ID() . '<br />';
415
-			echo "\n . . registration->status_ID: " . $registration->status_ID() . '<br />';
416
-			echo "\n . . transaction->status_ID(): " . $transaction->status_ID() . '<br />';
411
+	protected function _release_reserved_ticket_for_registration(EE_Registration $registration, EE_Transaction $transaction) {
412
+		if (self::debug) {
413
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
414
+			echo "\n . . registration->ID: ".$registration->ID().'<br />';
415
+			echo "\n . . registration->status_ID: ".$registration->status_ID().'<br />';
416
+			echo "\n . . transaction->status_ID(): ".$transaction->status_ID().'<br />';
417 417
 		}
418 418
 		if (
419 419
 			// release Tickets for Failed Transactions and Abandoned Transactions
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
 			)
427 427
 		) {
428 428
 			$ticket = $registration->ticket();
429
-			if ( $ticket instanceof EE_Ticket ) {
430
-				if ( self::debug ) {
431
-					echo "\n . . . ticket->ID: " . $ticket->ID() . '<br />';
432
-					echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />';
429
+			if ($ticket instanceof EE_Ticket) {
430
+				if (self::debug) {
431
+					echo "\n . . . ticket->ID: ".$ticket->ID().'<br />';
432
+					echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />';
433 433
 				}
434 434
 				$ticket->decrease_reserved();
435
-				if ( self::debug ) {
436
-					echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />';
435
+				if (self::debug) {
436
+					echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />';
437 437
 				}
438 438
 				return $ticket->save() ? 1 : 0;
439 439
 			}
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 	 * @param    EE_Session $session
456 456
 	 * @return    void
457 457
 	 */
458
-	public static function session_cart_reset( EE_Session $session ) {
459
-		if ( self::debug ) {
460
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
458
+	public static function session_cart_reset(EE_Session $session) {
459
+		if (self::debug) {
460
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
461 461
 		}
462 462
 		$cart = $session->cart();
463
-		if ( $cart instanceof EE_Cart ) {
464
-			if ( self::debug ) {
465
-				echo "\n\n cart instanceof EE_Cart: " . "<br />";
463
+		if ($cart instanceof EE_Cart) {
464
+			if (self::debug) {
465
+				echo "\n\n cart instanceof EE_Cart: "."<br />";
466 466
 			}
467
-			EED_Ticket_Sales_Monitor::instance()->_session_cart_reset( $cart );
467
+			EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart);
468 468
 		}
469 469
 	}
470 470
 
@@ -478,30 +478,30 @@  discard block
 block discarded – undo
478 478
 	 * @param    EE_Cart $cart
479 479
 	 * @return    void
480 480
 	 */
481
-	protected function _session_cart_reset( EE_Cart $cart ) {
482
-		if ( self::debug ) {
483
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
481
+	protected function _session_cart_reset(EE_Cart $cart) {
482
+		if (self::debug) {
483
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
484 484
 		}
485
-		EE_Registry::instance()->load_helper( 'Line_Item' );
485
+		EE_Registry::instance()->load_helper('Line_Item');
486 486
 		$ticket_line_items = $cart->get_tickets();
487
-		if ( empty( $ticket_line_items ) ) {
487
+		if (empty($ticket_line_items)) {
488 488
 			return;
489 489
 		}
490
-		foreach ( $ticket_line_items as $ticket_line_item ) {
491
-			if ( self::debug ) {
492
-				echo "\n . ticket_line_item->ID(): " . $ticket_line_item->ID() . "<br />";
490
+		foreach ($ticket_line_items as $ticket_line_item) {
491
+			if (self::debug) {
492
+				echo "\n . ticket_line_item->ID(): ".$ticket_line_item->ID()."<br />";
493 493
 			}
494
-			if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() == 'Ticket' ) {
495
-				if ( self::debug ) {
496
-					echo "\n . . ticket_line_item->OBJ_ID(): " . $ticket_line_item->OBJ_ID() . "<br />";
494
+			if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() == 'Ticket') {
495
+				if (self::debug) {
496
+					echo "\n . . ticket_line_item->OBJ_ID(): ".$ticket_line_item->OBJ_ID()."<br />";
497 497
 				}
498
-				$ticket = EEM_Ticket::instance()->get_one_by_ID( $ticket_line_item->OBJ_ID() );
499
-				if ( $ticket instanceof EE_Ticket ) {
500
-					if ( self::debug ) {
501
-						echo "\n . . ticket->ID(): " . $ticket->ID() . "<br />";
502
-						echo "\n . . ticket_line_item->quantity(): " . $ticket_line_item->quantity() . "<br />";
498
+				$ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID());
499
+				if ($ticket instanceof EE_Ticket) {
500
+					if (self::debug) {
501
+						echo "\n . . ticket->ID(): ".$ticket->ID()."<br />";
502
+						echo "\n . . ticket_line_item->quantity(): ".$ticket_line_item->quantity()."<br />";
503 503
 					}
504
-					$ticket->decrease_reserved( $ticket_line_item->quantity() );
504
+					$ticket->decrease_reserved($ticket_line_item->quantity());
505 505
 					$ticket->save();
506 506
 				}
507 507
 			}
@@ -522,10 +522,10 @@  discard block
 block discarded – undo
522 522
 	 * @param    EE_Session $session
523 523
 	 * @return    void
524 524
 	 */
525
-	public static function session_checkout_reset( EE_Session $session ) {
525
+	public static function session_checkout_reset(EE_Session $session) {
526 526
 		$checkout = $session->checkout();
527
-		if ( $checkout instanceof EE_Checkout ) {
528
-			EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset( $checkout );
527
+		if ($checkout instanceof EE_Checkout) {
528
+			EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout);
529 529
 		}
530 530
 	}
531 531
 
@@ -539,15 +539,15 @@  discard block
 block discarded – undo
539 539
 	 * @param    EE_Checkout $checkout
540 540
 	 * @return    void
541 541
 	 */
542
-	protected function _session_checkout_reset( EE_Checkout $checkout ) {
543
-		if ( self::debug ) {
544
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
542
+	protected function _session_checkout_reset(EE_Checkout $checkout) {
543
+		if (self::debug) {
544
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
545 545
 		}
546 546
 		// we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit
547
-		if ( $checkout->revisit || ! $checkout->transaction instanceof EE_Transaction ) {
547
+		if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) {
548 548
 			return;
549 549
 		}
550
-		$this->_release_all_reserved_tickets_for_transaction( $checkout->transaction );
550
+		$this->_release_all_reserved_tickets_for_transaction($checkout->transaction);
551 551
 	}
552 552
 
553 553
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @param    EE_Session $session
564 564
 	 * @return    void
565 565
 	 */
566
-	public static function session_expired_reset( EE_Session $session ) {
566
+	public static function session_expired_reset(EE_Session $session) {
567 567
 
568 568
 	}
569 569
 
@@ -582,30 +582,30 @@  discard block
 block discarded – undo
582 582
 	 * @param    EE_Transaction $transaction
583 583
 	 * @return    void
584 584
 	 */
585
-	public static function process_abandoned_transactions( EE_Transaction $transaction ) {
585
+	public static function process_abandoned_transactions(EE_Transaction $transaction) {
586 586
 		// is this TXN free or has any money been paid towards this TXN? If so, then leave it alone
587
-		if ( $transaction->is_free() || $transaction->paid() > 0 ) {
588
-			if ( self::debug ) {
587
+		if ($transaction->is_free() || $transaction->paid() > 0) {
588
+			if (self::debug) {
589 589
 				// DEBUG LOG
590 590
 				EEH_Debug_Tools::log(
591 591
 					__CLASS__, __FUNCTION__, __LINE__,
592
-					array( $transaction ),
593
-					false, 'EE_Transaction: ' . $transaction->ID()
592
+					array($transaction),
593
+					false, 'EE_Transaction: '.$transaction->ID()
594 594
 				);
595 595
 			}
596 596
 			return;
597 597
 		}
598 598
 		// have their been any successful payments made ?
599 599
 		$payments = $transaction->payments();
600
-		foreach ( $payments as $payment ) {
601
-			if ( $payment instanceof EE_Payment ) {
602
-				if ( $payment->status() === EEM_Payment::status_id_approved ) {
603
-					if ( self::debug ) {
600
+		foreach ($payments as $payment) {
601
+			if ($payment instanceof EE_Payment) {
602
+				if ($payment->status() === EEM_Payment::status_id_approved) {
603
+					if (self::debug) {
604 604
 						// DEBUG LOG
605 605
 						EEH_Debug_Tools::log(
606 606
 							__CLASS__, __FUNCTION__, __LINE__,
607
-							array( $payment ),
608
-							false, 'EE_Transaction: ' . $transaction->ID()
607
+							array($payment),
608
+							false, 'EE_Transaction: '.$transaction->ID()
609 609
 						);
610 610
 					}
611 611
 					return;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 			}
614 614
 		}
615 615
 		// since you haven't even attempted to pay for your ticket...
616
-		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction( $transaction );
616
+		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
617 617
 	}
618 618
 
619 619
 
@@ -630,9 +630,9 @@  discard block
 block discarded – undo
630 630
 	 * @param    EE_Transaction $transaction
631 631
 	 * @return    void
632 632
 	 */
633
-	public static function process_failed_transactions( EE_Transaction $transaction ) {
633
+	public static function process_failed_transactions(EE_Transaction $transaction) {
634 634
 		// since you haven't even attempted to pay for your ticket...
635
-		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction( $transaction );
635
+		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
636 636
 	}
637 637
 
638 638
 
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime.model.php 1 patch
Spacing   +133 added lines, -133 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_Datetime.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Datetime.class.php');
26 26
 
27 27
 class EEM_Datetime extends EEM_Soft_Delete_Base {
28 28
 
@@ -35,28 +35,28 @@  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 = __('Datetime','event_espresso');
40
-		$this->plural_item = __('Datetimes','event_espresso');
38
+	protected function __construct($timezone) {
39
+		$this->singular_item = __('Datetime', 'event_espresso');
40
+		$this->plural_item = __('Datetimes', 'event_espresso');
41 41
 
42 42
 		$this->_tables = array(
43 43
 			'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID')
44 44
 		);
45 45
 		$this->_fields = array(
46 46
 			'Datetime'=>array(
47
-				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')),
48
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
47
+				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')),
48
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
49 49
 				'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''),
50 50
 				'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''),
51
-				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ),
52
-				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ),
53
-				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF),
54
-				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ),
55
-				'DTT_reserved' => new EE_Integer_Field('DTT_reserved',__('Quantity of tickets that are reserved, but not yet fully purchased','event_espresso'),false,0),
56
-				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false),
51
+				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone),
52
+				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone),
53
+				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF),
54
+				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0),
55
+				'DTT_reserved' => new EE_Integer_Field('DTT_reserved', __('Quantity of tickets that are reserved, but not yet fully purchased', 'event_espresso'), false, 0),
56
+				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false),
57 57
 				'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0),
58
-				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ),
59
-				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ),
58
+				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0),
59
+				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false),
60 60
 			));
61 61
 		$this->_model_relations = array(
62 62
 			'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'),
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 		);
66 66
 		$this->_model_chain_to_wp_user = 'Event';
67 67
 		//this model is generally available for reading
68
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' );
69
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
70
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
71
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit );
72
-		parent::__construct( $timezone );
68
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
69
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
70
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
71
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
72
+		parent::__construct($timezone);
73 73
 	}
74 74
 
75 75
 
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
 	public function create_new_blank_datetime() {
85 85
 		$blank_datetime = EE_Datetime::new_instance(
86 86
 			array(
87
-				'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30),
88
-				'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30),
87
+				'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30),
88
+				'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30),
89 89
 				'DTT_order' => 1,
90 90
 				'DTT_reg_limit' => EE_INF
91 91
 			),
92 92
 			$this->_timezone
93 93
 		);
94
-		$blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) );
95
-		$blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) );
96
-		return array( $blank_datetime );
94
+		$blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone));
95
+		$blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone));
96
+		return array($blank_datetime);
97 97
 	}
98 98
 
99 99
 
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	* 		@param		int 			$EVT_ID
108 108
 	*		@return 		EE_Datetime[]		array on success, FALSE on fail
109 109
 	*/
110
-	public function get_all_event_dates( $EVT_ID = 0 ) {
111
-		if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0
110
+	public function get_all_event_dates($EVT_ID = 0) {
111
+		if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
112 112
 			return $this->create_new_blank_datetime();
113 113
 		}
114
-		$results =  $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
114
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
115 115
 
116
-		if ( empty( $results ) ) {
116
+		if (empty($results)) {
117 117
 			return $this->create_new_blank_datetime();
118 118
 		}
119 119
 
@@ -134,26 +134,26 @@  discard block
 block discarded – undo
134 134
 	 *                        	the given number
135 135
 	 * @return EE_Datetime[]
136 136
 	 */
137
-	public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL  ) {
137
+	public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) {
138 138
 
139 139
 		//sanitize EVT_ID
140
-		$EVT_ID = intval( $EVT_ID );
140
+		$EVT_ID = intval($EVT_ID);
141 141
 
142 142
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
143
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
144
-		$where_params = array( 'Event.EVT_ID' => $EVT_ID );
143
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
144
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
145 145
 
146
-		$query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' );
146
+		$query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none');
147 147
 
148
-		if( ! $include_expired){
149
-			$query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) );
148
+		if ( ! $include_expired) {
149
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
150 150
 		}
151
-		if( $include_deleted){
152
-			$query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE ));
151
+		if ($include_deleted) {
152
+			$query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE));
153 153
 		}
154 154
 
155
-		$result = $this->get_all( $query_params );
156
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
155
+		$result = $this->get_all($query_params);
156
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
157 157
 		return $result;
158 158
 	}
159 159
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param int $limit
169 169
 	 * @return EE_Datetime[]
170 170
 	 */
171
-	public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){
172
-		return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID),
171
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) {
172
+		return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID),
173 173
 			'limit'=>$limit,
174 174
 			'order_by'=>array('DTT_EVT_start'=>'ASC'),
175 175
 			'default_where_conditions' => 'none'));
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
 	 * @param boolean $include_deleted
185 185
 	 * @return EE_Datetime
186 186
 	 */
187
-	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){
188
-		$results =  $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
189
-		if($results){
187
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) {
188
+		$results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
189
+		if ($results) {
190 190
 			return array_shift($results);
191
-		}else{
191
+		} else {
192 192
 			return NULL;
193 193
 		}
194 194
 	}
@@ -202,16 +202,16 @@  discard block
 block discarded – undo
202 202
 	 * @param bool $try_to_exclude_deleted
203 203
 	 * @return \EE_Datetime
204 204
 	 */
205
-	public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){
206
-		if($try_to_exclude_expired){
207
-			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false);
208
-			if($non_expired){
205
+	public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) {
206
+		if ($try_to_exclude_expired) {
207
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
208
+			if ($non_expired) {
209 209
 				return $non_expired;
210 210
 			}
211 211
 		}
212
-		if($try_to_exclude_deleted){
212
+		if ($try_to_exclude_deleted) {
213 213
 			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
214
-			if($expired_even){
214
+			if ($expired_even) {
215 215
 				return $expired_even;
216 216
 			}
217 217
 		}
@@ -230,23 +230,23 @@  discard block
 block discarded – undo
230 230
 	 * @param int $limit
231 231
 	 * @return EE_Datetime[]
232 232
 	 */
233
-	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){
233
+	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
234 234
 		//sanitize EVT_ID
235
-		$EVT_ID = intval( $EVT_ID );
235
+		$EVT_ID = intval($EVT_ID);
236 236
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
237
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
238
-		$query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
239
-		if( ! $include_expired){
240
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
237
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
238
+		$query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
239
+		if ( ! $include_expired) {
240
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
241 241
 		}
242
-		if( $include_deleted){
243
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
242
+		if ($include_deleted) {
243
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
244 244
 		}
245
-		if($limit){
245
+		if ($limit) {
246 246
 			$query_params['limit'] = $limit;
247 247
 		}
248
-		$result = $this->get_all( $query_params );
249
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
248
+		$result = $this->get_all($query_params);
249
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
250 250
 		return $result;
251 251
 	}
252 252
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
 	 * @param int $limit
260 260
 	 * @return EE_Datetime[]
261 261
 	 */
262
-	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){
262
+	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
263 263
 		//sanitize TKT_ID
264
-		$TKT_ID =  intval( $TKT_ID );
264
+		$TKT_ID = intval($TKT_ID);
265 265
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
266
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
267
-		$query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
268
-		if( ! $include_expired){
269
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
266
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
267
+		$query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
268
+		if ( ! $include_expired) {
269
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
270 270
 		}
271
-		if( $include_deleted){
272
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
271
+		if ($include_deleted) {
272
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
273 273
 		}
274
-		if($limit){
274
+		if ($limit) {
275 275
 			$query_params['limit'] = $limit;
276 276
 		}
277
-		$result = $this->get_all( $query_params );
278
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
277
+		$result = $this->get_all($query_params);
278
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
279 279
 		return $result;
280 280
 	}
281 281
 
@@ -291,24 +291,24 @@  discard block
 block discarded – undo
291 291
 	 *                                  that number
292 292
 	 * @return EE_Datetime[]
293 293
 	 */
294
-	public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) {
294
+	public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
295 295
 		//sanitize id.
296
-		$TKT_ID =  intval( $TKT_ID );
296
+		$TKT_ID = intval($TKT_ID);
297 297
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
298
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
299
-		$where_params = array( 'Ticket.TKT_ID' => $TKT_ID );
300
-		$query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) );
301
-		if( ! $include_expired){
302
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
298
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
299
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
300
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
301
+		if ( ! $include_expired) {
302
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
303 303
 		}
304
-		if( $include_deleted){
305
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
304
+		if ($include_deleted) {
305
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
306 306
 		}
307
-		if($limit){
307
+		if ($limit) {
308 308
 			$query_params['limit'] = $limit;
309 309
 		}
310
-		$result = $this->get_all( $query_params );
311
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
310
+		$result = $this->get_all($query_params);
311
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
312 312
 		return $result;
313 313
 	}
314 314
 
@@ -319,11 +319,11 @@  discard block
 block discarded – undo
319 319
 	 * @param int $EVT_ID
320 320
 	 * @return EE_Datetime
321 321
 	 */
322
-	public function get_most_important_datetime_for_event($EVT_ID){
322
+	public function get_most_important_datetime_for_event($EVT_ID) {
323 323
 		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
324
-		if($results){
324
+		if ($results) {
325 325
 			return array_shift($results);
326
-		}else{
326
+		} else {
327 327
 			return null;
328 328
 		}
329 329
 	}
@@ -342,71 +342,71 @@  discard block
 block discarded – undo
342 342
 	 * 			- inactive = Events that are either not published.
343 343
 	 * @return wpdb results array
344 344
 	 */
345
-	public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) {
345
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '') {
346 346
 
347
-		switch ( $evt_active_status ) {
347
+		switch ($evt_active_status) {
348 348
 			case 'upcoming' :
349 349
 					$where_params['Event.status'] = 'publish';
350 350
 					//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
351
-					if ( isset( $where_params['DTT_EVT_start'] ) ) {
351
+					if (isset($where_params['DTT_EVT_start'])) {
352 352
 						$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
353 353
 					}
354
-					$where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query( 'DTT_EVT_start' ) );
354
+					$where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query('DTT_EVT_start'));
355 355
 					break;
356 356
 
357 357
 			case 'expired' :
358
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
358
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
359 359
 				//get events to exclude
360
-				$exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) );
360
+				$exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $this->current_time_for_query('DTT_EVT_end'))));
361 361
 				//first get all events that have datetimes where its not expired.
362
-				$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' );
363
-				$event_ids = array_keys( $event_ids );
362
+				$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID');
363
+				$event_ids = array_keys($event_ids);
364 364
 
365
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
365
+				if (isset($where_params['DTT_EVT_end'])) {
366 366
 					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
367 367
 				}
368
-				$where_params['DTT_EVT_end'] = array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
369
-				$where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids );
368
+				$where_params['DTT_EVT_end'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
369
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
370 370
 				break;
371 371
 
372 372
 			case 'active' :
373 373
 				$where_params['Event.status'] = 'publish';
374
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
374
+				if (isset($where_params['DTT_EVT_start'])) {
375 375
 					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
376 376
 				}
377
-				if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
377
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
378 378
 					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
379 379
 				}
380
-				$where_params['DTT_EVT_start'] = array('<',  $this->current_time_for_query( 'DTT_EVT_start' ) );
381
-				$where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query( 'DTT_EVT_end' ) );
380
+				$where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query('DTT_EVT_start'));
381
+				$where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query('DTT_EVT_end'));
382 382
 				break;
383 383
 
384 384
 			case 'inactive' :
385
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
386
-				if ( isset( $where_params['OR'] ) ) {
385
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
386
+				if (isset($where_params['OR'])) {
387 387
 					$where_params['AND']['OR'] = $where_params['OR'];
388 388
 				}
389
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
389
+				if (isset($where_params['DTT_EVT_end'])) {
390 390
 					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
391
-					unset( $where_params['DTT_EVT_end'] );
391
+					unset($where_params['DTT_EVT_end']);
392 392
 				}
393 393
 
394
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
394
+				if (isset($where_params['DTT_EVT_start'])) {
395 395
 					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
396
-					unset( $where_params['DTT_EVT_start'] );
396
+					unset($where_params['DTT_EVT_start']);
397 397
 				}
398
-				$where_params['AND']['Event.status'] = array( '!=', 'publish' );
398
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
399 399
 				break;
400 400
 		}
401 401
 
402 402
 		$query_params[0] = $where_params;
403 403
 		$query_params['group_by'] = array('dtt_year', 'dtt_month');
404
-		$query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' );
404
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
405 405
 		$columns_to_select = array(
406 406
 			'dtt_year' => array('YEAR(DTT_EVT_start)', '%s'),
407 407
 			'dtt_month' => array('MONTHNAME(DTT_EVT_start)', '%s')
408 408
 			);
409
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
409
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
410 410
 	}
411 411
 
412 412
 	/**
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	 * for the tickets for each datetime)
415 415
 	 * @param EE_Datetime[] $datetimes
416 416
 	 */
417
-	public function update_sold($datetimes){
418
-		foreach($datetimes as $datetime){
417
+	public function update_sold($datetimes) {
418
+		foreach ($datetimes as $datetime) {
419 419
 			$datetime->update_sold();
420 420
 		}
421 421
 	}
@@ -430,10 +430,10 @@  discard block
 block discarded – undo
430 430
 	 * @param array $query_params
431 431
 	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO tickets attached to datetime then FALSE is returned.
432 432
 	 */
433
-	public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) {
434
-		$datetime = $this->get_one_by_ID( $DTT_ID );
435
-		if ( $datetime instanceof EE_Datetime ) {
436
-			return $datetime->tickets_remaining( $query_params );
433
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) {
434
+		$datetime = $this->get_one_by_ID($DTT_ID);
435
+		if ($datetime instanceof EE_Datetime) {
436
+			return $datetime->tickets_remaining($query_params);
437 437
 		}
438 438
 		return 0;
439 439
 	}
@@ -455,36 +455,36 @@  discard block
 block discarded – undo
455 455
 	 *                EE_Datetime::upcoming
456 456
 	 *                EE_Datetime::expired
457 457
 	 */
458
-	public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) {
458
+	public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) {
459 459
 		//only accept where conditions for this query.
460
-		$_where = isset( $query_params[0] ) ? $query_params[0] : array();
460
+		$_where = isset($query_params[0]) ? $query_params[0] : array();
461 461
 		$status_query_args = array(
462 462
 				EE_Datetime::active => array_merge(
463 463
 						$_where,
464
-						array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) )
464
+						array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
465 465
 				),
466 466
 				EE_Datetime::upcoming => array_merge(
467 467
 						$_where,
468
-						array( 'DTT_EVT_start' => array( '>', time() ) )
468
+						array('DTT_EVT_start' => array('>', time()))
469 469
 				),
470 470
 				EE_Datetime::expired => array_merge(
471 471
 						$_where,
472
-						array( 'DTT_EVT_end' => array('<', time() ) )
472
+						array('DTT_EVT_end' => array('<', time()))
473 473
 				)
474 474
 		);
475 475
 
476
-		if ( ! empty( $stati_to_include ) ) {
477
-			foreach( array_keys( $status_query_args ) as $status ) {
478
-				if ( ! in_array( $status, $stati_to_include ) ) {
479
-					unset( $status_query_args[$status] );
476
+		if ( ! empty($stati_to_include)) {
477
+			foreach (array_keys($status_query_args) as $status) {
478
+				if ( ! in_array($status, $stati_to_include)) {
479
+					unset($status_query_args[$status]);
480 480
 				}
481 481
 			}
482 482
 		}
483 483
 
484 484
 		//loop through and query counts for each stati.
485 485
 		$status_query_results = array();
486
-		foreach( $status_query_args as $status => $status_where_conditions ) {
487
-			$status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true );
486
+		foreach ($status_query_args as $status => $status_where_conditions) {
487
+			$status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true);
488 488
 		}
489 489
 
490 490
 		return $status_query_results;
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 	 * @param array $query_params
499 499
 	 * @return int
500 500
 	 */
501
-	public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) {
502
-		$count = $this->get_datetime_counts_by_status( array( $status ), $query_params );
503
-		return ! empty( $count[$status] ) ? $count[$status] : 0;
501
+	public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) {
502
+		$count = $this->get_datetime_counts_by_status(array($status), $query_params);
503
+		return ! empty($count[$status]) ? $count[$status] : 0;
504 504
 	}
505 505
 
506 506
 
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 1 patch
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 	 * @return EED_Ticket_Selector
58 58
 	 */
59 59
 	public static function instance() {
60
-		return parent::get_instance( __CLASS__ );
60
+		return parent::get_instance(__CLASS__);
61 61
 	}
62 62
 
63 63
 
64 64
 
65
-	protected function set_config(){
66
-		$this->set_config_section( 'template_settings' );
67
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
68
-		$this->set_config_name( 'EED_Ticket_Selector' );
65
+	protected function set_config() {
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 69
 	}
70 70
 
71 71
 
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public static function set_hooks() {
82 82
 		// routing
83
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
84
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
85
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
83
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
84
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
85
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
86 86
 		//add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 );
87
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
87
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
88 88
 		//add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 );
89 89
 		//add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 );
90
-		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
90
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
91 91
 	}
92 92
 
93 93
 
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 *  @return 	void
100 100
 	 */
101 101
 	public static function set_hooks_admin() {
102
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
102
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
103 103
 		//add button for iframe code to event editor.
104
-		add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 );
105
-		add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 );
104
+		add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4);
105
+		add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
106 106
 	}
107 107
 
108 108
 
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 	 *  @return 	void
115 115
 	 */
116 116
 	public static function set_definitions() {
117
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
118
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
117
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
118
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
119 119
 
120 120
 		//if config is not set, initialize
121 121
 		//If config is not set, set it.
122
-		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) {
122
+		if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) {
123 123
 			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
124 124
 		}
125
-		EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' );
125
+		EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
126 126
 	}
127 127
 
128 128
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * 	@param	object 			$WP
134 134
 	 * 	@return 	void
135 135
 	 */
136
-	public function run( $WP ) {}
136
+	public function run($WP) {}
137 137
 
138 138
 
139 139
 	/**
@@ -145,23 +145,23 @@  discard block
 block discarded – undo
145 145
 	public function ticket_selector_iframe() {
146 146
 		self::$_in_iframe = true;
147 147
 		/** @type EEM_Event $EEM_Event */
148
-		$EEM_Event = EE_Registry::instance()->load_model( 'Event' );
148
+		$EEM_Event = EE_Registry::instance()->load_model('Event');
149 149
 		$event = $EEM_Event->get_one_by_ID(
150
-			EE_Registry::instance()->REQ->get( 'event', 0 )
150
+			EE_Registry::instance()->REQ->get('event', 0)
151 151
 		);
152
-		EE_Registry::instance()->REQ->set_espresso_page( true );
153
-		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event );
152
+		EE_Registry::instance()->REQ->set_espresso_page(true);
153
+		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
154 154
 		$template_args['css'] = apply_filters(
155 155
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
156 156
 			array(
157
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
158
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
159
-				includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ),
160
-				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
157
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION,
158
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION,
159
+				includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']),
160
+				EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
161 161
 			)
162 162
 		);
163
-		EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true;
164
-		EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' );
163
+		EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
164
+		EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso');
165 165
 		$template_args['eei18n'] = apply_filters(
166 166
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
167 167
 			EE_Registry::localize_i18n_js_strings()
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 		$template_args['js'] = apply_filters(
170 170
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
171 171
 			array(
172
-				includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ),
173
-				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
174
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION
172
+				includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']),
173
+				EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
174
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION
175 175
 			)
176 176
 		);
177 177
 		EE_Registry::instance()->load_helper('Template');
178
-		$template_args[ 'notices' ] = EEH_Template::display_template(
179
-			EE_TEMPLATES . 'espresso-ajax-notices.template.php',
178
+		$template_args['notices'] = EEH_Template::display_template(
179
+			EE_TEMPLATES.'espresso-ajax-notices.template.php',
180 180
 			array(),
181 181
 			true
182 182
 		);
183 183
 		EEH_Template::display_template(
184
-			TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
184
+			TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php',
185 185
 			$template_args
186 186
 		);
187 187
 		exit;
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return string The new html string for the permalink area.
202 202
 	 */
203
-	public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) {
203
+	public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) {
204 204
 		//make sure this is ONLY when editing and the event id has been set.
205
-		if ( ! empty( $id ) )  {
206
-			$post = get_post( $id );
205
+		if ( ! empty($id)) {
206
+			$post = get_post($id);
207 207
 
208 208
 			//if NOT event then let's get out.
209
-			if ( $post->post_type !== 'espresso_events' ) {
209
+			if ($post->post_type !== 'espresso_events') {
210 210
 				return $permalink_string;
211 211
 			}
212 212
 
213
-			$ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() );
213
+			$ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
214 214
 
215
-			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">' . __('Embed', 'event_espresso') . '</a> ';
215
+			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'.__('Embed', 'event_espresso').'</a> ';
216 216
 			$permalink_string .= '
217 217
 <div id="js-ts-iframe" style="display:none">
218 218
 	<div style="width:100%; height: 500px;">
219
-		<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>
219
+		<iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe>
220 220
 	</div>
221 221
 </div>';
222 222
 		}
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 	 * @param 	mixed $event
236 236
 	 * @return 	bool
237 237
 	 */
238
-	protected static function set_event( $event = null ) {
239
-		if( $event === null ) {
238
+	protected static function set_event($event = null) {
239
+		if ($event === null) {
240 240
 			global $post;
241 241
 			$event = $post;
242 242
 		}
243
-		if ( $event instanceof EE_Event ) {
243
+		if ($event instanceof EE_Event) {
244 244
 			self::$_event = $event;
245
-		} else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
245
+		} else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
246 246
 			self::$_event = $event->EE_Event;
247
-		} else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) {
248
-			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
247
+		} else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') {
248
+			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
249 249
 			self::$_event = $event->EE_Event;
250 250
 		} else {
251
-			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
252
-			$dev_msg = $user_msg . __( '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.', 'event_espresso' );
253
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
251
+			$user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
252
+			$dev_msg = $user_msg.__('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.', 'event_espresso');
253
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
254 254
 			return false;
255 255
 		}
256 256
 		return true;
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 	 * @param 	bool 	$view_details
270 270
 	 * @return 	string
271 271
 	 */
272
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
272
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
273 273
 		// reset filter for displaying submit button
274
-		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
274
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
275 275
 		// poke and prod incoming event till it tells us what it is
276
-		if ( ! EED_Ticket_Selector::set_event( $event )) {
276
+		if ( ! EED_Ticket_Selector::set_event($event)) {
277 277
 			return false;
278 278
 		}
279 279
 		$event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 			&& (
285 285
 				! self::$_event->display_ticket_selector()
286 286
 				|| $view_details
287
-				|| post_password_required( $event_post )
287
+				|| post_password_required($event_post)
288 288
 				|| (
289 289
 					$_event_active_status != EE_Datetime::active
290 290
 					&& $_event_active_status != EE_Datetime::upcoming
@@ -302,70 +302,70 @@  discard block
 block discarded – undo
302 302
 		$template_args = array();
303 303
 		$template_args['event_status'] = $_event_active_status;
304 304
 
305
-		$template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) );
306
-		$template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) );
305
+		$template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format'));
306
+		$template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format'));
307 307
 
308 308
 		$template_args['EVT_ID'] = self::$_event->ID();
309 309
 		$template_args['event'] = self::$_event;
310 310
 
311 311
 		// is the event expired ?
312 312
 		$template_args['event_is_expired'] = self::$_event->is_expired();
313
-		if ( $template_args['event_is_expired'] ) {
314
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>';
313
+		if ($template_args['event_is_expired']) {
314
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>';
315 315
 		}
316 316
 
317 317
 		$ticket_query_args = array(
318
-			array( 'Datetime.EVT_ID' => self::$_event->ID() ),
319
-			'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' )
318
+			array('Datetime.EVT_ID' => self::$_event->ID()),
319
+			'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC')
320 320
 		);
321 321
 
322
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) {
322
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
323 323
 			//use the correct applicable time query depending on what version of core is being run.
324
-			$current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp');
325
-			$ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time );
324
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp');
325
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
326 326
 		}
327 327
 
328 328
 		// get all tickets for this event ordered by the datetime
329
-		$template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args );
329
+		$template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
330 330
 
331
-		if ( count( $template_args['tickets'] ) < 1 ) {
332
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>';
331
+		if (count($template_args['tickets']) < 1) {
332
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>';
333 333
 		}
334 334
 
335 335
 		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
336
-		$template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() );
337
-		if ( $template_args['max_atndz'] < 1 ) {
338
-			$sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' );
339
-			if ( current_user_can( 'edit_post', self::$_event->ID() )) {
340
-				$sales_closed_msg .=  sprintf(
341
-					__( '%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', 'event_espresso' ),
336
+		$template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit());
337
+		if ($template_args['max_atndz'] < 1) {
338
+			$sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso');
339
+			if (current_user_can('edit_post', self::$_event->ID())) {
340
+				$sales_closed_msg .= sprintf(
341
+					__('%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', 'event_espresso'),
342 342
 					'<div class="ee-attention" style="text-align: left;"><b>',
343 343
 					'</b><br />',
344
-					$link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">',
344
+					$link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">',
345 345
 					'</a></span></div>'
346 346
 				);
347 347
 			}
348
-			return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
348
+			return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
349 349
 		}
350 350
 
351
-		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
352
-		$templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event );
351
+		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php';
352
+		$templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event);
353 353
 
354 354
 		// redirecting to another site for registration ??
355 355
 		$external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE;
356 356
 		// set up the form (but not for the admin)
357
-		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : '';
357
+		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : '';
358 358
 		// if not redirecting to another site for registration
359
-		if ( ! $external_url ) {
360
-			EE_Registry::instance()->load_helper( 'Template' );
361
-			EE_Registry::instance()->load_helper( 'URL' );
359
+		if ( ! $external_url) {
360
+			EE_Registry::instance()->load_helper('Template');
361
+			EE_Registry::instance()->load_helper('URL');
362 362
 			// then display the ticket selector
363
-			$ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args );
363
+			$ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args);
364 364
 		} else {
365 365
 			// if not we still need to trigger the display of the submit button
366
-			add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
366
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
367 367
 			//display notice to admin that registration is external
368
-			$ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' );
368
+			$ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso');
369 369
 		}
370 370
 		// submit button and form close tag
371 371
 		$ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : '';
@@ -385,27 +385,27 @@  discard block
 block discarded – undo
385 385
 	 * @param 		string $external_url
386 386
 	 * @return 		string
387 387
 	 */
388
-	public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) {
388
+	public static function ticket_selector_form_open($ID = 0, $external_url = '') {
389 389
 		// if redirecting, we don't need any anything else
390
-		if ( $external_url ) {
391
-			EE_Registry::instance()->load_helper( 'URL' );
392
-			$html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">';
393
-			$query_args = EEH_URL::get_query_string( $external_url );
394
-			foreach ( $query_args as $query_arg => $value ) {
395
-				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
390
+		if ($external_url) {
391
+			EE_Registry::instance()->load_helper('URL');
392
+			$html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">';
393
+			$query_args = EEH_URL::get_query_string($external_url);
394
+			foreach ($query_args as $query_arg => $value) {
395
+				$html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
396 396
 			}
397 397
 			return $html;
398 398
 		}
399
-		EE_Registry::instance()->load_helper( 'Event_View' );
400
-		$checkout_url = EEH_Event_View::event_link_url( $ID );
401
-		if ( ! $checkout_url ) {
402
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
399
+		EE_Registry::instance()->load_helper('Event_View');
400
+		$checkout_url = EEH_Event_View::event_link_url($ID);
401
+		if ( ! $checkout_url) {
402
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
403 403
 		}
404 404
 		$extra_params = self::$_in_iframe ? ' target="_blank"' : '';
405
-		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
406
-		$html .= wp_nonce_field( 	'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE );
405
+		$html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
406
+		$html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE);
407 407
 		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
408
-		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event );
408
+		$html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
409 409
 		return $html;
410 410
 	}
411 411
 
@@ -420,21 +420,21 @@  discard block
 block discarded – undo
420 420
 	 * 	@return		string
421 421
 	 */
422 422
 	public static function display_ticket_selector_submit() {
423
-		if ( ! is_admin() ) {
424
-			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) {
423
+		if ( ! is_admin()) {
424
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) {
425 425
 				$btn_text = apply_filters(
426 426
 					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
427
-					__('Register Now', 'event_espresso' ),
427
+					__('Register Now', 'event_espresso'),
428 428
 					self::$_event
429 429
 				);
430
-				$html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"';
430
+				$html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"';
431 431
 				$html .= ' class="ticket-selector-submit-btn ticket-selector-submit-ajax"';
432
-				$html .= ' type="submit" value="' . $btn_text . '" />';
433
-				$html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event );
432
+				$html .= ' type="submit" value="'.$btn_text.'" />';
433
+				$html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event);
434 434
 				$html .= '<div class="clear"><br/></div></form>';
435 435
 				return $html;
436
-			} else if ( is_archive() ) {
437
-				return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn();
436
+			} else if (is_archive()) {
437
+				return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn();
438 438
 			}
439 439
 		}
440 440
 		return '';
@@ -466,13 +466,13 @@  discard block
 block discarded – undo
466 466
 	 * 	@return		string
467 467
 	 */
468 468
 	public static function display_view_details_btn() {
469
-		if ( ! self::$_event->get_permalink() ) {
470
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
469
+		if ( ! self::$_event->get_permalink()) {
470
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
471 471
 		}
472
-		$view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">';
473
-		$btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event );
474
-		$view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />';
475
-		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event );
472
+		$view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">';
473
+		$btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event);
474
+		$view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />';
475
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
476 476
 		$view_details_btn .= '<div class="clear"><br/></div>';
477 477
 		$view_details_btn .= '</form>';
478 478
 		return $view_details_btn;
@@ -491,18 +491,18 @@  discard block
 block discarded – undo
491 491
 	 * 	@return		bool
492 492
 	 */
493 493
 	public function process_ticket_selections() {
494
-		do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
494
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
495 495
 		//echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n";
496 496
 		// check nonce
497 497
 		if (
498 498
 			! is_admin() &&
499 499
 			(
500
-				! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) ||
501
-				! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' )
500
+				! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') ||
501
+				! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections')
502 502
 			)
503 503
 		) {
504 504
 			EE_Error::add_error(
505
-				sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
505
+				sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
506 506
 				__FILE__, __FUNCTION__, __LINE__
507 507
 			);
508 508
 			return FALSE;
@@ -514,114 +514,114 @@  discard block
 block discarded – undo
514 514
 		);
515 515
 		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
516 516
 		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
517
-		EE_Registry::instance()->load_core( 'Session' );
517
+		EE_Registry::instance()->load_core('Session');
518 518
 		// unless otherwise requested, clear the session
519
-		if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) {
520
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
519
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) {
520
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
521 521
 		}
522 522
 		//d( EE_Registry::instance()->SSN );
523 523
 
524
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
524
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
525 525
 		// do we have an event id?
526
-		if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) {
526
+		if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
527 527
 			// validate/sanitize data
528 528
 			$valid = self::_validate_post_data();
529 529
 			//check total tickets ordered vs max number of attendees that can register
530
-			if ( $valid['total_tickets'] > $valid['max_atndz'] ) {
530
+			if ($valid['total_tickets'] > $valid['max_atndz']) {
531 531
 
532 532
 				// ordering too many tickets !!!
533 533
 				$singular = 'You have attempted to purchase %s ticket.';
534 534
 				$plural = 'You have attempted to purchase %s tickets.';
535
-				$limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] );
535
+				$limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']);
536 536
 				// dev only message
537 537
 				$singular = '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.';
538 538
 				$plural = '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.';
539
-				$limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] );
540
-				EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ );
539
+				$limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']);
540
+				EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
541 541
 			} else {
542 542
 
543 543
 				// all data appears to be valid
544 544
 				$tckts_slctd = false;
545 545
 				$success = true;
546 546
 				// validate/sanitize data
547
-				$valid = apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid );
548
-				if ( $valid[ 'total_tickets' ] >0 ) {
547
+				$valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid);
548
+				if ($valid['total_tickets'] > 0) {
549 549
 					// load cart
550
-					EE_Registry::instance()->load_core( 'Cart' );
550
+					EE_Registry::instance()->load_core('Cart');
551 551
 
552 552
 					// cycle thru the number of data rows sent from the event listing
553
-					for ( $x = 0; $x < $valid['rows']; $x++ ) {
553
+					for ($x = 0; $x < $valid['rows']; $x++) {
554 554
 						// does this row actually contain a ticket quantity?
555
-						if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) {
555
+						if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
556 556
 							// YES we have a ticket quantity
557 557
 							$tckts_slctd = TRUE;
558 558
 							// d( $valid['ticket_obj'][$x] );
559
-							if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) {
559
+							if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
560 560
 								// then add ticket to cart
561
-								$tickets_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] );
562
-								if ( $tickets_added < 1 ) {
561
+								$tickets_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
562
+								if ($tickets_added < 1) {
563 563
 									$success = false;
564 564
 								}
565 565
 								//echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
566 566
 								//echo "\n . ticket_added: " . $ticket_added . '<br />';
567
-								if ( EE_Error::has_error() ) {
567
+								if (EE_Error::has_error()) {
568 568
 									break;
569 569
 								}
570 570
 							} else {
571 571
 								// nothing added to cart retrieved
572 572
 								EE_Error::add_error(
573
-									sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
573
+									sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
574 574
 									__FILE__, __FUNCTION__, __LINE__
575 575
 								);
576 576
 							}
577 577
 						}
578 578
 					}
579 579
 				}
580
-				do_action( 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', EE_Registry::instance()->CART, $this );
580
+				do_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', EE_Registry::instance()->CART, $this);
581 581
 				//d( EE_Registry::instance()->CART );
582 582
 				//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
583 583
 
584
-				if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd ) ) {
585
-					if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', $success ) ) {
586
-						do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this );
584
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
585
+					if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $success)) {
586
+						do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this);
587 587
 						EE_Registry::instance()->CART->recalculate_all_cart_totals();
588
-						EE_Registry::instance()->CART->save_cart( FALSE );
588
+						EE_Registry::instance()->CART->save_cart(FALSE);
589 589
 						EE_Registry::instance()->SSN->update();
590 590
 						//d( EE_Registry::instance()->CART );
591 591
 						//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
592 592
 						// just return TRUE for registrations being made from admin
593
-						if ( is_admin() ) {
593
+						if (is_admin()) {
594 594
 							return TRUE;
595 595
 						}
596 596
 
597
-						EE_Error::get_notices( false, true );
598
-						wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() ));
597
+						EE_Error::get_notices(false, true);
598
+						wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url()));
599 599
 						exit();
600 600
 
601 601
 					} else {
602
-						if ( ! EE_Error::has_error() ) {
602
+						if ( ! EE_Error::has_error()) {
603 603
 							// nothing added to cart
604
-							EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
604
+							EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
605 605
 						}
606 606
 					}
607 607
 
608 608
 				} else {
609 609
 					// no ticket quantities were selected
610
-					EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
610
+					EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
611 611
 				}
612 612
 			}
613 613
 			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
614 614
 			// at this point, just return if registration is being made from admin
615
-			if ( is_admin() ) {
615
+			if (is_admin()) {
616 616
 				return FALSE;
617 617
 			}
618
-			if ( $valid['return_url'] ) {
619
-				EE_Error::get_notices( FALSE, TRUE );
620
-				wp_safe_redirect( $valid['return_url'] );
618
+			if ($valid['return_url']) {
619
+				EE_Error::get_notices(FALSE, TRUE);
620
+				wp_safe_redirect($valid['return_url']);
621 621
 				exit();
622
-			} elseif ( isset( $event_to_add['id'] )) {
623
-				EE_Error::get_notices( FALSE, TRUE );
624
-				wp_safe_redirect( get_permalink( $event_to_add['id'] ));
622
+			} elseif (isset($event_to_add['id'])) {
623
+				EE_Error::get_notices(FALSE, TRUE);
624
+				wp_safe_redirect(get_permalink($event_to_add['id']));
625 625
 				exit();
626 626
 			} else {
627 627
 				echo EE_Error::get_notices();
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		} else {
631 631
 			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
632 632
 			EE_Error::add_error(
633
-				sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
633
+				sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
634 634
 				__FILE__, __FUNCTION__, __LINE__
635 635
 			);
636 636
 		}
@@ -648,18 +648,18 @@  discard block
 block discarded – undo
648 648
 	 * @return        array  or FALSE
649 649
 	 */
650 650
 	private static function _validate_post_data() {
651
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
651
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
652 652
 
653 653
 		// start with an empty array()
654 654
 		$valid_data = array();
655 655
 		//		d( $_POST );
656 656
 		//if event id is valid
657
-		$id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ));
658
-		if ( $id ) {
657
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
658
+		if ($id) {
659 659
 			// grab valid id
660 660
 			$valid_data['id'] = $id;
661 661
 			// grab and sanitize return-url
662
-			$valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id ));
662
+			$valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id));
663 663
 			// array of other form names
664 664
 			$inputs_to_clean = array(
665 665
 				'event_id' => 'tkt-slctr-event-id',
@@ -672,22 +672,22 @@  discard block
 block discarded – undo
672 672
 			// let's track the total number of tickets ordered.'
673 673
 			$valid_data['total_tickets'] = 0;
674 674
 			// cycle through $inputs_to_clean array
675
-			foreach ( $inputs_to_clean as $what => $input_to_clean ) {
675
+			foreach ($inputs_to_clean as $what => $input_to_clean) {
676 676
 				// check for POST data
677
-				if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) {
677
+				if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
678 678
 					// grab value
679
-					$input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id );
679
+					$input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
680 680
 					switch ($what) {
681 681
 
682 682
 						// integers
683 683
 						case 'event_id':
684
-							$valid_data[$what] = absint( $input_value );
684
+							$valid_data[$what] = absint($input_value);
685 685
 							// get event via the event id we put in the form
686
-							$valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] );
686
+							$valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']);
687 687
 							break;
688 688
 						case 'rows':
689 689
 						case 'max_atndz':
690
-							$valid_data[$what] = absint( $input_value );
690
+							$valid_data[$what] = absint($input_value);
691 691
 							break;
692 692
 
693 693
 						// arrays of integers
@@ -695,27 +695,27 @@  discard block
 block discarded – undo
695 695
 							//							d( $input_value );
696 696
 							$row_qty = $input_value;
697 697
 							// if qty is coming from a radio button input, then we need to assemble an array of rows
698
-							if( ! is_array( $row_qty )) {
698
+							if ( ! is_array($row_qty)) {
699 699
 								// get number of rows
700
-								$rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1;
700
+								$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1;
701 701
 								//								d( $rows );
702 702
 								// explode ints by the dash
703
-								$row_qty = explode( '-', $row_qty );
704
-								$row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1;
705
-								$qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0;
706
-								$row_qty = array( $row => $qty );
703
+								$row_qty = explode('-', $row_qty);
704
+								$row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1;
705
+								$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
706
+								$row_qty = array($row => $qty);
707 707
 								//								 d( $row_qty );
708
-								for( $x = 1; $x <= $rows; $x++ ) {
709
-									if ( ! isset( $row_qty[$x] )) {
708
+								for ($x = 1; $x <= $rows; $x++) {
709
+									if ( ! isset($row_qty[$x])) {
710 710
 										$row_qty[$x] = 0;
711 711
 									}
712 712
 								}
713 713
 							}
714
-							ksort( $row_qty );
714
+							ksort($row_qty);
715 715
 							//							 d( $row_qty );
716 716
 							// cycle thru values
717
-							foreach ( $row_qty as $qty ) {
718
-								$qty = absint( $qty );
717
+							foreach ($row_qty as $qty) {
718
+								$qty = absint($qty);
719 719
 								// sanitize as integers
720 720
 								$valid_data[$what][] = $qty;
721 721
 								$valid_data['total_tickets'] += $qty;
@@ -726,19 +726,19 @@  discard block
 block discarded – undo
726 726
 						case 'ticket_id':
727 727
 							$value_array = array();
728 728
 							// cycle thru values
729
-							foreach ( $input_value as $key=>$value ) {
729
+							foreach ($input_value as $key=>$value) {
730 730
 								// allow only numbers, letters,  spaces, commas and dashes
731
-								$value_array[ $key ] = wp_strip_all_tags( $value );
731
+								$value_array[$key] = wp_strip_all_tags($value);
732 732
 								// get ticket via the ticket id we put in the form
733
-								$ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value );
734
-								$valid_data['ticket_obj'][ $key ] = $ticket_obj;
733
+								$ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
734
+								$valid_data['ticket_obj'][$key] = $ticket_obj;
735 735
 							}
736
-							$valid_data[ $what ] = $value_array;
736
+							$valid_data[$what] = $value_array;
737 737
 							break;
738 738
 
739 739
 						case 'return_url' :
740 740
 							// grab and sanitize return-url
741
-							$valid_data[$what] = esc_url_raw( $input_value );
741
+							$valid_data[$what] = esc_url_raw($input_value);
742 742
 							break;
743 743
 
744 744
 					} 	// end switch $what
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 			} 	// end foreach $inputs_to_clean
747 747
 
748 748
 		} else {
749
-			EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
749
+			EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
750 750
 			return FALSE;
751 751
 		}
752 752
 
@@ -764,29 +764,29 @@  discard block
 block discarded – undo
764 764
 	 * @param int       $qty
765 765
 	 * @return int quantity of tickets added
766 766
 	 */
767
-	private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) {
768
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
767
+	private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) {
768
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
769 769
 		// get the number of spaces left for this datetime ticket
770
-		$available_spaces = self::_ticket_datetime_availability( $ticket );
770
+		$available_spaces = self::_ticket_datetime_availability($ticket);
771 771
 		// compare available spaces against the number of tickets being purchased
772
-		if ( $available_spaces >= $qty ) {
772
+		if ($available_spaces >= $qty) {
773 773
 			// allow addons to prevent a ticket from being added to cart
774
-			if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) {
774
+			if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) {
775 775
 				return 0;
776 776
 			}
777
-			$qty = apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket );
777
+			$qty = apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket);
778 778
 			// add event to cart
779
-			if( $qty && EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) {
780
-				self::_recalculate_ticket_datetime_availability( $ticket, $qty );
779
+			if ($qty && EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
780
+				self::_recalculate_ticket_datetime_availability($ticket, $qty);
781 781
 				return $qty;
782 782
 			} else {
783 783
 				return 0;
784 784
 			}
785 785
 		} else {
786 786
 			// tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets
787
-			$available_spaces = self::_ticket_datetime_availability( $ticket, true );
787
+			$available_spaces = self::_ticket_datetime_availability($ticket, true);
788 788
 			// greedy greedy greedy eh?
789
-			if ( $available_spaces > 0 ) {
789
+			if ($available_spaces > 0) {
790 790
 				// add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces
791 791
 				EE_Error::add_error(
792 792
 					sprintf(
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 					__FILE__, __FUNCTION__, __LINE__
803 803
 				);
804 804
 			} else {
805
-				EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
805
+				EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
806 806
 			}
807 807
 			return 0;
808 808
 		}
@@ -820,22 +820,22 @@  discard block
 block discarded – undo
820 820
 	 * @param 	bool         $get_original_ticket_spaces
821 821
 	 * @return 	int
822 822
 	 */
823
-	private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) {
823
+	private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) {
824 824
 		// if the $_available_spaces array has not been set up yet...
825
-		if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
826
-				self::_set_initial_ticket_datetime_availability( $ticket );
825
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
826
+				self::_set_initial_ticket_datetime_availability($ticket);
827 827
 		}
828 828
 		$available_spaces = $ticket->qty() - $ticket->sold();
829
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
829
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
830 830
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
831
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
831
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
832 832
 				// if we want the original datetime availability BEFORE we started subtracting tickets ?
833
-				if ( $get_original_ticket_spaces ) {
833
+				if ($get_original_ticket_spaces) {
834 834
 					// then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
835
-					$available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] );
835
+					$available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
836 836
 				} else {
837 837
 					// we want the updated ticket availability as stored in the "datetimes" array
838
-					$available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] );
838
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
839 839
 				}
840 840
 			}
841 841
 		}
@@ -851,23 +851,23 @@  discard block
 block discarded – undo
851 851
 	 * @param 	EE_Ticket $ticket
852 852
 	 * @return 	int
853 853
 	 */
854
-	private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) {
854
+	private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) {
855 855
 		// first, get all of the datetimes that are available to this ticket
856 856
 		$datetimes = $ticket->get_many_related(
857 857
 			'Datetime',
858
-			array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ))
858
+			array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC'))
859 859
 		);
860
-		if ( ! empty( $datetimes )) {
860
+		if ( ! empty($datetimes)) {
861 861
 			// now loop thru all of the datetimes
862
-			foreach ( $datetimes as $datetime  ) {
863
-				if ( $datetime instanceof EE_Datetime ) {
862
+			foreach ($datetimes as $datetime) {
863
+				if ($datetime instanceof EE_Datetime) {
864 864
 					// the number of spaces available for the datetime without considering individual ticket quantities
865 865
 					$spaces_remaining = $datetime->spaces_remaining();
866 866
 					// 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
867
-					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining );
867
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining);
868 868
 					// if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
869 869
 					// else just take the datetime spaces remaining, and assign to the datetimes array
870
-					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining;
870
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining;
871 871
 				}
872 872
 			}
873 873
 		}
@@ -883,12 +883,12 @@  discard block
 block discarded – undo
883 883
 	 * @param 	int   $qty
884 884
 	 * @return 	int
885 885
 	 */
886
-	private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) {
887
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
886
+	private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) {
887
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
888 888
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
889
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
889
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
890 890
 				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
891
-				self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty;
891
+				self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty;
892 892
 			}
893 893
 		}
894 894
 	}
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	*/
906 906
 	public static function load_tckt_slctr_assets() {
907 907
 		// add some style
908
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
909
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
908
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
909
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
910 910
 			wp_enqueue_style('ticket_selector');
911 911
 			// make it dance
912 912
 			//			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
 
921 921
 	public static function load_tckt_slctr_assets_admin() {
922 922
 		//iframe button js on admin event editor page
923
-		if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) {
924
-			wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true );
925
-			wp_enqueue_script( 'ticket_selector_embed' );
923
+		if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') {
924
+			wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
925
+			wp_enqueue_script('ticket_selector_embed');
926 926
 		}
927 927
 	}
928 928
 
Please login to merge, or discard this patch.