@@ -13,195 +13,195 @@ |
||
13 | 13 | class EE_Specific_Registrations_Line_Item_Filter extends EE_Line_Item_Filter_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * array of line item codes and their corresponding quantities for registrations |
|
18 | - * |
|
19 | - * @type array $_line_item_registrations |
|
20 | - */ |
|
21 | - protected $_line_item_registrations = array(); |
|
16 | + /** |
|
17 | + * array of line item codes and their corresponding quantities for registrations |
|
18 | + * |
|
19 | + * @type array $_line_item_registrations |
|
20 | + */ |
|
21 | + protected $_line_item_registrations = array(); |
|
22 | 22 | |
23 | - /** |
|
24 | - * Just kept in case we want it someday. Currently unused |
|
25 | - * |
|
26 | - * @var EE_Registration[] |
|
27 | - */ |
|
28 | - protected $_registrations = array(); |
|
23 | + /** |
|
24 | + * Just kept in case we want it someday. Currently unused |
|
25 | + * |
|
26 | + * @var EE_Registration[] |
|
27 | + */ |
|
28 | + protected $_registrations = array(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var EE_Registration |
|
32 | - */ |
|
33 | - protected $_current_registration; |
|
30 | + /** |
|
31 | + * @var EE_Registration |
|
32 | + */ |
|
33 | + protected $_current_registration; |
|
34 | 34 | |
35 | - /** |
|
36 | - * these reg statuses should NOT increment the line item quantity |
|
37 | - * |
|
38 | - * @var array |
|
39 | - */ |
|
40 | - protected $_closed_reg_statuses = array(); |
|
35 | + /** |
|
36 | + * these reg statuses should NOT increment the line item quantity |
|
37 | + * |
|
38 | + * @var array |
|
39 | + */ |
|
40 | + protected $_closed_reg_statuses = array(); |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * EE_Billable_Line_Item_Filter constructor. |
|
45 | - * |
|
46 | - * @param EE_Registration[] $registrations |
|
47 | - * @throws EE_Error |
|
48 | - * @throws ReflectionException |
|
49 | - */ |
|
50 | - public function __construct(array $registrations) |
|
51 | - { |
|
52 | - $this->_registrations = $registrations; |
|
53 | - $this->_calculate_registrations_per_line_item_code($registrations); |
|
54 | - // these reg statuses should NOT increment the line item quantity |
|
55 | - $this->_closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
56 | - } |
|
43 | + /** |
|
44 | + * EE_Billable_Line_Item_Filter constructor. |
|
45 | + * |
|
46 | + * @param EE_Registration[] $registrations |
|
47 | + * @throws EE_Error |
|
48 | + * @throws ReflectionException |
|
49 | + */ |
|
50 | + public function __construct(array $registrations) |
|
51 | + { |
|
52 | + $this->_registrations = $registrations; |
|
53 | + $this->_calculate_registrations_per_line_item_code($registrations); |
|
54 | + // these reg statuses should NOT increment the line item quantity |
|
55 | + $this->_closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * sets the _line_item_registrations from the provided registrations |
|
61 | - * |
|
62 | - * @param EE_Registration[] $registrations |
|
63 | - * @return void |
|
64 | - * @throws EE_Error |
|
65 | - * @throws ReflectionException |
|
66 | - */ |
|
67 | - protected function _calculate_registrations_per_line_item_code(array $registrations) |
|
68 | - { |
|
69 | - foreach ($registrations as $registration) { |
|
70 | - $line_item_code = EEM_Line_Item::instance()->get_var( |
|
71 | - EEM_Line_Item::instance()->line_item_for_registration_query_params( |
|
72 | - $registration, |
|
73 | - array('limit' => 1) |
|
74 | - ), |
|
75 | - 'LIN_code' |
|
76 | - ); |
|
77 | - if ($line_item_code) { |
|
78 | - if (! isset($this->_line_item_registrations[ $line_item_code ])) { |
|
79 | - $this->_line_item_registrations[ $line_item_code ] = array(); |
|
80 | - } |
|
81 | - $this->_line_item_registrations[ $line_item_code ][ $registration->ID() ] = $registration; |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
59 | + /** |
|
60 | + * sets the _line_item_registrations from the provided registrations |
|
61 | + * |
|
62 | + * @param EE_Registration[] $registrations |
|
63 | + * @return void |
|
64 | + * @throws EE_Error |
|
65 | + * @throws ReflectionException |
|
66 | + */ |
|
67 | + protected function _calculate_registrations_per_line_item_code(array $registrations) |
|
68 | + { |
|
69 | + foreach ($registrations as $registration) { |
|
70 | + $line_item_code = EEM_Line_Item::instance()->get_var( |
|
71 | + EEM_Line_Item::instance()->line_item_for_registration_query_params( |
|
72 | + $registration, |
|
73 | + array('limit' => 1) |
|
74 | + ), |
|
75 | + 'LIN_code' |
|
76 | + ); |
|
77 | + if ($line_item_code) { |
|
78 | + if (! isset($this->_line_item_registrations[ $line_item_code ])) { |
|
79 | + $this->_line_item_registrations[ $line_item_code ] = array(); |
|
80 | + } |
|
81 | + $this->_line_item_registrations[ $line_item_code ][ $registration->ID() ] = $registration; |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * Creates a duplicate of the line item tree, except only includes billable items |
|
89 | - * and the portion of line items attributed to billable things |
|
90 | - * |
|
91 | - * @param EE_Line_Item $line_item |
|
92 | - * @return EE_Line_Item |
|
93 | - * @throws EE_Error |
|
94 | - * @throws ReflectionException |
|
95 | - */ |
|
96 | - public function process(EE_Line_Item $line_item): ?EE_Line_Item |
|
97 | - { |
|
98 | - $this->_adjust_line_item_quantity($line_item); |
|
99 | - if (! $line_item->children()) { |
|
100 | - return $line_item; |
|
101 | - } |
|
102 | - // the original running total (taking ALL tickets into account) |
|
103 | - $running_total_of_children = 0; |
|
104 | - // the new running total (only taking the specified ticket quantities into account) |
|
105 | - $running_total_of_children_under_consideration = 0; |
|
106 | - // let's also track the quantity of tickets that pertain to the registrations |
|
107 | - $total_child_ticket_quantity = 0; |
|
108 | - foreach ($line_item->children() as $child_line_item) { |
|
109 | - $original_li_total = $child_line_item->is_percent() |
|
110 | - ? $running_total_of_children * $child_line_item->percent() / 100 |
|
111 | - : $child_line_item->unit_price() * $child_line_item->quantity(); |
|
112 | - $this->process($child_line_item); |
|
113 | - // If this line item is a normal line item that isn't for a ticket, |
|
114 | - // we want to modify its total (and unit price if not a percentage line item) |
|
115 | - // so it reflects only that portion of the surcharge/discount shared by these registrations |
|
116 | - if ( |
|
117 | - $child_line_item->type() === EEM_Line_Item::type_line_item |
|
118 | - && $child_line_item->OBJ_type() !== 'Ticket' |
|
119 | - ) { |
|
120 | - $percent_of_running_total = $running_total_of_children |
|
121 | - ? $original_li_total / $running_total_of_children |
|
122 | - : 0; |
|
123 | - $child_line_item->set_total( |
|
124 | - $running_total_of_children_under_consideration * $percent_of_running_total |
|
125 | - ); |
|
126 | - if (! $child_line_item->is_percent()) { |
|
127 | - $child_line_item->set_unit_price($child_line_item->total() / $child_line_item->quantity()); |
|
128 | - } |
|
129 | - } elseif ( |
|
130 | - // make sure this item's quantity and total matches its parent |
|
131 | - $line_item->type() === EEM_Line_Item::type_line_item |
|
132 | - && $line_item->OBJ_type() === 'Ticket' |
|
133 | - // but not if it's a percentage modifier |
|
134 | - && ! $child_line_item->is_percent() |
|
135 | - && ! ( |
|
136 | - // or a cancellation |
|
137 | - $child_line_item->is_cancelled() |
|
138 | - && ! ( |
|
139 | - // unless it IS a cancellation and the current registration is cancelled |
|
140 | - $child_line_item->is_cancelled() |
|
141 | - && $this->_current_registration instanceof EE_Registration |
|
142 | - && in_array($this->_current_registration->status_ID(), $this->_closed_reg_statuses, true) |
|
143 | - ) |
|
144 | - ) |
|
145 | - ) { |
|
146 | - $child_line_item->set_quantity($line_item->quantity()); |
|
147 | - $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity()); |
|
148 | - } elseif ($child_line_item->type() === EEM_Line_Item::type_sub_tax) { |
|
149 | - // add this line item's portion of any directly applied taxes |
|
150 | - $child_line_item->set_quantity($line_item->quantity()); |
|
151 | - $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity()); |
|
152 | - } |
|
153 | - $running_total_of_children += $original_li_total; |
|
154 | - $running_total_of_children_under_consideration += $child_line_item->total(); |
|
155 | - if ($child_line_item->OBJ_type() === 'Ticket') { |
|
156 | - $total_child_ticket_quantity += $child_line_item->quantity(); |
|
157 | - } |
|
158 | - } |
|
159 | - $line_item->set_total($running_total_of_children_under_consideration); |
|
160 | - if ($line_item->quantity()) { |
|
161 | - $line_item->set_unit_price($running_total_of_children_under_consideration / $line_item->quantity()); |
|
162 | - } else { |
|
163 | - $line_item->set_unit_price(0); |
|
164 | - } |
|
165 | - if ($line_item->OBJ_type() === 'Event') { |
|
166 | - $line_item->set_quantity($total_child_ticket_quantity); |
|
167 | - } |
|
168 | - return $line_item; |
|
169 | - } |
|
87 | + /** |
|
88 | + * Creates a duplicate of the line item tree, except only includes billable items |
|
89 | + * and the portion of line items attributed to billable things |
|
90 | + * |
|
91 | + * @param EE_Line_Item $line_item |
|
92 | + * @return EE_Line_Item |
|
93 | + * @throws EE_Error |
|
94 | + * @throws ReflectionException |
|
95 | + */ |
|
96 | + public function process(EE_Line_Item $line_item): ?EE_Line_Item |
|
97 | + { |
|
98 | + $this->_adjust_line_item_quantity($line_item); |
|
99 | + if (! $line_item->children()) { |
|
100 | + return $line_item; |
|
101 | + } |
|
102 | + // the original running total (taking ALL tickets into account) |
|
103 | + $running_total_of_children = 0; |
|
104 | + // the new running total (only taking the specified ticket quantities into account) |
|
105 | + $running_total_of_children_under_consideration = 0; |
|
106 | + // let's also track the quantity of tickets that pertain to the registrations |
|
107 | + $total_child_ticket_quantity = 0; |
|
108 | + foreach ($line_item->children() as $child_line_item) { |
|
109 | + $original_li_total = $child_line_item->is_percent() |
|
110 | + ? $running_total_of_children * $child_line_item->percent() / 100 |
|
111 | + : $child_line_item->unit_price() * $child_line_item->quantity(); |
|
112 | + $this->process($child_line_item); |
|
113 | + // If this line item is a normal line item that isn't for a ticket, |
|
114 | + // we want to modify its total (and unit price if not a percentage line item) |
|
115 | + // so it reflects only that portion of the surcharge/discount shared by these registrations |
|
116 | + if ( |
|
117 | + $child_line_item->type() === EEM_Line_Item::type_line_item |
|
118 | + && $child_line_item->OBJ_type() !== 'Ticket' |
|
119 | + ) { |
|
120 | + $percent_of_running_total = $running_total_of_children |
|
121 | + ? $original_li_total / $running_total_of_children |
|
122 | + : 0; |
|
123 | + $child_line_item->set_total( |
|
124 | + $running_total_of_children_under_consideration * $percent_of_running_total |
|
125 | + ); |
|
126 | + if (! $child_line_item->is_percent()) { |
|
127 | + $child_line_item->set_unit_price($child_line_item->total() / $child_line_item->quantity()); |
|
128 | + } |
|
129 | + } elseif ( |
|
130 | + // make sure this item's quantity and total matches its parent |
|
131 | + $line_item->type() === EEM_Line_Item::type_line_item |
|
132 | + && $line_item->OBJ_type() === 'Ticket' |
|
133 | + // but not if it's a percentage modifier |
|
134 | + && ! $child_line_item->is_percent() |
|
135 | + && ! ( |
|
136 | + // or a cancellation |
|
137 | + $child_line_item->is_cancelled() |
|
138 | + && ! ( |
|
139 | + // unless it IS a cancellation and the current registration is cancelled |
|
140 | + $child_line_item->is_cancelled() |
|
141 | + && $this->_current_registration instanceof EE_Registration |
|
142 | + && in_array($this->_current_registration->status_ID(), $this->_closed_reg_statuses, true) |
|
143 | + ) |
|
144 | + ) |
|
145 | + ) { |
|
146 | + $child_line_item->set_quantity($line_item->quantity()); |
|
147 | + $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity()); |
|
148 | + } elseif ($child_line_item->type() === EEM_Line_Item::type_sub_tax) { |
|
149 | + // add this line item's portion of any directly applied taxes |
|
150 | + $child_line_item->set_quantity($line_item->quantity()); |
|
151 | + $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity()); |
|
152 | + } |
|
153 | + $running_total_of_children += $original_li_total; |
|
154 | + $running_total_of_children_under_consideration += $child_line_item->total(); |
|
155 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
156 | + $total_child_ticket_quantity += $child_line_item->quantity(); |
|
157 | + } |
|
158 | + } |
|
159 | + $line_item->set_total($running_total_of_children_under_consideration); |
|
160 | + if ($line_item->quantity()) { |
|
161 | + $line_item->set_unit_price($running_total_of_children_under_consideration / $line_item->quantity()); |
|
162 | + } else { |
|
163 | + $line_item->set_unit_price(0); |
|
164 | + } |
|
165 | + if ($line_item->OBJ_type() === 'Event') { |
|
166 | + $line_item->set_quantity($total_child_ticket_quantity); |
|
167 | + } |
|
168 | + return $line_item; |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | - /** |
|
173 | - * Adjusts quantities for line items for tickets according to the registrations provided |
|
174 | - * in the constructor |
|
175 | - * |
|
176 | - * @param EE_Line_Item $line_item |
|
177 | - * @return EE_Line_Item |
|
178 | - * @throws EE_Error |
|
179 | - * @throws ReflectionException |
|
180 | - */ |
|
181 | - protected function _adjust_line_item_quantity(EE_Line_Item $line_item): EE_Line_Item |
|
182 | - { |
|
183 | - // is this a ticket ? |
|
184 | - if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() === 'Ticket') { |
|
185 | - $this->_current_registration = null; |
|
186 | - $quantity = 0; |
|
187 | - // if this ticket is billable at this moment, then we should have a positive quantity |
|
188 | - if ( |
|
189 | - isset($this->_line_item_registrations[ $line_item->code() ]) |
|
190 | - && is_array($this->_line_item_registrations[ $line_item->code() ]) |
|
191 | - ) { |
|
192 | - // set quantity based on number of open registrations for this ticket |
|
193 | - foreach ($this->_line_item_registrations[ $line_item->code() ] as $registration) { |
|
194 | - if ( |
|
195 | - $registration instanceof EE_Registration |
|
196 | - ) { |
|
197 | - $quantity++; |
|
198 | - $this->_current_registration = $registration; |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - $line_item->set_quantity($quantity); |
|
203 | - $line_item->set_total($line_item->unit_price() * $line_item->quantity()); |
|
204 | - } |
|
205 | - return $line_item; |
|
206 | - } |
|
172 | + /** |
|
173 | + * Adjusts quantities for line items for tickets according to the registrations provided |
|
174 | + * in the constructor |
|
175 | + * |
|
176 | + * @param EE_Line_Item $line_item |
|
177 | + * @return EE_Line_Item |
|
178 | + * @throws EE_Error |
|
179 | + * @throws ReflectionException |
|
180 | + */ |
|
181 | + protected function _adjust_line_item_quantity(EE_Line_Item $line_item): EE_Line_Item |
|
182 | + { |
|
183 | + // is this a ticket ? |
|
184 | + if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() === 'Ticket') { |
|
185 | + $this->_current_registration = null; |
|
186 | + $quantity = 0; |
|
187 | + // if this ticket is billable at this moment, then we should have a positive quantity |
|
188 | + if ( |
|
189 | + isset($this->_line_item_registrations[ $line_item->code() ]) |
|
190 | + && is_array($this->_line_item_registrations[ $line_item->code() ]) |
|
191 | + ) { |
|
192 | + // set quantity based on number of open registrations for this ticket |
|
193 | + foreach ($this->_line_item_registrations[ $line_item->code() ] as $registration) { |
|
194 | + if ( |
|
195 | + $registration instanceof EE_Registration |
|
196 | + ) { |
|
197 | + $quantity++; |
|
198 | + $this->_current_registration = $registration; |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + $line_item->set_quantity($quantity); |
|
203 | + $line_item->set_total($line_item->unit_price() * $line_item->quantity()); |
|
204 | + } |
|
205 | + return $line_item; |
|
206 | + } |
|
207 | 207 | } |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | 'LIN_code' |
76 | 76 | ); |
77 | 77 | if ($line_item_code) { |
78 | - if (! isset($this->_line_item_registrations[ $line_item_code ])) { |
|
79 | - $this->_line_item_registrations[ $line_item_code ] = array(); |
|
78 | + if ( ! isset($this->_line_item_registrations[$line_item_code])) { |
|
79 | + $this->_line_item_registrations[$line_item_code] = array(); |
|
80 | 80 | } |
81 | - $this->_line_item_registrations[ $line_item_code ][ $registration->ID() ] = $registration; |
|
81 | + $this->_line_item_registrations[$line_item_code][$registration->ID()] = $registration; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function process(EE_Line_Item $line_item): ?EE_Line_Item |
97 | 97 | { |
98 | 98 | $this->_adjust_line_item_quantity($line_item); |
99 | - if (! $line_item->children()) { |
|
99 | + if ( ! $line_item->children()) { |
|
100 | 100 | return $line_item; |
101 | 101 | } |
102 | 102 | // the original running total (taking ALL tickets into account) |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $child_line_item->set_total( |
124 | 124 | $running_total_of_children_under_consideration * $percent_of_running_total |
125 | 125 | ); |
126 | - if (! $child_line_item->is_percent()) { |
|
126 | + if ( ! $child_line_item->is_percent()) { |
|
127 | 127 | $child_line_item->set_unit_price($child_line_item->total() / $child_line_item->quantity()); |
128 | 128 | } |
129 | 129 | } elseif ( |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | $quantity = 0; |
187 | 187 | // if this ticket is billable at this moment, then we should have a positive quantity |
188 | 188 | if ( |
189 | - isset($this->_line_item_registrations[ $line_item->code() ]) |
|
190 | - && is_array($this->_line_item_registrations[ $line_item->code() ]) |
|
189 | + isset($this->_line_item_registrations[$line_item->code()]) |
|
190 | + && is_array($this->_line_item_registrations[$line_item->code()]) |
|
191 | 191 | ) { |
192 | 192 | // set quantity based on number of open registrations for this ticket |
193 | - foreach ($this->_line_item_registrations[ $line_item->code() ] as $registration) { |
|
193 | + foreach ($this->_line_item_registrations[$line_item->code()] as $registration) { |
|
194 | 194 | if ( |
195 | 195 | $registration instanceof EE_Registration |
196 | 196 | ) { |
@@ -18,53 +18,53 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * EE_Billable_Line_Item_Filter constructor. |
|
23 | - * |
|
24 | - * @param EE_Registration[] $registrations |
|
25 | - * @throws EE_Error |
|
26 | - * @throws EE_Error |
|
27 | - */ |
|
28 | - public function __construct($registrations) |
|
29 | - { |
|
30 | - parent::__construct($this->_remove_unbillable_registrations($registrations)); |
|
31 | - } |
|
21 | + /** |
|
22 | + * EE_Billable_Line_Item_Filter constructor. |
|
23 | + * |
|
24 | + * @param EE_Registration[] $registrations |
|
25 | + * @throws EE_Error |
|
26 | + * @throws EE_Error |
|
27 | + */ |
|
28 | + public function __construct($registrations) |
|
29 | + { |
|
30 | + parent::__construct($this->_remove_unbillable_registrations($registrations)); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * _calculate_billable_ticket_quantities_from_registrations |
|
36 | - * compiles a list of EE_Tickets for each event in the passed array |
|
37 | - * |
|
38 | - * @access protected |
|
39 | - * @param EE_Registration[] $registrations |
|
40 | - * @return EE_Registration[] |
|
41 | - * @throws EE_Error |
|
42 | - * @throws EE_Error |
|
43 | - */ |
|
44 | - protected function _remove_unbillable_registrations(array $registrations = array()): array |
|
45 | - { |
|
46 | - if (! empty($registrations)) { |
|
47 | - // these reg statuses require payment (if event is not free) |
|
48 | - $requires_payment = EEM_Registration::reg_statuses_that_allow_payment(); |
|
49 | - foreach ($registrations as $key => $registration) { |
|
50 | - if (! $registration instanceof EE_Registration) { |
|
51 | - continue; |
|
52 | - } |
|
53 | - // are we billing for this registration at this moment ? |
|
54 | - if ( |
|
55 | - ! |
|
56 | - $registration->owes_monies_and_can_pay($requires_payment) && |
|
57 | - ! ( |
|
58 | - // free registration with valid reg status |
|
59 | - $registration->final_price() == 0 && |
|
60 | - in_array($registration->status_ID(), $requires_payment) |
|
61 | - ) |
|
62 | - ) { |
|
63 | - // not billable. remove it |
|
64 | - unset($registrations[ $key ]); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - return $registrations; |
|
69 | - } |
|
34 | + /** |
|
35 | + * _calculate_billable_ticket_quantities_from_registrations |
|
36 | + * compiles a list of EE_Tickets for each event in the passed array |
|
37 | + * |
|
38 | + * @access protected |
|
39 | + * @param EE_Registration[] $registrations |
|
40 | + * @return EE_Registration[] |
|
41 | + * @throws EE_Error |
|
42 | + * @throws EE_Error |
|
43 | + */ |
|
44 | + protected function _remove_unbillable_registrations(array $registrations = array()): array |
|
45 | + { |
|
46 | + if (! empty($registrations)) { |
|
47 | + // these reg statuses require payment (if event is not free) |
|
48 | + $requires_payment = EEM_Registration::reg_statuses_that_allow_payment(); |
|
49 | + foreach ($registrations as $key => $registration) { |
|
50 | + if (! $registration instanceof EE_Registration) { |
|
51 | + continue; |
|
52 | + } |
|
53 | + // are we billing for this registration at this moment ? |
|
54 | + if ( |
|
55 | + ! |
|
56 | + $registration->owes_monies_and_can_pay($requires_payment) && |
|
57 | + ! ( |
|
58 | + // free registration with valid reg status |
|
59 | + $registration->final_price() == 0 && |
|
60 | + in_array($registration->status_ID(), $requires_payment) |
|
61 | + ) |
|
62 | + ) { |
|
63 | + // not billable. remove it |
|
64 | + unset($registrations[ $key ]); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + return $registrations; |
|
69 | + } |
|
70 | 70 | } |
@@ -43,17 +43,16 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function _remove_unbillable_registrations(array $registrations = array()): array |
45 | 45 | { |
46 | - if (! empty($registrations)) { |
|
46 | + if ( ! empty($registrations)) { |
|
47 | 47 | // these reg statuses require payment (if event is not free) |
48 | 48 | $requires_payment = EEM_Registration::reg_statuses_that_allow_payment(); |
49 | 49 | foreach ($registrations as $key => $registration) { |
50 | - if (! $registration instanceof EE_Registration) { |
|
50 | + if ( ! $registration instanceof EE_Registration) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | // are we billing for this registration at this moment ? |
54 | 54 | if ( |
55 | - ! |
|
56 | - $registration->owes_monies_and_can_pay($requires_payment) && |
|
55 | + ! $registration->owes_monies_and_can_pay($requires_payment) && |
|
57 | 56 | ! ( |
58 | 57 | // free registration with valid reg status |
59 | 58 | $registration->final_price() == 0 && |
@@ -61,7 +60,7 @@ discard block |
||
61 | 60 | ) |
62 | 61 | ) { |
63 | 62 | // not billable. remove it |
64 | - unset($registrations[ $key ]); |
|
63 | + unset($registrations[$key]); |
|
65 | 64 | } |
66 | 65 | } |
67 | 66 | } |
@@ -18,11 +18,11 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * EE_Line_Item_Filter_Collection constructor. |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - $this->interface = 'EE_Line_Item_Filter'; |
|
27 | - } |
|
21 | + /** |
|
22 | + * EE_Line_Item_Filter_Collection constructor. |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + $this->interface = 'EE_Line_Item_Filter'; |
|
27 | + } |
|
28 | 28 | } |
@@ -14,101 +14,101 @@ |
||
14 | 14 | class EE_Non_Zero_Line_Item_Filter extends EE_Line_Item_Filter_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * EE_Non_Zero_Line_Item_Filter constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - } |
|
17 | + /** |
|
18 | + * EE_Non_Zero_Line_Item_Filter constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Creates a duplicate of the line item tree, except only includes billable items |
|
27 | - * and the portion of line items attributed to billable things |
|
28 | - * |
|
29 | - * @param EE_Line_Item $line_item |
|
30 | - * @return EE_Line_Item |
|
31 | - * @throws EE_Error |
|
32 | - * @throws ReflectionException |
|
33 | - */ |
|
34 | - public function process(EE_Line_Item $line_item): ?EE_Line_Item |
|
35 | - { |
|
36 | - $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
|
37 | - if (! $non_zero_line_item instanceof EE_Line_Item) { |
|
38 | - return null; |
|
39 | - } |
|
40 | - // if this is an event subtotal, we want to only include it if it |
|
41 | - // has a non-zero total and at least one ticket line item child |
|
42 | - if ($line_item->children()) { |
|
43 | - $ticket_or_subtotals_with_tkt_children_count = 0; |
|
44 | - foreach ($line_item->children() as $child_line_item) { |
|
45 | - $code = $child_line_item->code(); |
|
46 | - $child_line_item = $this->process($child_line_item); |
|
47 | - if (! $child_line_item instanceof EE_Line_Item) { |
|
48 | - $line_item->delete_child_line_item($code); |
|
49 | - continue; |
|
50 | - } |
|
51 | - if ( |
|
52 | - $child_line_item->type() === EEM_Line_Item::type_sub_total |
|
53 | - || ( |
|
54 | - $child_line_item->type() === EEM_Line_Item::type_line_item |
|
55 | - && $child_line_item->OBJ_type() === 'Ticket' |
|
56 | - ) |
|
57 | - ) { |
|
58 | - $ticket_or_subtotals_with_tkt_children_count++; |
|
59 | - } |
|
60 | - } |
|
61 | - // if this is an event subtotal with NO ticket children |
|
62 | - // we basically want to ignore it |
|
63 | - return $this->_filter_zero_subtotal_line_item( |
|
64 | - $non_zero_line_item, |
|
65 | - $ticket_or_subtotals_with_tkt_children_count |
|
66 | - ); |
|
67 | - } |
|
68 | - return $non_zero_line_item; |
|
69 | - } |
|
25 | + /** |
|
26 | + * Creates a duplicate of the line item tree, except only includes billable items |
|
27 | + * and the portion of line items attributed to billable things |
|
28 | + * |
|
29 | + * @param EE_Line_Item $line_item |
|
30 | + * @return EE_Line_Item |
|
31 | + * @throws EE_Error |
|
32 | + * @throws ReflectionException |
|
33 | + */ |
|
34 | + public function process(EE_Line_Item $line_item): ?EE_Line_Item |
|
35 | + { |
|
36 | + $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
|
37 | + if (! $non_zero_line_item instanceof EE_Line_Item) { |
|
38 | + return null; |
|
39 | + } |
|
40 | + // if this is an event subtotal, we want to only include it if it |
|
41 | + // has a non-zero total and at least one ticket line item child |
|
42 | + if ($line_item->children()) { |
|
43 | + $ticket_or_subtotals_with_tkt_children_count = 0; |
|
44 | + foreach ($line_item->children() as $child_line_item) { |
|
45 | + $code = $child_line_item->code(); |
|
46 | + $child_line_item = $this->process($child_line_item); |
|
47 | + if (! $child_line_item instanceof EE_Line_Item) { |
|
48 | + $line_item->delete_child_line_item($code); |
|
49 | + continue; |
|
50 | + } |
|
51 | + if ( |
|
52 | + $child_line_item->type() === EEM_Line_Item::type_sub_total |
|
53 | + || ( |
|
54 | + $child_line_item->type() === EEM_Line_Item::type_line_item |
|
55 | + && $child_line_item->OBJ_type() === 'Ticket' |
|
56 | + ) |
|
57 | + ) { |
|
58 | + $ticket_or_subtotals_with_tkt_children_count++; |
|
59 | + } |
|
60 | + } |
|
61 | + // if this is an event subtotal with NO ticket children |
|
62 | + // we basically want to ignore it |
|
63 | + return $this->_filter_zero_subtotal_line_item( |
|
64 | + $non_zero_line_item, |
|
65 | + $ticket_or_subtotals_with_tkt_children_count |
|
66 | + ); |
|
67 | + } |
|
68 | + return $non_zero_line_item; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Creates a new, unsaved line item, but if it's a ticket line item |
|
74 | - * with a total of 0, or a subtotal of 0, returns null instead |
|
75 | - * |
|
76 | - * @param EE_Line_Item $line_item |
|
77 | - * @return EE_Line_Item |
|
78 | - * @throws EE_Error |
|
79 | - * @throws ReflectionException |
|
80 | - */ |
|
81 | - protected function _filter_zero_line_item(EE_Line_Item $line_item): ?EE_Line_Item |
|
82 | - { |
|
83 | - if ( |
|
84 | - $line_item->type() === EEM_Line_Item::type_line_item |
|
85 | - && $line_item->OBJ_type() === 'Ticket' |
|
86 | - && $line_item->quantity() === 0 |
|
87 | - ) { |
|
88 | - return null; |
|
89 | - } |
|
90 | - return $line_item; |
|
91 | - } |
|
72 | + /** |
|
73 | + * Creates a new, unsaved line item, but if it's a ticket line item |
|
74 | + * with a total of 0, or a subtotal of 0, returns null instead |
|
75 | + * |
|
76 | + * @param EE_Line_Item $line_item |
|
77 | + * @return EE_Line_Item |
|
78 | + * @throws EE_Error |
|
79 | + * @throws ReflectionException |
|
80 | + */ |
|
81 | + protected function _filter_zero_line_item(EE_Line_Item $line_item): ?EE_Line_Item |
|
82 | + { |
|
83 | + if ( |
|
84 | + $line_item->type() === EEM_Line_Item::type_line_item |
|
85 | + && $line_item->OBJ_type() === 'Ticket' |
|
86 | + && $line_item->quantity() === 0 |
|
87 | + ) { |
|
88 | + return null; |
|
89 | + } |
|
90 | + return $line_item; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Creates a new, unsaved line item, but if it's a ticket line item |
|
96 | - * with a total of 0, or a subtotal of 0, returns null instead |
|
97 | - * |
|
98 | - * @param EE_Line_Item $line_item |
|
99 | - * @param int $ticket_children |
|
100 | - * @return EE_Line_Item |
|
101 | - * @throws EE_Error |
|
102 | - * @throws ReflectionException |
|
103 | - */ |
|
104 | - protected function _filter_zero_subtotal_line_item(EE_Line_Item $line_item, int $ticket_children = 0): ?EE_Line_Item |
|
105 | - { |
|
106 | - if ( |
|
107 | - $ticket_children === 0 |
|
108 | - && $line_item->type() === EEM_Line_Item::type_sub_total |
|
109 | - ) { |
|
110 | - return null; |
|
111 | - } |
|
112 | - return $line_item; |
|
113 | - } |
|
94 | + /** |
|
95 | + * Creates a new, unsaved line item, but if it's a ticket line item |
|
96 | + * with a total of 0, or a subtotal of 0, returns null instead |
|
97 | + * |
|
98 | + * @param EE_Line_Item $line_item |
|
99 | + * @param int $ticket_children |
|
100 | + * @return EE_Line_Item |
|
101 | + * @throws EE_Error |
|
102 | + * @throws ReflectionException |
|
103 | + */ |
|
104 | + protected function _filter_zero_subtotal_line_item(EE_Line_Item $line_item, int $ticket_children = 0): ?EE_Line_Item |
|
105 | + { |
|
106 | + if ( |
|
107 | + $ticket_children === 0 |
|
108 | + && $line_item->type() === EEM_Line_Item::type_sub_total |
|
109 | + ) { |
|
110 | + return null; |
|
111 | + } |
|
112 | + return $line_item; |
|
113 | + } |
|
114 | 114 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function process(EE_Line_Item $line_item): ?EE_Line_Item |
35 | 35 | { |
36 | 36 | $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
37 | - if (! $non_zero_line_item instanceof EE_Line_Item) { |
|
37 | + if ( ! $non_zero_line_item instanceof EE_Line_Item) { |
|
38 | 38 | return null; |
39 | 39 | } |
40 | 40 | // if this is an event subtotal, we want to only include it if it |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | foreach ($line_item->children() as $child_line_item) { |
45 | 45 | $code = $child_line_item->code(); |
46 | 46 | $child_line_item = $this->process($child_line_item); |
47 | - if (! $child_line_item instanceof EE_Line_Item) { |
|
47 | + if ( ! $child_line_item instanceof EE_Line_Item) { |
|
48 | 48 | $line_item->delete_child_line_item($code); |
49 | 49 | continue; |
50 | 50 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $html = ''; |
77 | 77 | // set some default options and merge with incoming |
78 | 78 | $default_options = array( |
79 | - 'show_desc' => true, // TRUE FALSE |
|
79 | + 'show_desc' => true, // TRUE FALSE |
|
80 | 80 | 'odd' => false |
81 | 81 | ); |
82 | 82 | $options = array_merge($default_options, (array) $options); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | ); |
164 | 164 | $name_and_desc .= apply_filters( |
165 | 165 | 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
166 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
166 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
167 | 167 | $line_item, |
168 | 168 | $options |
169 | 169 | ); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $includes_taxes = $this->prices_include_taxes |
172 | 172 | ? esc_html__('* price includes taxes', 'event_espresso') |
173 | 173 | : esc_html__('* price does not include taxes', 'event_espresso'); |
174 | - $name_and_desc .= '<br /><span class="smaller-text grey-text">' . $includes_taxes . '</span>'; |
|
174 | + $name_and_desc .= '<br /><span class="smaller-text grey-text">'.$includes_taxes.'</span>'; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | // name td |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | $html = EEH_HTML::tr('', 'item sub-item-row'); |
229 | 229 | // name && desc |
230 | 230 | $name_and_desc = $line_item->name(); |
231 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
231 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
232 | 232 | // name td |
233 | 233 | $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item'); |
234 | 234 | // discount/surcharge td |
235 | 235 | if ($line_item->is_percent()) { |
236 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
236 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
237 | 237 | } else { |
238 | 238 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
239 | 239 | } |
@@ -1,248 +1,248 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** |
4 | - * |
|
5 | - * Class EE_Default_Line_Item_Display_Strategy |
|
6 | - * |
|
7 | - * Description |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage core |
|
11 | - * @author Brent Christensen |
|
12 | - * |
|
13 | - * |
|
14 | - */ |
|
4 | + * |
|
5 | + * Class EE_Default_Line_Item_Display_Strategy |
|
6 | + * |
|
7 | + * Description |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage core |
|
11 | + * @author Brent Christensen |
|
12 | + * |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | class EE_Default_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
17 | 17 | { |
18 | - /** |
|
19 | - * @var bool |
|
20 | - */ |
|
21 | - protected $prices_include_taxes = false; |
|
22 | - |
|
23 | - /** |
|
24 | - * total amount of tax to apply |
|
25 | - * @type float $_tax_rate |
|
26 | - */ |
|
27 | - private $_tax_rate = 0; |
|
28 | - |
|
29 | - /** |
|
30 | - * total amount including tax we can bill for at this time |
|
31 | - * @type float $_grand_total |
|
32 | - */ |
|
33 | - private $_grand_total = 0.00; |
|
34 | - |
|
35 | - /** |
|
36 | - * total number of items being billed for |
|
37 | - * @type int $_total_items |
|
38 | - */ |
|
39 | - private $_total_items = 0; |
|
40 | - |
|
41 | - |
|
42 | - public function __construct() |
|
43 | - { |
|
44 | - $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return float |
|
50 | - */ |
|
51 | - public function grand_total() |
|
52 | - { |
|
53 | - return $this->_grand_total; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function total_items() |
|
62 | - { |
|
63 | - return $this->_total_items; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @param EE_Line_Item $line_item |
|
70 | - * @param array $options |
|
71 | - * @return mixed |
|
72 | - */ |
|
73 | - public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
74 | - { |
|
75 | - |
|
76 | - $html = ''; |
|
77 | - // set some default options and merge with incoming |
|
78 | - $default_options = array( |
|
79 | - 'show_desc' => true, // TRUE FALSE |
|
80 | - 'odd' => false |
|
81 | - ); |
|
82 | - $options = array_merge($default_options, (array) $options); |
|
83 | - |
|
84 | - switch ($line_item->type()) { |
|
85 | - case EEM_Line_Item::type_line_item: |
|
86 | - // item row |
|
87 | - $html .= $this->_item_row($line_item, $options); |
|
88 | - // got any kids? |
|
89 | - foreach ($line_item->children() as $child_line_item) { |
|
90 | - $this->display_line_item($child_line_item, $options); |
|
91 | - } |
|
92 | - break; |
|
93 | - |
|
94 | - case EEM_Line_Item::type_sub_line_item: |
|
95 | - $html .= $this->_sub_item_row($line_item, $options); |
|
96 | - break; |
|
97 | - |
|
98 | - case EEM_Line_Item::type_sub_total: |
|
99 | - break; |
|
100 | - |
|
101 | - case EEM_Line_Item::type_tax: |
|
102 | - $this->_tax_rate += $line_item->percent(); |
|
103 | - break; |
|
104 | - |
|
105 | - case EEM_Line_Item::type_tax_sub_total: |
|
106 | - foreach ($line_item->children() as $child_line_item) { |
|
107 | - if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
108 | - // recursively feed children back into this method |
|
109 | - $this->display_line_item($child_line_item, $options); |
|
110 | - } |
|
111 | - } |
|
112 | - break; |
|
113 | - |
|
114 | - case EEM_Line_Item::type_total: |
|
115 | - // get all child line items |
|
116 | - $children = $line_item->children(); |
|
117 | - if ($options['set_tax_rate'] === true) { |
|
118 | - // loop thru tax child line items just to determine tax rate |
|
119 | - foreach ($children as $child_line_item) { |
|
120 | - if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
121 | - // recursively feed children back into this method |
|
122 | - $this->display_line_item($child_line_item, $options); |
|
123 | - } |
|
124 | - } |
|
125 | - } else { |
|
126 | - // now loop thru all non-tax child line items |
|
127 | - foreach ($children as $child_line_item) { |
|
128 | - if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
129 | - // recursively feed children back into this method |
|
130 | - $html .= $this->display_line_item($child_line_item, $options); |
|
131 | - } |
|
132 | - } |
|
133 | - } |
|
134 | - break; |
|
135 | - } |
|
136 | - |
|
137 | - return $html; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * _total_row |
|
143 | - * |
|
144 | - * @param EE_Line_Item $line_item |
|
145 | - * @param array $options |
|
146 | - * @return string |
|
147 | - * @throws EE_Error |
|
148 | - * @throws ReflectionException |
|
149 | - */ |
|
150 | - private function _item_row(EE_Line_Item $line_item, array $options = array()): string |
|
151 | - { |
|
152 | - $sub_taxes = $line_item->getSubTaxes(); |
|
153 | - $has_sub_taxes = ! empty($sub_taxes); |
|
154 | - $is_taxable = $line_item->is_taxable(); |
|
155 | - |
|
156 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
157 | - $html = EEH_HTML::tr('', '', $row_class); |
|
158 | - // name && desc |
|
159 | - $name_and_desc = apply_filters( |
|
160 | - 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name', |
|
161 | - $line_item->name(), |
|
162 | - $line_item |
|
163 | - ); |
|
164 | - $name_and_desc .= apply_filters( |
|
165 | - 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
|
166 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
167 | - $line_item, |
|
168 | - $options |
|
169 | - ); |
|
170 | - if ($is_taxable || $has_sub_taxes) { |
|
171 | - $includes_taxes = $this->prices_include_taxes |
|
172 | - ? esc_html__('* price includes taxes', 'event_espresso') |
|
173 | - : esc_html__('* price does not include taxes', 'event_espresso'); |
|
174 | - $name_and_desc .= '<br /><span class="smaller-text grey-text">' . $includes_taxes . '</span>'; |
|
175 | - } |
|
176 | - |
|
177 | - // name td |
|
178 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
179 | - // quantity td |
|
180 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
181 | - $tax_rate = 1; |
|
182 | - if ($this->prices_include_taxes) { |
|
183 | - if ($has_sub_taxes) { |
|
184 | - $tax_rate = 0; |
|
185 | - foreach ($sub_taxes as $sub_tax) { |
|
186 | - if ($sub_tax instanceof EE_Line_Item && $sub_tax->isSubTax()) { |
|
187 | - $tax_rate += $sub_tax->percent(); |
|
188 | - } |
|
189 | - } |
|
190 | - $tax_rate = 1 + $tax_rate / 100; |
|
191 | - } elseif ($is_taxable && $this->prices_include_taxes) { |
|
192 | - $tax_rate = 1 + ($this->_tax_rate / 100); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - // price td |
|
197 | - $unit_price = apply_filters( |
|
198 | - 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price', |
|
199 | - EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false), |
|
200 | - $line_item, |
|
201 | - $tax_rate |
|
202 | - ); |
|
203 | - $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght'); |
|
204 | - // total td |
|
205 | - $total = apply_filters( |
|
206 | - 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total', |
|
207 | - EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false), |
|
208 | - $line_item, |
|
209 | - $tax_rate |
|
210 | - ); |
|
211 | - $html .= EEH_HTML::td($total, '', 'item_r jst-rght'); |
|
212 | - // end of row |
|
213 | - $html .= EEH_HTML::trx(); |
|
214 | - |
|
215 | - return $html; |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * _sub_item_row |
|
222 | - * |
|
223 | - * @param EE_Line_Item $line_item |
|
224 | - * @param array $options |
|
225 | - * @return mixed |
|
226 | - */ |
|
227 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
228 | - { |
|
229 | - // start of row |
|
230 | - $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
231 | - // name && desc |
|
232 | - $name_and_desc = $line_item->name(); |
|
233 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
234 | - // name td |
|
235 | - $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item'); |
|
236 | - // discount/surcharge td |
|
237 | - if ($line_item->is_percent()) { |
|
238 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
239 | - } else { |
|
240 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
241 | - } |
|
242 | - // total td |
|
243 | - $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
244 | - // end of row |
|
245 | - $html .= EEH_HTML::trx(); |
|
246 | - return $html; |
|
247 | - } |
|
18 | + /** |
|
19 | + * @var bool |
|
20 | + */ |
|
21 | + protected $prices_include_taxes = false; |
|
22 | + |
|
23 | + /** |
|
24 | + * total amount of tax to apply |
|
25 | + * @type float $_tax_rate |
|
26 | + */ |
|
27 | + private $_tax_rate = 0; |
|
28 | + |
|
29 | + /** |
|
30 | + * total amount including tax we can bill for at this time |
|
31 | + * @type float $_grand_total |
|
32 | + */ |
|
33 | + private $_grand_total = 0.00; |
|
34 | + |
|
35 | + /** |
|
36 | + * total number of items being billed for |
|
37 | + * @type int $_total_items |
|
38 | + */ |
|
39 | + private $_total_items = 0; |
|
40 | + |
|
41 | + |
|
42 | + public function __construct() |
|
43 | + { |
|
44 | + $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return float |
|
50 | + */ |
|
51 | + public function grand_total() |
|
52 | + { |
|
53 | + return $this->_grand_total; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function total_items() |
|
62 | + { |
|
63 | + return $this->_total_items; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @param EE_Line_Item $line_item |
|
70 | + * @param array $options |
|
71 | + * @return mixed |
|
72 | + */ |
|
73 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
74 | + { |
|
75 | + |
|
76 | + $html = ''; |
|
77 | + // set some default options and merge with incoming |
|
78 | + $default_options = array( |
|
79 | + 'show_desc' => true, // TRUE FALSE |
|
80 | + 'odd' => false |
|
81 | + ); |
|
82 | + $options = array_merge($default_options, (array) $options); |
|
83 | + |
|
84 | + switch ($line_item->type()) { |
|
85 | + case EEM_Line_Item::type_line_item: |
|
86 | + // item row |
|
87 | + $html .= $this->_item_row($line_item, $options); |
|
88 | + // got any kids? |
|
89 | + foreach ($line_item->children() as $child_line_item) { |
|
90 | + $this->display_line_item($child_line_item, $options); |
|
91 | + } |
|
92 | + break; |
|
93 | + |
|
94 | + case EEM_Line_Item::type_sub_line_item: |
|
95 | + $html .= $this->_sub_item_row($line_item, $options); |
|
96 | + break; |
|
97 | + |
|
98 | + case EEM_Line_Item::type_sub_total: |
|
99 | + break; |
|
100 | + |
|
101 | + case EEM_Line_Item::type_tax: |
|
102 | + $this->_tax_rate += $line_item->percent(); |
|
103 | + break; |
|
104 | + |
|
105 | + case EEM_Line_Item::type_tax_sub_total: |
|
106 | + foreach ($line_item->children() as $child_line_item) { |
|
107 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
108 | + // recursively feed children back into this method |
|
109 | + $this->display_line_item($child_line_item, $options); |
|
110 | + } |
|
111 | + } |
|
112 | + break; |
|
113 | + |
|
114 | + case EEM_Line_Item::type_total: |
|
115 | + // get all child line items |
|
116 | + $children = $line_item->children(); |
|
117 | + if ($options['set_tax_rate'] === true) { |
|
118 | + // loop thru tax child line items just to determine tax rate |
|
119 | + foreach ($children as $child_line_item) { |
|
120 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
121 | + // recursively feed children back into this method |
|
122 | + $this->display_line_item($child_line_item, $options); |
|
123 | + } |
|
124 | + } |
|
125 | + } else { |
|
126 | + // now loop thru all non-tax child line items |
|
127 | + foreach ($children as $child_line_item) { |
|
128 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
129 | + // recursively feed children back into this method |
|
130 | + $html .= $this->display_line_item($child_line_item, $options); |
|
131 | + } |
|
132 | + } |
|
133 | + } |
|
134 | + break; |
|
135 | + } |
|
136 | + |
|
137 | + return $html; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * _total_row |
|
143 | + * |
|
144 | + * @param EE_Line_Item $line_item |
|
145 | + * @param array $options |
|
146 | + * @return string |
|
147 | + * @throws EE_Error |
|
148 | + * @throws ReflectionException |
|
149 | + */ |
|
150 | + private function _item_row(EE_Line_Item $line_item, array $options = array()): string |
|
151 | + { |
|
152 | + $sub_taxes = $line_item->getSubTaxes(); |
|
153 | + $has_sub_taxes = ! empty($sub_taxes); |
|
154 | + $is_taxable = $line_item->is_taxable(); |
|
155 | + |
|
156 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
157 | + $html = EEH_HTML::tr('', '', $row_class); |
|
158 | + // name && desc |
|
159 | + $name_and_desc = apply_filters( |
|
160 | + 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name', |
|
161 | + $line_item->name(), |
|
162 | + $line_item |
|
163 | + ); |
|
164 | + $name_and_desc .= apply_filters( |
|
165 | + 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
|
166 | + ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
167 | + $line_item, |
|
168 | + $options |
|
169 | + ); |
|
170 | + if ($is_taxable || $has_sub_taxes) { |
|
171 | + $includes_taxes = $this->prices_include_taxes |
|
172 | + ? esc_html__('* price includes taxes', 'event_espresso') |
|
173 | + : esc_html__('* price does not include taxes', 'event_espresso'); |
|
174 | + $name_and_desc .= '<br /><span class="smaller-text grey-text">' . $includes_taxes . '</span>'; |
|
175 | + } |
|
176 | + |
|
177 | + // name td |
|
178 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
179 | + // quantity td |
|
180 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
181 | + $tax_rate = 1; |
|
182 | + if ($this->prices_include_taxes) { |
|
183 | + if ($has_sub_taxes) { |
|
184 | + $tax_rate = 0; |
|
185 | + foreach ($sub_taxes as $sub_tax) { |
|
186 | + if ($sub_tax instanceof EE_Line_Item && $sub_tax->isSubTax()) { |
|
187 | + $tax_rate += $sub_tax->percent(); |
|
188 | + } |
|
189 | + } |
|
190 | + $tax_rate = 1 + $tax_rate / 100; |
|
191 | + } elseif ($is_taxable && $this->prices_include_taxes) { |
|
192 | + $tax_rate = 1 + ($this->_tax_rate / 100); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + // price td |
|
197 | + $unit_price = apply_filters( |
|
198 | + 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price', |
|
199 | + EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false), |
|
200 | + $line_item, |
|
201 | + $tax_rate |
|
202 | + ); |
|
203 | + $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght'); |
|
204 | + // total td |
|
205 | + $total = apply_filters( |
|
206 | + 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total', |
|
207 | + EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false), |
|
208 | + $line_item, |
|
209 | + $tax_rate |
|
210 | + ); |
|
211 | + $html .= EEH_HTML::td($total, '', 'item_r jst-rght'); |
|
212 | + // end of row |
|
213 | + $html .= EEH_HTML::trx(); |
|
214 | + |
|
215 | + return $html; |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * _sub_item_row |
|
222 | + * |
|
223 | + * @param EE_Line_Item $line_item |
|
224 | + * @param array $options |
|
225 | + * @return mixed |
|
226 | + */ |
|
227 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
228 | + { |
|
229 | + // start of row |
|
230 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
231 | + // name && desc |
|
232 | + $name_and_desc = $line_item->name(); |
|
233 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
234 | + // name td |
|
235 | + $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item'); |
|
236 | + // discount/surcharge td |
|
237 | + if ($line_item->is_percent()) { |
|
238 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
239 | + } else { |
|
240 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
241 | + } |
|
242 | + // total td |
|
243 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
244 | + // end of row |
|
245 | + $html .= EEH_HTML::trx(); |
|
246 | + return $html; |
|
247 | + } |
|
248 | 248 | } |
@@ -13,359 +13,359 @@ |
||
13 | 13 | |
14 | 14 | class EE_Admin_Table_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
15 | 15 | { |
16 | - /** |
|
17 | - * @var bool |
|
18 | - */ |
|
19 | - protected $prices_include_taxes = false; |
|
20 | - |
|
21 | - /** |
|
22 | - * whether to display the taxes row or not |
|
23 | - * |
|
24 | - * @var bool |
|
25 | - */ |
|
26 | - protected $_show_taxes = false; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * html for any tax rows |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $_taxes_html = ''; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * total amount including tax we can bill for at this time |
|
39 | - * |
|
40 | - * @var float $_grand_total |
|
41 | - */ |
|
42 | - protected $_grand_total = 0.00; |
|
43 | - |
|
44 | - |
|
45 | - public function __construct() |
|
46 | - { |
|
47 | - $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @return float |
|
52 | - */ |
|
53 | - public function grand_total() |
|
54 | - { |
|
55 | - return $this->_grand_total; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * This is used to output a single |
|
61 | - * @param EE_Line_Item $line_item |
|
62 | - * @param array $options |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
66 | - { |
|
67 | - $html = ''; |
|
68 | - // set some default options and merge with incoming |
|
69 | - $default_options = array( |
|
70 | - 'odd' => true, |
|
71 | - 'use_table_wrapper' => true, |
|
72 | - 'table_css_class' => 'admin-primary-mbox-tbl', |
|
73 | - 'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr', |
|
74 | - 'total_tr_css_class' => 'admin-primary-mbox-total-tr' |
|
75 | - ); |
|
76 | - $options = array_merge($default_options, (array) $options); |
|
77 | - |
|
78 | - switch ($line_item->type()) { |
|
79 | - case EEM_Line_Item::type_line_item: |
|
80 | - // item row |
|
81 | - $html .= $this->_item_row($line_item, $options); |
|
82 | - break; |
|
83 | - |
|
84 | - case EEM_Line_Item::type_sub_line_item: |
|
85 | - $html .= $this->_sub_item_row($line_item, $options); |
|
86 | - break; |
|
87 | - |
|
88 | - case EEM_Line_Item::type_sub_total: |
|
89 | - if ($line_item->quantity() === 0) { |
|
90 | - return $html; |
|
91 | - } |
|
92 | - // loop through children |
|
93 | - $child_line_items = $line_item->children(); |
|
94 | - // loop through children |
|
95 | - foreach ($child_line_items as $child_line_item) { |
|
96 | - // recursively feed children back into this method |
|
97 | - $html .= $this->display_line_item($child_line_item, $options); |
|
98 | - } |
|
99 | - $html .= $this->_sub_total_row($line_item, $options); |
|
100 | - break; |
|
101 | - |
|
102 | - case EEM_Line_Item::type_tax: |
|
103 | - if ($this->_show_taxes) { |
|
104 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
105 | - } |
|
106 | - break; |
|
107 | - |
|
108 | - case EEM_Line_Item::type_tax_sub_total: |
|
109 | - foreach ($line_item->children() as $child_line_item) { |
|
110 | - if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
111 | - $this->display_line_item($child_line_item, $options); |
|
112 | - } |
|
113 | - } |
|
114 | - break; |
|
115 | - |
|
116 | - case EEM_Line_Item::type_total: |
|
117 | - // determine whether to display taxes or not |
|
118 | - $this->_show_taxes = $line_item->get_total_tax() > 0 ? true : false; |
|
119 | - // get all child line items |
|
120 | - $children = $line_item->children(); |
|
121 | - |
|
122 | - // loop thru all non-tax child line items |
|
123 | - foreach ($children as $child_line_item) { |
|
124 | - $html .= $this->display_line_item($child_line_item, $options); |
|
125 | - } |
|
126 | - |
|
127 | - $html .= $this->_taxes_html; |
|
128 | - $html .= $this->_total_row($line_item, $options); |
|
129 | - if ($options['use_table_wrapper']) { |
|
130 | - $html = $this->_table_header($options) . $html . $this->_table_footer($options); |
|
131 | - } |
|
132 | - break; |
|
133 | - } |
|
134 | - |
|
135 | - return $html; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * Table header for display. |
|
142 | - * @since 4.8 |
|
143 | - * @param array $options |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - protected function _table_header($options) |
|
147 | - { |
|
148 | - $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
149 | - $html .= EEH_HTML::thead(); |
|
150 | - $html .= EEH_HTML::tr(); |
|
151 | - $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
152 | - $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
153 | - $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
154 | - $html .= EEH_HTML::th(__('Qty', 'event_espresso'), '', 'jst-cntr'); |
|
155 | - $html .= EEH_HTML::th(__('Line Total', 'event_espresso'), '', 'jst-cntr'); |
|
156 | - $html .= EEH_HTML::tbody(); |
|
157 | - return $html; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Table footer for display |
|
163 | - * @since 4.8 |
|
164 | - * @param array $options array of options for the table. |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - protected function _table_footer($options) |
|
168 | - { |
|
169 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex(); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * _item_row |
|
176 | - * |
|
177 | - * @param EE_Line_Item $line_item |
|
178 | - * @param array $options |
|
179 | - * @return mixed |
|
180 | - */ |
|
181 | - protected function _item_row(EE_Line_Item $line_item, $options = array()) |
|
182 | - { |
|
183 | - $line_item_related_object = $line_item->get_object(); |
|
184 | - $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null; |
|
185 | - // start of row |
|
186 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
187 | - $html = EEH_HTML::tr('', '', $row_class); |
|
188 | - |
|
189 | - |
|
190 | - // Name Column |
|
191 | - $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : ''; |
|
192 | - |
|
193 | - // related object scope. |
|
194 | - $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : ''; |
|
195 | - $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
196 | - $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : ''; |
|
197 | - |
|
198 | - |
|
199 | - $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name(); |
|
200 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html; |
|
201 | - $name_html .= $line_item->is_taxable() ? ' *' : ''; |
|
202 | - // maybe preface with icon? |
|
203 | - $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html; |
|
204 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
205 | - $name_html .= sprintf( |
|
206 | - _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
207 | - '<span class="ee-line-item-related-parent-object">', |
|
208 | - $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __('Item:', 'event_espresso'), |
|
209 | - $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name, |
|
210 | - '</span>' |
|
211 | - ); |
|
212 | - |
|
213 | - $name_html = apply_filters( |
|
214 | - 'FHEE__EE_Admin_Table_Line_Item_Display_Strategy___item_row__name_html', |
|
215 | - $name_html, |
|
216 | - $line_item, |
|
217 | - $options |
|
218 | - ); |
|
219 | - |
|
220 | - $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
221 | - // Type Column |
|
222 | - $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : ''; |
|
223 | - $type_html .= $this->_get_cancellations($line_item); |
|
224 | - $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
|
225 | - $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
|
226 | - $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : ''; |
|
227 | - $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
228 | - |
|
229 | - |
|
230 | - // Amount Column |
|
231 | - if ($line_item->is_percent()) { |
|
232 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght'); |
|
233 | - } else { |
|
234 | - $include_taxes = $this->prices_include_taxes |
|
235 | - ? '<br /><span class="grey-text">' |
|
236 | - . sprintf( |
|
237 | - /* translators: 1: money amount like $123 */ |
|
238 | - esc_html__('%1$s before taxes', 'event_espresso'), |
|
239 | - $line_item->pretaxTotal() / $line_item->quantity() |
|
240 | - ) |
|
241 | - . '</span>' |
|
242 | - : ''; |
|
243 | - $price = $line_item->unit_price_no_code(); |
|
244 | - $html .= EEH_HTML::td($price . $include_taxes, '', 'jst-rght'); |
|
245 | - } |
|
246 | - |
|
247 | - // QTY column |
|
248 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'jst-rght'); |
|
249 | - |
|
250 | - // total column |
|
251 | - $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->pretaxTotal(), false, false), '', 'jst-rght'); |
|
252 | - |
|
253 | - // finish things off and return |
|
254 | - $html .= EEH_HTML::trx(); |
|
255 | - return $html; |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * _get_cancellations |
|
262 | - * |
|
263 | - * @param EE_Line_Item $line_item |
|
264 | - * @return string |
|
265 | - */ |
|
266 | - protected function _get_cancellations(EE_Line_Item $line_item) |
|
267 | - { |
|
268 | - $html = ''; |
|
269 | - $cancellations = $line_item->get_cancellations(); |
|
270 | - $cancellation = reset($cancellations); |
|
271 | - if ($cancellation instanceof EE_Line_Item) { |
|
272 | - $html .= ' <span class="ee-line-item-id">'; |
|
273 | - $html .= sprintf( |
|
274 | - _n( |
|
275 | - '(%1$s Cancellation)', |
|
276 | - '(%1$s Cancellations)', |
|
277 | - $cancellation->quantity(), |
|
278 | - 'event_espresso' |
|
279 | - ), |
|
280 | - $cancellation->quantity() |
|
281 | - ); |
|
282 | - $html .= '</span>'; |
|
283 | - } |
|
284 | - return $html; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * _sub_item_row |
|
291 | - * |
|
292 | - * @param EE_Line_Item $line_item |
|
293 | - * @param array $options |
|
294 | - * @return mixed |
|
295 | - */ |
|
296 | - protected function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
297 | - { |
|
298 | - // for now we're not showing sub-items |
|
299 | - return ''; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * _tax_row |
|
306 | - * |
|
307 | - * @param EE_Line_Item $line_item |
|
308 | - * @param array $options |
|
309 | - * @return mixed |
|
310 | - */ |
|
311 | - protected function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
312 | - { |
|
313 | - // start of row |
|
314 | - $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
315 | - // name th |
|
316 | - $tax_details = $line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)'; |
|
317 | - $html .= EEH_HTML::th( |
|
318 | - $tax_details, |
|
319 | - '', |
|
320 | - 'jst-rght', |
|
321 | - '', |
|
322 | - ' colspan="4"' |
|
323 | - ); |
|
324 | - // total th |
|
325 | - $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
326 | - // end of row |
|
327 | - $html .= EEH_HTML::trx(); |
|
328 | - return $html; |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * _total_row |
|
336 | - * |
|
337 | - * @param EE_Line_Item $line_item |
|
338 | - * @param string $text |
|
339 | - * @param array $options |
|
340 | - * @return mixed |
|
341 | - */ |
|
342 | - protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
343 | - { |
|
344 | - // currently not showing subtotal row |
|
345 | - return ''; |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * _total_row |
|
352 | - * |
|
353 | - * @param EE_Line_Item $line_item |
|
354 | - * @param array $options |
|
355 | - * @return mixed |
|
356 | - */ |
|
357 | - protected function _total_row(EE_Line_Item $line_item, $options = array()) |
|
358 | - { |
|
359 | - // start of row |
|
360 | - $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
361 | - // Total th label |
|
362 | - $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
363 | - $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"'); |
|
364 | - // total th |
|
365 | - |
|
366 | - $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
367 | - // end of row |
|
368 | - $html .= EEH_HTML::trx(); |
|
369 | - return $html; |
|
370 | - } |
|
16 | + /** |
|
17 | + * @var bool |
|
18 | + */ |
|
19 | + protected $prices_include_taxes = false; |
|
20 | + |
|
21 | + /** |
|
22 | + * whether to display the taxes row or not |
|
23 | + * |
|
24 | + * @var bool |
|
25 | + */ |
|
26 | + protected $_show_taxes = false; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * html for any tax rows |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $_taxes_html = ''; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * total amount including tax we can bill for at this time |
|
39 | + * |
|
40 | + * @var float $_grand_total |
|
41 | + */ |
|
42 | + protected $_grand_total = 0.00; |
|
43 | + |
|
44 | + |
|
45 | + public function __construct() |
|
46 | + { |
|
47 | + $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @return float |
|
52 | + */ |
|
53 | + public function grand_total() |
|
54 | + { |
|
55 | + return $this->_grand_total; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * This is used to output a single |
|
61 | + * @param EE_Line_Item $line_item |
|
62 | + * @param array $options |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
66 | + { |
|
67 | + $html = ''; |
|
68 | + // set some default options and merge with incoming |
|
69 | + $default_options = array( |
|
70 | + 'odd' => true, |
|
71 | + 'use_table_wrapper' => true, |
|
72 | + 'table_css_class' => 'admin-primary-mbox-tbl', |
|
73 | + 'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr', |
|
74 | + 'total_tr_css_class' => 'admin-primary-mbox-total-tr' |
|
75 | + ); |
|
76 | + $options = array_merge($default_options, (array) $options); |
|
77 | + |
|
78 | + switch ($line_item->type()) { |
|
79 | + case EEM_Line_Item::type_line_item: |
|
80 | + // item row |
|
81 | + $html .= $this->_item_row($line_item, $options); |
|
82 | + break; |
|
83 | + |
|
84 | + case EEM_Line_Item::type_sub_line_item: |
|
85 | + $html .= $this->_sub_item_row($line_item, $options); |
|
86 | + break; |
|
87 | + |
|
88 | + case EEM_Line_Item::type_sub_total: |
|
89 | + if ($line_item->quantity() === 0) { |
|
90 | + return $html; |
|
91 | + } |
|
92 | + // loop through children |
|
93 | + $child_line_items = $line_item->children(); |
|
94 | + // loop through children |
|
95 | + foreach ($child_line_items as $child_line_item) { |
|
96 | + // recursively feed children back into this method |
|
97 | + $html .= $this->display_line_item($child_line_item, $options); |
|
98 | + } |
|
99 | + $html .= $this->_sub_total_row($line_item, $options); |
|
100 | + break; |
|
101 | + |
|
102 | + case EEM_Line_Item::type_tax: |
|
103 | + if ($this->_show_taxes) { |
|
104 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
105 | + } |
|
106 | + break; |
|
107 | + |
|
108 | + case EEM_Line_Item::type_tax_sub_total: |
|
109 | + foreach ($line_item->children() as $child_line_item) { |
|
110 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
111 | + $this->display_line_item($child_line_item, $options); |
|
112 | + } |
|
113 | + } |
|
114 | + break; |
|
115 | + |
|
116 | + case EEM_Line_Item::type_total: |
|
117 | + // determine whether to display taxes or not |
|
118 | + $this->_show_taxes = $line_item->get_total_tax() > 0 ? true : false; |
|
119 | + // get all child line items |
|
120 | + $children = $line_item->children(); |
|
121 | + |
|
122 | + // loop thru all non-tax child line items |
|
123 | + foreach ($children as $child_line_item) { |
|
124 | + $html .= $this->display_line_item($child_line_item, $options); |
|
125 | + } |
|
126 | + |
|
127 | + $html .= $this->_taxes_html; |
|
128 | + $html .= $this->_total_row($line_item, $options); |
|
129 | + if ($options['use_table_wrapper']) { |
|
130 | + $html = $this->_table_header($options) . $html . $this->_table_footer($options); |
|
131 | + } |
|
132 | + break; |
|
133 | + } |
|
134 | + |
|
135 | + return $html; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * Table header for display. |
|
142 | + * @since 4.8 |
|
143 | + * @param array $options |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + protected function _table_header($options) |
|
147 | + { |
|
148 | + $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
149 | + $html .= EEH_HTML::thead(); |
|
150 | + $html .= EEH_HTML::tr(); |
|
151 | + $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
152 | + $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
153 | + $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
154 | + $html .= EEH_HTML::th(__('Qty', 'event_espresso'), '', 'jst-cntr'); |
|
155 | + $html .= EEH_HTML::th(__('Line Total', 'event_espresso'), '', 'jst-cntr'); |
|
156 | + $html .= EEH_HTML::tbody(); |
|
157 | + return $html; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Table footer for display |
|
163 | + * @since 4.8 |
|
164 | + * @param array $options array of options for the table. |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + protected function _table_footer($options) |
|
168 | + { |
|
169 | + return EEH_HTML::tbodyx() . EEH_HTML::tablex(); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * _item_row |
|
176 | + * |
|
177 | + * @param EE_Line_Item $line_item |
|
178 | + * @param array $options |
|
179 | + * @return mixed |
|
180 | + */ |
|
181 | + protected function _item_row(EE_Line_Item $line_item, $options = array()) |
|
182 | + { |
|
183 | + $line_item_related_object = $line_item->get_object(); |
|
184 | + $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null; |
|
185 | + // start of row |
|
186 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
187 | + $html = EEH_HTML::tr('', '', $row_class); |
|
188 | + |
|
189 | + |
|
190 | + // Name Column |
|
191 | + $name_link = $line_item_related_object instanceof EEI_Admin_Links ? $line_item_related_object->get_admin_details_link() : ''; |
|
192 | + |
|
193 | + // related object scope. |
|
194 | + $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : ''; |
|
195 | + $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
196 | + $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : ''; |
|
197 | + |
|
198 | + |
|
199 | + $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name(); |
|
200 | + $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html; |
|
201 | + $name_html .= $line_item->is_taxable() ? ' *' : ''; |
|
202 | + // maybe preface with icon? |
|
203 | + $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html; |
|
204 | + $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
205 | + $name_html .= sprintf( |
|
206 | + _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
207 | + '<span class="ee-line-item-related-parent-object">', |
|
208 | + $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __('Item:', 'event_espresso'), |
|
209 | + $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name, |
|
210 | + '</span>' |
|
211 | + ); |
|
212 | + |
|
213 | + $name_html = apply_filters( |
|
214 | + 'FHEE__EE_Admin_Table_Line_Item_Display_Strategy___item_row__name_html', |
|
215 | + $name_html, |
|
216 | + $line_item, |
|
217 | + $options |
|
218 | + ); |
|
219 | + |
|
220 | + $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
221 | + // Type Column |
|
222 | + $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : ''; |
|
223 | + $type_html .= $this->_get_cancellations($line_item); |
|
224 | + $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
|
225 | + $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
|
226 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : ''; |
|
227 | + $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
228 | + |
|
229 | + |
|
230 | + // Amount Column |
|
231 | + if ($line_item->is_percent()) { |
|
232 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght'); |
|
233 | + } else { |
|
234 | + $include_taxes = $this->prices_include_taxes |
|
235 | + ? '<br /><span class="grey-text">' |
|
236 | + . sprintf( |
|
237 | + /* translators: 1: money amount like $123 */ |
|
238 | + esc_html__('%1$s before taxes', 'event_espresso'), |
|
239 | + $line_item->pretaxTotal() / $line_item->quantity() |
|
240 | + ) |
|
241 | + . '</span>' |
|
242 | + : ''; |
|
243 | + $price = $line_item->unit_price_no_code(); |
|
244 | + $html .= EEH_HTML::td($price . $include_taxes, '', 'jst-rght'); |
|
245 | + } |
|
246 | + |
|
247 | + // QTY column |
|
248 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'jst-rght'); |
|
249 | + |
|
250 | + // total column |
|
251 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->pretaxTotal(), false, false), '', 'jst-rght'); |
|
252 | + |
|
253 | + // finish things off and return |
|
254 | + $html .= EEH_HTML::trx(); |
|
255 | + return $html; |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * _get_cancellations |
|
262 | + * |
|
263 | + * @param EE_Line_Item $line_item |
|
264 | + * @return string |
|
265 | + */ |
|
266 | + protected function _get_cancellations(EE_Line_Item $line_item) |
|
267 | + { |
|
268 | + $html = ''; |
|
269 | + $cancellations = $line_item->get_cancellations(); |
|
270 | + $cancellation = reset($cancellations); |
|
271 | + if ($cancellation instanceof EE_Line_Item) { |
|
272 | + $html .= ' <span class="ee-line-item-id">'; |
|
273 | + $html .= sprintf( |
|
274 | + _n( |
|
275 | + '(%1$s Cancellation)', |
|
276 | + '(%1$s Cancellations)', |
|
277 | + $cancellation->quantity(), |
|
278 | + 'event_espresso' |
|
279 | + ), |
|
280 | + $cancellation->quantity() |
|
281 | + ); |
|
282 | + $html .= '</span>'; |
|
283 | + } |
|
284 | + return $html; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * _sub_item_row |
|
291 | + * |
|
292 | + * @param EE_Line_Item $line_item |
|
293 | + * @param array $options |
|
294 | + * @return mixed |
|
295 | + */ |
|
296 | + protected function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
297 | + { |
|
298 | + // for now we're not showing sub-items |
|
299 | + return ''; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * _tax_row |
|
306 | + * |
|
307 | + * @param EE_Line_Item $line_item |
|
308 | + * @param array $options |
|
309 | + * @return mixed |
|
310 | + */ |
|
311 | + protected function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
312 | + { |
|
313 | + // start of row |
|
314 | + $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
315 | + // name th |
|
316 | + $tax_details = $line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)'; |
|
317 | + $html .= EEH_HTML::th( |
|
318 | + $tax_details, |
|
319 | + '', |
|
320 | + 'jst-rght', |
|
321 | + '', |
|
322 | + ' colspan="4"' |
|
323 | + ); |
|
324 | + // total th |
|
325 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
326 | + // end of row |
|
327 | + $html .= EEH_HTML::trx(); |
|
328 | + return $html; |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * _total_row |
|
336 | + * |
|
337 | + * @param EE_Line_Item $line_item |
|
338 | + * @param string $text |
|
339 | + * @param array $options |
|
340 | + * @return mixed |
|
341 | + */ |
|
342 | + protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
343 | + { |
|
344 | + // currently not showing subtotal row |
|
345 | + return ''; |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * _total_row |
|
352 | + * |
|
353 | + * @param EE_Line_Item $line_item |
|
354 | + * @param array $options |
|
355 | + * @return mixed |
|
356 | + */ |
|
357 | + protected function _total_row(EE_Line_Item $line_item, $options = array()) |
|
358 | + { |
|
359 | + // start of row |
|
360 | + $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
361 | + // Total th label |
|
362 | + $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
363 | + $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"'); |
|
364 | + // total th |
|
365 | + |
|
366 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
367 | + // end of row |
|
368 | + $html .= EEH_HTML::trx(); |
|
369 | + return $html; |
|
370 | + } |
|
371 | 371 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $html .= $this->_taxes_html; |
128 | 128 | $html .= $this->_total_row($line_item, $options); |
129 | 129 | if ($options['use_table_wrapper']) { |
130 | - $html = $this->_table_header($options) . $html . $this->_table_footer($options); |
|
130 | + $html = $this->_table_header($options).$html.$this->_table_footer($options); |
|
131 | 131 | } |
132 | 132 | break; |
133 | 133 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | protected function _table_footer($options) |
168 | 168 | { |
169 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex(); |
|
169 | + return EEH_HTML::tbodyx().EEH_HTML::tablex(); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name(); |
200 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html; |
|
200 | + $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>' : $name_html; |
|
201 | 201 | $name_html .= $line_item->is_taxable() ? ' *' : ''; |
202 | 202 | // maybe preface with icon? |
203 | - $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html; |
|
204 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
205 | - $name_html .= sprintf( |
|
203 | + $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon().$name_html : $name_html; |
|
204 | + $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>'; |
|
205 | + $name_html .= sprintf( |
|
206 | 206 | _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
207 | 207 | '<span class="ee-line-item-related-parent-object">', |
208 | 208 | $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __('Item:', 'event_espresso'), |
209 | - $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name, |
|
209 | + $parent_related_object_link ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>' : $parent_related_object_name, |
|
210 | 210 | '</span>' |
211 | 211 | ); |
212 | 212 | |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | $type_html .= $this->_get_cancellations($line_item); |
224 | 224 | $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
225 | 225 | $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
226 | - $type_html .= ! empty($code) ? '<span class="ee-line-item-id">' . sprintf(__('Code: %s', 'event_espresso'), $code) . '</span>' : ''; |
|
226 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : ''; |
|
227 | 227 | $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
228 | 228 | |
229 | 229 | |
230 | 230 | // Amount Column |
231 | 231 | if ($line_item->is_percent()) { |
232 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'jst-rght'); |
|
232 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght'); |
|
233 | 233 | } else { |
234 | 234 | $include_taxes = $this->prices_include_taxes |
235 | 235 | ? '<br /><span class="grey-text">' |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | . '</span>' |
242 | 242 | : ''; |
243 | 243 | $price = $line_item->unit_price_no_code(); |
244 | - $html .= EEH_HTML::td($price . $include_taxes, '', 'jst-rght'); |
|
244 | + $html .= EEH_HTML::td($price.$include_taxes, '', 'jst-rght'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // QTY column |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | // start of row |
314 | 314 | $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
315 | 315 | // name th |
316 | - $tax_details = $line_item->name() . '(' . $line_item->get_pretty('LIN_percent') . '%)'; |
|
316 | + $tax_details = $line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)'; |
|
317 | 317 | $html .= EEH_HTML::th( |
318 | 318 | $tax_details, |
319 | 319 | '', |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | // start of row |
360 | 360 | $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
361 | 361 | // Total th label |
362 | - $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')'); |
|
362 | + $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
363 | 363 | $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"'); |
364 | 364 | // total th |
365 | 365 |
@@ -11,684 +11,684 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
13 | 13 | { |
14 | - /** |
|
15 | - * @var bool |
|
16 | - */ |
|
17 | - protected $prices_include_taxes = false; |
|
18 | - |
|
19 | - /** |
|
20 | - * array of events |
|
21 | - * |
|
22 | - * @type EE_Line_Item[] $_events |
|
23 | - */ |
|
24 | - private $_events = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * whether to display the taxes row or not |
|
28 | - * |
|
29 | - * @type bool $_show_taxes |
|
30 | - */ |
|
31 | - private $_show_taxes = false; |
|
32 | - |
|
33 | - /** |
|
34 | - * html for any tax rows |
|
35 | - * |
|
36 | - * @type string $_show_taxes |
|
37 | - */ |
|
38 | - private $_taxes_html = ''; |
|
39 | - |
|
40 | - /** |
|
41 | - * total amount including tax we can bill for at this time |
|
42 | - * |
|
43 | - * @type float $_grand_total |
|
44 | - */ |
|
45 | - private $_grand_total = 0.00; |
|
46 | - |
|
47 | - /** |
|
48 | - * total number of items being billed for |
|
49 | - * |
|
50 | - * @type int $_total_items |
|
51 | - */ |
|
52 | - private $_total_items = 0; |
|
53 | - |
|
54 | - |
|
55 | - public function __construct() |
|
56 | - { |
|
57 | - $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return float |
|
64 | - */ |
|
65 | - public function grand_total() |
|
66 | - { |
|
67 | - return $this->_grand_total; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return int |
|
74 | - */ |
|
75 | - public function total_items() |
|
76 | - { |
|
77 | - return $this->_total_items; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @param EE_Line_Item $line_item |
|
84 | - * @param array $options |
|
85 | - * @param EE_Line_Item $parent_line_item |
|
86 | - * @return mixed |
|
87 | - * @throws EE_Error |
|
88 | - */ |
|
89 | - public function display_line_item( |
|
90 | - EE_Line_Item $line_item, |
|
91 | - $options = array(), |
|
92 | - EE_Line_Item $parent_line_item = null |
|
93 | - ) { |
|
94 | - $html = ''; |
|
95 | - // set some default options and merge with incoming |
|
96 | - $default_options = array( |
|
97 | - 'show_desc' => true, // true false |
|
98 | - 'odd' => false, |
|
99 | - ); |
|
100 | - $options = array_merge($default_options, (array) $options); |
|
101 | - |
|
102 | - switch ($line_item->type()) { |
|
103 | - case EEM_Line_Item::type_line_item: |
|
104 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
105 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
106 | - // item row |
|
107 | - $html .= $this->_ticket_row($line_item, $options); |
|
108 | - } else { |
|
109 | - // item row |
|
110 | - $html .= $this->_item_row($line_item, $options); |
|
111 | - } |
|
112 | - if ( |
|
113 | - apply_filters( |
|
114 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
115 | - true |
|
116 | - ) |
|
117 | - ) { |
|
118 | - // got any kids? |
|
119 | - foreach ($line_item->children() as $child_line_item) { |
|
120 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
121 | - } |
|
122 | - } |
|
123 | - break; |
|
124 | - |
|
125 | - case EEM_Line_Item::type_sub_line_item: |
|
126 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
127 | - break; |
|
128 | - |
|
129 | - case EEM_Line_Item::type_sub_tax: |
|
130 | - $this->_show_taxes = true; |
|
131 | - break; |
|
132 | - |
|
133 | - case EEM_Line_Item::type_sub_total: |
|
134 | - static $sub_total = 0; |
|
135 | - $event_sub_total = 0; |
|
136 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
137 | - if ($line_item->OBJ_type() === 'Event') { |
|
138 | - $options['event_id'] = $line_item->OBJ_ID(); |
|
139 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
140 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
141 | - // if event has default reg status of Not Approved, then don't display info on it |
|
142 | - if ( |
|
143 | - $event instanceof EE_Event |
|
144 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
145 | - ) { |
|
146 | - $display_event = false; |
|
147 | - // unless there are registrations for it that are returning to pay |
|
148 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
149 | - foreach ($options['registrations'] as $registration) { |
|
150 | - if (! $registration instanceof EE_Registration) { |
|
151 | - continue; |
|
152 | - } |
|
153 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
154 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
155 | - ? true |
|
156 | - : $display_event; |
|
157 | - } |
|
158 | - } |
|
159 | - if (! $display_event) { |
|
160 | - return ''; |
|
161 | - } |
|
162 | - } |
|
163 | - $this->_events[ $options['event_id'] ] = 0; |
|
164 | - $html .= $this->_event_row($line_item); |
|
165 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
166 | - } |
|
167 | - } |
|
168 | - $child_line_items = $line_item->children(); |
|
169 | - // loop thru children |
|
170 | - foreach ($child_line_items as $child_line_item) { |
|
171 | - // recursively feed children back into this method |
|
172 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
173 | - } |
|
174 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
175 | - $sub_total += $event_sub_total; |
|
176 | - if ( |
|
177 | - ( |
|
178 | - // event subtotals |
|
179 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
180 | - ) |
|
181 | - || ( |
|
182 | - // pre-tax subtotals |
|
183 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
184 | - ) |
|
185 | - ) { |
|
186 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
187 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
188 | - } |
|
189 | - break; |
|
190 | - |
|
191 | - case EEM_Line_Item::type_tax: |
|
192 | - if ($this->_show_taxes) { |
|
193 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
194 | - } |
|
195 | - break; |
|
196 | - |
|
197 | - case EEM_Line_Item::type_tax_sub_total: |
|
198 | - if ($this->_show_taxes) { |
|
199 | - $child_line_items = $line_item->children(); |
|
200 | - // loop thru children |
|
201 | - foreach ($child_line_items as $child_line_item) { |
|
202 | - // recursively feed children back into this method |
|
203 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
204 | - } |
|
205 | - if (count($child_line_items) > 1) { |
|
206 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
207 | - } |
|
208 | - } |
|
209 | - break; |
|
210 | - |
|
211 | - case EEM_Line_Item::type_total: |
|
212 | - // get all child line items |
|
213 | - $children = $line_item->children(); |
|
214 | - // loop thru all non-tax child line items |
|
215 | - foreach ($children as $child_line_item) { |
|
216 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
217 | - // recursively feed children back into this method |
|
218 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
219 | - } |
|
220 | - } |
|
221 | - // now loop thru tax child line items |
|
222 | - foreach ($children as $child_line_item) { |
|
223 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
224 | - // recursively feed children back into this method |
|
225 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
226 | - } |
|
227 | - } |
|
228 | - $html .= $this->_taxes_html; |
|
229 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
230 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
231 | - break; |
|
232 | - } |
|
233 | - return $html; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
240 | - * |
|
241 | - * @param EE_Line_Item $line_item |
|
242 | - * @return mixed |
|
243 | - */ |
|
244 | - private function _event_row(EE_Line_Item $line_item) |
|
245 | - { |
|
246 | - // start of row |
|
247 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
248 | - // event name td |
|
249 | - $html .= EEH_HTML::td( |
|
250 | - EEH_HTML::strong($line_item->name()), |
|
251 | - '', |
|
252 | - 'event-header', |
|
253 | - '', |
|
254 | - ' colspan="4"' |
|
255 | - ); |
|
256 | - // end of row |
|
257 | - $html .= EEH_HTML::trx(); |
|
258 | - return $html; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * _ticket_row |
|
265 | - * |
|
266 | - * @param EE_Line_Item $line_item |
|
267 | - * @param array $options |
|
268 | - * @return mixed |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
272 | - { |
|
273 | - // start of row |
|
274 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
275 | - $html = EEH_HTML::tr('', '', $row_class); |
|
276 | - // name && desc |
|
277 | - $name_and_desc = apply_filters( |
|
278 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
279 | - $line_item->name(), |
|
280 | - $line_item |
|
281 | - ); |
|
282 | - $name_and_desc .= apply_filters( |
|
283 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
284 | - ( |
|
285 | - $options['show_desc'] |
|
286 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
287 | - : '' |
|
288 | - ), |
|
289 | - $line_item, |
|
290 | - $options |
|
291 | - ); |
|
292 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
293 | - $name_and_desc = apply_filters( |
|
294 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__name_and_desc', |
|
295 | - $name_and_desc, |
|
296 | - $line_item, |
|
297 | - $options |
|
298 | - ); |
|
299 | - |
|
300 | - // name td |
|
301 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
302 | - $name_and_desc, |
|
303 | - '', |
|
304 | - 'item_l' |
|
305 | - ); |
|
306 | - // price td |
|
307 | - $price = apply_filters( |
|
308 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price', |
|
309 | - $line_item->unit_price_no_code(), |
|
310 | - $line_item |
|
311 | - ); |
|
312 | - $html .= EEH_HTML::td($price, '', 'spco-nowrap item_c jst-rght'); |
|
313 | - // quantity td |
|
314 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'spco-nowrap item_l jst-rght'); |
|
315 | - $this->_total_items += $line_item->quantity(); |
|
316 | - // determine total for line item |
|
317 | - $total = apply_filters( |
|
318 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total', |
|
319 | - $line_item->pretaxTotal(), |
|
320 | - $line_item |
|
321 | - ); |
|
322 | - $this->_events[ $options['event_id'] ] += $total; |
|
323 | - // total td |
|
324 | - $html .= EEH_HTML::td( |
|
325 | - EEH_Template::format_currency($total, false, false), |
|
326 | - '', |
|
327 | - 'spco-nowrap item_r jst-rght' |
|
328 | - ); |
|
329 | - // end of row |
|
330 | - $html .= EEH_HTML::trx(); |
|
331 | - return $html; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * _item_row |
|
338 | - * |
|
339 | - * @param EE_Line_Item $line_item |
|
340 | - * @param array $options |
|
341 | - * @return mixed |
|
342 | - * @throws EE_Error |
|
343 | - */ |
|
344 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
345 | - { |
|
346 | - // start of row |
|
347 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
348 | - $html = EEH_HTML::tr('', '', $row_class); |
|
349 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
350 | - // name && desc |
|
351 | - $name_and_desc = apply_filters( |
|
352 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
353 | - $obj_name . $line_item->name(), |
|
354 | - $line_item |
|
355 | - ); |
|
356 | - $name_and_desc .= apply_filters( |
|
357 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
358 | - ( |
|
359 | - $options['show_desc'] |
|
360 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
361 | - : '' |
|
362 | - ), |
|
363 | - $line_item, |
|
364 | - $options |
|
365 | - ); |
|
366 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
367 | - $name_and_desc = apply_filters( |
|
368 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___item_row__name_and_desc', |
|
369 | - $name_and_desc, |
|
370 | - $line_item, |
|
371 | - $options |
|
372 | - ); |
|
373 | - |
|
374 | - // name td |
|
375 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
376 | - // price td |
|
377 | - if ($line_item->is_percent()) { |
|
378 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'spco-nowrap item_c jst-rght'); |
|
379 | - } else { |
|
380 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'spco-nowrap item_c jst-rght'); |
|
381 | - } |
|
382 | - // quantity td |
|
383 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'spco-nowrap item_l jst-rght'); |
|
384 | - // $total = $line_item->total() * $line_item->quantity(); |
|
385 | - $total = $line_item->total(); |
|
386 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
387 | - $this->_events[ $options['event_id'] ] += $total; |
|
388 | - } |
|
389 | - // total td |
|
390 | - $html .= EEH_HTML::td( |
|
391 | - EEH_Template::format_currency($total, false, false), |
|
392 | - '', |
|
393 | - 'spco-nowrap item_r jst-rght' |
|
394 | - ); |
|
395 | - // end of row |
|
396 | - $html .= EEH_HTML::trx(); |
|
397 | - return $html; |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * _sub_item_row |
|
404 | - * |
|
405 | - * @param EE_Line_Item $line_item |
|
406 | - * @param array $options |
|
407 | - * @param EE_Line_Item $parent_line_item |
|
408 | - * @return mixed |
|
409 | - * @throws EE_Error |
|
410 | - */ |
|
411 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
412 | - { |
|
413 | - if ( |
|
414 | - $parent_line_item instanceof EE_Line_Item |
|
415 | - && $line_item->children() === array() |
|
416 | - && $line_item->name() === $parent_line_item->name() |
|
417 | - && apply_filters( |
|
418 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
419 | - true |
|
420 | - ) |
|
421 | - ) { |
|
422 | - return ''; |
|
423 | - } |
|
424 | - // start of row |
|
425 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
426 | - // name && desc |
|
427 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
428 | - . $line_item->name(); |
|
429 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
430 | - . $line_item->desc() |
|
431 | - . '</span>' : ''; |
|
432 | - // name td |
|
433 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
434 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
435 | - // discount/surcharge td |
|
436 | - if ($line_item->is_percent()) { |
|
437 | - $html .= EEH_HTML::td( |
|
438 | - EEH_Template::format_currency( |
|
439 | - $line_item->total() / $qty, |
|
440 | - false, |
|
441 | - false |
|
442 | - ), |
|
443 | - '', |
|
444 | - 'spco-nowrap item_c jst-rght' |
|
445 | - ); |
|
446 | - } else { |
|
447 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'spco-nowrap item_c jst-rght'); |
|
448 | - } |
|
449 | - // no quantity td |
|
450 | - $html .= EEH_HTML::td(); |
|
451 | - // no total td |
|
452 | - $html .= EEH_HTML::td(); |
|
453 | - // end of row |
|
454 | - $html .= EEH_HTML::trx(); |
|
455 | - $html = apply_filters( |
|
456 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
457 | - $html, |
|
458 | - $line_item, |
|
459 | - $options, |
|
460 | - $parent_line_item |
|
461 | - ); |
|
462 | - return $html; |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * _tax_row |
|
469 | - * |
|
470 | - * @param EE_Line_Item $line_item |
|
471 | - * @param array $options |
|
472 | - * @return mixed |
|
473 | - * @throws EE_Error |
|
474 | - */ |
|
475 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
476 | - { |
|
477 | - // start of row |
|
478 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
479 | - // name && desc |
|
480 | - $name_and_desc = $line_item->name(); |
|
481 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
482 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
483 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
484 | - // name td |
|
485 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
486 | - $name_and_desc, |
|
487 | - '', |
|
488 | - 'item_l sub-item' |
|
489 | - ); |
|
490 | - // percent td |
|
491 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'spco-nowrap jst-rght', ''); |
|
492 | - // empty td (price) |
|
493 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
494 | - // total td |
|
495 | - $html .= EEH_HTML::td( |
|
496 | - EEH_Template::format_currency( |
|
497 | - $line_item->total(), |
|
498 | - false, |
|
499 | - false |
|
500 | - ), |
|
501 | - '', |
|
502 | - 'spco-nowrap item_r jst-rght' |
|
503 | - ); |
|
504 | - // end of row |
|
505 | - $html .= EEH_HTML::trx(); |
|
506 | - return $html; |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * _total_row |
|
513 | - * |
|
514 | - * @param EE_Line_Item $line_item |
|
515 | - * @param string $text |
|
516 | - * @return mixed |
|
517 | - * @throws EE_Error |
|
518 | - */ |
|
519 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
520 | - { |
|
521 | - $html = ''; |
|
522 | - if ($line_item->total()) { |
|
523 | - // start of row |
|
524 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
525 | - // total td |
|
526 | - $html .= EEH_HTML::td( |
|
527 | - $text, |
|
528 | - '', |
|
529 | - 'total_currency total jst-rght', |
|
530 | - '', |
|
531 | - ' colspan="2"' |
|
532 | - ); |
|
533 | - // empty td (price) |
|
534 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
535 | - // total td |
|
536 | - $html .= EEH_HTML::td( |
|
537 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
538 | - '', |
|
539 | - 'spco-nowrap total jst-rght' |
|
540 | - ); |
|
541 | - // end of row |
|
542 | - $html .= EEH_HTML::trx(); |
|
543 | - } |
|
544 | - return $html; |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - |
|
549 | - /** |
|
550 | - * _total_row |
|
551 | - * |
|
552 | - * @param EE_Line_Item $line_item |
|
553 | - * @param string $text |
|
554 | - * @param array $options |
|
555 | - * @return mixed |
|
556 | - * @throws EE_Error |
|
557 | - */ |
|
558 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
559 | - { |
|
560 | - $html = ''; |
|
561 | - if ($line_item->total()) { |
|
562 | - // start of row |
|
563 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
564 | - // total td |
|
565 | - $html .= EEH_HTML::td( |
|
566 | - $text, |
|
567 | - '', |
|
568 | - 'total_currency total jst-rght', |
|
569 | - '', |
|
570 | - ' colspan="3"' |
|
571 | - ); |
|
572 | - // total td |
|
573 | - $html .= EEH_HTML::td( |
|
574 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
575 | - '', |
|
576 | - 'spco-nowrap total jst-rght' |
|
577 | - ); |
|
578 | - // end of row |
|
579 | - $html .= EEH_HTML::trx(); |
|
580 | - } |
|
581 | - return $html; |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * _total_row |
|
588 | - * |
|
589 | - * @param EE_Line_Item $line_item |
|
590 | - * @param string $text |
|
591 | - * @return mixed |
|
592 | - * @throws EE_Error |
|
593 | - */ |
|
594 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
595 | - { |
|
596 | - // start of row |
|
597 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
598 | - // total td |
|
599 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
600 | - // total td |
|
601 | - $html .= EEH_HTML::td( |
|
602 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
603 | - '', |
|
604 | - 'spco-nowrap total jst-rght' |
|
605 | - ); |
|
606 | - // end of row |
|
607 | - $html .= EEH_HTML::trx(); |
|
608 | - return $html; |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * _payments_and_amount_owing_rows |
|
615 | - * |
|
616 | - * @param EE_Line_Item $line_item |
|
617 | - * @param array $options |
|
618 | - * @return mixed |
|
619 | - * @throws EE_Error |
|
620 | - */ |
|
621 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
622 | - { |
|
623 | - $html = ''; |
|
624 | - $owing = $line_item->total(); |
|
625 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
626 | - if ($transaction instanceof EE_Transaction) { |
|
627 | - $registration_payments = array(); |
|
628 | - $registrations = ! empty($options['registrations']) |
|
629 | - ? $options['registrations'] |
|
630 | - : $transaction->registrations(); |
|
631 | - foreach ($registrations as $registration) { |
|
632 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
633 | - $registration_payments += $registration->registration_payments(); |
|
634 | - } |
|
635 | - } |
|
636 | - if (! empty($registration_payments)) { |
|
637 | - foreach ($registration_payments as $registration_payment) { |
|
638 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
639 | - $owing -= $registration_payment->amount(); |
|
640 | - $payment = $registration_payment->payment(); |
|
641 | - $payment_desc = ''; |
|
642 | - if ($payment instanceof EE_Payment) { |
|
643 | - $payment_desc = sprintf( |
|
644 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
645 | - $payment->txn_id_chq_nmbr() !== '' |
|
646 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
647 | - : '', |
|
648 | - $payment->timestamp() |
|
649 | - ); |
|
650 | - } |
|
651 | - // start of row |
|
652 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
653 | - // payment desc |
|
654 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
655 | - // total td |
|
656 | - $html .= EEH_HTML::td( |
|
657 | - EEH_Template::format_currency( |
|
658 | - $registration_payment->amount(), |
|
659 | - false, |
|
660 | - false |
|
661 | - ), |
|
662 | - '', |
|
663 | - 'spco-nowrap total jst-rght' |
|
664 | - ); |
|
665 | - // end of row |
|
666 | - $html .= EEH_HTML::trx(); |
|
667 | - } |
|
668 | - } |
|
669 | - if ($line_item->total()) { |
|
670 | - // start of row |
|
671 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
672 | - // total td |
|
673 | - $html .= EEH_HTML::td( |
|
674 | - esc_html__('Amount Owing', 'event_espresso'), |
|
675 | - '', |
|
676 | - 'total_currency total jst-rght', |
|
677 | - '', |
|
678 | - ' colspan="3"' |
|
679 | - ); |
|
680 | - // total td |
|
681 | - $html .= EEH_HTML::td( |
|
682 | - EEH_Template::format_currency($owing, false, false), |
|
683 | - '', |
|
684 | - 'spco-nowrap total jst-rght' |
|
685 | - ); |
|
686 | - // end of row |
|
687 | - $html .= EEH_HTML::trx(); |
|
688 | - } |
|
689 | - } |
|
690 | - } |
|
691 | - $this->_grand_total = $owing; |
|
692 | - return $html; |
|
693 | - } |
|
14 | + /** |
|
15 | + * @var bool |
|
16 | + */ |
|
17 | + protected $prices_include_taxes = false; |
|
18 | + |
|
19 | + /** |
|
20 | + * array of events |
|
21 | + * |
|
22 | + * @type EE_Line_Item[] $_events |
|
23 | + */ |
|
24 | + private $_events = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * whether to display the taxes row or not |
|
28 | + * |
|
29 | + * @type bool $_show_taxes |
|
30 | + */ |
|
31 | + private $_show_taxes = false; |
|
32 | + |
|
33 | + /** |
|
34 | + * html for any tax rows |
|
35 | + * |
|
36 | + * @type string $_show_taxes |
|
37 | + */ |
|
38 | + private $_taxes_html = ''; |
|
39 | + |
|
40 | + /** |
|
41 | + * total amount including tax we can bill for at this time |
|
42 | + * |
|
43 | + * @type float $_grand_total |
|
44 | + */ |
|
45 | + private $_grand_total = 0.00; |
|
46 | + |
|
47 | + /** |
|
48 | + * total number of items being billed for |
|
49 | + * |
|
50 | + * @type int $_total_items |
|
51 | + */ |
|
52 | + private $_total_items = 0; |
|
53 | + |
|
54 | + |
|
55 | + public function __construct() |
|
56 | + { |
|
57 | + $this->prices_include_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return float |
|
64 | + */ |
|
65 | + public function grand_total() |
|
66 | + { |
|
67 | + return $this->_grand_total; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return int |
|
74 | + */ |
|
75 | + public function total_items() |
|
76 | + { |
|
77 | + return $this->_total_items; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @param EE_Line_Item $line_item |
|
84 | + * @param array $options |
|
85 | + * @param EE_Line_Item $parent_line_item |
|
86 | + * @return mixed |
|
87 | + * @throws EE_Error |
|
88 | + */ |
|
89 | + public function display_line_item( |
|
90 | + EE_Line_Item $line_item, |
|
91 | + $options = array(), |
|
92 | + EE_Line_Item $parent_line_item = null |
|
93 | + ) { |
|
94 | + $html = ''; |
|
95 | + // set some default options and merge with incoming |
|
96 | + $default_options = array( |
|
97 | + 'show_desc' => true, // true false |
|
98 | + 'odd' => false, |
|
99 | + ); |
|
100 | + $options = array_merge($default_options, (array) $options); |
|
101 | + |
|
102 | + switch ($line_item->type()) { |
|
103 | + case EEM_Line_Item::type_line_item: |
|
104 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
105 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
106 | + // item row |
|
107 | + $html .= $this->_ticket_row($line_item, $options); |
|
108 | + } else { |
|
109 | + // item row |
|
110 | + $html .= $this->_item_row($line_item, $options); |
|
111 | + } |
|
112 | + if ( |
|
113 | + apply_filters( |
|
114 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
115 | + true |
|
116 | + ) |
|
117 | + ) { |
|
118 | + // got any kids? |
|
119 | + foreach ($line_item->children() as $child_line_item) { |
|
120 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
121 | + } |
|
122 | + } |
|
123 | + break; |
|
124 | + |
|
125 | + case EEM_Line_Item::type_sub_line_item: |
|
126 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
127 | + break; |
|
128 | + |
|
129 | + case EEM_Line_Item::type_sub_tax: |
|
130 | + $this->_show_taxes = true; |
|
131 | + break; |
|
132 | + |
|
133 | + case EEM_Line_Item::type_sub_total: |
|
134 | + static $sub_total = 0; |
|
135 | + $event_sub_total = 0; |
|
136 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
137 | + if ($line_item->OBJ_type() === 'Event') { |
|
138 | + $options['event_id'] = $line_item->OBJ_ID(); |
|
139 | + if (! isset($this->_events[ $options['event_id'] ])) { |
|
140 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
141 | + // if event has default reg status of Not Approved, then don't display info on it |
|
142 | + if ( |
|
143 | + $event instanceof EE_Event |
|
144 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
145 | + ) { |
|
146 | + $display_event = false; |
|
147 | + // unless there are registrations for it that are returning to pay |
|
148 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
149 | + foreach ($options['registrations'] as $registration) { |
|
150 | + if (! $registration instanceof EE_Registration) { |
|
151 | + continue; |
|
152 | + } |
|
153 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
154 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
155 | + ? true |
|
156 | + : $display_event; |
|
157 | + } |
|
158 | + } |
|
159 | + if (! $display_event) { |
|
160 | + return ''; |
|
161 | + } |
|
162 | + } |
|
163 | + $this->_events[ $options['event_id'] ] = 0; |
|
164 | + $html .= $this->_event_row($line_item); |
|
165 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
166 | + } |
|
167 | + } |
|
168 | + $child_line_items = $line_item->children(); |
|
169 | + // loop thru children |
|
170 | + foreach ($child_line_items as $child_line_item) { |
|
171 | + // recursively feed children back into this method |
|
172 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
173 | + } |
|
174 | + $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
175 | + $sub_total += $event_sub_total; |
|
176 | + if ( |
|
177 | + ( |
|
178 | + // event subtotals |
|
179 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
180 | + ) |
|
181 | + || ( |
|
182 | + // pre-tax subtotals |
|
183 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
184 | + ) |
|
185 | + ) { |
|
186 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
187 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
188 | + } |
|
189 | + break; |
|
190 | + |
|
191 | + case EEM_Line_Item::type_tax: |
|
192 | + if ($this->_show_taxes) { |
|
193 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
194 | + } |
|
195 | + break; |
|
196 | + |
|
197 | + case EEM_Line_Item::type_tax_sub_total: |
|
198 | + if ($this->_show_taxes) { |
|
199 | + $child_line_items = $line_item->children(); |
|
200 | + // loop thru children |
|
201 | + foreach ($child_line_items as $child_line_item) { |
|
202 | + // recursively feed children back into this method |
|
203 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
204 | + } |
|
205 | + if (count($child_line_items) > 1) { |
|
206 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
207 | + } |
|
208 | + } |
|
209 | + break; |
|
210 | + |
|
211 | + case EEM_Line_Item::type_total: |
|
212 | + // get all child line items |
|
213 | + $children = $line_item->children(); |
|
214 | + // loop thru all non-tax child line items |
|
215 | + foreach ($children as $child_line_item) { |
|
216 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
217 | + // recursively feed children back into this method |
|
218 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
219 | + } |
|
220 | + } |
|
221 | + // now loop thru tax child line items |
|
222 | + foreach ($children as $child_line_item) { |
|
223 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
224 | + // recursively feed children back into this method |
|
225 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
226 | + } |
|
227 | + } |
|
228 | + $html .= $this->_taxes_html; |
|
229 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
230 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
231 | + break; |
|
232 | + } |
|
233 | + return $html; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
240 | + * |
|
241 | + * @param EE_Line_Item $line_item |
|
242 | + * @return mixed |
|
243 | + */ |
|
244 | + private function _event_row(EE_Line_Item $line_item) |
|
245 | + { |
|
246 | + // start of row |
|
247 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
248 | + // event name td |
|
249 | + $html .= EEH_HTML::td( |
|
250 | + EEH_HTML::strong($line_item->name()), |
|
251 | + '', |
|
252 | + 'event-header', |
|
253 | + '', |
|
254 | + ' colspan="4"' |
|
255 | + ); |
|
256 | + // end of row |
|
257 | + $html .= EEH_HTML::trx(); |
|
258 | + return $html; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * _ticket_row |
|
265 | + * |
|
266 | + * @param EE_Line_Item $line_item |
|
267 | + * @param array $options |
|
268 | + * @return mixed |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
272 | + { |
|
273 | + // start of row |
|
274 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
275 | + $html = EEH_HTML::tr('', '', $row_class); |
|
276 | + // name && desc |
|
277 | + $name_and_desc = apply_filters( |
|
278 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
279 | + $line_item->name(), |
|
280 | + $line_item |
|
281 | + ); |
|
282 | + $name_and_desc .= apply_filters( |
|
283 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
284 | + ( |
|
285 | + $options['show_desc'] |
|
286 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
287 | + : '' |
|
288 | + ), |
|
289 | + $line_item, |
|
290 | + $options |
|
291 | + ); |
|
292 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
293 | + $name_and_desc = apply_filters( |
|
294 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__name_and_desc', |
|
295 | + $name_and_desc, |
|
296 | + $line_item, |
|
297 | + $options |
|
298 | + ); |
|
299 | + |
|
300 | + // name td |
|
301 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
302 | + $name_and_desc, |
|
303 | + '', |
|
304 | + 'item_l' |
|
305 | + ); |
|
306 | + // price td |
|
307 | + $price = apply_filters( |
|
308 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price', |
|
309 | + $line_item->unit_price_no_code(), |
|
310 | + $line_item |
|
311 | + ); |
|
312 | + $html .= EEH_HTML::td($price, '', 'spco-nowrap item_c jst-rght'); |
|
313 | + // quantity td |
|
314 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'spco-nowrap item_l jst-rght'); |
|
315 | + $this->_total_items += $line_item->quantity(); |
|
316 | + // determine total for line item |
|
317 | + $total = apply_filters( |
|
318 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total', |
|
319 | + $line_item->pretaxTotal(), |
|
320 | + $line_item |
|
321 | + ); |
|
322 | + $this->_events[ $options['event_id'] ] += $total; |
|
323 | + // total td |
|
324 | + $html .= EEH_HTML::td( |
|
325 | + EEH_Template::format_currency($total, false, false), |
|
326 | + '', |
|
327 | + 'spco-nowrap item_r jst-rght' |
|
328 | + ); |
|
329 | + // end of row |
|
330 | + $html .= EEH_HTML::trx(); |
|
331 | + return $html; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * _item_row |
|
338 | + * |
|
339 | + * @param EE_Line_Item $line_item |
|
340 | + * @param array $options |
|
341 | + * @return mixed |
|
342 | + * @throws EE_Error |
|
343 | + */ |
|
344 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
345 | + { |
|
346 | + // start of row |
|
347 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
348 | + $html = EEH_HTML::tr('', '', $row_class); |
|
349 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
350 | + // name && desc |
|
351 | + $name_and_desc = apply_filters( |
|
352 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
353 | + $obj_name . $line_item->name(), |
|
354 | + $line_item |
|
355 | + ); |
|
356 | + $name_and_desc .= apply_filters( |
|
357 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
358 | + ( |
|
359 | + $options['show_desc'] |
|
360 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
361 | + : '' |
|
362 | + ), |
|
363 | + $line_item, |
|
364 | + $options |
|
365 | + ); |
|
366 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
367 | + $name_and_desc = apply_filters( |
|
368 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___item_row__name_and_desc', |
|
369 | + $name_and_desc, |
|
370 | + $line_item, |
|
371 | + $options |
|
372 | + ); |
|
373 | + |
|
374 | + // name td |
|
375 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
376 | + // price td |
|
377 | + if ($line_item->is_percent()) { |
|
378 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'spco-nowrap item_c jst-rght'); |
|
379 | + } else { |
|
380 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'spco-nowrap item_c jst-rght'); |
|
381 | + } |
|
382 | + // quantity td |
|
383 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'spco-nowrap item_l jst-rght'); |
|
384 | + // $total = $line_item->total() * $line_item->quantity(); |
|
385 | + $total = $line_item->total(); |
|
386 | + if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
387 | + $this->_events[ $options['event_id'] ] += $total; |
|
388 | + } |
|
389 | + // total td |
|
390 | + $html .= EEH_HTML::td( |
|
391 | + EEH_Template::format_currency($total, false, false), |
|
392 | + '', |
|
393 | + 'spco-nowrap item_r jst-rght' |
|
394 | + ); |
|
395 | + // end of row |
|
396 | + $html .= EEH_HTML::trx(); |
|
397 | + return $html; |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * _sub_item_row |
|
404 | + * |
|
405 | + * @param EE_Line_Item $line_item |
|
406 | + * @param array $options |
|
407 | + * @param EE_Line_Item $parent_line_item |
|
408 | + * @return mixed |
|
409 | + * @throws EE_Error |
|
410 | + */ |
|
411 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
412 | + { |
|
413 | + if ( |
|
414 | + $parent_line_item instanceof EE_Line_Item |
|
415 | + && $line_item->children() === array() |
|
416 | + && $line_item->name() === $parent_line_item->name() |
|
417 | + && apply_filters( |
|
418 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
419 | + true |
|
420 | + ) |
|
421 | + ) { |
|
422 | + return ''; |
|
423 | + } |
|
424 | + // start of row |
|
425 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
426 | + // name && desc |
|
427 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
428 | + . $line_item->name(); |
|
429 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
430 | + . $line_item->desc() |
|
431 | + . '</span>' : ''; |
|
432 | + // name td |
|
433 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
434 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
435 | + // discount/surcharge td |
|
436 | + if ($line_item->is_percent()) { |
|
437 | + $html .= EEH_HTML::td( |
|
438 | + EEH_Template::format_currency( |
|
439 | + $line_item->total() / $qty, |
|
440 | + false, |
|
441 | + false |
|
442 | + ), |
|
443 | + '', |
|
444 | + 'spco-nowrap item_c jst-rght' |
|
445 | + ); |
|
446 | + } else { |
|
447 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'spco-nowrap item_c jst-rght'); |
|
448 | + } |
|
449 | + // no quantity td |
|
450 | + $html .= EEH_HTML::td(); |
|
451 | + // no total td |
|
452 | + $html .= EEH_HTML::td(); |
|
453 | + // end of row |
|
454 | + $html .= EEH_HTML::trx(); |
|
455 | + $html = apply_filters( |
|
456 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
457 | + $html, |
|
458 | + $line_item, |
|
459 | + $options, |
|
460 | + $parent_line_item |
|
461 | + ); |
|
462 | + return $html; |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * _tax_row |
|
469 | + * |
|
470 | + * @param EE_Line_Item $line_item |
|
471 | + * @param array $options |
|
472 | + * @return mixed |
|
473 | + * @throws EE_Error |
|
474 | + */ |
|
475 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
476 | + { |
|
477 | + // start of row |
|
478 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
479 | + // name && desc |
|
480 | + $name_and_desc = $line_item->name(); |
|
481 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
482 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
483 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
484 | + // name td |
|
485 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
486 | + $name_and_desc, |
|
487 | + '', |
|
488 | + 'item_l sub-item' |
|
489 | + ); |
|
490 | + // percent td |
|
491 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'spco-nowrap jst-rght', ''); |
|
492 | + // empty td (price) |
|
493 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
494 | + // total td |
|
495 | + $html .= EEH_HTML::td( |
|
496 | + EEH_Template::format_currency( |
|
497 | + $line_item->total(), |
|
498 | + false, |
|
499 | + false |
|
500 | + ), |
|
501 | + '', |
|
502 | + 'spco-nowrap item_r jst-rght' |
|
503 | + ); |
|
504 | + // end of row |
|
505 | + $html .= EEH_HTML::trx(); |
|
506 | + return $html; |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * _total_row |
|
513 | + * |
|
514 | + * @param EE_Line_Item $line_item |
|
515 | + * @param string $text |
|
516 | + * @return mixed |
|
517 | + * @throws EE_Error |
|
518 | + */ |
|
519 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
520 | + { |
|
521 | + $html = ''; |
|
522 | + if ($line_item->total()) { |
|
523 | + // start of row |
|
524 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
525 | + // total td |
|
526 | + $html .= EEH_HTML::td( |
|
527 | + $text, |
|
528 | + '', |
|
529 | + 'total_currency total jst-rght', |
|
530 | + '', |
|
531 | + ' colspan="2"' |
|
532 | + ); |
|
533 | + // empty td (price) |
|
534 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
535 | + // total td |
|
536 | + $html .= EEH_HTML::td( |
|
537 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
538 | + '', |
|
539 | + 'spco-nowrap total jst-rght' |
|
540 | + ); |
|
541 | + // end of row |
|
542 | + $html .= EEH_HTML::trx(); |
|
543 | + } |
|
544 | + return $html; |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + |
|
549 | + /** |
|
550 | + * _total_row |
|
551 | + * |
|
552 | + * @param EE_Line_Item $line_item |
|
553 | + * @param string $text |
|
554 | + * @param array $options |
|
555 | + * @return mixed |
|
556 | + * @throws EE_Error |
|
557 | + */ |
|
558 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
559 | + { |
|
560 | + $html = ''; |
|
561 | + if ($line_item->total()) { |
|
562 | + // start of row |
|
563 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
564 | + // total td |
|
565 | + $html .= EEH_HTML::td( |
|
566 | + $text, |
|
567 | + '', |
|
568 | + 'total_currency total jst-rght', |
|
569 | + '', |
|
570 | + ' colspan="3"' |
|
571 | + ); |
|
572 | + // total td |
|
573 | + $html .= EEH_HTML::td( |
|
574 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
575 | + '', |
|
576 | + 'spco-nowrap total jst-rght' |
|
577 | + ); |
|
578 | + // end of row |
|
579 | + $html .= EEH_HTML::trx(); |
|
580 | + } |
|
581 | + return $html; |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * _total_row |
|
588 | + * |
|
589 | + * @param EE_Line_Item $line_item |
|
590 | + * @param string $text |
|
591 | + * @return mixed |
|
592 | + * @throws EE_Error |
|
593 | + */ |
|
594 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
595 | + { |
|
596 | + // start of row |
|
597 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
598 | + // total td |
|
599 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
600 | + // total td |
|
601 | + $html .= EEH_HTML::td( |
|
602 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
603 | + '', |
|
604 | + 'spco-nowrap total jst-rght' |
|
605 | + ); |
|
606 | + // end of row |
|
607 | + $html .= EEH_HTML::trx(); |
|
608 | + return $html; |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * _payments_and_amount_owing_rows |
|
615 | + * |
|
616 | + * @param EE_Line_Item $line_item |
|
617 | + * @param array $options |
|
618 | + * @return mixed |
|
619 | + * @throws EE_Error |
|
620 | + */ |
|
621 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
622 | + { |
|
623 | + $html = ''; |
|
624 | + $owing = $line_item->total(); |
|
625 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
626 | + if ($transaction instanceof EE_Transaction) { |
|
627 | + $registration_payments = array(); |
|
628 | + $registrations = ! empty($options['registrations']) |
|
629 | + ? $options['registrations'] |
|
630 | + : $transaction->registrations(); |
|
631 | + foreach ($registrations as $registration) { |
|
632 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
633 | + $registration_payments += $registration->registration_payments(); |
|
634 | + } |
|
635 | + } |
|
636 | + if (! empty($registration_payments)) { |
|
637 | + foreach ($registration_payments as $registration_payment) { |
|
638 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
639 | + $owing -= $registration_payment->amount(); |
|
640 | + $payment = $registration_payment->payment(); |
|
641 | + $payment_desc = ''; |
|
642 | + if ($payment instanceof EE_Payment) { |
|
643 | + $payment_desc = sprintf( |
|
644 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
645 | + $payment->txn_id_chq_nmbr() !== '' |
|
646 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
647 | + : '', |
|
648 | + $payment->timestamp() |
|
649 | + ); |
|
650 | + } |
|
651 | + // start of row |
|
652 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
653 | + // payment desc |
|
654 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
655 | + // total td |
|
656 | + $html .= EEH_HTML::td( |
|
657 | + EEH_Template::format_currency( |
|
658 | + $registration_payment->amount(), |
|
659 | + false, |
|
660 | + false |
|
661 | + ), |
|
662 | + '', |
|
663 | + 'spco-nowrap total jst-rght' |
|
664 | + ); |
|
665 | + // end of row |
|
666 | + $html .= EEH_HTML::trx(); |
|
667 | + } |
|
668 | + } |
|
669 | + if ($line_item->total()) { |
|
670 | + // start of row |
|
671 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
672 | + // total td |
|
673 | + $html .= EEH_HTML::td( |
|
674 | + esc_html__('Amount Owing', 'event_espresso'), |
|
675 | + '', |
|
676 | + 'total_currency total jst-rght', |
|
677 | + '', |
|
678 | + ' colspan="3"' |
|
679 | + ); |
|
680 | + // total td |
|
681 | + $html .= EEH_HTML::td( |
|
682 | + EEH_Template::format_currency($owing, false, false), |
|
683 | + '', |
|
684 | + 'spco-nowrap total jst-rght' |
|
685 | + ); |
|
686 | + // end of row |
|
687 | + $html .= EEH_HTML::trx(); |
|
688 | + } |
|
689 | + } |
|
690 | + } |
|
691 | + $this->_grand_total = $owing; |
|
692 | + return $html; |
|
693 | + } |
|
694 | 694 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $html = ''; |
95 | 95 | // set some default options and merge with incoming |
96 | 96 | $default_options = array( |
97 | - 'show_desc' => true, // true false |
|
97 | + 'show_desc' => true, // true false |
|
98 | 98 | 'odd' => false, |
99 | 99 | ); |
100 | 100 | $options = array_merge($default_options, (array) $options); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $text = esc_html__('Sub-Total', 'event_espresso'); |
137 | 137 | if ($line_item->OBJ_type() === 'Event') { |
138 | 138 | $options['event_id'] = $line_item->OBJ_ID(); |
139 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
139 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
140 | 140 | $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
141 | 141 | // if event has default reg status of Not Approved, then don't display info on it |
142 | 142 | if ( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | // unless there are registrations for it that are returning to pay |
148 | 148 | if (isset($options['registrations']) && is_array($options['registrations'])) { |
149 | 149 | foreach ($options['registrations'] as $registration) { |
150 | - if (! $registration instanceof EE_Registration) { |
|
150 | + if ( ! $registration instanceof EE_Registration) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | $display_event = $registration->event_ID() === $options['event_id'] |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | : $display_event; |
157 | 157 | } |
158 | 158 | } |
159 | - if (! $display_event) { |
|
159 | + if ( ! $display_event) { |
|
160 | 160 | return ''; |
161 | 161 | } |
162 | 162 | } |
163 | - $this->_events[ $options['event_id'] ] = 0; |
|
163 | + $this->_events[$options['event_id']] = 0; |
|
164 | 164 | $html .= $this->_event_row($line_item); |
165 | 165 | $text = esc_html__('Event Sub-Total', 'event_espresso'); |
166 | 166 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | // recursively feed children back into this method |
172 | 172 | $html .= $this->display_line_item($child_line_item, $options, $line_item); |
173 | 173 | } |
174 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
174 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
175 | 175 | $sub_total += $event_sub_total; |
176 | 176 | if ( |
177 | 177 | ( |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
284 | 284 | ( |
285 | 285 | $options['show_desc'] |
286 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
286 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
287 | 287 | : '' |
288 | 288 | ), |
289 | 289 | $line_item, |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $line_item->pretaxTotal(), |
320 | 320 | $line_item |
321 | 321 | ); |
322 | - $this->_events[ $options['event_id'] ] += $total; |
|
322 | + $this->_events[$options['event_id']] += $total; |
|
323 | 323 | // total td |
324 | 324 | $html .= EEH_HTML::td( |
325 | 325 | EEH_Template::format_currency($total, false, false), |
@@ -346,18 +346,18 @@ discard block |
||
346 | 346 | // start of row |
347 | 347 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
348 | 348 | $html = EEH_HTML::tr('', '', $row_class); |
349 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
349 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
350 | 350 | // name && desc |
351 | 351 | $name_and_desc = apply_filters( |
352 | 352 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
353 | - $obj_name . $line_item->name(), |
|
353 | + $obj_name.$line_item->name(), |
|
354 | 354 | $line_item |
355 | 355 | ); |
356 | 356 | $name_and_desc .= apply_filters( |
357 | 357 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
358 | 358 | ( |
359 | 359 | $options['show_desc'] |
360 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
360 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
361 | 361 | : '' |
362 | 362 | ), |
363 | 363 | $line_item, |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
376 | 376 | // price td |
377 | 377 | if ($line_item->is_percent()) { |
378 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'spco-nowrap item_c jst-rght'); |
|
378 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'spco-nowrap item_c jst-rght'); |
|
379 | 379 | } else { |
380 | 380 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'spco-nowrap item_c jst-rght'); |
381 | 381 | } |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | $html .= EEH_HTML::td($line_item->quantity(), '', 'spco-nowrap item_l jst-rght'); |
384 | 384 | // $total = $line_item->total() * $line_item->quantity(); |
385 | 385 | $total = $line_item->total(); |
386 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
387 | - $this->_events[ $options['event_id'] ] += $total; |
|
386 | + if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
387 | + $this->_events[$options['event_id']] += $total; |
|
388 | 388 | } |
389 | 389 | // total td |
390 | 390 | $html .= EEH_HTML::td( |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | // name && desc |
480 | 480 | $name_and_desc = $line_item->name(); |
481 | 481 | $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
482 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
483 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
482 | + . esc_html__(' * taxable items', 'event_espresso').'</span>'; |
|
483 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
484 | 484 | // name td |
485 | 485 | $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
486 | 486 | $name_and_desc, |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | 'item_l sub-item' |
489 | 489 | ); |
490 | 490 | // percent td |
491 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'spco-nowrap jst-rght', ''); |
|
491 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'spco-nowrap jst-rght', ''); |
|
492 | 492 | // empty td (price) |
493 | 493 | $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
494 | 494 | // total td |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | $registration_payments += $registration->registration_payments(); |
634 | 634 | } |
635 | 635 | } |
636 | - if (! empty($registration_payments)) { |
|
636 | + if ( ! empty($registration_payments)) { |
|
637 | 637 | foreach ($registration_payments as $registration_payment) { |
638 | 638 | if ($registration_payment instanceof EE_Registration_Payment) { |
639 | 639 | $owing -= $registration_payment->amount(); |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | $payment_desc = sprintf( |
644 | 644 | esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
645 | 645 | $payment->txn_id_chq_nmbr() !== '' |
646 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
646 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
647 | 647 | : '', |
648 | 648 | $payment->timestamp() |
649 | 649 | ); |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_12_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = []; |
|
14 | - preg_match('~4_12_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = []; |
|
14 | + preg_match('~4_12_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_12_0__autoloaded_stages', $class_to_filepath); |
@@ -28,63 +28,63 @@ discard block |
||
28 | 28 | */ |
29 | 29 | class EE_DMS_Core_4_12_0 extends EE_Data_Migration_Script_Base |
30 | 30 | { |
31 | - /** |
|
32 | - * |
|
33 | - * @param EE_DMS_Core_4_11_0 $dms_4_11 |
|
34 | - * @param TableManager|null $table_manager |
|
35 | - * @param TableAnalysis|null $table_analysis |
|
36 | - */ |
|
37 | - public function __construct( |
|
38 | - EE_DMS_Core_4_11_0 $dms_4_11, |
|
39 | - TableManager $table_manager = null, |
|
40 | - TableAnalysis $table_analysis = null |
|
41 | - ) { |
|
42 | - $this->previous_dms = $dms_4_11; |
|
43 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.12.0", "event_espresso"); |
|
44 | - $this->_priority = 10; |
|
45 | - $this->_migration_stages = [ |
|
46 | - new EE_DMS_4_12_0_Event_Venues(), |
|
47 | - ]; |
|
48 | - parent::__construct($table_manager, $table_analysis); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Whether to migrate or not. |
|
54 | - * |
|
55 | - * @param array $version_array |
|
56 | - * @return bool |
|
57 | - */ |
|
58 | - public function can_migrate_from_version($version_array): bool |
|
59 | - { |
|
60 | - $version_string = $version_array['Core']; |
|
61 | - return $version_string |
|
62 | - && version_compare($version_string, '4.12.0.decaf', '<') |
|
63 | - && version_compare($version_string, '4.11.0.decaf', '>='); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return bool |
|
69 | - * @throws EE_Error |
|
70 | - * @throws ReflectionException |
|
71 | - */ |
|
72 | - public function schema_changes_before_migration(): bool |
|
73 | - { |
|
74 | - require_once EE_HELPERS . 'EEH_Activation.helper.php'; |
|
75 | - |
|
76 | - $table_name = 'esp_answer'; |
|
77 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
31 | + /** |
|
32 | + * |
|
33 | + * @param EE_DMS_Core_4_11_0 $dms_4_11 |
|
34 | + * @param TableManager|null $table_manager |
|
35 | + * @param TableAnalysis|null $table_analysis |
|
36 | + */ |
|
37 | + public function __construct( |
|
38 | + EE_DMS_Core_4_11_0 $dms_4_11, |
|
39 | + TableManager $table_manager = null, |
|
40 | + TableAnalysis $table_analysis = null |
|
41 | + ) { |
|
42 | + $this->previous_dms = $dms_4_11; |
|
43 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.12.0", "event_espresso"); |
|
44 | + $this->_priority = 10; |
|
45 | + $this->_migration_stages = [ |
|
46 | + new EE_DMS_4_12_0_Event_Venues(), |
|
47 | + ]; |
|
48 | + parent::__construct($table_manager, $table_analysis); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Whether to migrate or not. |
|
54 | + * |
|
55 | + * @param array $version_array |
|
56 | + * @return bool |
|
57 | + */ |
|
58 | + public function can_migrate_from_version($version_array): bool |
|
59 | + { |
|
60 | + $version_string = $version_array['Core']; |
|
61 | + return $version_string |
|
62 | + && version_compare($version_string, '4.12.0.decaf', '<') |
|
63 | + && version_compare($version_string, '4.11.0.decaf', '>='); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return bool |
|
69 | + * @throws EE_Error |
|
70 | + * @throws ReflectionException |
|
71 | + */ |
|
72 | + public function schema_changes_before_migration(): bool |
|
73 | + { |
|
74 | + require_once EE_HELPERS . 'EEH_Activation.helper.php'; |
|
75 | + |
|
76 | + $table_name = 'esp_answer'; |
|
77 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
78 | 78 | REG_ID int(10) unsigned NOT NULL, |
79 | 79 | QST_ID int(10) unsigned NOT NULL, |
80 | 80 | ANS_value text NOT NULL, |
81 | 81 | PRIMARY KEY (ANS_ID), |
82 | 82 | KEY REG_ID (REG_ID), |
83 | 83 | KEY QST_ID (QST_ID)"; |
84 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
84 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
85 | 85 | |
86 | - $table_name = 'esp_attendee_meta'; |
|
87 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
86 | + $table_name = 'esp_attendee_meta'; |
|
87 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | ATT_ID bigint(20) unsigned NOT NULL, |
89 | 89 | ATT_fname varchar(45) NOT NULL, |
90 | 90 | ATT_lname varchar(45) NOT NULL, |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | KEY ATT_email (ATT_email(191)), |
102 | 102 | KEY ATT_lname (ATT_lname), |
103 | 103 | KEY ATT_fname (ATT_fname)"; |
104 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
104 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
105 | 105 | |
106 | - $table_name = 'esp_checkin'; |
|
107 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
106 | + $table_name = 'esp_checkin'; |
|
107 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
108 | 108 | REG_ID int(10) unsigned NOT NULL, |
109 | 109 | DTT_ID int(10) unsigned NOT NULL, |
110 | 110 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | PRIMARY KEY (CHK_ID), |
113 | 113 | KEY REG_ID (REG_ID), |
114 | 114 | KEY DTT_ID (DTT_ID)"; |
115 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
115 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
116 | 116 | |
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
119 | 119 | CNT_ISO3 varchar(3) NOT NULL, |
120 | 120 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
121 | 121 | CNT_name varchar(45) NOT NULL, |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | CNT_is_EU tinyint(1) DEFAULT '0', |
132 | 132 | CNT_active tinyint(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
134 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | 135 | |
136 | - $table_name = 'esp_currency'; |
|
137 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
136 | + $table_name = 'esp_currency'; |
|
137 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
138 | 138 | CUR_single varchar(45) DEFAULT 'dollar', |
139 | 139 | CUR_plural varchar(45) DEFAULT 'dollars', |
140 | 140 | CUR_sign varchar(45) DEFAULT '$', |
141 | 141 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
142 | 142 | CUR_active tinyint(1) DEFAULT '0', |
143 | 143 | PRIMARY KEY (CUR_code)"; |
144 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
145 | - |
|
146 | - // note: although this table is no longer in use, |
|
147 | - // it hasn't been removed because then queries to the model will have errors. |
|
148 | - // but you should expect this table and its corresponding model to be removed in |
|
149 | - // the next few months |
|
150 | - $table_name = 'esp_currency_payment_method'; |
|
151 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
144 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
145 | + |
|
146 | + // note: although this table is no longer in use, |
|
147 | + // it hasn't been removed because then queries to the model will have errors. |
|
148 | + // but you should expect this table and its corresponding model to be removed in |
|
149 | + // the next few months |
|
150 | + $table_name = 'esp_currency_payment_method'; |
|
151 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
152 | 152 | CUR_code varchar(6) NOT NULL, |
153 | 153 | PMD_ID int(11) NOT NULL, |
154 | 154 | PRIMARY KEY (CPM_ID), |
155 | 155 | KEY PMD_ID (PMD_ID)"; |
156 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
156 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
157 | 157 | |
158 | - $table_name = 'esp_datetime'; |
|
159 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
158 | + $table_name = 'esp_datetime'; |
|
159 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
160 | 160 | EVT_ID bigint(20) unsigned NOT NULL, |
161 | 161 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
162 | 162 | DTT_name varchar(255) NOT NULL DEFAULT '', |
@@ -174,28 +174,28 @@ discard block |
||
174 | 174 | KEY DTT_EVT_start (DTT_EVT_start), |
175 | 175 | KEY EVT_ID (EVT_ID), |
176 | 176 | KEY DTT_is_primary (DTT_is_primary)"; |
177 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
177 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | 178 | |
179 | - $table_name = "esp_datetime_ticket"; |
|
180 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
179 | + $table_name = "esp_datetime_ticket"; |
|
180 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | 181 | DTT_ID int(10) unsigned NOT NULL, |
182 | 182 | TKT_ID int(10) unsigned NOT NULL, |
183 | 183 | PRIMARY KEY (DTK_ID), |
184 | 184 | KEY DTT_ID (DTT_ID), |
185 | 185 | KEY TKT_ID (TKT_ID)"; |
186 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | 187 | |
188 | - $table_name = 'esp_event_message_template'; |
|
189 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | + $table_name = 'esp_event_message_template'; |
|
189 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | 190 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
191 | 191 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
192 | 192 | PRIMARY KEY (EMT_ID), |
193 | 193 | KEY EVT_ID (EVT_ID), |
194 | 194 | KEY GRP_ID (GRP_ID)"; |
195 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
196 | 196 | |
197 | - $table_name = 'esp_event_meta'; |
|
198 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $table_name = 'esp_event_meta'; |
|
198 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
199 | 199 | EVT_ID bigint(20) unsigned NOT NULL, |
200 | 200 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | FSC_UUID varchar(25) DEFAULT NULL, |
213 | 213 | PRIMARY KEY (EVTM_ID), |
214 | 214 | KEY EVT_ID (EVT_ID)"; |
215 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | 216 | |
217 | - $table_name = 'esp_event_question_group'; |
|
218 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | + $table_name = 'esp_event_question_group'; |
|
218 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
219 | 219 | EVT_ID bigint(20) unsigned NOT NULL, |
220 | 220 | QSG_ID int(10) unsigned NOT NULL, |
221 | 221 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | PRIMARY KEY (EQG_ID), |
224 | 224 | KEY EVT_ID (EVT_ID), |
225 | 225 | KEY QSG_ID (QSG_ID)"; |
226 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
226 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | 227 | |
228 | - $table_name = 'esp_event_venue'; |
|
229 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
228 | + $table_name = 'esp_event_venue'; |
|
229 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | 230 | EVT_ID bigint(20) unsigned NOT NULL, |
231 | 231 | VNU_ID bigint(20) unsigned NOT NULL, |
232 | 232 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
233 | 233 | PRIMARY KEY (EVV_ID)"; |
234 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | 235 | |
236 | - $table_name = 'esp_extra_meta'; |
|
237 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
236 | + $table_name = 'esp_extra_meta'; |
|
237 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
238 | 238 | OBJ_ID int(11) DEFAULT NULL, |
239 | 239 | EXM_type varchar(45) DEFAULT NULL, |
240 | 240 | EXM_key varchar(45) DEFAULT NULL, |
241 | 241 | EXM_value text, |
242 | 242 | PRIMARY KEY (EXM_ID), |
243 | 243 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
244 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
244 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
245 | 245 | |
246 | - $table_name = 'esp_extra_join'; |
|
247 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | + $table_name = 'esp_extra_join'; |
|
247 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
248 | 248 | EXJ_first_model_id varchar(6) NOT NULL, |
249 | 249 | EXJ_first_model_name varchar(20) NOT NULL, |
250 | 250 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | PRIMARY KEY (EXJ_ID), |
253 | 253 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
254 | 254 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
255 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
255 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
256 | 256 | |
257 | - $table_name = 'esp_form_element'; |
|
258 | - $sql = "FIN_UUID varchar(25) NOT NULL, |
|
257 | + $table_name = 'esp_form_element'; |
|
258 | + $sql = "FIN_UUID varchar(25) NOT NULL, |
|
259 | 259 | FSC_UUID varchar(25) NOT NULL, |
260 | 260 | FIN_adminOnly tinyint(1) unsigned NOT NULL DEFAULT 0, |
261 | 261 | FIN_attributes text DEFAULT NULL, |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | KEY FSC_UUID (FSC_UUID), |
273 | 273 | KEY FIN_order (FIN_order), |
274 | 274 | KEY FIN_status (FIN_status)"; |
275 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
276 | 276 | |
277 | - $table_name = 'esp_form_section'; |
|
278 | - $sql = "FSC_UUID varchar(25) NOT NULL, |
|
277 | + $table_name = 'esp_form_section'; |
|
278 | + $sql = "FSC_UUID varchar(25) NOT NULL, |
|
279 | 279 | FSC_appliesTo tinytext NOT NULL, |
280 | 280 | FSC_attributes text DEFAULT NULL, |
281 | 281 | FSC_belongsTo varchar(25) DEFAULT NULL, |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | KEY FSC_belongsTo (FSC_belongsTo), |
288 | 288 | KEY FSC_order (FSC_order), |
289 | 289 | KEY FSC_status (FSC_status)"; |
290 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
290 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | 291 | |
292 | - $table_name = 'esp_form_submission'; |
|
293 | - $sql = "FSB_UUID varchar(25) NOT NULL, |
|
292 | + $table_name = 'esp_form_submission'; |
|
293 | + $sql = "FSB_UUID varchar(25) NOT NULL, |
|
294 | 294 | FSC_UUID varchar(25) NOT NULL, |
295 | 295 | TXN_ID int(10) DEFAULT NULL, |
296 | 296 | FSB_data mediumtext DEFAULT NULL, |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | PRIMARY KEY (FSB_UUID), |
299 | 299 | KEY FSC_UUID (FSC_UUID), |
300 | 300 | KEY TXN_ID (TXN_ID)"; |
301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
302 | 302 | |
303 | - $table_name = 'esp_line_item'; |
|
304 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
303 | + $table_name = 'esp_line_item'; |
|
304 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
305 | 305 | LIN_code varchar(245) NOT NULL DEFAULT '', |
306 | 306 | TXN_ID int(10) DEFAULT NULL, |
307 | 307 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
324 | 324 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
325 | 325 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
326 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
327 | 327 | |
328 | - $table_name = 'esp_log'; |
|
329 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
328 | + $table_name = 'esp_log'; |
|
329 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
330 | 330 | LOG_time datetime DEFAULT NULL, |
331 | 331 | OBJ_ID varchar(45) DEFAULT NULL, |
332 | 332 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | KEY LOG_time (LOG_time), |
338 | 338 | KEY OBJ (OBJ_type,OBJ_ID), |
339 | 339 | KEY LOG_type (LOG_type)"; |
340 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
340 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
341 | 341 | |
342 | - $table_name = 'esp_message'; |
|
343 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
342 | + $table_name = 'esp_message'; |
|
343 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | 344 | GRP_ID int(10) unsigned NULL, |
345 | 345 | MSG_token varchar(255) NULL, |
346 | 346 | TXN_ID int(10) unsigned NULL, |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | KEY STS_ID (STS_ID), |
373 | 373 | KEY MSG_created (MSG_created), |
374 | 374 | KEY MSG_modified (MSG_modified)"; |
375 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
375 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | 376 | |
377 | - $table_name = 'esp_message_template'; |
|
378 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
377 | + $table_name = 'esp_message_template'; |
|
378 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
379 | 379 | GRP_ID int(10) unsigned NOT NULL, |
380 | 380 | MTP_context varchar(50) NOT NULL, |
381 | 381 | MTP_template_field varchar(30) NOT NULL, |
382 | 382 | MTP_content text NOT NULL, |
383 | 383 | PRIMARY KEY (MTP_ID), |
384 | 384 | KEY GRP_ID (GRP_ID)"; |
385 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
386 | 386 | |
387 | - $table_name = 'esp_message_template_group'; |
|
388 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | + $table_name = 'esp_message_template_group'; |
|
388 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
389 | 389 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
390 | 390 | MTP_name varchar(245) NOT NULL DEFAULT '', |
391 | 391 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
398 | 398 | PRIMARY KEY (GRP_ID), |
399 | 399 | KEY MTP_user_id (MTP_user_id)"; |
400 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
401 | 401 | |
402 | - $table_name = 'esp_payment'; |
|
403 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
402 | + $table_name = 'esp_payment'; |
|
403 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
404 | 404 | TXN_ID int(10) unsigned DEFAULT NULL, |
405 | 405 | STS_ID varchar(3) DEFAULT NULL, |
406 | 406 | PAY_timestamp datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, |
@@ -417,10 +417,10 @@ discard block |
||
417 | 417 | PRIMARY KEY (PAY_ID), |
418 | 418 | KEY PAY_timestamp (PAY_timestamp), |
419 | 419 | KEY TXN_ID (TXN_ID)"; |
420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
421 | 421 | |
422 | - $table_name = 'esp_payment_method'; |
|
423 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
422 | + $table_name = 'esp_payment_method'; |
|
423 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
424 | 424 | PMD_type varchar(124) DEFAULT NULL, |
425 | 425 | PMD_name varchar(255) DEFAULT NULL, |
426 | 426 | PMD_desc text, |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | PRIMARY KEY (PMD_ID), |
437 | 437 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
438 | 438 | KEY PMD_type (PMD_type)"; |
439 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
439 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
440 | 440 | |
441 | - $table_name = "esp_price"; |
|
442 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
441 | + $table_name = "esp_price"; |
|
442 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
443 | 443 | PRT_ID tinyint(3) unsigned NOT NULL, |
444 | 444 | PRC_amount decimal(12,6) NOT NULL DEFAULT '0.00', |
445 | 445 | PRC_name varchar(245) NOT NULL, |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | PRC_parent int(10) unsigned DEFAULT 0, |
453 | 453 | PRIMARY KEY (PRC_ID), |
454 | 454 | KEY PRT_ID (PRT_ID)"; |
455 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
455 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
456 | 456 | |
457 | - $table_name = "esp_price_type"; |
|
458 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
457 | + $table_name = "esp_price_type"; |
|
458 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
459 | 459 | PRT_name varchar(45) NOT NULL, |
460 | 460 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
461 | 461 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -464,27 +464,27 @@ discard block |
||
464 | 464 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
465 | 465 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
466 | 466 | PRIMARY KEY (PRT_ID)"; |
467 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
467 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | 468 | |
469 | - $table_name = "esp_ticket_price"; |
|
470 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
469 | + $table_name = "esp_ticket_price"; |
|
470 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
471 | 471 | TKT_ID int(10) unsigned NOT NULL, |
472 | 472 | PRC_ID int(10) unsigned NOT NULL, |
473 | 473 | PRIMARY KEY (TKP_ID), |
474 | 474 | KEY TKT_ID (TKT_ID), |
475 | 475 | KEY PRC_ID (PRC_ID)"; |
476 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
476 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
477 | 477 | |
478 | - $table_name = "esp_ticket_template"; |
|
479 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
478 | + $table_name = "esp_ticket_template"; |
|
479 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
480 | 480 | TTM_name varchar(45) NOT NULL, |
481 | 481 | TTM_description text, |
482 | 482 | TTM_file varchar(45), |
483 | 483 | PRIMARY KEY (TTM_ID)"; |
484 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | 485 | |
486 | - $table_name = 'esp_question'; |
|
487 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
486 | + $table_name = 'esp_question'; |
|
487 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
488 | 488 | QST_display_text text NOT NULL, |
489 | 489 | QST_admin_label varchar(255) NOT NULL, |
490 | 490 | QST_system varchar(25) DEFAULT NULL, |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
499 | 499 | PRIMARY KEY (QST_ID), |
500 | 500 | KEY QST_order (QST_order)'; |
501 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
501 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | 502 | |
503 | - $table_name = 'esp_question_group'; |
|
504 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
503 | + $table_name = 'esp_question_group'; |
|
504 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
505 | 505 | QSG_name varchar(255) NOT NULL, |
506 | 506 | QSG_identifier varchar(100) NOT NULL, |
507 | 507 | QSG_desc text NULL, |
@@ -514,20 +514,20 @@ discard block |
||
514 | 514 | PRIMARY KEY (QSG_ID), |
515 | 515 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
516 | 516 | KEY QSG_order (QSG_order)'; |
517 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
517 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
518 | 518 | |
519 | - $table_name = 'esp_question_group_question'; |
|
520 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
519 | + $table_name = 'esp_question_group_question'; |
|
520 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
521 | 521 | QSG_ID int(10) unsigned NOT NULL, |
522 | 522 | QST_ID int(10) unsigned NOT NULL, |
523 | 523 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
524 | 524 | PRIMARY KEY (QGQ_ID), |
525 | 525 | KEY QST_ID (QST_ID), |
526 | 526 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
527 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
527 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
528 | 528 | |
529 | - $table_name = 'esp_question_option'; |
|
530 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
529 | + $table_name = 'esp_question_option'; |
|
530 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
531 | 531 | QSO_value varchar(255) NOT NULL, |
532 | 532 | QSO_desc text NOT NULL, |
533 | 533 | QST_ID int(10) unsigned NOT NULL, |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | PRIMARY KEY (QSO_ID), |
538 | 538 | KEY QST_ID (QST_ID), |
539 | 539 | KEY QSO_order (QSO_order)"; |
540 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
541 | 541 | |
542 | - $table_name = 'esp_registration'; |
|
543 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
542 | + $table_name = 'esp_registration'; |
|
543 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
544 | 544 | EVT_ID bigint(20) unsigned NOT NULL, |
545 | 545 | ATT_ID bigint(20) unsigned NOT NULL, |
546 | 546 | TXN_ID int(10) unsigned NOT NULL, |
@@ -564,20 +564,20 @@ discard block |
||
564 | 564 | KEY TKT_ID (TKT_ID), |
565 | 565 | KEY EVT_ID (EVT_ID), |
566 | 566 | KEY STS_ID (STS_ID)"; |
567 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
567 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
568 | 568 | |
569 | - $table_name = 'esp_registration_payment'; |
|
570 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
569 | + $table_name = 'esp_registration_payment'; |
|
570 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
571 | 571 | REG_ID int(10) unsigned NOT NULL, |
572 | 572 | PAY_ID int(10) unsigned NULL, |
573 | 573 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
574 | 574 | PRIMARY KEY (RPY_ID), |
575 | 575 | KEY REG_ID (REG_ID), |
576 | 576 | KEY PAY_ID (PAY_ID)"; |
577 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
577 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
578 | 578 | |
579 | - $table_name = 'esp_state'; |
|
580 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
579 | + $table_name = 'esp_state'; |
|
580 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
581 | 581 | CNT_ISO varchar(2) NOT NULL, |
582 | 582 | STA_abbrev varchar(24) NOT NULL, |
583 | 583 | STA_name varchar(100) NOT NULL, |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | PRIMARY KEY (STA_ID), |
586 | 586 | KEY STA_abbrev (STA_abbrev), |
587 | 587 | KEY CNT_ISO (CNT_ISO)"; |
588 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
588 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
589 | 589 | |
590 | - $table_name = 'esp_status'; |
|
591 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
590 | + $table_name = 'esp_status'; |
|
591 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
592 | 592 | STS_code varchar(45) NOT NULL, |
593 | 593 | STS_type varchar(45) NOT NULL, |
594 | 594 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
597 | 597 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
598 | 598 | KEY STS_type (STS_type)"; |
599 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
599 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
600 | 600 | |
601 | - $table_name = "esp_ticket"; |
|
602 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
601 | + $table_name = "esp_ticket"; |
|
602 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
603 | 603 | TTM_ID int(10) unsigned NOT NULL, |
604 | 604 | TKT_name varchar(245) NOT NULL DEFAULT '', |
605 | 605 | TKT_description text NOT NULL, |
@@ -624,10 +624,10 @@ discard block |
||
624 | 624 | TKT_visibility smallint(6) unsigned NOT NULL DEFAULT 100, |
625 | 625 | PRIMARY KEY (TKT_ID), |
626 | 626 | KEY TKT_start_date (TKT_start_date)"; |
627 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
627 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
628 | 628 | |
629 | - $table_name = 'esp_transaction'; |
|
630 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
629 | + $table_name = 'esp_transaction'; |
|
630 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
631 | 631 | TXN_timestamp datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, |
632 | 632 | TXN_total decimal(12,3) DEFAULT '0.00', |
633 | 633 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -639,10 +639,10 @@ discard block |
||
639 | 639 | PRIMARY KEY (TXN_ID), |
640 | 640 | KEY TXN_timestamp (TXN_timestamp), |
641 | 641 | KEY STS_ID (STS_ID)"; |
642 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
642 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
643 | 643 | |
644 | - $table_name = 'esp_venue_meta'; |
|
645 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
644 | + $table_name = 'esp_venue_meta'; |
|
645 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
646 | 646 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
647 | 647 | VNU_address varchar(255) DEFAULT NULL, |
648 | 648 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -661,18 +661,18 @@ discard block |
||
661 | 661 | KEY VNU_ID (VNU_ID), |
662 | 662 | KEY STA_ID (STA_ID), |
663 | 663 | KEY CNT_ISO (CNT_ISO)"; |
664 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
664 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
665 | 665 | |
666 | - $this->previous_dms->insert_default_data(); |
|
667 | - return true; |
|
668 | - } |
|
666 | + $this->previous_dms->insert_default_data(); |
|
667 | + return true; |
|
668 | + } |
|
669 | 669 | |
670 | 670 | |
671 | - /** |
|
672 | - * @return boolean |
|
673 | - */ |
|
674 | - public function schema_changes_after_migration(): bool |
|
675 | - { |
|
676 | - return true; |
|
677 | - } |
|
671 | + /** |
|
672 | + * @return boolean |
|
673 | + */ |
|
674 | + public function schema_changes_after_migration(): bool |
|
675 | + { |
|
676 | + return true; |
|
677 | + } |
|
678 | 678 | } |
@@ -6,57 +6,57 @@ |
||
6 | 6 | |
7 | 7 | class DecimalValues |
8 | 8 | { |
9 | - /** |
|
10 | - * number of decimal places to round numbers to when performing calculations |
|
11 | - * |
|
12 | - * @var integer |
|
13 | - */ |
|
14 | - protected $decimal_precision = 6; |
|
15 | - |
|
16 | - /** |
|
17 | - * number of decimal places to round numbers to for display |
|
18 | - * |
|
19 | - * @var integer |
|
20 | - */ |
|
21 | - protected $locale_precision = 6; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param EE_Currency_Config $currency_config |
|
26 | - */ |
|
27 | - public function __construct(EE_Currency_Config $currency_config) |
|
28 | - { |
|
29 | - $this->locale_precision = $currency_config->dec_plc; |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * strips formatting, rounds the provided number, and returns a float |
|
34 | - * if $round is set to true, then the decimal precision for the site locale will be used, |
|
35 | - * otherwise the default decimal precision of 6 will be used |
|
36 | - * |
|
37 | - * @param float|int|string $number unformatted number value, ex: 1234.5678956789 |
|
38 | - * @param bool $round whether to round the price off according to the locale settings |
|
39 | - * @return float rounded value, ex: 1,234.567896 |
|
40 | - */ |
|
41 | - public function roundDecimalValue($number, bool $round = false): float |
|
42 | - { |
|
43 | - $precision = $round ? $this->locale_precision : $this->decimal_precision; |
|
44 | - return round( |
|
45 | - $this->filterDecimalValue($number), |
|
46 | - $precision ?? $this->decimal_precision, |
|
47 | - PHP_ROUND_HALF_UP |
|
48 | - ); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Removes all characters except digits, +- and . |
|
54 | - * |
|
55 | - * @param float|int|string $number |
|
56 | - * @return float |
|
57 | - */ |
|
58 | - public function filterDecimalValue($number): float |
|
59 | - { |
|
60 | - return (float) filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
61 | - } |
|
9 | + /** |
|
10 | + * number of decimal places to round numbers to when performing calculations |
|
11 | + * |
|
12 | + * @var integer |
|
13 | + */ |
|
14 | + protected $decimal_precision = 6; |
|
15 | + |
|
16 | + /** |
|
17 | + * number of decimal places to round numbers to for display |
|
18 | + * |
|
19 | + * @var integer |
|
20 | + */ |
|
21 | + protected $locale_precision = 6; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param EE_Currency_Config $currency_config |
|
26 | + */ |
|
27 | + public function __construct(EE_Currency_Config $currency_config) |
|
28 | + { |
|
29 | + $this->locale_precision = $currency_config->dec_plc; |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * strips formatting, rounds the provided number, and returns a float |
|
34 | + * if $round is set to true, then the decimal precision for the site locale will be used, |
|
35 | + * otherwise the default decimal precision of 6 will be used |
|
36 | + * |
|
37 | + * @param float|int|string $number unformatted number value, ex: 1234.5678956789 |
|
38 | + * @param bool $round whether to round the price off according to the locale settings |
|
39 | + * @return float rounded value, ex: 1,234.567896 |
|
40 | + */ |
|
41 | + public function roundDecimalValue($number, bool $round = false): float |
|
42 | + { |
|
43 | + $precision = $round ? $this->locale_precision : $this->decimal_precision; |
|
44 | + return round( |
|
45 | + $this->filterDecimalValue($number), |
|
46 | + $precision ?? $this->decimal_precision, |
|
47 | + PHP_ROUND_HALF_UP |
|
48 | + ); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Removes all characters except digits, +- and . |
|
54 | + * |
|
55 | + * @param float|int|string $number |
|
56 | + * @return float |
|
57 | + */ |
|
58 | + public function filterDecimalValue($number): float |
|
59 | + { |
|
60 | + return (float) filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
61 | + } |
|
62 | 62 | } |