@@ -12,68 +12,68 @@ discard block |
||
12 | 12 | * @since $VID:$ |
13 | 13 | * |
14 | 14 | */ |
15 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
15 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
16 | 16 | exit('No direct script access allowed'); |
17 | 17 | } |
18 | 18 | |
19 | -abstract class EE_Quantity_Modifying_Line_Item_Filter extends EE_Line_Item_Filter_Base{ |
|
19 | +abstract class EE_Quantity_Modifying_Line_Item_Filter extends EE_Line_Item_Filter_Base { |
|
20 | 20 | /** |
21 | 21 | * Creates a duplicate of the line item tree, except only includes billable items |
22 | 22 | * and the portion of line items attributed to billable things |
23 | 23 | * @param EEI_Line_Item $line_item |
24 | 24 | * @return \EEI_Line_Item |
25 | 25 | */ |
26 | - public function process( EEI_Line_Item $line_item ) { |
|
27 | - $this->_adjust_line_item_quantity( $line_item ); |
|
28 | - if( ! $line_item->children() ) { |
|
26 | + public function process(EEI_Line_Item $line_item) { |
|
27 | + $this->_adjust_line_item_quantity($line_item); |
|
28 | + if ( ! $line_item->children()) { |
|
29 | 29 | return $line_item; |
30 | 30 | } |
31 | 31 | //the original running total (taking ALL tickets into account) |
32 | 32 | $running_total_of_children = 0; |
33 | 33 | //the new running total (only taking the specified ticket quantities into account) |
34 | 34 | $runnign_total_of_children_under_consideration = 0; |
35 | - foreach ( $line_item->children() as $child_line_item ) { |
|
36 | - if( $child_line_item->is_percent() ) { |
|
35 | + foreach ($line_item->children() as $child_line_item) { |
|
36 | + if ($child_line_item->is_percent()) { |
|
37 | 37 | $original_li_total = $running_total_of_children * $child_line_item->percent() / 100; |
38 | - }else{ |
|
38 | + } else { |
|
39 | 39 | $original_li_total = $child_line_item->unit_price() * $child_line_item->quantity(); |
40 | 40 | } |
41 | 41 | |
42 | - $this->process( $child_line_item ); |
|
42 | + $this->process($child_line_item); |
|
43 | 43 | /* |
44 | 44 | * If this line item is a normal line item that isn't for a ticket |
45 | 45 | * we want to modify its total (and unit price if not a percentage line item) |
46 | 46 | * so it reflects only that portion of the surcharge/discount shared by these |
47 | 47 | * registrations |
48 | 48 | */ |
49 | - if( $child_line_item->type() === EEM_Line_Item::type_line_item && |
|
50 | - $child_line_item->OBJ_type() !== 'Ticket' ) { |
|
51 | - if( $running_total_of_children ) { |
|
49 | + if ($child_line_item->type() === EEM_Line_Item::type_line_item && |
|
50 | + $child_line_item->OBJ_type() !== 'Ticket') { |
|
51 | + if ($running_total_of_children) { |
|
52 | 52 | $percent_of_running_total = $original_li_total / $running_total_of_children; |
53 | 53 | } else { |
54 | 54 | $percent_of_running_total = 0; |
55 | 55 | } |
56 | 56 | |
57 | - $child_line_item->set_total( $runnign_total_of_children_under_consideration * $percent_of_running_total ); |
|
58 | - if( ! $child_line_item->is_percent() ) { |
|
59 | - $child_line_item->set_unit_price( $child_line_item->total() / $child_line_item->quantity() ); |
|
57 | + $child_line_item->set_total($runnign_total_of_children_under_consideration * $percent_of_running_total); |
|
58 | + if ( ! $child_line_item->is_percent()) { |
|
59 | + $child_line_item->set_unit_price($child_line_item->total() / $child_line_item->quantity()); |
|
60 | 60 | } |
61 | - }elseif( $line_item->type() === EEM_Line_Item::type_line_item && |
|
62 | - $line_item->OBJ_type() === 'Ticket' ) { |
|
61 | + }elseif ($line_item->type() === EEM_Line_Item::type_line_item && |
|
62 | + $line_item->OBJ_type() === 'Ticket') { |
|
63 | 63 | //make sure this item's quantity matches its parent |
64 | - if( ! $child_line_item->is_percent() ) { |
|
65 | - $child_line_item->set_quantity( $line_item->quantity() ); |
|
66 | - $child_line_item->set_total( $child_line_item->unit_price() * $child_line_item->quantity() ); |
|
64 | + if ( ! $child_line_item->is_percent()) { |
|
65 | + $child_line_item->set_quantity($line_item->quantity()); |
|
66 | + $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity()); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | $running_total_of_children += $original_li_total; |
70 | 70 | $runnign_total_of_children_under_consideration += $child_line_item->total(); |
71 | 71 | } |
72 | - $line_item->set_total( $runnign_total_of_children_under_consideration ); |
|
73 | - if( $line_item->quantity() ) { |
|
74 | - $line_item->set_unit_price( $runnign_total_of_children_under_consideration / $line_item->quantity() ); |
|
72 | + $line_item->set_total($runnign_total_of_children_under_consideration); |
|
73 | + if ($line_item->quantity()) { |
|
74 | + $line_item->set_unit_price($runnign_total_of_children_under_consideration / $line_item->quantity()); |
|
75 | 75 | } else { |
76 | - $line_item->set_unit_price( 0 ); |
|
76 | + $line_item->set_unit_price(0); |
|
77 | 77 | } |
78 | 78 | return $line_item; |
79 | 79 | } |
@@ -82,5 +82,5 @@ discard block |
||
82 | 82 | * Updates the line item's quantity according to whatever logic |
83 | 83 | * @return EE_Line_Item |
84 | 84 | */ |
85 | - abstract protected function _adjust_line_item_quantity( EEI_Line_Item $line_item ); |
|
85 | + abstract protected function _adjust_line_item_quantity(EEI_Line_Item $line_item); |
|
86 | 86 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | foreach ( $line_item->children() as $child_line_item ) { |
36 | 36 | if( $child_line_item->is_percent() ) { |
37 | 37 | $original_li_total = $running_total_of_children * $child_line_item->percent() / 100; |
38 | - }else{ |
|
38 | + } else{ |
|
39 | 39 | $original_li_total = $child_line_item->unit_price() * $child_line_item->quantity(); |
40 | 40 | } |
41 | 41 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | if( ! $child_line_item->is_percent() ) { |
59 | 59 | $child_line_item->set_unit_price( $child_line_item->total() / $child_line_item->quantity() ); |
60 | 60 | } |
61 | - }elseif( $line_item->type() === EEM_Line_Item::type_line_item && |
|
61 | + } elseif( $line_item->type() === EEM_Line_Item::type_line_item && |
|
62 | 62 | $line_item->OBJ_type() === 'Ticket' ) { |
63 | 63 | //make sure this item's quantity matches its parent |
64 | 64 | if( ! $child_line_item->is_percent() ) { |
@@ -1,6 +1,6 @@ discard block |
||
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 EE_Single_Registration_Line_Item_Filter |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param EE_Registration $registration |
23 | 23 | */ |
24 | - public function __construct( $registration ) { |
|
25 | - if( $registration instanceof EE_Registration ) { |
|
26 | - $registrations = array( $registration ); |
|
24 | + public function __construct($registration) { |
|
25 | + if ($registration instanceof EE_Registration) { |
|
26 | + $registrations = array($registration); |
|
27 | 27 | } else { |
28 | 28 | $registrations = array(); |
29 | 29 | } |
30 | - parent::__construct( $registrations ); |
|
30 | + parent::__construct($registrations); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | // End of file EE_Single_Registration_Line_Item_Filter.class.php |
@@ -1,6 +1,6 @@ discard block |
||
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 | /** |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * EE_Billable_Line_Item_Filter constructor. |
37 | 37 | * @param EE_Ticket[] $tickets |
38 | 38 | */ |
39 | - public function __construct( $tickets ) { |
|
39 | + public function __construct($tickets) { |
|
40 | 40 | $this->_tickets = $tickets; |
41 | - foreach( $this->_tickets as $ticket ) { |
|
41 | + foreach ($this->_tickets as $ticket) { |
|
42 | 42 | $this->_ticket_ids[] = $ticket->ID(); |
43 | 43 | } |
44 | 44 | } |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param EEI_Line_Item $line_item |
50 | 50 | * @return EEI_Line_Item |
51 | 51 | */ |
52 | - protected function _adjust_line_item_quantity( EEI_Line_Item $line_item ) { |
|
52 | + protected function _adjust_line_item_quantity(EEI_Line_Item $line_item) { |
|
53 | 53 | // is this a ticket ? |
54 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket' ) { |
|
54 | + if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket') { |
|
55 | 55 | // if this ticket is billable at this moment, then we should have a positive quantity |
56 | - if ( ! in_array( $line_item->OBJ_ID(), $this->_ticket_ids ) ) { |
|
57 | - $line_item->set_quantity( 0 ); |
|
58 | - $line_item->set_total( $line_item->unit_price() * $line_item->quantity() ); |
|
56 | + if ( ! in_array($line_item->OBJ_ID(), $this->_ticket_ids)) { |
|
57 | + $line_item->set_quantity(0); |
|
58 | + $line_item->set_total($line_item->unit_price() * $line_item->quantity()); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | return $line_item; |
@@ -1,6 +1,6 @@ discard block |
||
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 | /** |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * EE_Billable_Line_Item_Filter constructor. |
37 | 37 | * @param EE_Registration[] $registrations |
38 | 38 | */ |
39 | - public function __construct( $registrations ) { |
|
39 | + public function __construct($registrations) { |
|
40 | 40 | $this->_registrations = $registrations; |
41 | - $this->_calculate_counts_per_line_item_code( $registrations ); |
|
41 | + $this->_calculate_counts_per_line_item_code($registrations); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * @param EE_Registration[] $registrations |
47 | 47 | * @return void |
48 | 48 | */ |
49 | - protected function _calculate_counts_per_line_item_code( $registrations ) { |
|
50 | - foreach( $registrations as $registration ) { |
|
51 | - $line_item_code = EEM_Line_Item::instance()->get_var( EEM_Line_Item::instance()->line_item_for_registration_query_params( $registration, array( 'limit' => 1 ) ), 'LIN_code' ); |
|
52 | - if( $line_item_code ) { |
|
53 | - if( ! isset( $this->_counts_per_line_item_code[ $line_item_code ] ) ) { |
|
54 | - $this->_counts_per_line_item_code[ $line_item_code ] = 1; |
|
55 | - }else{ |
|
56 | - $this->_counts_per_line_item_code[ $line_item_code ]++; |
|
49 | + protected function _calculate_counts_per_line_item_code($registrations) { |
|
50 | + foreach ($registrations as $registration) { |
|
51 | + $line_item_code = EEM_Line_Item::instance()->get_var(EEM_Line_Item::instance()->line_item_for_registration_query_params($registration, array('limit' => 1)), 'LIN_code'); |
|
52 | + if ($line_item_code) { |
|
53 | + if ( ! isset($this->_counts_per_line_item_code[$line_item_code])) { |
|
54 | + $this->_counts_per_line_item_code[$line_item_code] = 1; |
|
55 | + } else { |
|
56 | + $this->_counts_per_line_item_code[$line_item_code]++; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | * @param EEI_Line_Item $line_item |
70 | 70 | * @return EEI_Line_Item |
71 | 71 | */ |
72 | - protected function _adjust_line_item_quantity( EEI_Line_Item $line_item ) { |
|
72 | + protected function _adjust_line_item_quantity(EEI_Line_Item $line_item) { |
|
73 | 73 | // is this a ticket ? |
74 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket' ) { |
|
74 | + if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket') { |
|
75 | 75 | // if this ticket is billable at this moment, then we should have a positive quantity |
76 | - if ( isset( $this->_counts_per_line_item_code[ $line_item->code() ] )) { |
|
76 | + if (isset($this->_counts_per_line_item_code[$line_item->code()])) { |
|
77 | 77 | // set quantity based on number of billable registrations for this ticket |
78 | - $quantity = $this->_counts_per_line_item_code[ $line_item->code() ]; |
|
78 | + $quantity = $this->_counts_per_line_item_code[$line_item->code()]; |
|
79 | 79 | } else { |
80 | 80 | $quantity = 0; |
81 | 81 | } |
82 | - $line_item->set_quantity( $quantity ); |
|
83 | - $line_item->set_total( $line_item->unit_price() * $line_item->quantity() ); |
|
82 | + $line_item->set_quantity($quantity); |
|
83 | + $line_item->set_total($line_item->unit_price() * $line_item->quantity()); |
|
84 | 84 | } |
85 | 85 | return $line_item; |
86 | 86 | } |
@@ -459,7 +459,7 @@ |
||
459 | 459 | //must be explicit because schema could equal true. |
460 | 460 | if( $schema === 'no_html' ){ |
461 | 461 | $timezone_string = ' (' . $DateTime->format( 'T' ) . ')'; |
462 | - }else{ |
|
462 | + } else{ |
|
463 | 463 | $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>'; |
464 | 464 | } |
465 | 465 | } else { |