@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Line_Item_Display |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since $VID:$ |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Line_Item_Display |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since $VID:$ |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Line_Item_Display { |
15 | 15 | |
16 | 16 | private $strategy = NULL; |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * @param string $context - where/how the line items are being displayed |
22 | 22 | * @param string $other_line_item_display_strategy |
23 | 23 | */ |
24 | - public function __construct( $context = '', $other_line_item_display_strategy = '' ) { |
|
25 | - $context = strtolower( $context ); |
|
26 | - switch ( $context ) { |
|
24 | + public function __construct($context = '', $other_line_item_display_strategy = '') { |
|
25 | + $context = strtolower($context); |
|
26 | + switch ($context) { |
|
27 | 27 | case 'invoice' : |
28 | 28 | $this->strategy = new EE_Invoice_Line_Item_Display_Strategy(); |
29 | 29 | break; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | break; |
36 | 36 | default : |
37 | 37 | if ( |
38 | - ! empty( $other_line_item_display_strategy ) && |
|
39 | - class_exists( $other_line_item_display_strategy ) |
|
38 | + ! empty($other_line_item_display_strategy) && |
|
39 | + class_exists($other_line_item_display_strategy) |
|
40 | 40 | ) { |
41 | 41 | $this->strategy = new $other_line_item_display_strategy(); |
42 | 42 | } else { |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @param array $options |
51 | 51 | * @return mixed |
52 | 52 | */ |
53 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
54 | - return $this->strategy->display_line_item( $line_item, $options ); |
|
53 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
54 | + return $this->strategy->display_line_item($line_item, $options); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_SPCO_Line_Item_Display_Strategy |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since $VID:$ |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_SPCO_Line_Item_Display_Strategy |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since $VID:$ |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display { |
16 | 16 |
@@ -69,101 +69,101 @@ discard block |
||
69 | 69 | * @param array $options |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
72 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
73 | 73 | |
74 | 74 | $html = ''; |
75 | 75 | // set some default options and merge with incoming |
76 | 76 | $default_options = array( |
77 | - 'show_desc' => true, // true false |
|
77 | + 'show_desc' => true, // true false |
|
78 | 78 | 'odd' => false |
79 | 79 | ); |
80 | - $options = array_merge( $default_options, (array)$options ); |
|
80 | + $options = array_merge($default_options, (array) $options); |
|
81 | 81 | |
82 | - switch( $line_item->type() ) { |
|
82 | + switch ($line_item->type()) { |
|
83 | 83 | |
84 | 84 | case EEM_Line_Item::type_line_item: |
85 | 85 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
86 | - if ( $line_item->OBJ_type() == 'Ticket' ) { |
|
86 | + if ($line_item->OBJ_type() == 'Ticket') { |
|
87 | 87 | // item row |
88 | - $html .= $this->_ticket_row( $line_item, $options ); |
|
88 | + $html .= $this->_ticket_row($line_item, $options); |
|
89 | 89 | // got any kids? |
90 | - foreach ( $line_item->children() as $child_line_item ) { |
|
91 | - $this->display_line_item( $child_line_item, $options ); |
|
90 | + foreach ($line_item->children() as $child_line_item) { |
|
91 | + $this->display_line_item($child_line_item, $options); |
|
92 | 92 | } |
93 | 93 | } else { |
94 | 94 | // item row |
95 | - $html .= $this->_item_row( $line_item, $options ); |
|
95 | + $html .= $this->_item_row($line_item, $options); |
|
96 | 96 | // got any kids? |
97 | - foreach ( $line_item->children() as $child_line_item ) { |
|
98 | - $this->display_line_item( $child_line_item, $options ); |
|
97 | + foreach ($line_item->children() as $child_line_item) { |
|
98 | + $this->display_line_item($child_line_item, $options); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | break; |
102 | 102 | |
103 | 103 | case EEM_Line_Item::type_sub_line_item: |
104 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
104 | + $html .= $this->_sub_item_row($line_item, $options); |
|
105 | 105 | break; |
106 | 106 | |
107 | 107 | case EEM_Line_Item::type_sub_total: |
108 | 108 | static $sub_total = 0; |
109 | 109 | $event_sub_total = 0; |
110 | - $text = __( 'Sub-Total', 'event_espresso' ); |
|
111 | - if ( $line_item->OBJ_type() == 'Event' ) { |
|
112 | - $options[ 'event_id' ] = $event_id = $line_item->OBJ_ID(); |
|
113 | - if ( ! isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
114 | - $event = EEM_Event::instance()->get_one_by_ID( $options[ 'event_id' ] ); |
|
115 | - if ( $event instanceof EE_Event ) { |
|
116 | - if ( $event->default_registration_status() == EEM_Registration::status_id_not_approved ) { |
|
110 | + $text = __('Sub-Total', 'event_espresso'); |
|
111 | + if ($line_item->OBJ_type() == 'Event') { |
|
112 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
113 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
114 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
115 | + if ($event instanceof EE_Event) { |
|
116 | + if ($event->default_registration_status() == EEM_Registration::status_id_not_approved) { |
|
117 | 117 | return ''; |
118 | 118 | } |
119 | 119 | } |
120 | - $this->_events[ $options[ 'event_id' ] ] = 0; |
|
121 | - $html .= $this->_event_row( $line_item ); |
|
122 | - $text = __( 'Event Sub-Total', 'event_espresso' ); |
|
120 | + $this->_events[$options['event_id']] = 0; |
|
121 | + $html .= $this->_event_row($line_item); |
|
122 | + $text = __('Event Sub-Total', 'event_espresso'); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | $child_line_items = $line_item->children(); |
126 | 126 | // loop thru children |
127 | - foreach( $child_line_items as $child_line_item ) { |
|
127 | + foreach ($child_line_items as $child_line_item) { |
|
128 | 128 | // recursively feed children back into this method |
129 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
129 | + $html .= $this->display_line_item($child_line_item, $options); |
|
130 | 130 | } |
131 | - $event_sub_total += isset( $options[ 'event_id' ] ) ? $this->_events[ $options[ 'event_id' ] ] : 0; |
|
131 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
132 | 132 | $sub_total += $event_sub_total; |
133 | 133 | if ( |
134 | 134 | ( |
135 | 135 | // event subtotals |
136 | 136 | $line_item->code() != 'pre-tax-subtotal' && |
137 | - count( $child_line_items ) > 1 |
|
137 | + count($child_line_items) > 1 |
|
138 | 138 | ) |
139 | 139 | || |
140 | 140 | ( |
141 | 141 | // pre-tax subtotals |
142 | 142 | $line_item->code() == 'pre-tax-subtotal' && |
143 | - count( $this->_events ) > 1 |
|
143 | + count($this->_events) > 1 |
|
144 | 144 | ) |
145 | 145 | ) { |
146 | 146 | $options['sub_total'] = $line_item->OBJ_type() == 'Event' ? $event_sub_total : $sub_total; |
147 | - $html .= $this->_sub_total_row( $line_item, $text, $options ); |
|
147 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
148 | 148 | } |
149 | 149 | break; |
150 | 150 | |
151 | 151 | case EEM_Line_Item::type_tax: |
152 | - if ( $this->_show_taxes ) { |
|
153 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
152 | + if ($this->_show_taxes) { |
|
153 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
154 | 154 | } |
155 | 155 | break; |
156 | 156 | |
157 | 157 | case EEM_Line_Item::type_tax_sub_total: |
158 | - if ( $this->_show_taxes ) { |
|
158 | + if ($this->_show_taxes) { |
|
159 | 159 | $child_line_items = $line_item->children(); |
160 | 160 | // loop thru children |
161 | - foreach( $child_line_items as $child_line_item ) { |
|
161 | + foreach ($child_line_items as $child_line_item) { |
|
162 | 162 | // recursively feed children back into this method |
163 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
163 | + $html .= $this->display_line_item($child_line_item, $options); |
|
164 | 164 | } |
165 | - if ( count( $child_line_items ) > 1 ) { |
|
166 | - $this->_taxes_html .= $this->_total_tax_row( $line_item, __( 'Tax Total', 'event_espresso' ) ); |
|
165 | + if (count($child_line_items) > 1) { |
|
166 | + $this->_taxes_html .= $this->_total_tax_row($line_item, __('Tax Total', 'event_espresso')); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | break; |
@@ -172,25 +172,25 @@ discard block |
||
172 | 172 | // get all child line items |
173 | 173 | $children = $line_item->children(); |
174 | 174 | // loop thru all non-tax child line items |
175 | - foreach( $children as $child_line_item ) { |
|
176 | - if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) { |
|
175 | + foreach ($children as $child_line_item) { |
|
176 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
177 | 177 | // recursively feed children back into this method |
178 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
178 | + $html .= $this->display_line_item($child_line_item, $options); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | // now loop thru tax child line items |
183 | - foreach( $children as $child_line_item ) { |
|
184 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) { |
|
183 | + foreach ($children as $child_line_item) { |
|
184 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
185 | 185 | // recursively feed children back into this method |
186 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
186 | + $html .= $this->display_line_item($child_line_item, $options); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | $html .= $this->_taxes_html; |
190 | - $html .= $this->_total_row( $line_item, __('Total', 'event_espresso') ); |
|
190 | + $html .= $this->_total_row($line_item, __('Total', 'event_espresso')); |
|
191 | 191 | |
192 | 192 | |
193 | - $html .= $this->_payments_and_amount_owing_rows( $line_item, $options ); |
|
193 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
194 | 194 | break; |
195 | 195 | |
196 | 196 | } |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | * @param EE_Line_Item $line_item |
206 | 206 | * @return mixed |
207 | 207 | */ |
208 | - private function _event_row( EE_Line_Item $line_item ) { |
|
208 | + private function _event_row(EE_Line_Item $line_item) { |
|
209 | 209 | // start of row |
210 | - $html = EEH_HTML::tr( '', 'event-cart-total-row', 'total_tr odd' ); |
|
210 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
211 | 211 | // event name td |
212 | - $html .= EEH_HTML::td( EEH_HTML::strong( $line_item->name() ), '', 'event-header', '', ' colspan="4"' ); |
|
212 | + $html .= EEH_HTML::td(EEH_HTML::strong($line_item->name()), '', 'event-header', '', ' colspan="4"'); |
|
213 | 213 | // end of row |
214 | 214 | $html .= EEH_HTML::trx(); |
215 | 215 | return $html; |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | * @param array $options |
225 | 225 | * @return mixed |
226 | 226 | */ |
227 | - private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
|
227 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) { |
|
228 | 228 | // start of row |
229 | 229 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
230 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
230 | + $html = EEH_HTML::tr('', '', $row_class); |
|
231 | 231 | // name && desc |
232 | 232 | $name_and_desc = apply_filters( |
233 | 233 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | ); |
237 | 237 | $name_and_desc .= apply_filters( |
238 | 238 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
239 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
239 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
240 | 240 | $line_item, |
241 | 241 | $options |
242 | 242 | ); |
243 | 243 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
244 | 244 | // name td |
245 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
245 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
246 | 246 | // price td |
247 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
247 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
248 | 248 | // quantity td |
249 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
249 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
250 | 250 | $this->_total_items += $line_item->quantity(); |
251 | 251 | // determine total for line item |
252 | 252 | $total = $line_item->total(); |
253 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
253 | + $this->_events[$options['event_id']] += $total; |
|
254 | 254 | // total td |
255 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
255 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
256 | 256 | // end of row |
257 | 257 | $html .= EEH_HTML::trx(); |
258 | 258 | return $html; |
@@ -267,41 +267,41 @@ discard block |
||
267 | 267 | * @param array $options |
268 | 268 | * @return mixed |
269 | 269 | */ |
270 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
270 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
271 | 271 | // start of row |
272 | 272 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
273 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
274 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
273 | + $html = EEH_HTML::tr('', '', $row_class); |
|
274 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
275 | 275 | // name && desc |
276 | 276 | $name_and_desc = apply_filters( |
277 | 277 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
278 | - $obj_name . $line_item->name(), |
|
278 | + $obj_name.$line_item->name(), |
|
279 | 279 | $line_item |
280 | 280 | ); |
281 | 281 | $name_and_desc .= apply_filters( |
282 | 282 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
283 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
283 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
284 | 284 | $line_item, |
285 | 285 | $options |
286 | 286 | ); |
287 | 287 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
288 | 288 | // name td |
289 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l' ); |
|
289 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
290 | 290 | // price td |
291 | - if ( $line_item->is_percent() ) { |
|
292 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' ); |
|
291 | + if ($line_item->is_percent()) { |
|
292 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
293 | 293 | } else { |
294 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
294 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
295 | 295 | } |
296 | 296 | // quantity td |
297 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
297 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
298 | 298 | //$total = $line_item->total() * $line_item->quantity(); |
299 | 299 | $total = $line_item->total(); |
300 | - if( isset( $options[ 'event_id' ] ) && isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
301 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
300 | + if (isset($options['event_id']) && isset($this->_events[$options['event_id']])) { |
|
301 | + $this->_events[$options['event_id']] += $total; |
|
302 | 302 | } |
303 | 303 | // total td |
304 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
304 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
305 | 305 | // end of row |
306 | 306 | $html .= EEH_HTML::trx(); |
307 | 307 | return $html; |
@@ -316,22 +316,22 @@ discard block |
||
316 | 316 | * @param array $options |
317 | 317 | * @return mixed |
318 | 318 | */ |
319 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
319 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
320 | 320 | // start of row |
321 | - $html = EEH_HTML::tr( '', 'item sub-item-row' ); |
|
321 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
322 | 322 | // name && desc |
323 | 323 | $name_and_desc = $line_item->name(); |
324 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
324 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
325 | 325 | // name td |
326 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
326 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
327 | 327 | // discount/surcharge td |
328 | - if ( $line_item->is_percent() ) { |
|
329 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c' ); |
|
328 | + if ($line_item->is_percent()) { |
|
329 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
330 | 330 | } else { |
331 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
331 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
332 | 332 | } |
333 | 333 | // total td |
334 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
334 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
335 | 335 | // end of row |
336 | 336 | $html .= EEH_HTML::trx(); |
337 | 337 | return $html; |
@@ -346,21 +346,21 @@ discard block |
||
346 | 346 | * @param array $options |
347 | 347 | * @return mixed |
348 | 348 | */ |
349 | - private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
349 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
350 | 350 | // start of row |
351 | - $html = EEH_HTML::tr( '', 'item sub-item tax-total' ); |
|
351 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
352 | 352 | // name && desc |
353 | 353 | $name_and_desc = $line_item->name(); |
354 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>'; |
|
355 | - $name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : ''; |
|
354 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>'; |
|
355 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
356 | 356 | // name td |
357 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
357 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
358 | 358 | // percent td |
359 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', ' jst-rght', '' ); |
|
359 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
360 | 360 | // empty td (price) |
361 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
361 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
362 | 362 | // total td |
363 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
363 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
364 | 364 | // end of row |
365 | 365 | $html .= EEH_HTML::trx(); |
366 | 366 | return $html; |
@@ -375,17 +375,17 @@ discard block |
||
375 | 375 | * @param string $text |
376 | 376 | * @return mixed |
377 | 377 | */ |
378 | - private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) { |
|
378 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') { |
|
379 | 379 | $html = ''; |
380 | - if ( $line_item->total() ) { |
|
380 | + if ($line_item->total()) { |
|
381 | 381 | // start of row |
382 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
382 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
383 | 383 | // total td |
384 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' ); |
|
384 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"'); |
|
385 | 385 | // empty td (price) |
386 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
386 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
387 | 387 | // total td |
388 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
388 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
389 | 389 | // end of row |
390 | 390 | $html .= EEH_HTML::trx(); |
391 | 391 | } |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | * @param array $options |
403 | 403 | * @return mixed |
404 | 404 | */ |
405 | - private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
405 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
406 | 406 | $html = ''; |
407 | - if ( $line_item->total() ) { |
|
407 | + if ($line_item->total()) { |
|
408 | 408 | // start of row |
409 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
409 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
410 | 410 | // total td |
411 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
411 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
412 | 412 | // total td |
413 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' ); |
|
413 | + $html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght'); |
|
414 | 414 | // end of row |
415 | 415 | $html .= EEH_HTML::trx(); |
416 | 416 | } |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | * @param string $text |
428 | 428 | * @return mixed |
429 | 429 | */ |
430 | - private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
|
430 | + private function _total_row(EE_Line_Item $line_item, $text = '') { |
|
431 | 431 | // start of row |
432 | - $html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' ); |
|
432 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
433 | 433 | // total td |
434 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
434 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
435 | 435 | // total td |
436 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
436 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
437 | 437 | // end of row |
438 | 438 | $html .= EEH_HTML::trx(); |
439 | 439 | return $html; |
@@ -448,30 +448,30 @@ discard block |
||
448 | 448 | * @param array $options |
449 | 449 | * @return mixed |
450 | 450 | */ |
451 | - private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) { |
|
451 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) { |
|
452 | 452 | $html = ''; |
453 | 453 | $owing = $line_item->total(); |
454 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() ); |
|
455 | - if ( $transaction instanceof EE_Transaction ) { |
|
454 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
455 | + if ($transaction instanceof EE_Transaction) { |
|
456 | 456 | $registration_payments = array(); |
457 | - $registrations = ! empty( $options['registrations'] ) |
|
458 | - ? $options[ 'registrations' ] |
|
457 | + $registrations = ! empty($options['registrations']) |
|
458 | + ? $options['registrations'] |
|
459 | 459 | : $transaction->registrations(); |
460 | - foreach ( $registrations as $registration ) { |
|
461 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
460 | + foreach ($registrations as $registration) { |
|
461 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
462 | 462 | $registration_payments = $registration_payments + $registration->registration_payments(); |
463 | 463 | } |
464 | 464 | } |
465 | - if ( ! empty( $registration_payments )) { |
|
466 | - foreach ( $registration_payments as $registration_payment ) { |
|
467 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
465 | + if ( ! empty($registration_payments)) { |
|
466 | + foreach ($registration_payments as $registration_payment) { |
|
467 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
468 | 468 | $owing = $owing - $registration_payment->amount(); |
469 | 469 | $payment = $registration_payment->payment(); |
470 | - if ( $payment instanceof EE_Payment ) { |
|
470 | + if ($payment instanceof EE_Payment) { |
|
471 | 471 | $payment_desc = sprintf( |
472 | - __( 'Payment%1$s Received: %2$s', 'event_espresso' ), |
|
472 | + __('Payment%1$s Received: %2$s', 'event_espresso'), |
|
473 | 473 | $payment->txn_id_chq_nmbr() != '' |
474 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
474 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
475 | 475 | : '', |
476 | 476 | $payment->timestamp() |
477 | 477 | ); |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | $payment_desc = ''; |
480 | 480 | } |
481 | 481 | // start of row |
482 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
482 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
483 | 483 | // payment desc |
484 | - $html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' ); |
|
484 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
485 | 485 | // total td |
486 | 486 | $html .= EEH_HTML::td( |
487 | - EEH_Template::format_currency( $registration_payment->amount(), false, false ), |
|
487 | + EEH_Template::format_currency($registration_payment->amount(), false, false), |
|
488 | 488 | '', |
489 | 489 | 'total jst-rght' |
490 | 490 | ); |
@@ -492,17 +492,17 @@ discard block |
||
492 | 492 | $html .= EEH_HTML::trx(); |
493 | 493 | } |
494 | 494 | } |
495 | - if ( $line_item->total() ) { |
|
495 | + if ($line_item->total()) { |
|
496 | 496 | // start of row |
497 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
497 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
498 | 498 | // total td |
499 | 499 | $html .= EEH_HTML::td( |
500 | 500 | __('Amount Owing', 'event_espresso'), |
501 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
501 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
502 | 502 | ); |
503 | 503 | // total td |
504 | 504 | $html .= EEH_HTML::td( |
505 | - EEH_Template::format_currency( $owing, false, false ), '', 'total jst-rght' |
|
505 | + EEH_Template::format_currency($owing, false, false), '', 'total jst-rght' |
|
506 | 506 | ); |
507 | 507 | // end of row |
508 | 508 | $html .= EEH_HTML::trx(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * @param EE_Line_Item $line_item |
69 | 69 | * @param array $options |
70 | - * @return mixed |
|
70 | + * @return string |
|
71 | 71 | */ |
72 | 72 | public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
73 | 73 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * _event_row - basically a Heading row displayed once above each event's ticket rows |
204 | 204 | * |
205 | 205 | * @param EE_Line_Item $line_item |
206 | - * @return mixed |
|
206 | + * @return string |
|
207 | 207 | */ |
208 | 208 | private function _event_row( EE_Line_Item $line_item ) { |
209 | 209 | // start of row |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @param EE_Line_Item $line_item |
224 | 224 | * @param array $options |
225 | - * @return mixed |
|
225 | + * @return string |
|
226 | 226 | */ |
227 | 227 | private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
228 | 228 | // start of row |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param EE_Line_Item $line_item |
267 | 267 | * @param array $options |
268 | - * @return mixed |
|
268 | + * @return string |
|
269 | 269 | */ |
270 | 270 | private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
271 | 271 | // start of row |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @param EE_Line_Item $line_item |
316 | 316 | * @param array $options |
317 | - * @return mixed |
|
317 | + * @return string |
|
318 | 318 | */ |
319 | 319 | private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
320 | 320 | // start of row |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @param EE_Line_Item $line_item |
346 | 346 | * @param array $options |
347 | - * @return mixed |
|
347 | + * @return string |
|
348 | 348 | */ |
349 | 349 | private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
350 | 350 | // start of row |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @param EE_Line_Item $line_item |
375 | 375 | * @param string $text |
376 | - * @return mixed |
|
376 | + * @return string |
|
377 | 377 | */ |
378 | 378 | private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) { |
379 | 379 | $html = ''; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param EE_Line_Item $line_item |
401 | 401 | * @param string $text |
402 | 402 | * @param array $options |
403 | - * @return mixed |
|
403 | + * @return string |
|
404 | 404 | */ |
405 | 405 | private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
406 | 406 | $html = ''; |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @param EE_Line_Item $line_item |
427 | 427 | * @param string $text |
428 | - * @return mixed |
|
428 | + * @return string |
|
429 | 429 | */ |
430 | 430 | private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
431 | 431 | // start of row |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @param EE_Line_Item $line_item |
448 | 448 | * @param array $options |
449 | - * @return mixed |
|
449 | + * @return string |
|
450 | 450 | */ |
451 | 451 | private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) { |
452 | 452 | $html = ''; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Billable_Line_Item_Filter |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * EE_Billable_Line_Item_Filter constructor. |
26 | 26 | * @param EE_Registration[] $registrations |
27 | 27 | */ |
28 | - public function __construct( $registrations ) { |
|
29 | - parent::__construct( $this->_remove_unbillable_registrations( $registrations ) ); |
|
28 | + public function __construct($registrations) { |
|
29 | + parent::__construct($this->_remove_unbillable_registrations($registrations)); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -39,25 +39,24 @@ discard block |
||
39 | 39 | * @param EE_Registration[] $registrations |
40 | 40 | * @return mixed |
41 | 41 | */ |
42 | - protected function _remove_unbillable_registrations( $registrations = array() ) { |
|
43 | - if ( ! empty( $registrations ) ) { |
|
42 | + protected function _remove_unbillable_registrations($registrations = array()) { |
|
43 | + if ( ! empty($registrations)) { |
|
44 | 44 | // these reg statuses require payment (if event is not free) |
45 | 45 | $requires_payment = EEM_Registration::reg_statuses_that_allow_payment(); |
46 | - foreach ( $registrations as $key => $registration ) { |
|
47 | - if ( ! $registration instanceof EE_Registration ) { |
|
46 | + foreach ($registrations as $key => $registration) { |
|
47 | + if ( ! $registration instanceof EE_Registration) { |
|
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | // are we billing for this registration at this moment ? |
51 | - if ( ! |
|
52 | - $registration->owes_monies_and_can_pay( $requires_payment ) && |
|
51 | + if ( ! $registration->owes_monies_and_can_pay($requires_payment) && |
|
53 | 52 | ! ( |
54 | 53 | // free registration with valid reg status |
55 | 54 | $registration->final_price() == 0 && |
56 | - in_array( $registration->status_ID(), $requires_payment ) |
|
55 | + in_array($registration->status_ID(), $requires_payment) |
|
57 | 56 | ) |
58 | 57 | ) { |
59 | 58 | // not billable. remove it |
60 | - unset( $registrations[ $key ] ); |
|
59 | + unset($registrations[$key]); |
|
61 | 60 | } |
62 | 61 | } |
63 | 62 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Processor |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * @param \EEI_Line_Item $grand_total_line_item |
56 | 56 | * @throws \EE_Error |
57 | 57 | */ |
58 | - public function __construct( EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item ) { |
|
58 | + public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item) { |
|
59 | 59 | $this->line_item_filters = $line_item_filters; |
60 | - if ( $grand_total_line_item->type() !== EEM_Line_Item::type_total ) { |
|
61 | - throw new EE_Error( __( 'A Line Item of the type total is required', 'event_espresso' ) ); |
|
60 | + if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) { |
|
61 | + throw new EE_Error(__('A Line Item of the type total is required', 'event_espresso')); |
|
62 | 62 | } |
63 | - $this->grand_total_line_item = $this->clone_and_reset_line_item_tree( $grand_total_line_item ); |
|
63 | + $this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * @param \EEI_Line_Item $line_item |
72 | 72 | * @return \EEI_Line_Item |
73 | 73 | */ |
74 | - protected function clone_and_reset_line_item_tree( EEI_Line_Item $line_item ) { |
|
75 | - $cloned_line_item = $this->clone_and_reset_line_item( $line_item ); |
|
76 | - foreach ( $line_item->children() as $child_line_item ) { |
|
77 | - $cloned_line_item->add_child_line_item( $this->clone_and_reset_line_item_tree( $child_line_item ) ); |
|
74 | + protected function clone_and_reset_line_item_tree(EEI_Line_Item $line_item) { |
|
75 | + $cloned_line_item = $this->clone_and_reset_line_item($line_item); |
|
76 | + foreach ($line_item->children() as $child_line_item) { |
|
77 | + $cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item)); |
|
78 | 78 | } |
79 | 79 | return $cloned_line_item; |
80 | 80 | } |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | * @param \EEI_Line_Item $line_item |
92 | 92 | * @return \EEI_Line_Item |
93 | 93 | */ |
94 | - protected function clone_and_reset_line_item( EEI_Line_Item $line_item ) { |
|
94 | + protected function clone_and_reset_line_item(EEI_Line_Item $line_item) { |
|
95 | 95 | // we don't actually want to work with the original line item, so clone it |
96 | 96 | $cloned_line_item = clone $line_item; |
97 | - $cloned_line_item->set( 'LIN_ID', null ); |
|
98 | - $cloned_line_item->set( 'LIN_parent', null ); |
|
97 | + $cloned_line_item->set('LIN_ID', null); |
|
98 | + $cloned_line_item->set('LIN_parent', null); |
|
99 | 99 | $cloned_line_item->clear_related_line_item_cache(); |
100 | - foreach( array_keys( EEM_Line_Item::instance()->relation_settings() ) as $relation_name) { |
|
101 | - $cloned_line_item->clear_cache( $relation_name, null, true ); |
|
100 | + foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) { |
|
101 | + $cloned_line_item->clear_cache($relation_name, null, true); |
|
102 | 102 | } |
103 | - $cloned_line_item->set_allow_persist( false ); |
|
103 | + $cloned_line_item->set_allow_persist(false); |
|
104 | 104 | return $cloned_line_item; |
105 | 105 | } |
106 | 106 | |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function process() { |
115 | 115 | $this->line_item_filters->rewind(); |
116 | - while ( $this->line_item_filters->valid() ) { |
|
117 | - $this->grand_total_line_item = $this->line_item_filters->current()->process( $this->grand_total_line_item ); |
|
116 | + while ($this->line_item_filters->valid()) { |
|
117 | + $this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item); |
|
118 | 118 | $this->line_item_filters->next(); |
119 | 119 | } |
120 | 120 | $this->grand_total_line_item->recalculate_total_including_taxes(); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Non_Zero_Line_Item_Filter |
@@ -31,36 +31,36 @@ discard block |
||
31 | 31 | * @param EEI_Line_Item $line_item |
32 | 32 | * @return \EEI_Line_Item |
33 | 33 | */ |
34 | - public function process( EEI_Line_Item $line_item ) { |
|
35 | - $non_zero_line_item = $this->_filter_zero_line_item( $line_item ); |
|
36 | - if ( ! $non_zero_line_item instanceof EEI_Line_Item ) { |
|
34 | + public function process(EEI_Line_Item $line_item) { |
|
35 | + $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
|
36 | + if ( ! $non_zero_line_item instanceof EEI_Line_Item) { |
|
37 | 37 | return null; |
38 | 38 | } |
39 | 39 | //if this is an event subtotal, we want to only include it if it |
40 | 40 | //has a non-zero total and at least one ticket line item child |
41 | - if( $line_item->children() ) { |
|
41 | + if ($line_item->children()) { |
|
42 | 42 | $ticket_or_subtotals_with_tkt_children_count = 0; |
43 | - foreach ( $line_item->children() as $child_line_item ) { |
|
43 | + foreach ($line_item->children() as $child_line_item) { |
|
44 | 44 | $code = $child_line_item->code(); |
45 | - $child_line_item = $this->process( $child_line_item ); |
|
46 | - if( ! $child_line_item instanceof EEI_Line_Item ) { |
|
47 | - $line_item->delete_child_line_item( $code ); |
|
45 | + $child_line_item = $this->process($child_line_item); |
|
46 | + if ( ! $child_line_item instanceof EEI_Line_Item) { |
|
47 | + $line_item->delete_child_line_item($code); |
|
48 | 48 | continue; |
49 | 49 | } |
50 | 50 | if ( |
51 | - ( $child_line_item instanceof EEI_Line_Item && |
|
51 | + ($child_line_item instanceof EEI_Line_Item && |
|
52 | 52 | $child_line_item->type() === EEM_Line_Item::type_line_item && |
53 | - $child_line_item->OBJ_type() === 'Ticket' ) || |
|
54 | - ( $child_line_item instanceof EEI_Line_Item && |
|
55 | - $child_line_item->type() === EEM_Line_Item::type_sub_total ) |
|
53 | + $child_line_item->OBJ_type() === 'Ticket') || |
|
54 | + ($child_line_item instanceof EEI_Line_Item && |
|
55 | + $child_line_item->type() === EEM_Line_Item::type_sub_total) |
|
56 | 56 | ) { |
57 | 57 | $ticket_or_subtotals_with_tkt_children_count++; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | // if this is an event subtotal with NO ticket children |
61 | 61 | // we basically want to ignore it |
62 | - return $this->_filter_zero_subtotal_line_item( $non_zero_line_item, $ticket_or_subtotals_with_tkt_children_count ); |
|
63 | - }else{ |
|
62 | + return $this->_filter_zero_subtotal_line_item($non_zero_line_item, $ticket_or_subtotals_with_tkt_children_count); |
|
63 | + } else { |
|
64 | 64 | return $non_zero_line_item; |
65 | 65 | } |
66 | 66 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param EEI_Line_Item $line_item |
74 | 74 | * @return EEI_Line_Item |
75 | 75 | */ |
76 | - protected function _filter_zero_line_item( EEI_Line_Item $line_item ) { |
|
76 | + protected function _filter_zero_line_item(EEI_Line_Item $line_item) { |
|
77 | 77 | if ( |
78 | 78 | $line_item->type() === EEM_Line_Item::type_line_item && |
79 | 79 | $line_item->OBJ_type() === 'Ticket' && |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param int $ticket_children |
94 | 94 | * @return \EEI_Line_Item |
95 | 95 | */ |
96 | - protected function _filter_zero_subtotal_line_item( EEI_Line_Item $line_item, $ticket_children = 0 ) { |
|
96 | + protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0) { |
|
97 | 97 | if ( |
98 | 98 | $line_item->type() === EEM_Line_Item::type_sub_total && |
99 | 99 | $ticket_children === 0 |
@@ -60,7 +60,7 @@ |
||
60 | 60 | // if this is an event subtotal with NO ticket children |
61 | 61 | // we basically want to ignore it |
62 | 62 | return $this->_filter_zero_subtotal_line_item( $non_zero_line_item, $ticket_or_subtotals_with_tkt_children_count ); |
63 | - }else{ |
|
63 | + } else{ |
|
64 | 64 | return $non_zero_line_item; |
65 | 65 | } |
66 | 66 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Single_Registration_Line_Item_Filter |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param EE_Registration $registration |
23 | 23 | */ |
24 | - public function __construct( $registration ) { |
|
25 | - parent::__construct( array( $registration ) ); |
|
24 | + public function __construct($registration) { |
|
25 | + parent::__construct(array($registration)); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | // End of file EE_Single_Registration_Line_Item_Filter.class.php |
@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Specific_Registrations_Line_Item_Filter extends EE_Line_Item_Filter_Base { |
20 | 20 | /** |
21 | - * array of line item codes and their corresponding quantities for |
|
22 | - * registrations that owe money and can pay at this moment |
|
23 | - * @type array $_counts_per_line_item_code |
|
24 | - */ |
|
21 | + * array of line item codes and their corresponding quantities for |
|
22 | + * registrations that owe money and can pay at this moment |
|
23 | + * @type array $_counts_per_line_item_code |
|
24 | + */ |
|
25 | 25 | protected $_counts_per_line_item_code = array(); |
26 | 26 | |
27 | 27 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * EE_Billable_Line_Item_Filter constructor. |
37 | 37 | * @param EE_Registration[] $registrations |
38 | 38 | */ |
39 | - public function __construct( $registrations ) { |
|
39 | + public function __construct($registrations) { |
|
40 | 40 | $this->_registrations = $registrations; |
41 | - $this->_calculate_counts_per_line_item_code( $registrations ); |
|
41 | + $this->_calculate_counts_per_line_item_code($registrations); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * @param EE_Registration[] $registrations |
47 | 47 | * @return void |
48 | 48 | */ |
49 | - protected function _calculate_counts_per_line_item_code( $registrations ) { |
|
50 | - foreach( $registrations as $registration ) { |
|
51 | - $line_item_code = EEM_Line_Item::instance()->get_var( EEM_Line_Item::instance()->line_item_for_registration_query_params( $registration, array( 'limit' => 1 ) ), 'LIN_code' ); |
|
52 | - if( $line_item_code ) { |
|
53 | - if( ! isset( $this->_counts_per_line_item_code[ $line_item_code ] ) ) { |
|
54 | - $this->_counts_per_line_item_code[ $line_item_code ] = 1; |
|
55 | - }else{ |
|
56 | - $this->_counts_per_line_item_code[ $line_item_code ]++; |
|
49 | + protected function _calculate_counts_per_line_item_code($registrations) { |
|
50 | + foreach ($registrations as $registration) { |
|
51 | + $line_item_code = EEM_Line_Item::instance()->get_var(EEM_Line_Item::instance()->line_item_for_registration_query_params($registration, array('limit' => 1)), 'LIN_code'); |
|
52 | + if ($line_item_code) { |
|
53 | + if ( ! isset($this->_counts_per_line_item_code[$line_item_code])) { |
|
54 | + $this->_counts_per_line_item_code[$line_item_code] = 1; |
|
55 | + } else { |
|
56 | + $this->_counts_per_line_item_code[$line_item_code]++; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
@@ -67,57 +67,57 @@ discard block |
||
67 | 67 | * @param EEI_Line_Item $line_item |
68 | 68 | * @return \EEI_Line_Item |
69 | 69 | */ |
70 | - public function process( EEI_Line_Item $line_item ) { |
|
71 | - $this->_filter_billable_line_item( $line_item ); |
|
72 | - if( ! $line_item->children() ) { |
|
70 | + public function process(EEI_Line_Item $line_item) { |
|
71 | + $this->_filter_billable_line_item($line_item); |
|
72 | + if ( ! $line_item->children()) { |
|
73 | 73 | return $line_item; |
74 | 74 | } |
75 | 75 | //the original running total (taking ALL tickets into account) |
76 | 76 | $running_total_of_children = 0; |
77 | 77 | //the new running total (only taking the specified ticket quantities into account) |
78 | 78 | $runnign_total_of_children_under_consideration = 0; |
79 | - foreach ( $line_item->children() as $child_line_item ) { |
|
80 | - if( $child_line_item->is_percent() ) { |
|
79 | + foreach ($line_item->children() as $child_line_item) { |
|
80 | + if ($child_line_item->is_percent()) { |
|
81 | 81 | $original_li_total = $running_total_of_children * $child_line_item->percent() / 100; |
82 | - }else{ |
|
82 | + } else { |
|
83 | 83 | $original_li_total = $child_line_item->unit_price() * $child_line_item->quantity(); |
84 | 84 | } |
85 | 85 | |
86 | - $this->process( $child_line_item ); |
|
86 | + $this->process($child_line_item); |
|
87 | 87 | /* |
88 | 88 | * If this line item is a normal line item that isn't for a ticket |
89 | 89 | * we want to modify its total (and unit price if not a percentage line item) |
90 | 90 | * so it reflects only that portion of the surcharge/discount shared by these |
91 | 91 | * registrations |
92 | 92 | */ |
93 | - if( $child_line_item->type() === EEM_Line_Item::type_line_item && |
|
94 | - $child_line_item->OBJ_type() !== 'Ticket' ) { |
|
95 | - if( $running_total_of_children ) { |
|
93 | + if ($child_line_item->type() === EEM_Line_Item::type_line_item && |
|
94 | + $child_line_item->OBJ_type() !== 'Ticket') { |
|
95 | + if ($running_total_of_children) { |
|
96 | 96 | $percent_of_running_total = $original_li_total / $running_total_of_children; |
97 | 97 | } else { |
98 | 98 | $percent_of_running_total = 0; |
99 | 99 | } |
100 | 100 | |
101 | - $child_line_item->set_total( $runnign_total_of_children_under_consideration * $percent_of_running_total ); |
|
102 | - if( ! $child_line_item->is_percent() ) { |
|
103 | - $child_line_item->set_unit_price( $child_line_item->total() / $child_line_item->quantity() ); |
|
101 | + $child_line_item->set_total($runnign_total_of_children_under_consideration * $percent_of_running_total); |
|
102 | + if ( ! $child_line_item->is_percent()) { |
|
103 | + $child_line_item->set_unit_price($child_line_item->total() / $child_line_item->quantity()); |
|
104 | 104 | } |
105 | - }elseif( $line_item->type() === EEM_Line_Item::type_line_item && |
|
106 | - $line_item->OBJ_type() === 'Ticket' ) { |
|
105 | + }elseif ($line_item->type() === EEM_Line_Item::type_line_item && |
|
106 | + $line_item->OBJ_type() === 'Ticket') { |
|
107 | 107 | //make sure this item's quantity matches its parent |
108 | - if( ! $child_line_item->is_percent() ) { |
|
109 | - $child_line_item->set_quantity( $line_item->quantity() ); |
|
110 | - $child_line_item->set_total( $child_line_item->unit_price() * $child_line_item->quantity() ); |
|
108 | + if ( ! $child_line_item->is_percent()) { |
|
109 | + $child_line_item->set_quantity($line_item->quantity()); |
|
110 | + $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity()); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | $running_total_of_children += $original_li_total; |
114 | 114 | $runnign_total_of_children_under_consideration += $child_line_item->total(); |
115 | 115 | } |
116 | - $line_item->set_total( $runnign_total_of_children_under_consideration ); |
|
117 | - if( $line_item->quantity() ) { |
|
118 | - $line_item->set_unit_price( $runnign_total_of_children_under_consideration / $line_item->quantity() ); |
|
116 | + $line_item->set_total($runnign_total_of_children_under_consideration); |
|
117 | + if ($line_item->quantity()) { |
|
118 | + $line_item->set_unit_price($runnign_total_of_children_under_consideration / $line_item->quantity()); |
|
119 | 119 | } else { |
120 | - $line_item->set_unit_price( 0 ); |
|
120 | + $line_item->set_unit_price(0); |
|
121 | 121 | } |
122 | 122 | return $line_item; |
123 | 123 | } |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | * @param EEI_Line_Item $line_item |
131 | 131 | * @return EEI_Line_Item |
132 | 132 | */ |
133 | - protected function _filter_billable_line_item( EEI_Line_Item $line_item ) { |
|
133 | + protected function _filter_billable_line_item(EEI_Line_Item $line_item) { |
|
134 | 134 | // is this a ticket ? |
135 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket' ) { |
|
135 | + if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() == 'Ticket') { |
|
136 | 136 | // if this ticket is billable at this moment, then we should have a positive quantity |
137 | - if ( isset( $this->_counts_per_line_item_code[ $line_item->code() ] )) { |
|
137 | + if (isset($this->_counts_per_line_item_code[$line_item->code()])) { |
|
138 | 138 | // set quantity based on number of billable registrations for this ticket |
139 | - $quantity = $this->_counts_per_line_item_code[ $line_item->code() ]; |
|
139 | + $quantity = $this->_counts_per_line_item_code[$line_item->code()]; |
|
140 | 140 | } else { |
141 | 141 | $quantity = 0; |
142 | 142 | } |
143 | - $line_item->set_quantity( $quantity ); |
|
144 | - $line_item->set_total( $line_item->unit_price() * $line_item->quantity() ); |
|
143 | + $line_item->set_quantity($quantity); |
|
144 | + $line_item->set_total($line_item->unit_price() * $line_item->quantity()); |
|
145 | 145 | } |
146 | 146 | return $line_item; |
147 | 147 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if( $line_item_code ) { |
53 | 53 | if( ! isset( $this->_counts_per_line_item_code[ $line_item_code ] ) ) { |
54 | 54 | $this->_counts_per_line_item_code[ $line_item_code ] = 1; |
55 | - }else{ |
|
55 | + } else{ |
|
56 | 56 | $this->_counts_per_line_item_code[ $line_item_code ]++; |
57 | 57 | } |
58 | 58 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | foreach ( $line_item->children() as $child_line_item ) { |
80 | 80 | if( $child_line_item->is_percent() ) { |
81 | 81 | $original_li_total = $running_total_of_children * $child_line_item->percent() / 100; |
82 | - }else{ |
|
82 | + } else{ |
|
83 | 83 | $original_li_total = $child_line_item->unit_price() * $child_line_item->quantity(); |
84 | 84 | } |
85 | 85 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if( ! $child_line_item->is_percent() ) { |
103 | 103 | $child_line_item->set_unit_price( $child_line_item->total() / $child_line_item->quantity() ); |
104 | 104 | } |
105 | - }elseif( $line_item->type() === EEM_Line_Item::type_line_item && |
|
105 | + } elseif( $line_item->type() === EEM_Line_Item::type_line_item && |
|
106 | 106 | $line_item->OBJ_type() === 'Ticket' ) { |
107 | 107 | //make sure this item's quantity matches its parent |
108 | 108 | if( ! $child_line_item->is_percent() ) { |
@@ -6,7 +6,9 @@ |
||
6 | 6 | * @subpackage messages |
7 | 7 | * @since 4.5.0 |
8 | 8 | */ |
9 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | +} |
|
10 | 12 | |
11 | 13 | /** |
12 | 14 | * This class contains common methods/properties shared among all payment message types. |
@@ -51,26 +51,26 @@ |
||
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - protected function _get_data_for_context( $context, EE_Registration $registration, $id ) { |
|
54 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) { |
|
55 | 55 | |
56 | 56 | //use the registration to get the transaction. |
57 | 57 | $transaction = $registration->transaction(); |
58 | 58 | |
59 | 59 | //bail early if no transaction |
60 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
61 | - throw new EE_Error( __('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso' ) ); |
|
60 | + if ( ! $transaction instanceof EE_Transaction) { |
|
61 | + throw new EE_Error(__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso')); |
|
62 | 62 | } |
63 | 63 | |
64 | - $payment = ! empty( $id ) ? EEM_Payment::instance()->get_one( array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) ) ) : 0; |
|
64 | + $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0; |
|
65 | 65 | |
66 | - return array( $transaction, $payment ); |
|
66 | + return array($transaction, $payment); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - protected function _get_admin_content_events_edit_for_messenger( EE_messenger $messenger ) { |
|
71 | + protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger) { |
|
72 | 72 | //this is just a test |
73 | - return $this->name . ' Message Type for ' . $messenger->name . ' Messenger '; |
|
73 | + return $this->name.' Message Type for '.$messenger->name.' Messenger '; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |