@@ -3,79 +3,79 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab. When you click one of those tabs it will display that messenger.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab. When you click one of those tabs it will display that messenger.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'There are two ways to determine whether a messenger is active or not. The first way is via the messenger tab itself.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'There are two ways to determine whether a messenger is active or not. The first way is via the messenger tab itself.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <?php printf( |
18 | - esc_html__( |
|
19 | - 'The green colored gear %s indicates that this messenger is currently active.', |
|
20 | - 'event_espresso' |
|
21 | - ), |
|
22 | - '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"' |
|
23 | - . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />' |
|
24 | - ); |
|
25 | - printf( |
|
26 | - esc_html__( |
|
27 | - ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' |
|
31 | - . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />' |
|
32 | - ); ?> |
|
18 | + esc_html__( |
|
19 | + 'The green colored gear %s indicates that this messenger is currently active.', |
|
20 | + 'event_espresso' |
|
21 | + ), |
|
22 | + '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"' |
|
23 | + . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />' |
|
24 | + ); |
|
25 | + printf( |
|
26 | + esc_html__( |
|
27 | + ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' |
|
31 | + . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />' |
|
32 | + ); ?> |
|
33 | 33 | </p> |
34 | 34 | <p> |
35 | 35 | <?php esc_html_e( |
36 | - 'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:', |
|
37 | - 'event_espresso' |
|
38 | - ); ?> |
|
36 | + 'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:', |
|
37 | + 'event_espresso' |
|
38 | + ); ?> |
|
39 | 39 | </p> |
40 | 40 | <p> |
41 | 41 | <?php printf( |
42 | - esc_html__( |
|
43 | - '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - '<div class="switch">' |
|
47 | - . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked disabled>' |
|
48 | - . '<label for="ee-on-off-toggle-on"></label>' |
|
49 | - . '</div>', |
|
50 | - '<div class="switch">' |
|
51 | - . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>' |
|
52 | - . '<label for="ee-on-off-toggle-on"></label>' |
|
53 | - . '</div>' |
|
54 | - ); ?> |
|
42 | + esc_html__( |
|
43 | + '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + '<div class="switch">' |
|
47 | + . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked disabled>' |
|
48 | + . '<label for="ee-on-off-toggle-on"></label>' |
|
49 | + . '</div>', |
|
50 | + '<div class="switch">' |
|
51 | + . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>' |
|
52 | + . '<label for="ee-on-off-toggle-on"></label>' |
|
53 | + . '</div>' |
|
54 | + ); ?> |
|
55 | 55 | </p> |
56 | 56 | <p> |
57 | 57 | <?php |
58 | - esc_html_e( |
|
59 | - 'The on/off toggle is also what you use to activate or deactivate a messenger.', |
|
60 | - 'event_espresso' |
|
61 | - ); ?> |
|
58 | + esc_html_e( |
|
59 | + 'The on/off toggle is also what you use to activate or deactivate a messenger.', |
|
60 | + 'event_espresso' |
|
61 | + ); ?> |
|
62 | 62 | </p> |
63 | 63 | <p> |
64 | 64 | <?php esc_html_e( |
65 | - 'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger. Then, if there are any default settings for either the messenger or message types those settings are saved. Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated). Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.', |
|
66 | - 'event_espresso' |
|
67 | - ); ?> |
|
65 | + 'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger. Then, if there are any default settings for either the messenger or message types those settings are saved. Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated). Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.', |
|
66 | + 'event_espresso' |
|
67 | + ); ?> |
|
68 | 68 | </p> |
69 | 69 | <p> |
70 | 70 | <?php esc_html_e( |
71 | - 'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate. If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.', |
|
72 | - 'event_espresso' |
|
73 | - ); ?> |
|
71 | + 'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate. If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.', |
|
72 | + 'event_espresso' |
|
73 | + ); ?> |
|
74 | 74 | </p> |
75 | 75 | <p> |
76 | 76 | <strong><?php esc_html_e('Important', 'event_espresso'); ?></strong><br /> |
77 | 77 | <?php esc_html_e( |
78 | - 'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation. Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.', |
|
79 | - 'event_espresso' |
|
80 | - ); ?> |
|
78 | + 'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation. Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.', |
|
79 | + 'event_espresso' |
|
80 | + ); ?> |
|
81 | 81 | </p> |
@@ -13,36 +13,36 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function espresso_invoice_template_files($class_file) |
15 | 15 | { |
16 | - $files = []; |
|
17 | - // read our template dir and build an array of files |
|
18 | - $directory_handle = opendir(dirname($class_file) . '/lib/templates/css/'); |
|
19 | - //if we managed to open the directory |
|
20 | - if ($directory_handle) { |
|
21 | - /** @var RequestInterface $request */ |
|
22 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
23 | - $skip = [ |
|
24 | - '.', |
|
25 | - '..', |
|
26 | - '.DS_Store', |
|
27 | - '.svn', |
|
28 | - 'images', |
|
29 | - 'index.php', |
|
30 | - 'print', |
|
31 | - basename($request->getServerParam('PHP_SELF')), |
|
32 | - ]; |
|
33 | - // loop through all of the files |
|
34 | - while (false !== ($fname = readdir($directory_handle))) { |
|
35 | - // if the file is not this file, and does not start with a '.' or '..', |
|
36 | - // then store it for later display |
|
37 | - if (! in_array($fname, $skip, true)) { |
|
38 | - $files[] = $fname; |
|
39 | - } |
|
40 | - } |
|
41 | - // close the directory |
|
42 | - closedir($directory_handle); |
|
43 | - } |
|
16 | + $files = []; |
|
17 | + // read our template dir and build an array of files |
|
18 | + $directory_handle = opendir(dirname($class_file) . '/lib/templates/css/'); |
|
19 | + //if we managed to open the directory |
|
20 | + if ($directory_handle) { |
|
21 | + /** @var RequestInterface $request */ |
|
22 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
23 | + $skip = [ |
|
24 | + '.', |
|
25 | + '..', |
|
26 | + '.DS_Store', |
|
27 | + '.svn', |
|
28 | + 'images', |
|
29 | + 'index.php', |
|
30 | + 'print', |
|
31 | + basename($request->getServerParam('PHP_SELF')), |
|
32 | + ]; |
|
33 | + // loop through all of the files |
|
34 | + while (false !== ($fname = readdir($directory_handle))) { |
|
35 | + // if the file is not this file, and does not start with a '.' or '..', |
|
36 | + // then store it for later display |
|
37 | + if (! in_array($fname, $skip, true)) { |
|
38 | + $files[] = $fname; |
|
39 | + } |
|
40 | + } |
|
41 | + // close the directory |
|
42 | + closedir($directory_handle); |
|
43 | + } |
|
44 | 44 | |
45 | - return $files; |
|
45 | + return $files; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function espresso_invoice_is_selected($input_item, $selected = '') |
58 | 58 | { |
59 | - if ($input_item === $selected) { |
|
60 | - return 'selected'; |
|
61 | - } |
|
62 | - return ''; |
|
59 | + if ($input_item === $selected) { |
|
60 | + return 'selected'; |
|
61 | + } |
|
62 | + return ''; |
|
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -20,364 +20,364 @@ |
||
20 | 20 | class TicketSelectorRowStandard extends TicketSelectorRow |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var TicketDetails |
|
25 | - */ |
|
26 | - protected $ticket_details; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var EE_Ticket_Selector_Config |
|
30 | - */ |
|
31 | - protected $template_settings; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var EE_Tax_Config |
|
35 | - */ |
|
36 | - protected $tax_settings; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var boolean |
|
40 | - */ |
|
41 | - protected $prices_displayed_including_taxes; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var int |
|
45 | - */ |
|
46 | - protected $row; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - protected $cols; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var boolean |
|
55 | - */ |
|
56 | - protected $hidden_input_qty = false; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - protected $ticket_datetime_classes; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * TicketDetails constructor. |
|
66 | - * |
|
67 | - * @param TicketDetails $ticket_details |
|
68 | - * @param EE_Tax_Config $tax_settings |
|
69 | - * @param int $total_tickets |
|
70 | - * @param int $max_attendees |
|
71 | - * @param int $row |
|
72 | - * @param int $cols |
|
73 | - * @param boolean $required_ticket_sold_out |
|
74 | - * @param string $event_status |
|
75 | - * @param string $ticket_datetime_classes |
|
76 | - * @throws EE_Error |
|
77 | - * @throws UnexpectedEntityException |
|
78 | - */ |
|
79 | - public function __construct( |
|
80 | - TicketDetails $ticket_details, |
|
81 | - EE_Tax_Config $tax_settings, |
|
82 | - $total_tickets, |
|
83 | - $max_attendees, |
|
84 | - $row, |
|
85 | - $cols, |
|
86 | - $required_ticket_sold_out, |
|
87 | - $event_status, |
|
88 | - $ticket_datetime_classes |
|
89 | - ) { |
|
90 | - $this->ticket_details = $ticket_details; |
|
91 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
92 | - $this->tax_settings = $tax_settings; |
|
93 | - $this->row = $row; |
|
94 | - $this->cols = $cols; |
|
95 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
96 | - parent::__construct( |
|
97 | - $ticket_details->getTicket(), |
|
98 | - $max_attendees, |
|
99 | - $ticket_details->getDateFormat(), |
|
100 | - $event_status, |
|
101 | - $required_ticket_sold_out, |
|
102 | - $total_tickets |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * other ticket rows will need to know if a required ticket is sold out, |
|
109 | - * so that they are not offered for sale |
|
110 | - * |
|
111 | - * @return boolean |
|
112 | - */ |
|
113 | - public function getRequiredTicketSoldOut() |
|
114 | - { |
|
115 | - return $this->required_ticket_sold_out; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function getCols() |
|
123 | - { |
|
124 | - return $this->cols; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * getHtml |
|
130 | - * |
|
131 | - * @return string |
|
132 | - * @throws EE_Error |
|
133 | - * @throws ReflectionException |
|
134 | - */ |
|
135 | - public function getHtml() |
|
136 | - { |
|
137 | - $this->min = 0; |
|
138 | - $this->max = $this->ticket->max(); |
|
139 | - $remaining = $this->ticket->remaining(); |
|
140 | - $this->setTicketMinAndMax($remaining); |
|
141 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
142 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
143 | - ? $this->ticket->start_date() |
|
144 | - : $this->required_ticket_sold_out; |
|
145 | - $this->setTicketPriceDetails(); |
|
146 | - $this->setTicketStatusClasses($remaining); |
|
147 | - $filtered_row_html = $this->getFilteredRowHtml(); |
|
148 | - if ($filtered_row_html !== false) { |
|
149 | - return $filtered_row_html; |
|
150 | - } |
|
151 | - $ticket_selector_row_html = EEH_HTML::tr( |
|
152 | - '', |
|
153 | - '', |
|
154 | - "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
155 | - . espresso_get_object_css_class($this->ticket) |
|
156 | - ); |
|
157 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
158 | - if ($filtered_row_content !== false) { |
|
159 | - if ($this->max_attendees === 1) { |
|
160 | - return $ticket_selector_row_html |
|
161 | - . $filtered_row_content |
|
162 | - . $this->ticketQtyAndIdHiddenInputs() |
|
163 | - . EEH_HTML::trx(); |
|
164 | - } |
|
165 | - return $ticket_selector_row_html |
|
166 | - . $filtered_row_content |
|
167 | - . EEH_HTML::trx(); |
|
168 | - } |
|
169 | - $this->hidden_input_qty = $this->max_attendees > 1; |
|
170 | - |
|
171 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
172 | - $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
173 | - $ticket_selector_row_html .= EEH_HTML::td( |
|
174 | - '', |
|
175 | - '', |
|
176 | - 'tckt-slctr-tbl-td-qty cntr', |
|
177 | - '', |
|
178 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
179 | - ); |
|
180 | - $this->setTicketStatusDisplay($remaining); |
|
181 | - if (empty($this->ticket_status_display)) { |
|
182 | - if ($this->max_attendees === 1) { |
|
183 | - // only ONE attendee is allowed to register at a time |
|
184 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
185 | - } elseif ($this->max > 0) { |
|
186 | - $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
187 | - } |
|
188 | - } |
|
189 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
190 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
191 | - $ticket_selector_row_html .= $this->ticket_details->display( |
|
192 | - $this->ticket_price, |
|
193 | - $remaining, |
|
194 | - $this->cols |
|
195 | - ); |
|
196 | - $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
197 | - $ticket_selector_row_html .= EEH_HTML::trx(); |
|
198 | - |
|
199 | - |
|
200 | - $this->row++; |
|
201 | - return $ticket_selector_row_html; |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * getTicketPriceDetails |
|
207 | - * |
|
208 | - * @return void |
|
209 | - * @throws EE_Error |
|
210 | - */ |
|
211 | - protected function setTicketPriceDetails() |
|
212 | - { |
|
213 | - $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
214 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
215 | - : $this->ticket->get_ticket_subtotal(); |
|
216 | - $this->ticket_bundle = false; |
|
217 | - $ticket_min = $this->ticket->min(); |
|
218 | - // for ticket bundles, set min and max qty the same |
|
219 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
220 | - $this->ticket_price *= $ticket_min; |
|
221 | - $this->ticket_bundle = true; |
|
222 | - } |
|
223 | - $this->ticket_price = apply_filters( |
|
224 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
225 | - $this->ticket_price, |
|
226 | - $this->ticket |
|
227 | - ); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * ticketNameTableCell |
|
233 | - * |
|
234 | - * @return string |
|
235 | - * @throws EE_Error |
|
236 | - * @throws ReflectionException |
|
237 | - */ |
|
238 | - protected function ticketNameTableCell() |
|
239 | - { |
|
240 | - $html = EEH_HTML::td( |
|
241 | - '', |
|
242 | - '', |
|
243 | - 'tckt-slctr-tbl-td-name', |
|
244 | - '', |
|
245 | - 'headers="details-' . $this->EVT_ID . '"' |
|
246 | - ); |
|
247 | - $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
248 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
249 | - if ($this->ticket->required()) { |
|
250 | - $html .= EEH_HTML::p( |
|
251 | - apply_filters( |
|
252 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
253 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
254 | - ), |
|
255 | - '', |
|
256 | - 'ticket-required-pg' |
|
257 | - ); |
|
258 | - } |
|
259 | - $html .= EEH_HTML::tdx(); |
|
260 | - return $html; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * ticketPriceTableCell |
|
266 | - * |
|
267 | - * @return string |
|
268 | - * @throws EE_Error |
|
269 | - */ |
|
270 | - protected function ticketPriceTableCell() |
|
271 | - { |
|
272 | - $html = ''; |
|
273 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
274 | - $html .= EEH_HTML::td( |
|
275 | - '', |
|
276 | - '', |
|
277 | - 'tckt-slctr-tbl-td-price jst-rght', |
|
278 | - '', |
|
279 | - 'headers="price-' . $this->EVT_ID . '"' |
|
280 | - ); |
|
281 | - $html .= EEH_Template::format_currency($this->ticket_price); |
|
282 | - $html .= $this->ticket->taxable() |
|
283 | - ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
284 | - : ''; |
|
285 | - $html .= ' '; |
|
286 | - // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
287 | - $html .= EEH_HTML::span( |
|
288 | - $this->ticket_bundle |
|
289 | - ? apply_filters( |
|
290 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
291 | - esc_html__(' / bundle', 'event_espresso') |
|
292 | - ) |
|
293 | - : apply_filters( |
|
294 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
295 | - esc_html__('', 'event_espresso') |
|
296 | - ), |
|
297 | - '', |
|
298 | - 'smaller-text no-bold' |
|
299 | - ); |
|
300 | - $html .= ' '; |
|
301 | - $html .= EEH_HTML::tdx(); |
|
302 | - $this->cols++; |
|
303 | - } |
|
304 | - return $html; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * onlyOneAttendeeCanRegister |
|
310 | - * |
|
311 | - * @return string |
|
312 | - * @throws EE_Error |
|
313 | - */ |
|
314 | - protected function onlyOneAttendeeCanRegister() |
|
315 | - { |
|
316 | - $this->hidden_input_qty = false; |
|
317 | - // display submit button since we have tickets available |
|
318 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
319 | - |
|
320 | - $TKT = $this->ticket->ID(); |
|
321 | - $label = esc_html__('Select this ticket', 'event_espresso'); |
|
322 | - $name = "tkt-slctr-qty-{$this->EVT_ID}"; |
|
323 | - $class = "ticket-selector-tbl-qty-slct"; |
|
324 | - $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
325 | - $checked = $this->total_tickets === 1 ? ' checked' : ''; |
|
326 | - |
|
327 | - $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
328 | - $html .= "<input type='radio'{$checked} name='{$name}' id='{$id}' class='{$class}' value='{$TKT}-1' title='' />"; |
|
329 | - return $html; |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - /** |
|
334 | - * ticketQuantitySelector |
|
335 | - * |
|
336 | - * @return string |
|
337 | - * @throws EE_Error |
|
338 | - */ |
|
339 | - protected function ticketQuantitySelector() |
|
340 | - { |
|
341 | - $this->hidden_input_qty = false; |
|
342 | - // display submit button since we have tickets available |
|
343 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
344 | - |
|
345 | - $TKT = $this->ticket->ID(); |
|
346 | - $label = esc_html__('Quantity', 'event_espresso'); |
|
347 | - $class = 'ticket-selector-tbl-qty-slct'; |
|
348 | - $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
349 | - |
|
350 | - $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
351 | - $html .= "<select name='tkt-slctr-qty-{$this->EVT_ID}[{$TKT}]' id='{$id}' class='{$class}'>"; |
|
352 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
353 | - if ($this->min !== 0 && ! $this->ticket->required()) { |
|
354 | - $html .= "<option value='0'> 0 </option>"; |
|
355 | - } |
|
356 | - // offer ticket quantities from the min to the max |
|
357 | - for ($i = $this->min; $i <= $this->max; $i++) { |
|
358 | - $html .= "<option value='{$i}'> {$i} </option>"; |
|
359 | - } |
|
360 | - $html .= "</select>"; |
|
361 | - return $html; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * getHiddenInputs |
|
367 | - * |
|
368 | - * @return string |
|
369 | - * @throws EE_Error |
|
370 | - */ |
|
371 | - protected function ticketQtyAndIdHiddenInputs() |
|
372 | - { |
|
373 | - $html = ''; |
|
374 | - $EVT = $this->EVT_ID; |
|
375 | - $TKT = $this->ticket->ID(); |
|
376 | - // depending on group reg we need to change the format for qty |
|
377 | - if ($this->hidden_input_qty) { |
|
378 | - $html .= "<input type='hidden' name='tkt-slctr-qty-{$EVT}[]' value='0' />"; |
|
379 | - } |
|
380 | - $html .= "<input type='hidden' name='tkt-slctr-ticket-id-{$EVT}[]' value='{$TKT}' />"; |
|
381 | - return $html; |
|
382 | - } |
|
23 | + /** |
|
24 | + * @var TicketDetails |
|
25 | + */ |
|
26 | + protected $ticket_details; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var EE_Ticket_Selector_Config |
|
30 | + */ |
|
31 | + protected $template_settings; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var EE_Tax_Config |
|
35 | + */ |
|
36 | + protected $tax_settings; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | + protected $prices_displayed_including_taxes; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var int |
|
45 | + */ |
|
46 | + protected $row; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + protected $cols; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var boolean |
|
55 | + */ |
|
56 | + protected $hidden_input_qty = false; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + protected $ticket_datetime_classes; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * TicketDetails constructor. |
|
66 | + * |
|
67 | + * @param TicketDetails $ticket_details |
|
68 | + * @param EE_Tax_Config $tax_settings |
|
69 | + * @param int $total_tickets |
|
70 | + * @param int $max_attendees |
|
71 | + * @param int $row |
|
72 | + * @param int $cols |
|
73 | + * @param boolean $required_ticket_sold_out |
|
74 | + * @param string $event_status |
|
75 | + * @param string $ticket_datetime_classes |
|
76 | + * @throws EE_Error |
|
77 | + * @throws UnexpectedEntityException |
|
78 | + */ |
|
79 | + public function __construct( |
|
80 | + TicketDetails $ticket_details, |
|
81 | + EE_Tax_Config $tax_settings, |
|
82 | + $total_tickets, |
|
83 | + $max_attendees, |
|
84 | + $row, |
|
85 | + $cols, |
|
86 | + $required_ticket_sold_out, |
|
87 | + $event_status, |
|
88 | + $ticket_datetime_classes |
|
89 | + ) { |
|
90 | + $this->ticket_details = $ticket_details; |
|
91 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
92 | + $this->tax_settings = $tax_settings; |
|
93 | + $this->row = $row; |
|
94 | + $this->cols = $cols; |
|
95 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
96 | + parent::__construct( |
|
97 | + $ticket_details->getTicket(), |
|
98 | + $max_attendees, |
|
99 | + $ticket_details->getDateFormat(), |
|
100 | + $event_status, |
|
101 | + $required_ticket_sold_out, |
|
102 | + $total_tickets |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * other ticket rows will need to know if a required ticket is sold out, |
|
109 | + * so that they are not offered for sale |
|
110 | + * |
|
111 | + * @return boolean |
|
112 | + */ |
|
113 | + public function getRequiredTicketSoldOut() |
|
114 | + { |
|
115 | + return $this->required_ticket_sold_out; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function getCols() |
|
123 | + { |
|
124 | + return $this->cols; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * getHtml |
|
130 | + * |
|
131 | + * @return string |
|
132 | + * @throws EE_Error |
|
133 | + * @throws ReflectionException |
|
134 | + */ |
|
135 | + public function getHtml() |
|
136 | + { |
|
137 | + $this->min = 0; |
|
138 | + $this->max = $this->ticket->max(); |
|
139 | + $remaining = $this->ticket->remaining(); |
|
140 | + $this->setTicketMinAndMax($remaining); |
|
141 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
142 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
143 | + ? $this->ticket->start_date() |
|
144 | + : $this->required_ticket_sold_out; |
|
145 | + $this->setTicketPriceDetails(); |
|
146 | + $this->setTicketStatusClasses($remaining); |
|
147 | + $filtered_row_html = $this->getFilteredRowHtml(); |
|
148 | + if ($filtered_row_html !== false) { |
|
149 | + return $filtered_row_html; |
|
150 | + } |
|
151 | + $ticket_selector_row_html = EEH_HTML::tr( |
|
152 | + '', |
|
153 | + '', |
|
154 | + "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
155 | + . espresso_get_object_css_class($this->ticket) |
|
156 | + ); |
|
157 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
158 | + if ($filtered_row_content !== false) { |
|
159 | + if ($this->max_attendees === 1) { |
|
160 | + return $ticket_selector_row_html |
|
161 | + . $filtered_row_content |
|
162 | + . $this->ticketQtyAndIdHiddenInputs() |
|
163 | + . EEH_HTML::trx(); |
|
164 | + } |
|
165 | + return $ticket_selector_row_html |
|
166 | + . $filtered_row_content |
|
167 | + . EEH_HTML::trx(); |
|
168 | + } |
|
169 | + $this->hidden_input_qty = $this->max_attendees > 1; |
|
170 | + |
|
171 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
172 | + $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
173 | + $ticket_selector_row_html .= EEH_HTML::td( |
|
174 | + '', |
|
175 | + '', |
|
176 | + 'tckt-slctr-tbl-td-qty cntr', |
|
177 | + '', |
|
178 | + 'headers="quantity-' . $this->EVT_ID . '"' |
|
179 | + ); |
|
180 | + $this->setTicketStatusDisplay($remaining); |
|
181 | + if (empty($this->ticket_status_display)) { |
|
182 | + if ($this->max_attendees === 1) { |
|
183 | + // only ONE attendee is allowed to register at a time |
|
184 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
185 | + } elseif ($this->max > 0) { |
|
186 | + $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
187 | + } |
|
188 | + } |
|
189 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
190 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
191 | + $ticket_selector_row_html .= $this->ticket_details->display( |
|
192 | + $this->ticket_price, |
|
193 | + $remaining, |
|
194 | + $this->cols |
|
195 | + ); |
|
196 | + $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
197 | + $ticket_selector_row_html .= EEH_HTML::trx(); |
|
198 | + |
|
199 | + |
|
200 | + $this->row++; |
|
201 | + return $ticket_selector_row_html; |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * getTicketPriceDetails |
|
207 | + * |
|
208 | + * @return void |
|
209 | + * @throws EE_Error |
|
210 | + */ |
|
211 | + protected function setTicketPriceDetails() |
|
212 | + { |
|
213 | + $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
214 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
215 | + : $this->ticket->get_ticket_subtotal(); |
|
216 | + $this->ticket_bundle = false; |
|
217 | + $ticket_min = $this->ticket->min(); |
|
218 | + // for ticket bundles, set min and max qty the same |
|
219 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
220 | + $this->ticket_price *= $ticket_min; |
|
221 | + $this->ticket_bundle = true; |
|
222 | + } |
|
223 | + $this->ticket_price = apply_filters( |
|
224 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
225 | + $this->ticket_price, |
|
226 | + $this->ticket |
|
227 | + ); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * ticketNameTableCell |
|
233 | + * |
|
234 | + * @return string |
|
235 | + * @throws EE_Error |
|
236 | + * @throws ReflectionException |
|
237 | + */ |
|
238 | + protected function ticketNameTableCell() |
|
239 | + { |
|
240 | + $html = EEH_HTML::td( |
|
241 | + '', |
|
242 | + '', |
|
243 | + 'tckt-slctr-tbl-td-name', |
|
244 | + '', |
|
245 | + 'headers="details-' . $this->EVT_ID . '"' |
|
246 | + ); |
|
247 | + $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
248 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
249 | + if ($this->ticket->required()) { |
|
250 | + $html .= EEH_HTML::p( |
|
251 | + apply_filters( |
|
252 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
253 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
254 | + ), |
|
255 | + '', |
|
256 | + 'ticket-required-pg' |
|
257 | + ); |
|
258 | + } |
|
259 | + $html .= EEH_HTML::tdx(); |
|
260 | + return $html; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * ticketPriceTableCell |
|
266 | + * |
|
267 | + * @return string |
|
268 | + * @throws EE_Error |
|
269 | + */ |
|
270 | + protected function ticketPriceTableCell() |
|
271 | + { |
|
272 | + $html = ''; |
|
273 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
274 | + $html .= EEH_HTML::td( |
|
275 | + '', |
|
276 | + '', |
|
277 | + 'tckt-slctr-tbl-td-price jst-rght', |
|
278 | + '', |
|
279 | + 'headers="price-' . $this->EVT_ID . '"' |
|
280 | + ); |
|
281 | + $html .= EEH_Template::format_currency($this->ticket_price); |
|
282 | + $html .= $this->ticket->taxable() |
|
283 | + ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
284 | + : ''; |
|
285 | + $html .= ' '; |
|
286 | + // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
287 | + $html .= EEH_HTML::span( |
|
288 | + $this->ticket_bundle |
|
289 | + ? apply_filters( |
|
290 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
291 | + esc_html__(' / bundle', 'event_espresso') |
|
292 | + ) |
|
293 | + : apply_filters( |
|
294 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
295 | + esc_html__('', 'event_espresso') |
|
296 | + ), |
|
297 | + '', |
|
298 | + 'smaller-text no-bold' |
|
299 | + ); |
|
300 | + $html .= ' '; |
|
301 | + $html .= EEH_HTML::tdx(); |
|
302 | + $this->cols++; |
|
303 | + } |
|
304 | + return $html; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * onlyOneAttendeeCanRegister |
|
310 | + * |
|
311 | + * @return string |
|
312 | + * @throws EE_Error |
|
313 | + */ |
|
314 | + protected function onlyOneAttendeeCanRegister() |
|
315 | + { |
|
316 | + $this->hidden_input_qty = false; |
|
317 | + // display submit button since we have tickets available |
|
318 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
319 | + |
|
320 | + $TKT = $this->ticket->ID(); |
|
321 | + $label = esc_html__('Select this ticket', 'event_espresso'); |
|
322 | + $name = "tkt-slctr-qty-{$this->EVT_ID}"; |
|
323 | + $class = "ticket-selector-tbl-qty-slct"; |
|
324 | + $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
325 | + $checked = $this->total_tickets === 1 ? ' checked' : ''; |
|
326 | + |
|
327 | + $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
328 | + $html .= "<input type='radio'{$checked} name='{$name}' id='{$id}' class='{$class}' value='{$TKT}-1' title='' />"; |
|
329 | + return $html; |
|
330 | + } |
|
331 | + |
|
332 | + |
|
333 | + /** |
|
334 | + * ticketQuantitySelector |
|
335 | + * |
|
336 | + * @return string |
|
337 | + * @throws EE_Error |
|
338 | + */ |
|
339 | + protected function ticketQuantitySelector() |
|
340 | + { |
|
341 | + $this->hidden_input_qty = false; |
|
342 | + // display submit button since we have tickets available |
|
343 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
344 | + |
|
345 | + $TKT = $this->ticket->ID(); |
|
346 | + $label = esc_html__('Quantity', 'event_espresso'); |
|
347 | + $class = 'ticket-selector-tbl-qty-slct'; |
|
348 | + $id = "{$class}-{$this->EVT_ID}-{$this->row}"; |
|
349 | + |
|
350 | + $html = "<label class='ee-a11y-screen-reader-text' for='{$id}' >{$label}</label>"; |
|
351 | + $html .= "<select name='tkt-slctr-qty-{$this->EVT_ID}[{$TKT}]' id='{$id}' class='{$class}'>"; |
|
352 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
353 | + if ($this->min !== 0 && ! $this->ticket->required()) { |
|
354 | + $html .= "<option value='0'> 0 </option>"; |
|
355 | + } |
|
356 | + // offer ticket quantities from the min to the max |
|
357 | + for ($i = $this->min; $i <= $this->max; $i++) { |
|
358 | + $html .= "<option value='{$i}'> {$i} </option>"; |
|
359 | + } |
|
360 | + $html .= "</select>"; |
|
361 | + return $html; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * getHiddenInputs |
|
367 | + * |
|
368 | + * @return string |
|
369 | + * @throws EE_Error |
|
370 | + */ |
|
371 | + protected function ticketQtyAndIdHiddenInputs() |
|
372 | + { |
|
373 | + $html = ''; |
|
374 | + $EVT = $this->EVT_ID; |
|
375 | + $TKT = $this->ticket->ID(); |
|
376 | + // depending on group reg we need to change the format for qty |
|
377 | + if ($this->hidden_input_qty) { |
|
378 | + $html .= "<input type='hidden' name='tkt-slctr-qty-{$EVT}[]' value='0' />"; |
|
379 | + } |
|
380 | + $html .= "<input type='hidden' name='tkt-slctr-ticket-id-{$EVT}[]' value='{$TKT}' />"; |
|
381 | + return $html; |
|
382 | + } |
|
383 | 383 | } |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | </th> |
36 | 36 | <td> |
37 | 37 | <?php |
38 | - if ($payment_log->object() instanceof EE_Transaction) { |
|
39 | - esc_html_e('Unknown', 'event_espresso'); |
|
40 | - } else { |
|
41 | - echo ($payment_method |
|
42 | - ? esc_html($payment_method->admin_name()) |
|
43 | - : esc_html__("No Longer Exists", 'event_espresso')); |
|
44 | - } |
|
45 | - ?> |
|
38 | + if ($payment_log->object() instanceof EE_Transaction) { |
|
39 | + esc_html_e('Unknown', 'event_espresso'); |
|
40 | + } else { |
|
41 | + echo ($payment_method |
|
42 | + ? esc_html($payment_method->admin_name()) |
|
43 | + : esc_html__("No Longer Exists", 'event_espresso')); |
|
44 | + } |
|
45 | + ?> |
|
46 | 46 | </td> |
47 | 47 | </tr> |
48 | 48 | <tr> |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | </th> |
54 | 54 | <td> |
55 | 55 | <?php echo ($transaction |
56 | - ? absint($transaction->ID()) |
|
57 | - : esc_html__('Could not be determined', 'event_espresso')); ?> |
|
56 | + ? absint($transaction->ID()) |
|
57 | + : esc_html__('Could not be determined', 'event_espresso')); ?> |
|
58 | 58 | </td> |
59 | 59 | </tr> |
60 | 60 | <tr> |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.013'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.013'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | \ No newline at end of file |
@@ -17,783 +17,783 @@ |
||
17 | 17 | class EE_Transaction_Shortcodes extends EE_Shortcodes |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var EE_Payment_Method $_invoice_pm the invoice payment method for use in invoices etc |
|
22 | - */ |
|
23 | - protected $_invoice_pm; |
|
24 | - |
|
25 | - |
|
26 | - protected function _init_props() |
|
27 | - { |
|
28 | - $this->label = esc_html__('Transaction Shortcodes', 'event_espresso'); |
|
29 | - $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso'); |
|
30 | - $this->_shortcodes = array( |
|
31 | - '[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'), |
|
32 | - '[PAYMENT_URL]' => esc_html__( |
|
33 | - 'This is a link to make a payment for the event', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__( |
|
37 | - 'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', |
|
38 | - 'event_espresso' |
|
39 | - ) |
|
40 | - . '<ul>' |
|
41 | - . '<li>' |
|
42 | - . sprintf( |
|
43 | - esc_html__( |
|
44 | - '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - '<strong>', |
|
48 | - '</strong>' |
|
49 | - ) |
|
50 | - . '</li>' |
|
51 | - . '<li>' |
|
52 | - . sprintf( |
|
53 | - esc_html__( |
|
54 | - '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', |
|
55 | - 'event_espresso' |
|
56 | - ), |
|
57 | - '<strong>', |
|
58 | - '</strong>' |
|
59 | - ) |
|
60 | - . '</li>' |
|
61 | - . '<li>' |
|
62 | - . sprintf( |
|
63 | - esc_html__( |
|
64 | - '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - '<strong>', |
|
68 | - '</strong>' |
|
69 | - ) |
|
70 | - . '</li>' |
|
71 | - . '</ul>', |
|
72 | - '[PAYMENT_DUE_DATE_*]' => esc_html__( |
|
73 | - 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', |
|
74 | - 'event_espresso' |
|
75 | - ) |
|
76 | - . '<ul>' |
|
77 | - . '<li>' |
|
78 | - . sprintf( |
|
79 | - esc_html__( |
|
80 | - '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - '<strong>', |
|
84 | - '</strong>' |
|
85 | - ) |
|
86 | - . '</li>' |
|
87 | - . '<li>' |
|
88 | - . sprintf( |
|
89 | - esc_html__( |
|
90 | - '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', |
|
91 | - 'event_espresso' |
|
92 | - ), |
|
93 | - '<strong>', |
|
94 | - '</strong>' |
|
95 | - ) |
|
96 | - . '</li>' |
|
97 | - . '<li>' |
|
98 | - . sprintf( |
|
99 | - esc_html__( |
|
100 | - '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', |
|
101 | - 'event_espresso' |
|
102 | - ), |
|
103 | - '<strong>', |
|
104 | - '</strong>' |
|
105 | - ) |
|
106 | - . '</li>', |
|
107 | - '[INVOICE_LINK]' => esc_html__( |
|
108 | - 'This is a full html link to the invoice', |
|
109 | - 'event_espresso' |
|
110 | - ), |
|
111 | - '[INVOICE_URL]' => esc_html__( |
|
112 | - 'This is just the url for the invoice', |
|
113 | - 'event_espresso' |
|
114 | - ), |
|
115 | - '[INVOICE_LOGO_URL]' => esc_html__( |
|
116 | - 'This returns the url for the logo uploaded via the invoice settings page.', |
|
117 | - 'event_espresso' |
|
118 | - ), |
|
119 | - '[INVOICE_LOGO]' => esc_html__( |
|
120 | - 'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', |
|
121 | - 'event_espresso' |
|
122 | - ), |
|
123 | - '[INVOICE_PAYEE_NAME]' => esc_html__( |
|
124 | - 'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', |
|
125 | - 'event_espresso' |
|
126 | - ), |
|
127 | - '[INVOICE_PAYEE_ADDRESS]' => esc_html__( |
|
128 | - 'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', |
|
129 | - 'event_espresso' |
|
130 | - ), |
|
131 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__( |
|
132 | - 'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', |
|
133 | - 'event_espresso' |
|
134 | - ), |
|
135 | - '[INVOICE_PAYEE_EMAIL]' => esc_html__( |
|
136 | - 'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', |
|
137 | - 'event_espresso' |
|
138 | - ), |
|
139 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( |
|
140 | - esc_html__( |
|
141 | - 'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', |
|
142 | - 'event_espresso' |
|
143 | - ), |
|
144 | - '<code>', |
|
145 | - '</code>' |
|
146 | - ), |
|
147 | - '[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'), |
|
148 | - '[TXN_STATUS]' => esc_html__( |
|
149 | - 'The transaction status for the transaction.', |
|
150 | - 'event_espresso' |
|
151 | - ), |
|
152 | - '[TXN_STATUS_ID]' => esc_html__( |
|
153 | - 'The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', |
|
154 | - 'event_espresso' |
|
155 | - ), |
|
156 | - '[PAYMENT_STATUS]' => esc_html__( |
|
157 | - 'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', |
|
158 | - 'event_espresso' |
|
159 | - ), |
|
160 | - '[PAYMENT_GATEWAY]' => esc_html__( |
|
161 | - 'The payment gateway used for the transaction', |
|
162 | - 'event_espresso' |
|
163 | - ), |
|
164 | - '[AMOUNT_PAID]' => esc_html__( |
|
165 | - 'The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', |
|
166 | - 'event_espresso' |
|
167 | - ), |
|
168 | - '[LAST_AMOUNT_PAID]' => esc_html__( |
|
169 | - 'This is the last payment or refund made on the transaction related to the message being generated.', |
|
170 | - 'event_espresso' |
|
171 | - ), |
|
172 | - '[TOTAL_AMOUNT_PAID]' => esc_html__( |
|
173 | - 'This parses to the total amount paid over all payments', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - '[TOTAL_OWING]' => esc_html__( |
|
177 | - 'The total owing on a transaction with no attributes.', |
|
178 | - 'event_espresso' |
|
179 | - ), |
|
180 | - '[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'), |
|
181 | - '[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'), |
|
182 | - '[OWING_STATUS_MESSAGE_*]' => esc_html__( |
|
183 | - 'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', |
|
184 | - 'event_espresso' |
|
185 | - ) |
|
186 | - . '<p></ul>' |
|
187 | - . '<li><strong>still_owing</strong>:' |
|
188 | - . esc_html__( |
|
189 | - 'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', |
|
190 | - 'event_espresso' |
|
191 | - ) |
|
192 | - . sprintf( |
|
193 | - esc_html__('%sPlease make a payment.%s', 'event_espresso'), |
|
194 | - '<a href="[PAYMENT_URL]" class="noPrint">', |
|
195 | - '</a>' |
|
196 | - ) |
|
197 | - . '</li>' |
|
198 | - . |
|
199 | - '<li><strong>none_owing</strong>:' |
|
200 | - . esc_html__( |
|
201 | - 'If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', |
|
202 | - 'event_espresso' |
|
203 | - ) |
|
204 | - . '</li></ul></p>', |
|
205 | - '[TXN_TOTAL_TICKETS]' => esc_html__( |
|
206 | - 'The total number of all tickets purchased in a transaction', |
|
207 | - 'event_espresso' |
|
208 | - ), |
|
209 | - '[TKT_QTY_PURCHASED]' => sprintf( |
|
210 | - esc_html__( |
|
211 | - 'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', |
|
212 | - 'event_espresso' |
|
213 | - ), |
|
214 | - '<strong>', |
|
215 | - '</strong>' |
|
216 | - ), |
|
217 | - '[TRANSACTION_ADMIN_URL]' => esc_html__( |
|
218 | - 'The url to the admin page for this transaction', |
|
219 | - 'event_espresso' |
|
220 | - ), |
|
221 | - '[RECEIPT_URL]' => esc_html__( |
|
222 | - 'This parses to the generated url for retrieving the receipt for the transaction', |
|
223 | - 'event_espresso' |
|
224 | - ), |
|
225 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( |
|
226 | - 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', |
|
227 | - 'event_espresso' |
|
228 | - ), |
|
229 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( |
|
230 | - esc_html__( |
|
231 | - 'The same as %1$s%2$s except this returns the html for a button linked to the invoice or receipt.', |
|
232 | - 'event_espresso' |
|
233 | - ), |
|
234 | - '<code>[INVOICE_RECEIPT_SWITCHER_URL]', |
|
235 | - '</code>' |
|
236 | - ), |
|
237 | - '[LAST_PAYMENT_TRANSACTION_ID]' => esc_html__( |
|
238 | - 'This will output the value of the payment transaction id for the last payment made on the transaction. Note, if a specific payment was included for message generation, that will be used when parsing the shortcode.', |
|
239 | - 'event_espresso' |
|
240 | - ), |
|
241 | - ); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @param string $shortcode the shortcode to be parsed. |
|
247 | - * @return string parsed shortcode |
|
248 | - * @throws EE_Error |
|
249 | - * @throws InvalidArgumentException |
|
250 | - * @throws ReflectionException |
|
251 | - * @throws InvalidDataTypeException |
|
252 | - * @throws InvalidInterfaceException |
|
253 | - */ |
|
254 | - protected function _parser($shortcode) |
|
255 | - { |
|
256 | - // attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the |
|
257 | - // _extra_data for the transaction. |
|
258 | - $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
|
259 | - $transaction = ! $transaction instanceof EE_Transaction |
|
260 | - && is_array($this->_extra_data) |
|
261 | - && isset($this->_extra_data['data']) |
|
262 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
263 | - ? $this->_extra_data['data']->txn |
|
264 | - : $transaction; |
|
265 | - // payment |
|
266 | - $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
|
267 | - $payment = ! $payment instanceof EE_Payment |
|
268 | - && is_array($this->_extra_data) |
|
269 | - && isset($this->_extra_data['data']) |
|
270 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment |
|
271 | - : $payment; |
|
272 | - if (! $transaction instanceof EE_Transaction) { |
|
273 | - return ''; |
|
274 | - } |
|
275 | - switch ($shortcode) { |
|
276 | - case '[TXN_ID]': |
|
277 | - return $transaction->ID(); |
|
278 | - break; |
|
279 | - case '[PAYMENT_URL]': |
|
280 | - $payment_url = $transaction->payment_overview_url(); |
|
281 | - return empty($payment_url) |
|
282 | - ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') |
|
283 | - : $payment_url; |
|
284 | - break; |
|
285 | - case '[INVOICE_LINK]': |
|
286 | - $invoice_url = $transaction->invoice_url(); |
|
287 | - $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
288 | - return sprintf( |
|
289 | - esc_html__('%sClick here for Invoice%s', 'event_espresso'), |
|
290 | - '<a href="' . $invoice_url . '">', |
|
291 | - '</a>' |
|
292 | - ); |
|
293 | - break; |
|
294 | - case '[INVOICE_URL]': |
|
295 | - $invoice_url = $transaction->invoice_url(); |
|
296 | - return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
297 | - break; |
|
298 | - case '[INVOICE_LOGO_URL]': |
|
299 | - return $this->_get_invoice_logo(); |
|
300 | - break; |
|
301 | - case '[INVOICE_LOGO]': |
|
302 | - return $this->_get_invoice_logo(true); |
|
303 | - break; |
|
304 | - case '[INVOICE_PAYEE_NAME]': |
|
305 | - return $this->_get_invoice_payee_name(); |
|
306 | - break; |
|
307 | - case '[INVOICE_PAYEE_ADDRESS]': |
|
308 | - return $this->_get_invoice_payee_address(); |
|
309 | - break; |
|
310 | - case '[INVOICE_PAYMENT_INSTRUCTIONS]': |
|
311 | - return $this->_get_invoice_payment_instructions(); |
|
312 | - break; |
|
313 | - case '[INVOICE_PAYEE_EMAIL]': |
|
314 | - return $this->_get_invoice_payee_email(); |
|
315 | - break; |
|
316 | - case '[TOTAL_COST]': |
|
317 | - $total = $transaction->total(); |
|
318 | - return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
319 | - break; |
|
320 | - case '[PAYMENT_STATUS]': |
|
321 | - $status = $transaction->pretty_status(); |
|
322 | - return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
323 | - break; /**/ |
|
324 | - // note the [payment_status] shortcode is kind of misleading because payment status might be different |
|
325 | - // from txn status so I'm adding this here for clarity. |
|
326 | - case '[TXN_STATUS]': |
|
327 | - $status = $transaction->pretty_status(); |
|
328 | - return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
329 | - break; |
|
330 | - case '[TXN_STATUS_ID]': |
|
331 | - return $transaction->status_ID(); |
|
332 | - break; |
|
333 | - case '[PAYMENT_GATEWAY]': |
|
334 | - return $this->_get_payment_gateway($transaction); |
|
335 | - break; |
|
336 | - case '[AMOUNT_PAID]': |
|
337 | - return $payment instanceof EE_Payment |
|
338 | - ? EEH_Template::format_currency($payment->amount()) |
|
339 | - : EEH_Template::format_currency(0); |
|
340 | - break; |
|
341 | - case '[LAST_AMOUNT_PAID]': |
|
342 | - $last_payment = $transaction->last_payment(); |
|
343 | - return $last_payment instanceof EE_Payment |
|
344 | - ? EEH_Template::format_currency($last_payment->amount()) |
|
345 | - : EEH_Template::format_currency(0); |
|
346 | - case '[TOTAL_AMOUNT_PAID]': |
|
347 | - return EEH_Template::format_currency($transaction->paid()); |
|
348 | - break; |
|
349 | - case '[TOTAL_OWING]': |
|
350 | - $total_owing = $transaction->remaining(); |
|
351 | - return EEH_Template::format_currency($total_owing); |
|
352 | - break; |
|
353 | - case '[TXN_SUBTOTAL]': |
|
354 | - return EEH_Template::format_currency($this->_get_subtotal()); |
|
355 | - break; |
|
356 | - case '[TXN_TAX_SUBTOTAL]': |
|
357 | - return EEH_Template::format_currency($this->_get_subtotal(true)); |
|
358 | - break; |
|
359 | - case '[TKT_QTY_PURCHASED]': |
|
360 | - case '[TXN_TOTAL_TICKETS]': |
|
361 | - return $this->_data->total_ticket_count; |
|
362 | - break; |
|
363 | - case '[TRANSACTION_ADMIN_URL]': |
|
364 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
365 | - $query_args = array( |
|
366 | - 'page' => 'espresso_transactions', |
|
367 | - 'action' => 'view_transaction', |
|
368 | - 'TXN_ID' => $transaction->ID(), |
|
369 | - ); |
|
370 | - $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
371 | - return $url; |
|
372 | - break; |
|
373 | - case '[RECEIPT_URL]': |
|
374 | - // get primary_registration |
|
375 | - $reg = $this->_data->primary_reg_obj; |
|
376 | - if (! $reg instanceof EE_Registration) { |
|
377 | - return ''; |
|
378 | - } |
|
379 | - return $reg->receipt_url(); |
|
380 | - break; |
|
381 | - case '[INVOICE_RECEIPT_SWITCHER_URL]': |
|
382 | - return $this->_get_invoice_receipt_switcher(false); |
|
383 | - break; |
|
384 | - case '[INVOICE_RECEIPT_SWITCHER_BUTTON]': |
|
385 | - return $this->_get_invoice_receipt_switcher(); |
|
386 | - break; |
|
387 | - case '[LAST_PAYMENT_TRANSACTION_ID]': |
|
388 | - $id = ''; |
|
389 | - $payment = $payment instanceof EE_Payment && $payment->ID() !== 0 |
|
390 | - ? $payment |
|
391 | - : $transaction->last_payment(); |
|
392 | - if ($payment instanceof EE_Payment) { |
|
393 | - $id = $payment->txn_id_chq_nmbr(); |
|
394 | - } |
|
395 | - return $id; |
|
396 | - break; |
|
397 | - } |
|
398 | - if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) { |
|
399 | - return $this->_get_custom_total_owing($shortcode); |
|
400 | - } |
|
401 | - if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) { |
|
402 | - return $this->_get_invoice_payee_tax_number($shortcode); |
|
403 | - } |
|
404 | - if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) { |
|
405 | - return $this->_get_payment_link_if_needed($shortcode); |
|
406 | - } |
|
407 | - if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
408 | - return $this->_get_payment_due_date($shortcode, $transaction); |
|
409 | - } |
|
410 | - return ''; |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode |
|
416 | - * |
|
417 | - * @since 4.5.0 |
|
418 | - * @param string $shortcode the incoming shortcode |
|
419 | - * @return string parsed. |
|
420 | - * @throws EE_Error |
|
421 | - */ |
|
422 | - private function _get_custom_total_owing($shortcode) |
|
423 | - { |
|
424 | - $valid_shortcodes = array('transaction'); |
|
425 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
426 | - // ensure default is set. |
|
427 | - $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
428 | - $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction |
|
429 | - ? $addressee->txn->remaining() : 0; |
|
430 | - if ($total_owing > 0) { |
|
431 | - $owing_content = ! empty($attrs['still_owing']) |
|
432 | - ? $attrs['still_owing'] |
|
433 | - : sprintf( |
|
434 | - esc_html__('%sPlease make a payment.%s', 'event_espresso'), |
|
435 | - '<a href="[PAYMENT_URL]" class="noPrint">', |
|
436 | - '</a>' |
|
437 | - ); |
|
438 | - $owing_content = $this->_shortcode_helper->parse_message_template( |
|
439 | - $owing_content, |
|
440 | - $addressee, |
|
441 | - $valid_shortcodes, |
|
442 | - $this->_message_type, |
|
443 | - $this->_messenger, |
|
444 | - $this->_message |
|
445 | - ); |
|
446 | - } else { |
|
447 | - $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
448 | - } |
|
449 | - return $owing_content; |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * @param EE_Transaction $transaction |
|
455 | - * @return string |
|
456 | - * @throws EE_Error |
|
457 | - */ |
|
458 | - private function _get_payment_gateway($transaction) |
|
459 | - { |
|
460 | - if ($transaction instanceof EE_Transaction) { |
|
461 | - $pm = $transaction->payment_method(); |
|
462 | - } else { |
|
463 | - $pm = null; |
|
464 | - } |
|
465 | - return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
|
466 | - } |
|
467 | - |
|
468 | - |
|
469 | - /** |
|
470 | - * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page. If its |
|
471 | - * not present then the organization logo is used if its found (set on the organization settings page). |
|
472 | - * |
|
473 | - * @since 4.5.0 |
|
474 | - * @param bool $img_tags TRUE means to return with the img tag wrappers. False just returns the url to the image. |
|
475 | - * @return string url or html |
|
476 | - * @throws EE_Error |
|
477 | - * @throws InvalidArgumentException |
|
478 | - * @throws InvalidDataTypeException |
|
479 | - * @throws InvalidInterfaceException |
|
480 | - */ |
|
481 | - private function _get_invoice_logo($img_tags = false) |
|
482 | - { |
|
483 | - $invoice_logo_url = ''; |
|
484 | - // try to get the invoice payment method's logo for this transaction image first |
|
485 | - $pm = $this->_get_invoice_payment_method(); |
|
486 | - if ($pm instanceof EE_Payment_Method) { |
|
487 | - $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true); |
|
488 | - } |
|
489 | - if (empty($invoice_logo_url)) { |
|
490 | - $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
|
491 | - } |
|
492 | - if (empty($invoice_logo_url)) { |
|
493 | - return ''; |
|
494 | - } |
|
495 | - if (! $img_tags) { |
|
496 | - return $invoice_logo_url; |
|
497 | - } |
|
498 | - // image tags have been requested. |
|
499 | - $image_size = getimagesize($invoice_logo_url); |
|
500 | - // if image is wider than 300px, set the width to 300 |
|
501 | - if ($image_size[0] > 300) { |
|
502 | - $image_width = 300; |
|
503 | - } else { |
|
504 | - $image_width = $image_size[0]; |
|
505 | - } |
|
506 | - return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />'; |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - /** |
|
511 | - * Used to retrieve the appropriate content for the invoice payee name shortcode |
|
512 | - * |
|
513 | - * @since 4.5.0 |
|
514 | - * @return string |
|
515 | - * @throws EE_Error |
|
516 | - * @throws InvalidArgumentException |
|
517 | - * @throws InvalidDataTypeException |
|
518 | - * @throws InvalidInterfaceException |
|
519 | - */ |
|
520 | - private function _get_invoice_payee_name() |
|
521 | - { |
|
522 | - $payee_name = null; |
|
523 | - $pm = $this->_get_invoice_payment_method(); |
|
524 | - if ($pm instanceof EE_Payment_Method) { |
|
525 | - $payee_name = $pm->get_extra_meta('pdf_payee_name', true); |
|
526 | - } |
|
527 | - $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
528 | - return $payee_name; |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * gets the default invoice payment method, but has a filter so it can be overridden |
|
534 | - * |
|
535 | - * @return EE_Payment_Method|null |
|
536 | - * @throws EE_Error |
|
537 | - * @throws InvalidArgumentException |
|
538 | - * @throws InvalidDataTypeException |
|
539 | - * @throws InvalidInterfaceException |
|
540 | - */ |
|
541 | - private function _get_invoice_payment_method() |
|
542 | - { |
|
543 | - if (! $this->_invoice_pm instanceof EE_Payment_Method) { |
|
544 | - $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
|
545 | - $transaction = ! $transaction instanceof EE_Transaction |
|
546 | - && is_array($this->_extra_data) |
|
547 | - && isset($this->_extra_data['data']) |
|
548 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
549 | - ? $this->_extra_data['data']->txn : $transaction; |
|
550 | - // get the invoice payment method, and remember it for the next call too |
|
551 | - $this->_invoice_pm = apply_filters( |
|
552 | - 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', |
|
553 | - EEM_Payment_Method::instance()->get_one_of_type('Invoice'), |
|
554 | - $transaction |
|
555 | - ); |
|
556 | - } |
|
557 | - return $this->_invoice_pm; |
|
558 | - } |
|
559 | - |
|
560 | - |
|
561 | - /** |
|
562 | - * Used to retrieve the appropriate content for the invoice payee email shortcode |
|
563 | - * |
|
564 | - * @since 4.5.0 |
|
565 | - * @return string |
|
566 | - * @throws EE_Error |
|
567 | - * @throws InvalidArgumentException |
|
568 | - * @throws InvalidDataTypeException |
|
569 | - * @throws InvalidInterfaceException |
|
570 | - */ |
|
571 | - private function _get_invoice_payee_email() |
|
572 | - { |
|
573 | - $payee_email = null; |
|
574 | - $pm = $this->_get_invoice_payment_method(); |
|
575 | - if ($pm instanceof EE_Payment_Method) { |
|
576 | - $payee_email = $pm->get_extra_meta('pdf_payee_email', true); |
|
577 | - } |
|
578 | - $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
579 | - : $payee_email; |
|
580 | - return $payee_email; |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * Used to retrieve the appropriate content for the invoice payee tax number shortcode |
|
586 | - * |
|
587 | - * @since 4.5.0 |
|
588 | - * @param string $shortcode |
|
589 | - * @return string |
|
590 | - * @throws EE_Error |
|
591 | - * @throws InvalidArgumentException |
|
592 | - * @throws InvalidDataTypeException |
|
593 | - * @throws InvalidInterfaceException |
|
594 | - */ |
|
595 | - private function _get_invoice_payee_tax_number($shortcode) |
|
596 | - { |
|
597 | - $payee_tax_number = null; |
|
598 | - $pm = $this->_get_invoice_payment_method(); |
|
599 | - if ($pm instanceof EE_Payment_Method) { |
|
600 | - $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true); |
|
601 | - } |
|
602 | - $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat |
|
603 | - : $payee_tax_number; |
|
604 | - if (empty($payee_tax_number)) { |
|
605 | - return ''; |
|
606 | - } |
|
607 | - // any attributes? |
|
608 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
609 | - // prefix? |
|
610 | - $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
611 | - return $prefix . $payee_tax_number; |
|
612 | - } |
|
613 | - |
|
614 | - |
|
615 | - /** |
|
616 | - * Used to retrieve the appropriate content for the invoice payee address shortcode. |
|
617 | - * |
|
618 | - * @since 4.5.0 |
|
619 | - * @return string |
|
620 | - * @throws EE_Error |
|
621 | - * @throws InvalidArgumentException |
|
622 | - * @throws ReflectionException |
|
623 | - * @throws InvalidDataTypeException |
|
624 | - * @throws InvalidInterfaceException |
|
625 | - */ |
|
626 | - private function _get_invoice_payee_address() |
|
627 | - { |
|
628 | - $payee_address = null; |
|
629 | - $pm = $this->_get_invoice_payment_method(); |
|
630 | - if ($pm instanceof EE_Payment_Method) { |
|
631 | - $payee_address = $pm->get_extra_meta('pdf_payee_address', true); |
|
632 | - } |
|
633 | - if (empty($payee_address)) { |
|
634 | - $organization = EE_Registry::instance()->CFG->organization; |
|
635 | - $payee_address = $organization->get_pretty('address_1') . '<br>'; |
|
636 | - $payee_address .= ! empty($organization->address_2) |
|
637 | - ? $organization->get_pretty('address_2') . '<br>' |
|
638 | - : ''; |
|
639 | - $payee_address .= $organization->get_pretty('city') . '<br>'; |
|
640 | - // state |
|
641 | - $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
642 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
643 | - // Country |
|
644 | - $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
645 | - $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
646 | - } |
|
647 | - return $payee_address; |
|
648 | - } |
|
649 | - |
|
650 | - |
|
651 | - /** |
|
652 | - * Used to retrieve the appropriate content for the invoice payment instructions shortcode. |
|
653 | - * |
|
654 | - * @since 4.5.0 |
|
655 | - * @return string |
|
656 | - * @throws EE_Error |
|
657 | - * @throws InvalidArgumentException |
|
658 | - * @throws InvalidDataTypeException |
|
659 | - * @throws InvalidInterfaceException |
|
660 | - */ |
|
661 | - private function _get_invoice_payment_instructions() |
|
662 | - { |
|
663 | - $instructions = null; |
|
664 | - $pm = $this->_get_invoice_payment_method(); |
|
665 | - return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : ''; |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - /** |
|
670 | - * get invoice/receipt switch button or url. |
|
671 | - * |
|
672 | - * @param bool $button true (default) returns the html for a button, false just returns the url. |
|
673 | - * @return string |
|
674 | - * @throws EE_Error |
|
675 | - */ |
|
676 | - protected function _get_invoice_receipt_switcher($button = true) |
|
677 | - { |
|
678 | - $reg = $this->_data->primary_reg_obj; |
|
679 | - $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
680 | - if (! $reg instanceof EE_Registration || empty($message_type)) { |
|
681 | - return ''; |
|
682 | - } |
|
683 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
684 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type |
|
685 | - ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
|
686 | - $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
687 | - $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
|
688 | - if (! $button) { |
|
689 | - return $switch_to_url; |
|
690 | - } |
|
691 | - if (! empty($switch_to_url)) { |
|
692 | - return ' |
|
20 | + /** |
|
21 | + * @var EE_Payment_Method $_invoice_pm the invoice payment method for use in invoices etc |
|
22 | + */ |
|
23 | + protected $_invoice_pm; |
|
24 | + |
|
25 | + |
|
26 | + protected function _init_props() |
|
27 | + { |
|
28 | + $this->label = esc_html__('Transaction Shortcodes', 'event_espresso'); |
|
29 | + $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso'); |
|
30 | + $this->_shortcodes = array( |
|
31 | + '[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'), |
|
32 | + '[PAYMENT_URL]' => esc_html__( |
|
33 | + 'This is a link to make a payment for the event', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__( |
|
37 | + 'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', |
|
38 | + 'event_espresso' |
|
39 | + ) |
|
40 | + . '<ul>' |
|
41 | + . '<li>' |
|
42 | + . sprintf( |
|
43 | + esc_html__( |
|
44 | + '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + '<strong>', |
|
48 | + '</strong>' |
|
49 | + ) |
|
50 | + . '</li>' |
|
51 | + . '<li>' |
|
52 | + . sprintf( |
|
53 | + esc_html__( |
|
54 | + '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', |
|
55 | + 'event_espresso' |
|
56 | + ), |
|
57 | + '<strong>', |
|
58 | + '</strong>' |
|
59 | + ) |
|
60 | + . '</li>' |
|
61 | + . '<li>' |
|
62 | + . sprintf( |
|
63 | + esc_html__( |
|
64 | + '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', |
|
65 | + 'event_espresso' |
|
66 | + ), |
|
67 | + '<strong>', |
|
68 | + '</strong>' |
|
69 | + ) |
|
70 | + . '</li>' |
|
71 | + . '</ul>', |
|
72 | + '[PAYMENT_DUE_DATE_*]' => esc_html__( |
|
73 | + 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', |
|
74 | + 'event_espresso' |
|
75 | + ) |
|
76 | + . '<ul>' |
|
77 | + . '<li>' |
|
78 | + . sprintf( |
|
79 | + esc_html__( |
|
80 | + '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + '<strong>', |
|
84 | + '</strong>' |
|
85 | + ) |
|
86 | + . '</li>' |
|
87 | + . '<li>' |
|
88 | + . sprintf( |
|
89 | + esc_html__( |
|
90 | + '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', |
|
91 | + 'event_espresso' |
|
92 | + ), |
|
93 | + '<strong>', |
|
94 | + '</strong>' |
|
95 | + ) |
|
96 | + . '</li>' |
|
97 | + . '<li>' |
|
98 | + . sprintf( |
|
99 | + esc_html__( |
|
100 | + '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', |
|
101 | + 'event_espresso' |
|
102 | + ), |
|
103 | + '<strong>', |
|
104 | + '</strong>' |
|
105 | + ) |
|
106 | + . '</li>', |
|
107 | + '[INVOICE_LINK]' => esc_html__( |
|
108 | + 'This is a full html link to the invoice', |
|
109 | + 'event_espresso' |
|
110 | + ), |
|
111 | + '[INVOICE_URL]' => esc_html__( |
|
112 | + 'This is just the url for the invoice', |
|
113 | + 'event_espresso' |
|
114 | + ), |
|
115 | + '[INVOICE_LOGO_URL]' => esc_html__( |
|
116 | + 'This returns the url for the logo uploaded via the invoice settings page.', |
|
117 | + 'event_espresso' |
|
118 | + ), |
|
119 | + '[INVOICE_LOGO]' => esc_html__( |
|
120 | + 'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', |
|
121 | + 'event_espresso' |
|
122 | + ), |
|
123 | + '[INVOICE_PAYEE_NAME]' => esc_html__( |
|
124 | + 'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', |
|
125 | + 'event_espresso' |
|
126 | + ), |
|
127 | + '[INVOICE_PAYEE_ADDRESS]' => esc_html__( |
|
128 | + 'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', |
|
129 | + 'event_espresso' |
|
130 | + ), |
|
131 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__( |
|
132 | + 'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', |
|
133 | + 'event_espresso' |
|
134 | + ), |
|
135 | + '[INVOICE_PAYEE_EMAIL]' => esc_html__( |
|
136 | + 'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', |
|
137 | + 'event_espresso' |
|
138 | + ), |
|
139 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( |
|
140 | + esc_html__( |
|
141 | + 'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', |
|
142 | + 'event_espresso' |
|
143 | + ), |
|
144 | + '<code>', |
|
145 | + '</code>' |
|
146 | + ), |
|
147 | + '[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'), |
|
148 | + '[TXN_STATUS]' => esc_html__( |
|
149 | + 'The transaction status for the transaction.', |
|
150 | + 'event_espresso' |
|
151 | + ), |
|
152 | + '[TXN_STATUS_ID]' => esc_html__( |
|
153 | + 'The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', |
|
154 | + 'event_espresso' |
|
155 | + ), |
|
156 | + '[PAYMENT_STATUS]' => esc_html__( |
|
157 | + 'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', |
|
158 | + 'event_espresso' |
|
159 | + ), |
|
160 | + '[PAYMENT_GATEWAY]' => esc_html__( |
|
161 | + 'The payment gateway used for the transaction', |
|
162 | + 'event_espresso' |
|
163 | + ), |
|
164 | + '[AMOUNT_PAID]' => esc_html__( |
|
165 | + 'The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', |
|
166 | + 'event_espresso' |
|
167 | + ), |
|
168 | + '[LAST_AMOUNT_PAID]' => esc_html__( |
|
169 | + 'This is the last payment or refund made on the transaction related to the message being generated.', |
|
170 | + 'event_espresso' |
|
171 | + ), |
|
172 | + '[TOTAL_AMOUNT_PAID]' => esc_html__( |
|
173 | + 'This parses to the total amount paid over all payments', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + '[TOTAL_OWING]' => esc_html__( |
|
177 | + 'The total owing on a transaction with no attributes.', |
|
178 | + 'event_espresso' |
|
179 | + ), |
|
180 | + '[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'), |
|
181 | + '[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'), |
|
182 | + '[OWING_STATUS_MESSAGE_*]' => esc_html__( |
|
183 | + 'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', |
|
184 | + 'event_espresso' |
|
185 | + ) |
|
186 | + . '<p></ul>' |
|
187 | + . '<li><strong>still_owing</strong>:' |
|
188 | + . esc_html__( |
|
189 | + 'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', |
|
190 | + 'event_espresso' |
|
191 | + ) |
|
192 | + . sprintf( |
|
193 | + esc_html__('%sPlease make a payment.%s', 'event_espresso'), |
|
194 | + '<a href="[PAYMENT_URL]" class="noPrint">', |
|
195 | + '</a>' |
|
196 | + ) |
|
197 | + . '</li>' |
|
198 | + . |
|
199 | + '<li><strong>none_owing</strong>:' |
|
200 | + . esc_html__( |
|
201 | + 'If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', |
|
202 | + 'event_espresso' |
|
203 | + ) |
|
204 | + . '</li></ul></p>', |
|
205 | + '[TXN_TOTAL_TICKETS]' => esc_html__( |
|
206 | + 'The total number of all tickets purchased in a transaction', |
|
207 | + 'event_espresso' |
|
208 | + ), |
|
209 | + '[TKT_QTY_PURCHASED]' => sprintf( |
|
210 | + esc_html__( |
|
211 | + 'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', |
|
212 | + 'event_espresso' |
|
213 | + ), |
|
214 | + '<strong>', |
|
215 | + '</strong>' |
|
216 | + ), |
|
217 | + '[TRANSACTION_ADMIN_URL]' => esc_html__( |
|
218 | + 'The url to the admin page for this transaction', |
|
219 | + 'event_espresso' |
|
220 | + ), |
|
221 | + '[RECEIPT_URL]' => esc_html__( |
|
222 | + 'This parses to the generated url for retrieving the receipt for the transaction', |
|
223 | + 'event_espresso' |
|
224 | + ), |
|
225 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( |
|
226 | + 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', |
|
227 | + 'event_espresso' |
|
228 | + ), |
|
229 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( |
|
230 | + esc_html__( |
|
231 | + 'The same as %1$s%2$s except this returns the html for a button linked to the invoice or receipt.', |
|
232 | + 'event_espresso' |
|
233 | + ), |
|
234 | + '<code>[INVOICE_RECEIPT_SWITCHER_URL]', |
|
235 | + '</code>' |
|
236 | + ), |
|
237 | + '[LAST_PAYMENT_TRANSACTION_ID]' => esc_html__( |
|
238 | + 'This will output the value of the payment transaction id for the last payment made on the transaction. Note, if a specific payment was included for message generation, that will be used when parsing the shortcode.', |
|
239 | + 'event_espresso' |
|
240 | + ), |
|
241 | + ); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @param string $shortcode the shortcode to be parsed. |
|
247 | + * @return string parsed shortcode |
|
248 | + * @throws EE_Error |
|
249 | + * @throws InvalidArgumentException |
|
250 | + * @throws ReflectionException |
|
251 | + * @throws InvalidDataTypeException |
|
252 | + * @throws InvalidInterfaceException |
|
253 | + */ |
|
254 | + protected function _parser($shortcode) |
|
255 | + { |
|
256 | + // attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the |
|
257 | + // _extra_data for the transaction. |
|
258 | + $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
|
259 | + $transaction = ! $transaction instanceof EE_Transaction |
|
260 | + && is_array($this->_extra_data) |
|
261 | + && isset($this->_extra_data['data']) |
|
262 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
263 | + ? $this->_extra_data['data']->txn |
|
264 | + : $transaction; |
|
265 | + // payment |
|
266 | + $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
|
267 | + $payment = ! $payment instanceof EE_Payment |
|
268 | + && is_array($this->_extra_data) |
|
269 | + && isset($this->_extra_data['data']) |
|
270 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment |
|
271 | + : $payment; |
|
272 | + if (! $transaction instanceof EE_Transaction) { |
|
273 | + return ''; |
|
274 | + } |
|
275 | + switch ($shortcode) { |
|
276 | + case '[TXN_ID]': |
|
277 | + return $transaction->ID(); |
|
278 | + break; |
|
279 | + case '[PAYMENT_URL]': |
|
280 | + $payment_url = $transaction->payment_overview_url(); |
|
281 | + return empty($payment_url) |
|
282 | + ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') |
|
283 | + : $payment_url; |
|
284 | + break; |
|
285 | + case '[INVOICE_LINK]': |
|
286 | + $invoice_url = $transaction->invoice_url(); |
|
287 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
288 | + return sprintf( |
|
289 | + esc_html__('%sClick here for Invoice%s', 'event_espresso'), |
|
290 | + '<a href="' . $invoice_url . '">', |
|
291 | + '</a>' |
|
292 | + ); |
|
293 | + break; |
|
294 | + case '[INVOICE_URL]': |
|
295 | + $invoice_url = $transaction->invoice_url(); |
|
296 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
297 | + break; |
|
298 | + case '[INVOICE_LOGO_URL]': |
|
299 | + return $this->_get_invoice_logo(); |
|
300 | + break; |
|
301 | + case '[INVOICE_LOGO]': |
|
302 | + return $this->_get_invoice_logo(true); |
|
303 | + break; |
|
304 | + case '[INVOICE_PAYEE_NAME]': |
|
305 | + return $this->_get_invoice_payee_name(); |
|
306 | + break; |
|
307 | + case '[INVOICE_PAYEE_ADDRESS]': |
|
308 | + return $this->_get_invoice_payee_address(); |
|
309 | + break; |
|
310 | + case '[INVOICE_PAYMENT_INSTRUCTIONS]': |
|
311 | + return $this->_get_invoice_payment_instructions(); |
|
312 | + break; |
|
313 | + case '[INVOICE_PAYEE_EMAIL]': |
|
314 | + return $this->_get_invoice_payee_email(); |
|
315 | + break; |
|
316 | + case '[TOTAL_COST]': |
|
317 | + $total = $transaction->total(); |
|
318 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
319 | + break; |
|
320 | + case '[PAYMENT_STATUS]': |
|
321 | + $status = $transaction->pretty_status(); |
|
322 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
323 | + break; /**/ |
|
324 | + // note the [payment_status] shortcode is kind of misleading because payment status might be different |
|
325 | + // from txn status so I'm adding this here for clarity. |
|
326 | + case '[TXN_STATUS]': |
|
327 | + $status = $transaction->pretty_status(); |
|
328 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
329 | + break; |
|
330 | + case '[TXN_STATUS_ID]': |
|
331 | + return $transaction->status_ID(); |
|
332 | + break; |
|
333 | + case '[PAYMENT_GATEWAY]': |
|
334 | + return $this->_get_payment_gateway($transaction); |
|
335 | + break; |
|
336 | + case '[AMOUNT_PAID]': |
|
337 | + return $payment instanceof EE_Payment |
|
338 | + ? EEH_Template::format_currency($payment->amount()) |
|
339 | + : EEH_Template::format_currency(0); |
|
340 | + break; |
|
341 | + case '[LAST_AMOUNT_PAID]': |
|
342 | + $last_payment = $transaction->last_payment(); |
|
343 | + return $last_payment instanceof EE_Payment |
|
344 | + ? EEH_Template::format_currency($last_payment->amount()) |
|
345 | + : EEH_Template::format_currency(0); |
|
346 | + case '[TOTAL_AMOUNT_PAID]': |
|
347 | + return EEH_Template::format_currency($transaction->paid()); |
|
348 | + break; |
|
349 | + case '[TOTAL_OWING]': |
|
350 | + $total_owing = $transaction->remaining(); |
|
351 | + return EEH_Template::format_currency($total_owing); |
|
352 | + break; |
|
353 | + case '[TXN_SUBTOTAL]': |
|
354 | + return EEH_Template::format_currency($this->_get_subtotal()); |
|
355 | + break; |
|
356 | + case '[TXN_TAX_SUBTOTAL]': |
|
357 | + return EEH_Template::format_currency($this->_get_subtotal(true)); |
|
358 | + break; |
|
359 | + case '[TKT_QTY_PURCHASED]': |
|
360 | + case '[TXN_TOTAL_TICKETS]': |
|
361 | + return $this->_data->total_ticket_count; |
|
362 | + break; |
|
363 | + case '[TRANSACTION_ADMIN_URL]': |
|
364 | + require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
365 | + $query_args = array( |
|
366 | + 'page' => 'espresso_transactions', |
|
367 | + 'action' => 'view_transaction', |
|
368 | + 'TXN_ID' => $transaction->ID(), |
|
369 | + ); |
|
370 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
371 | + return $url; |
|
372 | + break; |
|
373 | + case '[RECEIPT_URL]': |
|
374 | + // get primary_registration |
|
375 | + $reg = $this->_data->primary_reg_obj; |
|
376 | + if (! $reg instanceof EE_Registration) { |
|
377 | + return ''; |
|
378 | + } |
|
379 | + return $reg->receipt_url(); |
|
380 | + break; |
|
381 | + case '[INVOICE_RECEIPT_SWITCHER_URL]': |
|
382 | + return $this->_get_invoice_receipt_switcher(false); |
|
383 | + break; |
|
384 | + case '[INVOICE_RECEIPT_SWITCHER_BUTTON]': |
|
385 | + return $this->_get_invoice_receipt_switcher(); |
|
386 | + break; |
|
387 | + case '[LAST_PAYMENT_TRANSACTION_ID]': |
|
388 | + $id = ''; |
|
389 | + $payment = $payment instanceof EE_Payment && $payment->ID() !== 0 |
|
390 | + ? $payment |
|
391 | + : $transaction->last_payment(); |
|
392 | + if ($payment instanceof EE_Payment) { |
|
393 | + $id = $payment->txn_id_chq_nmbr(); |
|
394 | + } |
|
395 | + return $id; |
|
396 | + break; |
|
397 | + } |
|
398 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) { |
|
399 | + return $this->_get_custom_total_owing($shortcode); |
|
400 | + } |
|
401 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) { |
|
402 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
403 | + } |
|
404 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) { |
|
405 | + return $this->_get_payment_link_if_needed($shortcode); |
|
406 | + } |
|
407 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
408 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
409 | + } |
|
410 | + return ''; |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode |
|
416 | + * |
|
417 | + * @since 4.5.0 |
|
418 | + * @param string $shortcode the incoming shortcode |
|
419 | + * @return string parsed. |
|
420 | + * @throws EE_Error |
|
421 | + */ |
|
422 | + private function _get_custom_total_owing($shortcode) |
|
423 | + { |
|
424 | + $valid_shortcodes = array('transaction'); |
|
425 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
426 | + // ensure default is set. |
|
427 | + $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
428 | + $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction |
|
429 | + ? $addressee->txn->remaining() : 0; |
|
430 | + if ($total_owing > 0) { |
|
431 | + $owing_content = ! empty($attrs['still_owing']) |
|
432 | + ? $attrs['still_owing'] |
|
433 | + : sprintf( |
|
434 | + esc_html__('%sPlease make a payment.%s', 'event_espresso'), |
|
435 | + '<a href="[PAYMENT_URL]" class="noPrint">', |
|
436 | + '</a>' |
|
437 | + ); |
|
438 | + $owing_content = $this->_shortcode_helper->parse_message_template( |
|
439 | + $owing_content, |
|
440 | + $addressee, |
|
441 | + $valid_shortcodes, |
|
442 | + $this->_message_type, |
|
443 | + $this->_messenger, |
|
444 | + $this->_message |
|
445 | + ); |
|
446 | + } else { |
|
447 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
448 | + } |
|
449 | + return $owing_content; |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * @param EE_Transaction $transaction |
|
455 | + * @return string |
|
456 | + * @throws EE_Error |
|
457 | + */ |
|
458 | + private function _get_payment_gateway($transaction) |
|
459 | + { |
|
460 | + if ($transaction instanceof EE_Transaction) { |
|
461 | + $pm = $transaction->payment_method(); |
|
462 | + } else { |
|
463 | + $pm = null; |
|
464 | + } |
|
465 | + return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
|
466 | + } |
|
467 | + |
|
468 | + |
|
469 | + /** |
|
470 | + * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page. If its |
|
471 | + * not present then the organization logo is used if its found (set on the organization settings page). |
|
472 | + * |
|
473 | + * @since 4.5.0 |
|
474 | + * @param bool $img_tags TRUE means to return with the img tag wrappers. False just returns the url to the image. |
|
475 | + * @return string url or html |
|
476 | + * @throws EE_Error |
|
477 | + * @throws InvalidArgumentException |
|
478 | + * @throws InvalidDataTypeException |
|
479 | + * @throws InvalidInterfaceException |
|
480 | + */ |
|
481 | + private function _get_invoice_logo($img_tags = false) |
|
482 | + { |
|
483 | + $invoice_logo_url = ''; |
|
484 | + // try to get the invoice payment method's logo for this transaction image first |
|
485 | + $pm = $this->_get_invoice_payment_method(); |
|
486 | + if ($pm instanceof EE_Payment_Method) { |
|
487 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true); |
|
488 | + } |
|
489 | + if (empty($invoice_logo_url)) { |
|
490 | + $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
|
491 | + } |
|
492 | + if (empty($invoice_logo_url)) { |
|
493 | + return ''; |
|
494 | + } |
|
495 | + if (! $img_tags) { |
|
496 | + return $invoice_logo_url; |
|
497 | + } |
|
498 | + // image tags have been requested. |
|
499 | + $image_size = getimagesize($invoice_logo_url); |
|
500 | + // if image is wider than 300px, set the width to 300 |
|
501 | + if ($image_size[0] > 300) { |
|
502 | + $image_width = 300; |
|
503 | + } else { |
|
504 | + $image_width = $image_size[0]; |
|
505 | + } |
|
506 | + return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />'; |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + /** |
|
511 | + * Used to retrieve the appropriate content for the invoice payee name shortcode |
|
512 | + * |
|
513 | + * @since 4.5.0 |
|
514 | + * @return string |
|
515 | + * @throws EE_Error |
|
516 | + * @throws InvalidArgumentException |
|
517 | + * @throws InvalidDataTypeException |
|
518 | + * @throws InvalidInterfaceException |
|
519 | + */ |
|
520 | + private function _get_invoice_payee_name() |
|
521 | + { |
|
522 | + $payee_name = null; |
|
523 | + $pm = $this->_get_invoice_payment_method(); |
|
524 | + if ($pm instanceof EE_Payment_Method) { |
|
525 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', true); |
|
526 | + } |
|
527 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
528 | + return $payee_name; |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * gets the default invoice payment method, but has a filter so it can be overridden |
|
534 | + * |
|
535 | + * @return EE_Payment_Method|null |
|
536 | + * @throws EE_Error |
|
537 | + * @throws InvalidArgumentException |
|
538 | + * @throws InvalidDataTypeException |
|
539 | + * @throws InvalidInterfaceException |
|
540 | + */ |
|
541 | + private function _get_invoice_payment_method() |
|
542 | + { |
|
543 | + if (! $this->_invoice_pm instanceof EE_Payment_Method) { |
|
544 | + $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
|
545 | + $transaction = ! $transaction instanceof EE_Transaction |
|
546 | + && is_array($this->_extra_data) |
|
547 | + && isset($this->_extra_data['data']) |
|
548 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
549 | + ? $this->_extra_data['data']->txn : $transaction; |
|
550 | + // get the invoice payment method, and remember it for the next call too |
|
551 | + $this->_invoice_pm = apply_filters( |
|
552 | + 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', |
|
553 | + EEM_Payment_Method::instance()->get_one_of_type('Invoice'), |
|
554 | + $transaction |
|
555 | + ); |
|
556 | + } |
|
557 | + return $this->_invoice_pm; |
|
558 | + } |
|
559 | + |
|
560 | + |
|
561 | + /** |
|
562 | + * Used to retrieve the appropriate content for the invoice payee email shortcode |
|
563 | + * |
|
564 | + * @since 4.5.0 |
|
565 | + * @return string |
|
566 | + * @throws EE_Error |
|
567 | + * @throws InvalidArgumentException |
|
568 | + * @throws InvalidDataTypeException |
|
569 | + * @throws InvalidInterfaceException |
|
570 | + */ |
|
571 | + private function _get_invoice_payee_email() |
|
572 | + { |
|
573 | + $payee_email = null; |
|
574 | + $pm = $this->_get_invoice_payment_method(); |
|
575 | + if ($pm instanceof EE_Payment_Method) { |
|
576 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', true); |
|
577 | + } |
|
578 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
579 | + : $payee_email; |
|
580 | + return $payee_email; |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * Used to retrieve the appropriate content for the invoice payee tax number shortcode |
|
586 | + * |
|
587 | + * @since 4.5.0 |
|
588 | + * @param string $shortcode |
|
589 | + * @return string |
|
590 | + * @throws EE_Error |
|
591 | + * @throws InvalidArgumentException |
|
592 | + * @throws InvalidDataTypeException |
|
593 | + * @throws InvalidInterfaceException |
|
594 | + */ |
|
595 | + private function _get_invoice_payee_tax_number($shortcode) |
|
596 | + { |
|
597 | + $payee_tax_number = null; |
|
598 | + $pm = $this->_get_invoice_payment_method(); |
|
599 | + if ($pm instanceof EE_Payment_Method) { |
|
600 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true); |
|
601 | + } |
|
602 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat |
|
603 | + : $payee_tax_number; |
|
604 | + if (empty($payee_tax_number)) { |
|
605 | + return ''; |
|
606 | + } |
|
607 | + // any attributes? |
|
608 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
609 | + // prefix? |
|
610 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
611 | + return $prefix . $payee_tax_number; |
|
612 | + } |
|
613 | + |
|
614 | + |
|
615 | + /** |
|
616 | + * Used to retrieve the appropriate content for the invoice payee address shortcode. |
|
617 | + * |
|
618 | + * @since 4.5.0 |
|
619 | + * @return string |
|
620 | + * @throws EE_Error |
|
621 | + * @throws InvalidArgumentException |
|
622 | + * @throws ReflectionException |
|
623 | + * @throws InvalidDataTypeException |
|
624 | + * @throws InvalidInterfaceException |
|
625 | + */ |
|
626 | + private function _get_invoice_payee_address() |
|
627 | + { |
|
628 | + $payee_address = null; |
|
629 | + $pm = $this->_get_invoice_payment_method(); |
|
630 | + if ($pm instanceof EE_Payment_Method) { |
|
631 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', true); |
|
632 | + } |
|
633 | + if (empty($payee_address)) { |
|
634 | + $organization = EE_Registry::instance()->CFG->organization; |
|
635 | + $payee_address = $organization->get_pretty('address_1') . '<br>'; |
|
636 | + $payee_address .= ! empty($organization->address_2) |
|
637 | + ? $organization->get_pretty('address_2') . '<br>' |
|
638 | + : ''; |
|
639 | + $payee_address .= $organization->get_pretty('city') . '<br>'; |
|
640 | + // state |
|
641 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
642 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
643 | + // Country |
|
644 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
645 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
646 | + } |
|
647 | + return $payee_address; |
|
648 | + } |
|
649 | + |
|
650 | + |
|
651 | + /** |
|
652 | + * Used to retrieve the appropriate content for the invoice payment instructions shortcode. |
|
653 | + * |
|
654 | + * @since 4.5.0 |
|
655 | + * @return string |
|
656 | + * @throws EE_Error |
|
657 | + * @throws InvalidArgumentException |
|
658 | + * @throws InvalidDataTypeException |
|
659 | + * @throws InvalidInterfaceException |
|
660 | + */ |
|
661 | + private function _get_invoice_payment_instructions() |
|
662 | + { |
|
663 | + $instructions = null; |
|
664 | + $pm = $this->_get_invoice_payment_method(); |
|
665 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : ''; |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + /** |
|
670 | + * get invoice/receipt switch button or url. |
|
671 | + * |
|
672 | + * @param bool $button true (default) returns the html for a button, false just returns the url. |
|
673 | + * @return string |
|
674 | + * @throws EE_Error |
|
675 | + */ |
|
676 | + protected function _get_invoice_receipt_switcher($button = true) |
|
677 | + { |
|
678 | + $reg = $this->_data->primary_reg_obj; |
|
679 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
680 | + if (! $reg instanceof EE_Registration || empty($message_type)) { |
|
681 | + return ''; |
|
682 | + } |
|
683 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
684 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type |
|
685 | + ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
|
686 | + $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
687 | + $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
|
688 | + if (! $button) { |
|
689 | + return $switch_to_url; |
|
690 | + } |
|
691 | + if (! empty($switch_to_url)) { |
|
692 | + return ' |
|
693 | 693 | <form method="post" action="' . $switch_to_url . '" > |
694 | 694 | <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
695 | 695 | </form> |
696 | 696 | '; |
697 | - } |
|
698 | - return ''; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - /** |
|
703 | - * This returns a subtotal. |
|
704 | - * |
|
705 | - * @param bool $tax if true then return the subtotal for tax otherwise return subtotal. |
|
706 | - * @return int |
|
707 | - * @throws EE_Error |
|
708 | - */ |
|
709 | - private function _get_subtotal($tax = false) |
|
710 | - { |
|
711 | - $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null; |
|
712 | - if (! $grand_total instanceof EE_Line_Item) { |
|
713 | - return 0; |
|
714 | - } |
|
715 | - return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total(); |
|
716 | - } |
|
717 | - |
|
718 | - |
|
719 | - /** |
|
720 | - * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode |
|
721 | - * |
|
722 | - * @since 4.7.0 |
|
723 | - * @param string $shortcode the incoming shortcode |
|
724 | - * @return string parsed. |
|
725 | - * @throws EE_Error |
|
726 | - */ |
|
727 | - private function _get_payment_link_if_needed($shortcode) |
|
728 | - { |
|
729 | - $valid_shortcodes = array('transaction'); |
|
730 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
731 | - // ensure default is set. |
|
732 | - $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
733 | - $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction |
|
734 | - ? $addressee->txn->remaining() : 0; |
|
735 | - if ($total_owing > 0) { |
|
736 | - $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
737 | - $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
738 | - $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
739 | - $opening_tag = ! empty($container_tag) ? '<' . $container_tag : ''; |
|
740 | - $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag; |
|
741 | - $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
742 | - $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : ''; |
|
743 | - $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag; |
|
744 | - // we need to re run this string through the parser to catch any shortcodes that are in it. |
|
745 | - $owing_content = $this->_shortcode_helper->parse_message_template( |
|
746 | - $content, |
|
747 | - $addressee, |
|
748 | - $valid_shortcodes, |
|
749 | - $this->_message_type, |
|
750 | - $this->_messenger, |
|
751 | - $this->_message |
|
752 | - ); |
|
753 | - } else { |
|
754 | - return ''; |
|
755 | - } |
|
756 | - return $owing_content; |
|
757 | - } |
|
758 | - |
|
759 | - |
|
760 | - /** |
|
761 | - * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode |
|
762 | - * |
|
763 | - * @since 4.8.28.rc.011 |
|
764 | - * @param string $shortcode The shortcode being parsed. |
|
765 | - * @param EE_Transaction $transaction |
|
766 | - * @return string |
|
767 | - * @throws EE_Error |
|
768 | - */ |
|
769 | - protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) |
|
770 | - { |
|
771 | - // if transaction is paid in full then we can just return an empty string |
|
772 | - if ($transaction->remaining() === 0) { |
|
773 | - return ''; |
|
774 | - } |
|
775 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
776 | - $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
777 | - $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
778 | - $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] |
|
779 | - : esc_html__('Payment in full due by: ', 'event_espresso'); |
|
780 | - $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
781 | - // setup date due: |
|
782 | - try { |
|
783 | - if ($transaction_created instanceof DateTime) { |
|
784 | - $date_due = $transaction_created->add( |
|
785 | - new DateInterval('P' . $days_until_due . 'D') |
|
786 | - )->format($format); |
|
787 | - } else { |
|
788 | - throw new Exception(); |
|
789 | - } |
|
790 | - } catch (Exception $e) { |
|
791 | - // format was likely invalid. |
|
792 | - $date_due = esc_html__( |
|
793 | - 'Unable to calculate date due, likely the format string is invalid.', |
|
794 | - 'event_espresso' |
|
795 | - ); |
|
796 | - } |
|
797 | - return $prefix_text . $date_due; |
|
798 | - } |
|
697 | + } |
|
698 | + return ''; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + /** |
|
703 | + * This returns a subtotal. |
|
704 | + * |
|
705 | + * @param bool $tax if true then return the subtotal for tax otherwise return subtotal. |
|
706 | + * @return int |
|
707 | + * @throws EE_Error |
|
708 | + */ |
|
709 | + private function _get_subtotal($tax = false) |
|
710 | + { |
|
711 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null; |
|
712 | + if (! $grand_total instanceof EE_Line_Item) { |
|
713 | + return 0; |
|
714 | + } |
|
715 | + return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total(); |
|
716 | + } |
|
717 | + |
|
718 | + |
|
719 | + /** |
|
720 | + * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode |
|
721 | + * |
|
722 | + * @since 4.7.0 |
|
723 | + * @param string $shortcode the incoming shortcode |
|
724 | + * @return string parsed. |
|
725 | + * @throws EE_Error |
|
726 | + */ |
|
727 | + private function _get_payment_link_if_needed($shortcode) |
|
728 | + { |
|
729 | + $valid_shortcodes = array('transaction'); |
|
730 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
731 | + // ensure default is set. |
|
732 | + $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
733 | + $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction |
|
734 | + ? $addressee->txn->remaining() : 0; |
|
735 | + if ($total_owing > 0) { |
|
736 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
737 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
738 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
739 | + $opening_tag = ! empty($container_tag) ? '<' . $container_tag : ''; |
|
740 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag; |
|
741 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
742 | + $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : ''; |
|
743 | + $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag; |
|
744 | + // we need to re run this string through the parser to catch any shortcodes that are in it. |
|
745 | + $owing_content = $this->_shortcode_helper->parse_message_template( |
|
746 | + $content, |
|
747 | + $addressee, |
|
748 | + $valid_shortcodes, |
|
749 | + $this->_message_type, |
|
750 | + $this->_messenger, |
|
751 | + $this->_message |
|
752 | + ); |
|
753 | + } else { |
|
754 | + return ''; |
|
755 | + } |
|
756 | + return $owing_content; |
|
757 | + } |
|
758 | + |
|
759 | + |
|
760 | + /** |
|
761 | + * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode |
|
762 | + * |
|
763 | + * @since 4.8.28.rc.011 |
|
764 | + * @param string $shortcode The shortcode being parsed. |
|
765 | + * @param EE_Transaction $transaction |
|
766 | + * @return string |
|
767 | + * @throws EE_Error |
|
768 | + */ |
|
769 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) |
|
770 | + { |
|
771 | + // if transaction is paid in full then we can just return an empty string |
|
772 | + if ($transaction->remaining() === 0) { |
|
773 | + return ''; |
|
774 | + } |
|
775 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
776 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
777 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
778 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] |
|
779 | + : esc_html__('Payment in full due by: ', 'event_espresso'); |
|
780 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
781 | + // setup date due: |
|
782 | + try { |
|
783 | + if ($transaction_created instanceof DateTime) { |
|
784 | + $date_due = $transaction_created->add( |
|
785 | + new DateInterval('P' . $days_until_due . 'D') |
|
786 | + )->format($format); |
|
787 | + } else { |
|
788 | + throw new Exception(); |
|
789 | + } |
|
790 | + } catch (Exception $e) { |
|
791 | + // format was likely invalid. |
|
792 | + $date_due = esc_html__( |
|
793 | + 'Unable to calculate date due, likely the format string is invalid.', |
|
794 | + 'event_espresso' |
|
795 | + ); |
|
796 | + } |
|
797 | + return $prefix_text . $date_due; |
|
798 | + } |
|
799 | 799 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | && isset($this->_extra_data['data']) |
270 | 270 | && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment |
271 | 271 | : $payment; |
272 | - if (! $transaction instanceof EE_Transaction) { |
|
272 | + if ( ! $transaction instanceof EE_Transaction) { |
|
273 | 273 | return ''; |
274 | 274 | } |
275 | 275 | switch ($shortcode) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
288 | 288 | return sprintf( |
289 | 289 | esc_html__('%sClick here for Invoice%s', 'event_espresso'), |
290 | - '<a href="' . $invoice_url . '">', |
|
290 | + '<a href="'.$invoice_url.'">', |
|
291 | 291 | '</a>' |
292 | 292 | ); |
293 | 293 | break; |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | return $this->_data->total_ticket_count; |
362 | 362 | break; |
363 | 363 | case '[TRANSACTION_ADMIN_URL]': |
364 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
364 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
365 | 365 | $query_args = array( |
366 | 366 | 'page' => 'espresso_transactions', |
367 | 367 | 'action' => 'view_transaction', |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | case '[RECEIPT_URL]': |
374 | 374 | // get primary_registration |
375 | 375 | $reg = $this->_data->primary_reg_obj; |
376 | - if (! $reg instanceof EE_Registration) { |
|
376 | + if ( ! $reg instanceof EE_Registration) { |
|
377 | 377 | return ''; |
378 | 378 | } |
379 | 379 | return $reg->receipt_url(); |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | if (empty($invoice_logo_url)) { |
493 | 493 | return ''; |
494 | 494 | } |
495 | - if (! $img_tags) { |
|
495 | + if ( ! $img_tags) { |
|
496 | 496 | return $invoice_logo_url; |
497 | 497 | } |
498 | 498 | // image tags have been requested. |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | } else { |
504 | 504 | $image_width = $image_size[0]; |
505 | 505 | } |
506 | - return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />'; |
|
506 | + return '<img class="logo screen" src="'.esc_url_raw($invoice_logo_url).'" width="'.esc_attr($image_width).'" alt="logo" />'; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | */ |
541 | 541 | private function _get_invoice_payment_method() |
542 | 542 | { |
543 | - if (! $this->_invoice_pm instanceof EE_Payment_Method) { |
|
543 | + if ( ! $this->_invoice_pm instanceof EE_Payment_Method) { |
|
544 | 544 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
545 | 545 | $transaction = ! $transaction instanceof EE_Transaction |
546 | 546 | && is_array($this->_extra_data) |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | $attrs = $this->_get_shortcode_attrs($shortcode); |
609 | 609 | // prefix? |
610 | 610 | $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
611 | - return $prefix . $payee_tax_number; |
|
611 | + return $prefix.$payee_tax_number; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -632,16 +632,16 @@ discard block |
||
632 | 632 | } |
633 | 633 | if (empty($payee_address)) { |
634 | 634 | $organization = EE_Registry::instance()->CFG->organization; |
635 | - $payee_address = $organization->get_pretty('address_1') . '<br>'; |
|
635 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
636 | 636 | $payee_address .= ! empty($organization->address_2) |
637 | - ? $organization->get_pretty('address_2') . '<br>' |
|
637 | + ? $organization->get_pretty('address_2').'<br>' |
|
638 | 638 | : ''; |
639 | - $payee_address .= $organization->get_pretty('city') . '<br>'; |
|
639 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
640 | 640 | // state |
641 | 641 | $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
642 | 642 | $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
643 | 643 | // Country |
644 | - $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
644 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
645 | 645 | $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
646 | 646 | } |
647 | 647 | return $payee_address; |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | { |
678 | 678 | $reg = $this->_data->primary_reg_obj; |
679 | 679 | $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
680 | - if (! $reg instanceof EE_Registration || empty($message_type)) { |
|
680 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
681 | 681 | return ''; |
682 | 682 | } |
683 | 683 | $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
@@ -685,13 +685,13 @@ discard block |
||
685 | 685 | ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
686 | 686 | $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
687 | 687 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
688 | - if (! $button) { |
|
688 | + if ( ! $button) { |
|
689 | 689 | return $switch_to_url; |
690 | 690 | } |
691 | - if (! empty($switch_to_url)) { |
|
691 | + if ( ! empty($switch_to_url)) { |
|
692 | 692 | return ' |
693 | - <form method="post" action="' . $switch_to_url . '" > |
|
694 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
693 | + <form method="post" action="' . $switch_to_url.'" > |
|
694 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
695 | 695 | </form> |
696 | 696 | '; |
697 | 697 | } |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | private function _get_subtotal($tax = false) |
710 | 710 | { |
711 | 711 | $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null; |
712 | - if (! $grand_total instanceof EE_Line_Item) { |
|
712 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
713 | 713 | return 0; |
714 | 714 | } |
715 | 715 | return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total(); |
@@ -736,11 +736,11 @@ discard block |
||
736 | 736 | $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
737 | 737 | $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
738 | 738 | $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
739 | - $opening_tag = ! empty($container_tag) ? '<' . $container_tag : ''; |
|
740 | - $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag; |
|
739 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
740 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
741 | 741 | $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
742 | - $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : ''; |
|
743 | - $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag; |
|
742 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
743 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
744 | 744 | // we need to re run this string through the parser to catch any shortcodes that are in it. |
745 | 745 | $owing_content = $this->_shortcode_helper->parse_message_template( |
746 | 746 | $content, |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | try { |
783 | 783 | if ($transaction_created instanceof DateTime) { |
784 | 784 | $date_due = $transaction_created->add( |
785 | - new DateInterval('P' . $days_until_due . 'D') |
|
785 | + new DateInterval('P'.$days_until_due.'D') |
|
786 | 786 | )->format($format); |
787 | 787 | } else { |
788 | 788 | throw new Exception(); |
@@ -794,6 +794,6 @@ discard block |
||
794 | 794 | 'event_espresso' |
795 | 795 | ); |
796 | 796 | } |
797 | - return $prefix_text . $date_due; |
|
797 | + return $prefix_text.$date_due; |
|
798 | 798 | } |
799 | 799 | } |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | </thead> |
77 | 77 | <tbody> |
78 | 78 | <?php |
79 | - /** |
|
80 | - * Recursive function for traversing all the sub-items of each line item |
|
81 | - * and displaying them in the table |
|
82 | - * |
|
83 | - * @param EE_Line_Item $line_item |
|
84 | - * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
85 | - */ |
|
86 | - function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
87 | - { |
|
88 | - switch ($line_item->type()) { |
|
89 | - case EEM_Line_Item::type_total: |
|
90 | - foreach ($line_item->children() as $child_line_item) { |
|
91 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
92 | - } ?> |
|
79 | + /** |
|
80 | + * Recursive function for traversing all the sub-items of each line item |
|
81 | + * and displaying them in the table |
|
82 | + * |
|
83 | + * @param EE_Line_Item $line_item |
|
84 | + * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
85 | + */ |
|
86 | + function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
87 | + { |
|
88 | + switch ($line_item->type()) { |
|
89 | + case EEM_Line_Item::type_total: |
|
90 | + foreach ($line_item->children() as $child_line_item) { |
|
91 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
92 | + } ?> |
|
93 | 93 | <tr> |
94 | 94 | <td colspan="<?php echo ($show_line_item_description ? 5 : 4) ?>"> |
95 | 95 | <hr> |
@@ -101,50 +101,50 @@ discard block |
||
101 | 101 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
102 | 102 | </tr> |
103 | 103 | <?php |
104 | - break; |
|
104 | + break; |
|
105 | 105 | |
106 | 106 | |
107 | - case EEM_Line_Item::type_sub_total: |
|
108 | - foreach ($line_item->children() as $child_line_item) { |
|
109 | - // $odd = !$odd; |
|
110 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
111 | - } ?> |
|
107 | + case EEM_Line_Item::type_sub_total: |
|
108 | + foreach ($line_item->children() as $child_line_item) { |
|
109 | + // $odd = !$odd; |
|
110 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
111 | + } ?> |
|
112 | 112 | <tr class="total_tr odd"> |
113 | 113 | <td colspan="<?php echo ($show_line_item_description ? 2 : 1) ?>"> </td> |
114 | 114 | <td colspan="2" class="total" id="total_currency"> |
115 | 115 | <?php esc_html_e( |
116 | - 'Sub-Total', |
|
117 | - 'event_espresso' |
|
118 | - ); ?></td> |
|
116 | + 'Sub-Total', |
|
117 | + 'event_espresso' |
|
118 | + ); ?></td> |
|
119 | 119 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
120 | 120 | </tr> |
121 | 121 | <?php |
122 | - break; |
|
122 | + break; |
|
123 | 123 | |
124 | 124 | |
125 | - case EEM_Line_Item::type_tax_sub_total: |
|
126 | - foreach ($line_item->children() as $child_line_item) { |
|
127 | - $odd = ! $odd; |
|
128 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
129 | - } ?> |
|
125 | + case EEM_Line_Item::type_tax_sub_total: |
|
126 | + foreach ($line_item->children() as $child_line_item) { |
|
127 | + $odd = ! $odd; |
|
128 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
129 | + } ?> |
|
130 | 130 | <tr class="total_tr odd"> |
131 | 131 | <td colspan="<?php echo ($show_line_item_description ? 2 : 1) ?>"> </td> |
132 | 132 | <td colspan="2" class="total" id="total_currency"> |
133 | 133 | <?php esc_html_e( |
134 | - 'Tax Total', |
|
135 | - 'event_espresso' |
|
136 | - ); ?></td> |
|
134 | + 'Tax Total', |
|
135 | + 'event_espresso' |
|
136 | + ); ?></td> |
|
137 | 137 | <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
138 | 138 | </tr> |
139 | 139 | <?php |
140 | - break; |
|
140 | + break; |
|
141 | 141 | |
142 | 142 | |
143 | - case EEM_Line_Item::type_line_item: |
|
144 | - $subitems = $line_item->children(); |
|
145 | - $has_subitems = count($subitems) > 1; |
|
146 | - if ($has_subitems) { |
|
147 | - ?> |
|
143 | + case EEM_Line_Item::type_line_item: |
|
144 | + $subitems = $line_item->children(); |
|
145 | + $has_subitems = count($subitems) > 1; |
|
146 | + if ($has_subitems) { |
|
147 | + ?> |
|
148 | 148 | <tr class="item <?php echo ($odd ? 'odd' : ''); ?>"> |
149 | 149 | <td class="item_l"><?php echo esc_html($line_item->name()) ?></td> |
150 | 150 | <?php if ($show_line_item_description) { ?> |
@@ -155,18 +155,18 @@ discard block |
||
155 | 155 | <td class="item_c"><?php echo esc_html($line_item->unit_price_no_code()) ?></td> |
156 | 156 | |
157 | 157 | <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); |
158 | - echo ($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
158 | + echo ($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
159 | 159 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
160 | - ?> |
|
160 | + ?> |
|
161 | 161 | </tr> |
162 | 162 | <?php |
163 | - if ($has_subitems) { |
|
164 | - foreach ($line_item->children() as $child_line_item) { |
|
165 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
166 | - } |
|
167 | - } |
|
168 | - } else {// no subitems - just show this line item |
|
169 | - ?> |
|
163 | + if ($has_subitems) { |
|
164 | + foreach ($line_item->children() as $child_line_item) { |
|
165 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
166 | + } |
|
167 | + } |
|
168 | + } else {// no subitems - just show this line item |
|
169 | + ?> |
|
170 | 170 | <tr class="item <?php echo ($odd ? 'odd' : ''); ?>"> |
171 | 171 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
172 | 172 | <?php if ($show_line_item_description) { ?> |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | <td class="item_l"><?php echo esc_html($line_item->quantity()); ?></td> |
176 | 176 | <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td> |
177 | 177 | <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); |
178 | - echo ($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
178 | + echo ($line_item->is_taxable() ? '*' : ''); ?> </td> |
|
179 | 179 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
180 | - ?> |
|
180 | + ?> |
|
181 | 181 | </tr> |
182 | 182 | <?php } |
183 | 183 | |
184 | - break; |
|
185 | - case EEM_Line_Item::type_sub_line_item: |
|
186 | - ?> |
|
184 | + break; |
|
185 | + case EEM_Line_Item::type_sub_line_item: |
|
186 | + ?> |
|
187 | 187 | <tr class="item subitem-row"> |
188 | 188 | <td class="item_l subitem"><?php echo esc_html($line_item->name()); ?></td> |
189 | 189 | <?php if ($show_line_item_description) { ?> |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
200 | 200 | </tr> |
201 | 201 | <?php |
202 | - break; |
|
203 | - case EEM_Line_Item::type_tax: |
|
204 | - ?> |
|
202 | + break; |
|
203 | + case EEM_Line_Item::type_tax: |
|
204 | + ?> |
|
205 | 205 | <tr class="item sub-item tax-total"> |
206 | 206 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
207 | 207 | <?php if ($show_line_item_description) { ?> |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | |
212 | 212 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
213 | 213 | </tr><?php |
214 | - break; |
|
215 | - } |
|
216 | - } |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - $c = false; |
|
219 | - /* @var $transaction EE_Transaction */ |
|
220 | - $total_line_item = $transaction->total_line_item(); |
|
221 | - ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
222 | - /* foreach($transaction->registrations() as $registration){ |
|
218 | + $c = false; |
|
219 | + /* @var $transaction EE_Transaction */ |
|
220 | + $total_line_item = $transaction->total_line_item(); |
|
221 | + ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
222 | + /* foreach($transaction->registrations() as $registration){ |
|
223 | 223 | ?> |
224 | 224 | <tr class="item <?php echo ($c = !$c) ? ' odd' : ''; ?>"> |
225 | 225 | <td class="item_l">1</td> |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | </thead> |
249 | 249 | <tbody> |
250 | 250 | <?php |
251 | - $c = false; |
|
252 | - if (! empty($payments)) { |
|
253 | - foreach ($payments as $payment) { |
|
254 | - /* @var $payment EE_Payment */ |
|
255 | - ?> |
|
251 | + $c = false; |
|
252 | + if (! empty($payments)) { |
|
253 | + foreach ($payments as $payment) { |
|
254 | + /* @var $payment EE_Payment */ |
|
255 | + ?> |
|
256 | 256 | <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'> |
257 | 257 | <td><?php $payment->e('PAY_gateway') ?></td> |
258 | 258 | <td><?php echo esc_html($payment->timestamp('D M j, Y')); ?></td> |
@@ -262,17 +262,17 @@ discard block |
||
262 | 262 | <td class='item_r'><?php echo EEH_Template::format_currency($payment->amount()); ?></td> |
263 | 263 | </tr> |
264 | 264 | <?php } |
265 | - } else { |
|
266 | - ?> |
|
265 | + } else { |
|
266 | + ?> |
|
267 | 267 | <tr class='item'> |
268 | 268 | <td class='aln-cntr' colspan=6> |
269 | 269 | <?php esc_html_e( |
270 | - "No approved payments have been received", |
|
271 | - 'event_espresso' |
|
272 | - ) ?></td> |
|
270 | + "No approved payments have been received", |
|
271 | + 'event_espresso' |
|
272 | + ) ?></td> |
|
273 | 273 | </tr> |
274 | 274 | <?php } |
275 | - ?> |
|
275 | + ?> |
|
276 | 276 | </tbody> |
277 | 277 | <tfoot> |
278 | 278 | <tr class='total_tr'> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <div class="fn">[name]</div> |
55 | 55 | <div class="adr"> |
56 | 56 | <div class="street-address"><?php echo wp_kses($attendee_address, AllowedTags::getAllowedTags()); ?></div> |
57 | - <div class="locality"><?php echo wp_kses($attendee_city . ' ' . $attendee_state, AllowedTags::getAllowedTags()); ?></div> |
|
57 | + <div class="locality"><?php echo wp_kses($attendee_city.' '.$attendee_state, AllowedTags::getAllowedTags()); ?></div> |
|
58 | 58 | <div id="client-postcode"><?php echo wp_kses($attendee_zip, AllowedTags::getAllowedTags()); ?></div> |
59 | 59 | </div> |
60 | 60 | </div> |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | <tbody> |
250 | 250 | <?php |
251 | 251 | $c = false; |
252 | - if (! empty($payments)) { |
|
252 | + if ( ! empty($payments)) { |
|
253 | 253 | foreach ($payments as $payment) { |
254 | 254 | /* @var $payment EE_Payment */ |
255 | 255 | ?> |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | <h3 class="section-title event-name"> |
65 | 65 | <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
66 | 66 | <?php |
67 | - esc_html_e( |
|
68 | - "Event Name:", |
|
69 | - "event_espresso" |
|
70 | - ) ?> |
|
67 | + esc_html_e( |
|
68 | + "Event Name:", |
|
69 | + "event_espresso" |
|
70 | + ) ?> |
|
71 | 71 | <span class="plain-text"><?php echo wp_kses($event->name(), AllowedTags::getAllowedTags()); ?></span> |
72 | 72 | <span class="small-text link"> |
73 | 73 | [ <a href='<?php echo esc_url_raw($event->get_permalink()) ?>'><?php esc_html_e('view', 'event_espresso'); ?></a> ] |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | <?php } ?> |
79 | 79 | <ul class="tickets-per-event"> |
80 | 80 | <?php |
81 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
82 | - $ticket = $line_item->ticket(); |
|
83 | - $taxable_html = $ticket->taxable() |
|
84 | - ? '*' |
|
85 | - : ''; |
|
86 | - $subitems = $line_item->children(); |
|
87 | - $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
88 | - ?> |
|
81 | + foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
82 | + $ticket = $line_item->ticket(); |
|
83 | + $taxable_html = $ticket->taxable() |
|
84 | + ? '*' |
|
85 | + : ''; |
|
86 | + $subitems = $line_item->children(); |
|
87 | + $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
88 | + ?> |
|
89 | 89 | <li class="event-ticket"> |
90 | 90 | <div class="ticket-details"> |
91 | 91 | <table class="invoice-amount"> |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | <th class="name-column"><?php esc_html_e("Ticket", "event_espresso"); ?></th> |
95 | 95 | <th colspan="2" class="desc-column"> |
96 | 96 | <?php |
97 | - esc_html_e( |
|
98 | - "Description", |
|
99 | - "event_espresso" |
|
100 | - ); ?></th> |
|
97 | + esc_html_e( |
|
98 | + "Description", |
|
99 | + "event_espresso" |
|
100 | + ); ?></th> |
|
101 | 101 | <th class="number-column item_c"><?php esc_html_e("Quantity", "event_espresso"); ?></th> |
102 | 102 | <th class="number-column item_c"><?php esc_html_e("Price", "event_espresso"); ?></th> |
103 | 103 | <th class="number-column item_r"><?php esc_html_e("Total", "event_espresso"); ?></th> |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | </thead> |
106 | 106 | <tbody> |
107 | 107 | <?php |
108 | - if (count($subitems) < 2) { ?> |
|
108 | + if (count($subitems) < 2) { ?> |
|
109 | 109 | <tr class="item"> |
110 | 110 | <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
111 | 111 | <td colspan="2"> |
112 | 112 | <?php echo esc_html($line_item->desc()); ?> |
113 | 113 | <p class="ticket-note"> |
114 | 114 | <?php |
115 | - echo sprintf( |
|
116 | - esc_html__( |
|
117 | - 'This ticket can be used once at %s of the dates/times below.', |
|
118 | - 'event_espresso' |
|
119 | - ), |
|
120 | - $ticket_uses |
|
121 | - ); ?> |
|
115 | + echo sprintf( |
|
116 | + esc_html__( |
|
117 | + 'This ticket can be used once at %s of the dates/times below.', |
|
118 | + 'event_espresso' |
|
119 | + ), |
|
120 | + $ticket_uses |
|
121 | + ); ?> |
|
122 | 122 | </p> |
123 | 123 | </td> |
124 | 124 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
127 | 127 | </tr> |
128 | 128 | <?php |
129 | - } else { ?> |
|
129 | + } else { ?> |
|
130 | 130 | <tr class="item"> |
131 | 131 | <td class="aln-left"> |
132 | 132 | <?php echo esc_html($line_item->name() . $taxable_html); ?> |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
135 | 135 | <p class="ticket-note"> |
136 | 136 | <?php |
137 | - echo sprintf( |
|
138 | - esc_html__( |
|
139 | - 'This ticket can be used once at %s of the dates/times below.', |
|
140 | - 'event_espresso' |
|
141 | - ), |
|
142 | - $ticket_uses |
|
143 | - ); ?> |
|
137 | + echo sprintf( |
|
138 | + esc_html__( |
|
139 | + 'This ticket can be used once at %s of the dates/times below.', |
|
140 | + 'event_espresso' |
|
141 | + ), |
|
142 | + $ticket_uses |
|
143 | + ); ?> |
|
144 | 144 | </p> |
145 | 145 | </td> |
146 | 146 | <td class="item_c"> |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | </td> |
155 | 155 | </tr> |
156 | 156 | <?php |
157 | - foreach ($subitems as $sub_line_item) { |
|
158 | - $is_percent = $sub_line_item->is_percent(); ?> |
|
157 | + foreach ($subitems as $sub_line_item) { |
|
158 | + $is_percent = $sub_line_item->is_percent(); ?> |
|
159 | 159 | <tr class="subitem-row"> |
160 | 160 | <td class="subitem"> |
161 | 161 | <?php echo esc_html($sub_line_item->name()); ?> |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | <?php // echo $is_percent ? '' : $sub_line_item->quantity()?> |
168 | 168 | </td> |
169 | 169 | <td class="item_c"><?php |
170 | - echo ($is_percent |
|
171 | - ? $sub_line_item->percent() . "%" |
|
172 | - : $sub_line_item->unit_price_no_code()); ?> |
|
170 | + echo ($is_percent |
|
171 | + ? $sub_line_item->percent() . "%" |
|
172 | + : $sub_line_item->unit_price_no_code()); ?> |
|
173 | 173 | </td> |
174 | 174 | <td class="item_r"><?php echo wp_kses($sub_line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
175 | 175 | </tr> |
176 | 176 | <?php |
177 | - } ?> |
|
177 | + } ?> |
|
178 | 178 | <tr class="total_tr odd"> |
179 | 179 | <td colspan="4"></td> |
180 | 180 | <td class="total" nowrap="nowrap"> |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | </td> |
186 | 186 | </tr> |
187 | 187 | <?php |
188 | - } ?> |
|
188 | + } ?> |
|
189 | 189 | </tbody> |
190 | 190 | </table> |
191 | 191 | |
@@ -196,49 +196,49 @@ discard block |
||
196 | 196 | <h4 class="sub-section-title no-bottom-margin"> |
197 | 197 | <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
198 | 198 | <?php |
199 | - echo _n( |
|
200 | - "Date/Time:", |
|
201 | - "Dates/Times:", |
|
202 | - count($ticket->datetimes()), |
|
203 | - "event_espresso" |
|
204 | - ); ?></h4> |
|
199 | + echo _n( |
|
200 | + "Date/Time:", |
|
201 | + "Dates/Times:", |
|
202 | + count($ticket->datetimes()), |
|
203 | + "event_espresso" |
|
204 | + ); ?></h4> |
|
205 | 205 | <ul class="event-dates"> |
206 | 206 | <?php |
207 | - foreach ($ticket->datetimes_ordered() as $datetime) { |
|
208 | - /* @var $datetime EE_Datetime */ ?> |
|
207 | + foreach ($ticket->datetimes_ordered() as $datetime) { |
|
208 | + /* @var $datetime EE_Datetime */ ?> |
|
209 | 209 | <li><?php |
210 | - echo ($datetime->name() |
|
211 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
212 | - : ''); |
|
213 | - echo sprintf( |
|
214 | - esc_html__("%s - %s (%s)", "event_espresso"), |
|
215 | - $datetime->start_date_and_time(), |
|
216 | - $datetime->end_date_and_time(), |
|
217 | - $datetime->get_timezone() |
|
218 | - ); |
|
219 | - echo ($datetime->description() |
|
220 | - ? '<p class="ticket-note">' . wp_kses($datetime->description(), AllowedTags::getAllowedTags()) . '</p>' |
|
221 | - : ''); ?></li> |
|
210 | + echo ($datetime->name() |
|
211 | + ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
212 | + : ''); |
|
213 | + echo sprintf( |
|
214 | + esc_html__("%s - %s (%s)", "event_espresso"), |
|
215 | + $datetime->start_date_and_time(), |
|
216 | + $datetime->end_date_and_time(), |
|
217 | + $datetime->get_timezone() |
|
218 | + ); |
|
219 | + echo ($datetime->description() |
|
220 | + ? '<p class="ticket-note">' . wp_kses($datetime->description(), AllowedTags::getAllowedTags()) . '</p>' |
|
221 | + : ''); ?></li> |
|
222 | 222 | <?php |
223 | - } ?> |
|
223 | + } ?> |
|
224 | 224 | </ul> |
225 | 225 | </div> |
226 | 226 | <?php |
227 | - if ($event->venues()) { ?> |
|
227 | + if ($event->venues()) { ?> |
|
228 | 228 | <div class="ticket-place-details"> |
229 | 229 | <h4 class="sub-section-title no-bottom-margin"> |
230 | 230 | <img class="icon" src="<?php |
231 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
231 | + echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
232 | 232 | <?php |
233 | - echo _n( |
|
234 | - "Venue:", |
|
235 | - "Venues:", |
|
236 | - count($event->venues()), |
|
237 | - "event_espresso" |
|
238 | - ); ?></h4> |
|
233 | + echo _n( |
|
234 | + "Venue:", |
|
235 | + "Venues:", |
|
236 | + count($event->venues()), |
|
237 | + "event_espresso" |
|
238 | + ); ?></h4> |
|
239 | 239 | <ul class="event-venues"> |
240 | 240 | <?php |
241 | - foreach ($event->venues() as $venue) { ?> |
|
241 | + foreach ($event->venues() as $venue) { ?> |
|
242 | 242 | <li><?php echo esc_html($venue->name()) ?> |
243 | 243 | <span class="small-text"> |
244 | 244 | [ |
@@ -249,18 +249,18 @@ discard block |
||
249 | 249 | </span> |
250 | 250 | </li> |
251 | 251 | <?php |
252 | - } ?> |
|
252 | + } ?> |
|
253 | 253 | </ul> |
254 | 254 | </div> |
255 | 255 | <?php |
256 | - } ?> |
|
256 | + } ?> |
|
257 | 257 | </div> |
258 | 258 | <div class="ticket-registrations-area"> |
259 | 259 | <h4 class="sub-section-title"> |
260 | 260 | <img class="icon" src="<?php |
261 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
261 | + echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
262 | 262 | <?php |
263 | - echo esc_html__("Registration Details", "event_espresso"); ?> |
|
263 | + echo esc_html__("Registration Details", "event_espresso"); ?> |
|
264 | 264 | <span class="small-text link">[ |
265 | 265 | <a class="print_button noPrint" href="<?php echo esc_url_raw($edit_reg_info_url); ?>"> |
266 | 266 | <?php esc_html_e('edit', 'event_espresso'); ?> |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | </h4> |
271 | 271 | <ul class="ticket-registrations-list"> |
272 | 272 | <?php |
273 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
274 | - /* @var $registration EE_Registration */ |
|
275 | - $attendee = $registration->attendee(); |
|
276 | - $answers = $registration->answers( |
|
277 | - ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
278 | - ); ?> |
|
273 | + foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
274 | + /* @var $registration EE_Registration */ |
|
275 | + $attendee = $registration->attendee(); |
|
276 | + $answers = $registration->answers( |
|
277 | + ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
278 | + ); ?> |
|
279 | 279 | <li class="ticket-registration"> |
280 | 280 | <table class="registration-details"> |
281 | 281 | <tr class="odd"> |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | </td> |
291 | 291 | </tr> |
292 | 292 | <?php |
293 | - foreach ($event->question_groups() as $question_group) { ?> |
|
293 | + foreach ($event->question_groups() as $question_group) { ?> |
|
294 | 294 | <tr> |
295 | 295 | <th> |
296 | 296 | <?php $question_group->e('QSG_name'); ?> |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | <td></td> |
299 | 299 | </tr> |
300 | 300 | <?php $has_personal_info = false; |
301 | - foreach ($question_group->questions() as $question) { |
|
302 | - if (in_array($question->system_ID(), $questions_to_skip)) { |
|
303 | - $has_personal_info = true; |
|
304 | - continue; |
|
305 | - } |
|
306 | - ?> |
|
301 | + foreach ($question_group->questions() as $question) { |
|
302 | + if (in_array($question->system_ID(), $questions_to_skip)) { |
|
303 | + $has_personal_info = true; |
|
304 | + continue; |
|
305 | + } |
|
306 | + ?> |
|
307 | 307 | <tr> |
308 | 308 | <th> |
309 | 309 | <?php echo wp_kses($question->display_text(), AllowedTags::getAllowedTags()); ?> |
@@ -313,26 +313,26 @@ discard block |
||
313 | 313 | </td> |
314 | 314 | </tr> |
315 | 315 | <?php } |
316 | - if ($has_personal_info) { ?> |
|
316 | + if ($has_personal_info) { ?> |
|
317 | 317 | <tr> |
318 | 318 | <th><?php esc_html_e('Attendee', 'event_espresso'); ?></th> |
319 | 319 | <td> |
320 | 320 | <?php |
321 | - echo sprintf( |
|
322 | - esc_html__('%s (%s)', "event_espresso"), |
|
323 | - esc_html($attendee->full_name()), |
|
324 | - sanitize_email($attendee->email()) |
|
325 | - ) ?> |
|
321 | + echo sprintf( |
|
322 | + esc_html__('%s (%s)', "event_espresso"), |
|
323 | + esc_html($attendee->full_name()), |
|
324 | + sanitize_email($attendee->email()) |
|
325 | + ) ?> |
|
326 | 326 | </td> |
327 | 327 | </tr> |
328 | 328 | <?php |
329 | - } |
|
330 | - } |
|
331 | - ?> |
|
329 | + } |
|
330 | + } |
|
331 | + ?> |
|
332 | 332 | </table> |
333 | 333 | </li> |
334 | 334 | <?php |
335 | - } ?> |
|
335 | + } ?> |
|
336 | 336 | </ul> |
337 | 337 | </div> |
338 | 338 | </div> |
@@ -376,10 +376,10 @@ discard block |
||
376 | 376 | <div class="grand-total-dv"> |
377 | 377 | <h2 class="grand-total"> |
378 | 378 | <?php |
379 | - printf( |
|
380 | - esc_html__("Grand Total: %s", "event_espresso"), |
|
381 | - EEH_Template::format_currency($total_cost) |
|
382 | - ); ?> |
|
379 | + printf( |
|
380 | + esc_html__("Grand Total: %s", "event_espresso"), |
|
381 | + EEH_Template::format_currency($total_cost) |
|
382 | + ); ?> |
|
383 | 383 | </h2> |
384 | 384 | </div> |
385 | 385 | <div class="payment-dv"> |
@@ -398,13 +398,13 @@ discard block |
||
398 | 398 | </thead> |
399 | 399 | <tbody> |
400 | 400 | <?php |
401 | - $c = false; |
|
402 | - if (! empty($payments)) { |
|
403 | - foreach ($payments as $payment) { |
|
404 | - /* @var $payment EE_Payment */ ?> |
|
401 | + $c = false; |
|
402 | + if (! empty($payments)) { |
|
403 | + foreach ($payments as $payment) { |
|
404 | + /* @var $payment EE_Payment */ ?> |
|
405 | 405 | <tr class='item <?php echo(($c = ! $c) |
406 | - ? ' odd' |
|
407 | - : '') ?>'> |
|
406 | + ? ' odd' |
|
407 | + : '') ?>'> |
|
408 | 408 | <td><?php $payment->e('PAY_gateway') ?></td> |
409 | 409 | <td><?php echo esc_html($payment->timestamp()); ?></td> |
410 | 410 | <td><?php $payment->e('PAY_txn_id_chq_nmbr') ?></td> |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | <td class='item_r'><?php echo wp_kses($payment->amount_no_code(), AllowedTags::getAllowedTags()); ?></td> |
414 | 414 | </tr> |
415 | 415 | <?php } |
416 | - } else { ?> |
|
416 | + } else { ?> |
|
417 | 417 | <tr class='item'> |
418 | 418 | <td class='aln-cntr' colspan="6"> |
419 | 419 | <?php |
420 | - esc_html_e( |
|
421 | - "No approved payments have been received.", |
|
422 | - 'event_espresso' |
|
423 | - ) ?> |
|
420 | + esc_html_e( |
|
421 | + "No approved payments have been received.", |
|
422 | + 'event_espresso' |
|
423 | + ) ?> |
|
424 | 424 | </td> |
425 | 425 | </tr> |
426 | 426 | <?php } ?> |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | <?php if ($venues_for_events) { ?> |
458 | 458 | <h2> |
459 | 459 | <?php |
460 | - echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
460 | + echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
461 | 461 | </h2> |
462 | 462 | <table class="venue-list"> |
463 | 463 | <?php foreach ($venues_for_events as $venue) { ?> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | <div class="events"> |
63 | 63 | <?php foreach ($events_for_txn as $event_id => $event) { ?> |
64 | 64 | <h3 class="section-title event-name"> |
65 | - <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
|
65 | + <img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"> |
|
66 | 66 | <?php |
67 | 67 | esc_html_e( |
68 | 68 | "Event Name:", |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | <?php } ?> |
79 | 79 | <ul class="tickets-per-event"> |
80 | 80 | <?php |
81 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
81 | + foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) { |
|
82 | 82 | $ticket = $line_item->ticket(); |
83 | 83 | $taxable_html = $ticket->taxable() |
84 | 84 | ? '*' |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | <?php |
108 | 108 | if (count($subitems) < 2) { ?> |
109 | 109 | <tr class="item"> |
110 | - <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
|
110 | + <td><?php echo esc_html($line_item->name().$taxable_html); ?></td> |
|
111 | 111 | <td colspan="2"> |
112 | 112 | <?php echo esc_html($line_item->desc()); ?> |
113 | 113 | <p class="ticket-note"> |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | </td> |
124 | 124 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
125 | 125 | <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td> |
126 | - <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
|
126 | + <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
|
127 | 127 | </tr> |
128 | 128 | <?php |
129 | 129 | } else { ?> |
130 | 130 | <tr class="item"> |
131 | 131 | <td class="aln-left"> |
132 | - <?php echo esc_html($line_item->name() . $taxable_html); ?> |
|
132 | + <?php echo esc_html($line_item->name().$taxable_html); ?> |
|
133 | 133 | </td> |
134 | 134 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
135 | 135 | <p class="ticket-note"> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | </td> |
169 | 169 | <td class="item_c"><?php |
170 | 170 | echo ($is_percent |
171 | - ? $sub_line_item->percent() . "%" |
|
171 | + ? $sub_line_item->percent()."%" |
|
172 | 172 | : $sub_line_item->unit_price_no_code()); ?> |
173 | 173 | </td> |
174 | 174 | <td class="item_r"><?php echo wp_kses($sub_line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td> |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | <div class="ticket-time-and-place-details"> |
195 | 195 | <div class="ticket-time-details"> |
196 | 196 | <h4 class="sub-section-title no-bottom-margin"> |
197 | - <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
|
197 | + <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'clock-16x16.png'); ?>"> |
|
198 | 198 | <?php |
199 | 199 | echo _n( |
200 | 200 | "Date/Time:", |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | /* @var $datetime EE_Datetime */ ?> |
209 | 209 | <li><?php |
210 | 210 | echo ($datetime->name() |
211 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
211 | + ? '<b>'.esc_html($datetime->name()).' </b>' |
|
212 | 212 | : ''); |
213 | 213 | echo sprintf( |
214 | 214 | esc_html__("%s - %s (%s)", "event_espresso"), |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $datetime->get_timezone() |
218 | 218 | ); |
219 | 219 | echo ($datetime->description() |
220 | - ? '<p class="ticket-note">' . wp_kses($datetime->description(), AllowedTags::getAllowedTags()) . '</p>' |
|
220 | + ? '<p class="ticket-note">'.wp_kses($datetime->description(), AllowedTags::getAllowedTags()).'</p>' |
|
221 | 221 | : ''); ?></li> |
222 | 222 | <?php |
223 | 223 | } ?> |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | <div class="ticket-place-details"> |
229 | 229 | <h4 class="sub-section-title no-bottom-margin"> |
230 | 230 | <img class="icon" src="<?php |
231 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
231 | + echo esc_url_raw(EE_IMAGES_URL.'location-pin-16x16.png'); ?>"> |
|
232 | 232 | <?php |
233 | 233 | echo _n( |
234 | 234 | "Venue:", |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | <div class="ticket-registrations-area"> |
259 | 259 | <h4 class="sub-section-title"> |
260 | 260 | <img class="icon" src="<?php |
261 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
261 | + echo esc_url_raw(EE_IMAGES_URL.'users-16x16.png'); ?>"> |
|
262 | 262 | <?php |
263 | 263 | echo esc_html__("Registration Details", "event_espresso"); ?> |
264 | 264 | <span class="small-text link">[ |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | </h4> |
271 | 271 | <ul class="ticket-registrations-list"> |
272 | 272 | <?php |
273 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
273 | + foreach ($registrations_per_line_item[$line_item_id] as $registration) { |
|
274 | 274 | /* @var $registration EE_Registration */ |
275 | 275 | $attendee = $registration->attendee(); |
276 | 276 | $answers = $registration->answers( |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | <tbody> |
400 | 400 | <?php |
401 | 401 | $c = false; |
402 | - if (! empty($payments)) { |
|
402 | + if ( ! empty($payments)) { |
|
403 | 403 | foreach ($payments as $payment) { |
404 | 404 | /* @var $payment EE_Payment */ ?> |
405 | 405 | <tr class='item <?php echo(($c = ! $c) |
@@ -13,433 +13,433 @@ |
||
13 | 13 | class Invoice |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * |
|
18 | - * @var EE_Registration |
|
19 | - */ |
|
20 | - private $registration; |
|
21 | - |
|
22 | - /** |
|
23 | - * |
|
24 | - * @var EE_Transaction |
|
25 | - */ |
|
26 | - private $transaction; |
|
27 | - |
|
28 | - /** |
|
29 | - * |
|
30 | - * @var EE_Payment_Method |
|
31 | - */ |
|
32 | - private $invoice_payment_method; |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * Invoice constructor. |
|
37 | - * |
|
38 | - * @param int $url_link |
|
39 | - * @throws EE_Error |
|
40 | - * @throws ReflectionException |
|
41 | - * @deprecated 4.9.13 |
|
42 | - */ |
|
43 | - public function __construct($url_link = 0) |
|
44 | - { |
|
45 | - EE_Error::doing_it_wrong( |
|
46 | - __CLASS__, |
|
47 | - esc_html__( |
|
48 | - 'This class has been deprecated and replaced by the new Messages library.', |
|
49 | - 'event_espresso' |
|
50 | - ), |
|
51 | - '4.9.12', |
|
52 | - '5.0.0' |
|
53 | - ); |
|
54 | - /** @var EEM_Registration $reg_model */ |
|
55 | - $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
56 | - if ($this->registration = $reg_model->get_registration_for_reg_url_link($url_link)) { |
|
57 | - $this->transaction = $this->registration->transaction(); |
|
58 | - EE_Config::instance()->gateway->payment_settings; |
|
59 | - $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
60 | - } else { |
|
61 | - EE_Error::add_error( |
|
62 | - esc_html__( |
|
63 | - 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', |
|
64 | - 'event_espresso' |
|
65 | - ), |
|
66 | - __FILE__, |
|
67 | - __FUNCTION__, |
|
68 | - __LINE__ |
|
69 | - ); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param false $download |
|
76 | - * @throws EE_Error |
|
77 | - * @throws ReflectionException |
|
78 | - */ |
|
79 | - public function send_invoice($download = false) |
|
80 | - { |
|
81 | - $template_args = []; |
|
82 | - $EE = EE_Registry::instance(); |
|
83 | - /** @var RequestInterface $request */ |
|
84 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
85 | - $theme = $request->getRequestParam('theme', 0, 'int'); |
|
86 | - // allow the request to override the default theme defined in the invoice settings |
|
87 | - $theme_requested = $theme > 0 && $theme < 8 |
|
88 | - ? $theme |
|
89 | - : null; |
|
90 | - $themes = [ |
|
91 | - 1 => "simple.css", |
|
92 | - 2 => "bauhaus.css", |
|
93 | - 3 => "ejs.css", |
|
94 | - 4 => "horizon.css", |
|
95 | - 5 => "lola.css", |
|
96 | - 6 => "tranquility.css", |
|
97 | - 7 => "union.css", |
|
98 | - ]; |
|
99 | - // Get the CSS file |
|
100 | - if (isset($themes[ $theme_requested ])) { |
|
101 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
102 | - } else { |
|
103 | - $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
|
104 | - 'legacy_invoice_css', |
|
105 | - true, |
|
106 | - 'simple.css' |
|
107 | - ); |
|
108 | - } |
|
109 | - |
|
110 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
111 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
112 | - } else { |
|
113 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
114 | - } |
|
115 | - $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
116 | - |
|
117 | - $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
118 | - $template_args['street'] = empty($EE->CFG->organization->address_2) |
|
119 | - ? $EE->CFG->organization->get_pretty('address_1') |
|
120 | - : $EE->CFG->organization->get_pretty('address_1') |
|
121 | - . '<br>' |
|
122 | - . $EE->CFG->organization->get_pretty('address_2'); |
|
123 | - $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
124 | - $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
125 | - $EE->CFG->organization->STA_ID |
|
126 | - ); |
|
127 | - $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID( |
|
128 | - $EE->CFG->organization->CNT_ISO |
|
129 | - ); |
|
130 | - $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
131 | - $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
132 | - |
|
133 | - $template_args['registration_code'] = $this->registration->reg_code(); |
|
134 | - $template_args['registration_date'] = $this->registration->date(); |
|
135 | - $template_args['name'] = $primary_attendee->full_name(); |
|
136 | - $template_args['attendee_address'] = $primary_attendee->address(); |
|
137 | - $template_args['attendee_address2'] = $primary_attendee->address2(); |
|
138 | - $template_args['attendee_city'] = $primary_attendee->city(); |
|
139 | - $attendee_state = $primary_attendee->state_obj(); |
|
140 | - if ($attendee_state) { |
|
141 | - $attendee_state_name = $attendee_state->name(); |
|
142 | - } else { |
|
143 | - $attendee_state_name = ''; |
|
144 | - } |
|
145 | - $template_args['attendee_state'] = $attendee_state_name; |
|
146 | - $template_args['attendee_zip'] = $primary_attendee->zip(); |
|
147 | - |
|
148 | - $template_args['ship_name'] = $template_args['name']; |
|
149 | - $template_args['ship_address'] = $template_args['attendee_address']; |
|
150 | - $template_args['ship_city'] = $template_args['attendee_city']; |
|
151 | - $template_args['ship_state'] = $template_args['attendee_state']; |
|
152 | - $template_args['ship_zip'] = $template_args['attendee_zip']; |
|
153 | - |
|
154 | - $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', ''); |
|
155 | - $template_args['transaction'] = $this->transaction; |
|
156 | - $template_args['amount_pd'] = $this->transaction->paid(); |
|
157 | - $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid(); |
|
158 | - $template_args['payments'] = $this->transaction->approved_payments(); |
|
159 | - $template_args['net_total'] = ''; |
|
160 | - $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url(); |
|
161 | - $template_args['retry_payment_url'] = $this->registration->payment_overview_url(); |
|
162 | - $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description( |
|
163 | - $this->transaction->total_line_item() |
|
164 | - ); |
|
165 | - if ($template_args['amount_pd'] != $template_args['total_cost']) { |
|
166 | - // $template_args['net_total'] = $this->espressoInvoiceTotals( |
|
167 | - // esc_html__('SubTotal', 'event_espresso'), |
|
168 | - // $this->transaction->total()); |
|
169 | - // $this->session_data['cart']['REG']['sub_total'] |
|
170 | - // ); |
|
171 | - $tax_items = $this->transaction->tax_items(); |
|
172 | - if (! empty($tax_items)) { |
|
173 | - foreach ($tax_items as $tax) { |
|
174 | - $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - $difference = $template_args['amount_pd'] - $template_args['total_cost']; |
|
179 | - if ($difference < 0) { |
|
180 | - $text = esc_html__('Discount', 'event_espresso'); |
|
181 | - } else { |
|
182 | - $text = esc_html__('Extra', 'event_espresso'); |
|
183 | - } |
|
184 | - $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
185 | - } |
|
186 | - |
|
187 | - $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
|
188 | - $template_args['template_payment_instructions'] = wpautop( |
|
189 | - stripslashes_deep( |
|
190 | - html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
|
191 | - ) |
|
192 | - ); |
|
193 | - $template_args['shameless_plug'] = apply_filters( |
|
194 | - 'FHEE_Invoice__send_invoice__shameless_plug', |
|
195 | - true |
|
196 | - ); |
|
197 | - $receipt = $request->getRequestParam('receipt'); |
|
198 | - if ($receipt) { |
|
199 | - // receipt-specific stuff |
|
200 | - $events_for_txn = EEM_Event::instance()->get_all( |
|
201 | - [['Registration.TXN_ID' => $this->transaction->ID()]] |
|
202 | - ); |
|
203 | - $ticket_line_items_per_event = []; |
|
204 | - $registrations_per_line_item = []; |
|
205 | - $venues_for_events = []; |
|
206 | - foreach ($events_for_txn as $event_id => $event) { |
|
207 | - $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
|
208 | - [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]] |
|
209 | - ); |
|
210 | - $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
211 | - foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
212 | - if (! $line_item instanceof EE_Line_Item) { |
|
213 | - continue; |
|
214 | - } |
|
215 | - $ticket = $line_item->ticket(); |
|
216 | - $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
|
217 | - [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]] |
|
218 | - ); |
|
219 | - $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
220 | - } |
|
221 | - if ($event instanceof EE_Event) { |
|
222 | - $venues_for_events += $event->venues(); |
|
223 | - } |
|
224 | - } |
|
225 | - $tax_total_line_item = EEM_Line_Item::instance()->get_one( |
|
226 | - [['TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total]] |
|
227 | - ); |
|
228 | - $questions_to_skip = [ |
|
229 | - EEM_Attendee::system_question_fname, |
|
230 | - EEM_Attendee::system_question_lname, |
|
231 | - EEM_Attendee::system_question_email, |
|
232 | - ]; |
|
233 | - |
|
234 | - |
|
235 | - $template_args['events_for_txn'] = $events_for_txn; |
|
236 | - $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event; |
|
237 | - $template_args['registrations_per_line_item'] = $registrations_per_line_item; |
|
238 | - $template_args['venues_for_events'] = $venues_for_events; |
|
239 | - $template_args['tax_total_line_item'] = $tax_total_line_item; |
|
240 | - $template_args['questions_to_skip'] = $questions_to_skip; |
|
241 | - // d($template_args); |
|
242 | - $template_args['download_link'] = $this->registration->receipt_url('download'); |
|
243 | - } else { |
|
244 | - // it's just an invoice we're accessing |
|
245 | - $template_args['download_link'] = $this->registration->invoice_url('download'); |
|
246 | - } |
|
247 | - |
|
248 | - // Get the HTML as an object |
|
249 | - $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
250 | - $template_header = EEH_Template::locate_template( |
|
251 | - $templates_relative_path . 'invoice_header.template.php', |
|
252 | - $template_args |
|
253 | - ); |
|
254 | - if ($receipt) { |
|
255 | - $template_body = EEH_Template::locate_template( |
|
256 | - $templates_relative_path . 'receipt_body.template.php', |
|
257 | - $template_args |
|
258 | - ); |
|
259 | - } else { |
|
260 | - $template_body = EEH_Template::locate_template( |
|
261 | - $templates_relative_path . 'invoice_body.template.php', |
|
262 | - $template_args |
|
263 | - ); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - $template_footer = EEH_Template::locate_template( |
|
268 | - $templates_relative_path . 'invoice_footer.template.php', |
|
269 | - $template_args |
|
270 | - ); |
|
271 | - |
|
272 | - $copies = $request->getRequestParam('copies', 1, 'int'); |
|
273 | - |
|
274 | - $content = $this->espresso_replace_invoice_shortcodes($template_header); |
|
275 | - for ($x = 1; $x <= $copies; $x++) { |
|
276 | - $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
|
277 | - } |
|
278 | - $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
|
279 | - |
|
280 | - // Check if debugging or mobile is set |
|
281 | - if ($request->getRequestParam('html')) { |
|
282 | - echo wp_kses($content, AllowedTags::getWithFormTags()); |
|
283 | - exit(0); |
|
284 | - } |
|
285 | - $invoice_name = $template_args['organization'] . ' '; |
|
286 | - $invoice_name .= esc_html__('Invoice #', 'event_espresso'); |
|
287 | - $invoice_name .= $template_args['registration_code']; |
|
288 | - $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name']; |
|
289 | - $invoice_name = str_replace(' ', '_', $invoice_name); |
|
290 | - // Create the PDF |
|
291 | - if ($request->requestParamIsSet('html')) { |
|
292 | - echo wp_kses($content, AllowedTags::getWithFormTags()); |
|
293 | - } else { |
|
294 | - // only load dompdf if nobody else has yet... |
|
295 | - if (! class_exists('Dompdf\Dompdf')) { |
|
296 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
297 | - Dompdf\Autoloader::register(); |
|
298 | - } |
|
299 | - $options = new Dompdf\Options(); |
|
300 | - $options->set('isRemoteEnabled', true); |
|
301 | - $options->set('isJavascriptEnabled', false); |
|
302 | - if (defined('DOMPDF_FONT_DIR')) { |
|
303 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
304 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
305 | - } |
|
306 | - $dompdf = new Dompdf\Dompdf($options); |
|
307 | - $dompdf->loadHtml($content); |
|
308 | - $dompdf->render(); |
|
309 | - $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]); |
|
310 | - } |
|
311 | - exit(0); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Checks if this line item, or any of its children, actually has a description. |
|
317 | - * If none do, then the template can decide to not show any description column |
|
318 | - * |
|
319 | - * @param EE_Line_Item $line_item |
|
320 | - * @return boolean |
|
321 | - * @throws EE_Error |
|
322 | - * @throws ReflectionException |
|
323 | - */ |
|
324 | - public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) |
|
325 | - { |
|
326 | - if ($line_item->desc()) { |
|
327 | - return true; |
|
328 | - } else { |
|
329 | - foreach ($line_item->children() as $child_line_item) { |
|
330 | - if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
331 | - return true; |
|
332 | - } |
|
333 | - } |
|
334 | - // well, if I and my children don't have descriptions, I guess not |
|
335 | - return false; |
|
336 | - } |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - /** |
|
341 | - * Perform the shortcode replacement |
|
342 | - * |
|
343 | - * @param $content |
|
344 | - * @return array|string|string[] |
|
345 | - * @throws EE_Error |
|
346 | - * @throws ReflectionException |
|
347 | - */ |
|
348 | - public function espresso_replace_invoice_shortcodes($content) |
|
349 | - { |
|
350 | - |
|
351 | - $EE = EE_Registry::instance(); |
|
352 | - // Create the logo |
|
353 | - $invoice_logo_url = $this->invoice_payment_method->get_extra_meta( |
|
354 | - 'pdf_logo_image', |
|
355 | - true, |
|
356 | - $EE->CFG->organization->logo_url |
|
357 | - ); |
|
358 | - if (! empty($invoice_logo_url)) { |
|
359 | - $image_size = getimagesize($invoice_logo_url); |
|
360 | - $invoice_logo_image = |
|
361 | - '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
362 | - } else { |
|
363 | - $invoice_logo_image = ''; |
|
364 | - } |
|
365 | - $SearchValues = [ |
|
366 | - "[organization]", |
|
367 | - "[registration_code]", |
|
368 | - "[transaction_id]", |
|
369 | - "[name]", |
|
370 | - "[base_url]", |
|
371 | - "[download_link]", |
|
372 | - "[invoice_logo_image]", |
|
373 | - "[street]", |
|
374 | - "[city]", |
|
375 | - "[state]", |
|
376 | - "[zip]", |
|
377 | - "[email]", |
|
378 | - "[vat]", |
|
379 | - "[registration_date]", |
|
380 | - "[instructions]", |
|
381 | - ]; |
|
382 | - $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
383 | - $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
384 | - if ($org_state) { |
|
385 | - $org_state_name = $org_state->name(); |
|
386 | - } else { |
|
387 | - $org_state_name = ''; |
|
388 | - } |
|
389 | - $ReplaceValues = [ |
|
390 | - $EE->CFG->organization->get_pretty('name'), |
|
391 | - $this->registration->reg_code(), |
|
392 | - $this->transaction->ID(), |
|
393 | - $primary_attendee->full_name(), |
|
394 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) |
|
395 | - ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
396 | - : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
397 | - $this->registration->invoice_url(), |
|
398 | - // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
399 | - $invoice_logo_image, |
|
400 | - empty($EE->CFG->organization->address_2) |
|
401 | - ? $EE->CFG->organization->get_pretty('address_1') |
|
402 | - : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
403 | - 'address_2' |
|
404 | - ), |
|
405 | - $EE->CFG->organization->get_pretty('city'), |
|
406 | - $org_state_name, |
|
407 | - $EE->CFG->organization->get_pretty('zip'), |
|
408 | - $EE->CFG->organization->get_pretty('email'), |
|
409 | - $EE->CFG->organization->vat, |
|
410 | - $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
411 | - $this->invoice_payment_method->get_extra_meta('pdf_instructions', true), |
|
412 | - ]; |
|
413 | - |
|
414 | - return str_replace($SearchValues, $ReplaceValues, $content); |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - public function espressoLoadData($items) |
|
419 | - { |
|
420 | - $lines = $items; |
|
421 | - $data = []; |
|
422 | - foreach ($lines as $line) { |
|
423 | - $data[] = explode(';', chop($line)); |
|
424 | - } |
|
425 | - |
|
426 | - return $data; |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - public function espressoInvoiceTotals($text, $total_cost) |
|
431 | - { |
|
432 | - $html = ''; |
|
433 | - if ($total_cost < 0) { |
|
434 | - $total_cost = (-1) * $total_cost; |
|
435 | - } |
|
436 | - $find = [' ']; |
|
437 | - $replace = ['-']; |
|
438 | - $row_id = strtolower(str_replace($find, $replace, $text)); |
|
439 | - $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
440 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
441 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
442 | - $html .= '</tr>'; |
|
443 | - return $html; |
|
444 | - } |
|
16 | + /** |
|
17 | + * |
|
18 | + * @var EE_Registration |
|
19 | + */ |
|
20 | + private $registration; |
|
21 | + |
|
22 | + /** |
|
23 | + * |
|
24 | + * @var EE_Transaction |
|
25 | + */ |
|
26 | + private $transaction; |
|
27 | + |
|
28 | + /** |
|
29 | + * |
|
30 | + * @var EE_Payment_Method |
|
31 | + */ |
|
32 | + private $invoice_payment_method; |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * Invoice constructor. |
|
37 | + * |
|
38 | + * @param int $url_link |
|
39 | + * @throws EE_Error |
|
40 | + * @throws ReflectionException |
|
41 | + * @deprecated 4.9.13 |
|
42 | + */ |
|
43 | + public function __construct($url_link = 0) |
|
44 | + { |
|
45 | + EE_Error::doing_it_wrong( |
|
46 | + __CLASS__, |
|
47 | + esc_html__( |
|
48 | + 'This class has been deprecated and replaced by the new Messages library.', |
|
49 | + 'event_espresso' |
|
50 | + ), |
|
51 | + '4.9.12', |
|
52 | + '5.0.0' |
|
53 | + ); |
|
54 | + /** @var EEM_Registration $reg_model */ |
|
55 | + $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
56 | + if ($this->registration = $reg_model->get_registration_for_reg_url_link($url_link)) { |
|
57 | + $this->transaction = $this->registration->transaction(); |
|
58 | + EE_Config::instance()->gateway->payment_settings; |
|
59 | + $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
60 | + } else { |
|
61 | + EE_Error::add_error( |
|
62 | + esc_html__( |
|
63 | + 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + __FILE__, |
|
67 | + __FUNCTION__, |
|
68 | + __LINE__ |
|
69 | + ); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param false $download |
|
76 | + * @throws EE_Error |
|
77 | + * @throws ReflectionException |
|
78 | + */ |
|
79 | + public function send_invoice($download = false) |
|
80 | + { |
|
81 | + $template_args = []; |
|
82 | + $EE = EE_Registry::instance(); |
|
83 | + /** @var RequestInterface $request */ |
|
84 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
85 | + $theme = $request->getRequestParam('theme', 0, 'int'); |
|
86 | + // allow the request to override the default theme defined in the invoice settings |
|
87 | + $theme_requested = $theme > 0 && $theme < 8 |
|
88 | + ? $theme |
|
89 | + : null; |
|
90 | + $themes = [ |
|
91 | + 1 => "simple.css", |
|
92 | + 2 => "bauhaus.css", |
|
93 | + 3 => "ejs.css", |
|
94 | + 4 => "horizon.css", |
|
95 | + 5 => "lola.css", |
|
96 | + 6 => "tranquility.css", |
|
97 | + 7 => "union.css", |
|
98 | + ]; |
|
99 | + // Get the CSS file |
|
100 | + if (isset($themes[ $theme_requested ])) { |
|
101 | + $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
102 | + } else { |
|
103 | + $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
|
104 | + 'legacy_invoice_css', |
|
105 | + true, |
|
106 | + 'simple.css' |
|
107 | + ); |
|
108 | + } |
|
109 | + |
|
110 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
111 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
112 | + } else { |
|
113 | + $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
114 | + } |
|
115 | + $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
116 | + |
|
117 | + $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
118 | + $template_args['street'] = empty($EE->CFG->organization->address_2) |
|
119 | + ? $EE->CFG->organization->get_pretty('address_1') |
|
120 | + : $EE->CFG->organization->get_pretty('address_1') |
|
121 | + . '<br>' |
|
122 | + . $EE->CFG->organization->get_pretty('address_2'); |
|
123 | + $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
124 | + $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
125 | + $EE->CFG->organization->STA_ID |
|
126 | + ); |
|
127 | + $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID( |
|
128 | + $EE->CFG->organization->CNT_ISO |
|
129 | + ); |
|
130 | + $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
131 | + $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
132 | + |
|
133 | + $template_args['registration_code'] = $this->registration->reg_code(); |
|
134 | + $template_args['registration_date'] = $this->registration->date(); |
|
135 | + $template_args['name'] = $primary_attendee->full_name(); |
|
136 | + $template_args['attendee_address'] = $primary_attendee->address(); |
|
137 | + $template_args['attendee_address2'] = $primary_attendee->address2(); |
|
138 | + $template_args['attendee_city'] = $primary_attendee->city(); |
|
139 | + $attendee_state = $primary_attendee->state_obj(); |
|
140 | + if ($attendee_state) { |
|
141 | + $attendee_state_name = $attendee_state->name(); |
|
142 | + } else { |
|
143 | + $attendee_state_name = ''; |
|
144 | + } |
|
145 | + $template_args['attendee_state'] = $attendee_state_name; |
|
146 | + $template_args['attendee_zip'] = $primary_attendee->zip(); |
|
147 | + |
|
148 | + $template_args['ship_name'] = $template_args['name']; |
|
149 | + $template_args['ship_address'] = $template_args['attendee_address']; |
|
150 | + $template_args['ship_city'] = $template_args['attendee_city']; |
|
151 | + $template_args['ship_state'] = $template_args['attendee_state']; |
|
152 | + $template_args['ship_zip'] = $template_args['attendee_zip']; |
|
153 | + |
|
154 | + $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', ''); |
|
155 | + $template_args['transaction'] = $this->transaction; |
|
156 | + $template_args['amount_pd'] = $this->transaction->paid(); |
|
157 | + $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid(); |
|
158 | + $template_args['payments'] = $this->transaction->approved_payments(); |
|
159 | + $template_args['net_total'] = ''; |
|
160 | + $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url(); |
|
161 | + $template_args['retry_payment_url'] = $this->registration->payment_overview_url(); |
|
162 | + $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description( |
|
163 | + $this->transaction->total_line_item() |
|
164 | + ); |
|
165 | + if ($template_args['amount_pd'] != $template_args['total_cost']) { |
|
166 | + // $template_args['net_total'] = $this->espressoInvoiceTotals( |
|
167 | + // esc_html__('SubTotal', 'event_espresso'), |
|
168 | + // $this->transaction->total()); |
|
169 | + // $this->session_data['cart']['REG']['sub_total'] |
|
170 | + // ); |
|
171 | + $tax_items = $this->transaction->tax_items(); |
|
172 | + if (! empty($tax_items)) { |
|
173 | + foreach ($tax_items as $tax) { |
|
174 | + $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + $difference = $template_args['amount_pd'] - $template_args['total_cost']; |
|
179 | + if ($difference < 0) { |
|
180 | + $text = esc_html__('Discount', 'event_espresso'); |
|
181 | + } else { |
|
182 | + $text = esc_html__('Extra', 'event_espresso'); |
|
183 | + } |
|
184 | + $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
185 | + } |
|
186 | + |
|
187 | + $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
|
188 | + $template_args['template_payment_instructions'] = wpautop( |
|
189 | + stripslashes_deep( |
|
190 | + html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
|
191 | + ) |
|
192 | + ); |
|
193 | + $template_args['shameless_plug'] = apply_filters( |
|
194 | + 'FHEE_Invoice__send_invoice__shameless_plug', |
|
195 | + true |
|
196 | + ); |
|
197 | + $receipt = $request->getRequestParam('receipt'); |
|
198 | + if ($receipt) { |
|
199 | + // receipt-specific stuff |
|
200 | + $events_for_txn = EEM_Event::instance()->get_all( |
|
201 | + [['Registration.TXN_ID' => $this->transaction->ID()]] |
|
202 | + ); |
|
203 | + $ticket_line_items_per_event = []; |
|
204 | + $registrations_per_line_item = []; |
|
205 | + $venues_for_events = []; |
|
206 | + foreach ($events_for_txn as $event_id => $event) { |
|
207 | + $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
|
208 | + [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]] |
|
209 | + ); |
|
210 | + $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
211 | + foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
212 | + if (! $line_item instanceof EE_Line_Item) { |
|
213 | + continue; |
|
214 | + } |
|
215 | + $ticket = $line_item->ticket(); |
|
216 | + $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
|
217 | + [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]] |
|
218 | + ); |
|
219 | + $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
220 | + } |
|
221 | + if ($event instanceof EE_Event) { |
|
222 | + $venues_for_events += $event->venues(); |
|
223 | + } |
|
224 | + } |
|
225 | + $tax_total_line_item = EEM_Line_Item::instance()->get_one( |
|
226 | + [['TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total]] |
|
227 | + ); |
|
228 | + $questions_to_skip = [ |
|
229 | + EEM_Attendee::system_question_fname, |
|
230 | + EEM_Attendee::system_question_lname, |
|
231 | + EEM_Attendee::system_question_email, |
|
232 | + ]; |
|
233 | + |
|
234 | + |
|
235 | + $template_args['events_for_txn'] = $events_for_txn; |
|
236 | + $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event; |
|
237 | + $template_args['registrations_per_line_item'] = $registrations_per_line_item; |
|
238 | + $template_args['venues_for_events'] = $venues_for_events; |
|
239 | + $template_args['tax_total_line_item'] = $tax_total_line_item; |
|
240 | + $template_args['questions_to_skip'] = $questions_to_skip; |
|
241 | + // d($template_args); |
|
242 | + $template_args['download_link'] = $this->registration->receipt_url('download'); |
|
243 | + } else { |
|
244 | + // it's just an invoice we're accessing |
|
245 | + $template_args['download_link'] = $this->registration->invoice_url('download'); |
|
246 | + } |
|
247 | + |
|
248 | + // Get the HTML as an object |
|
249 | + $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
250 | + $template_header = EEH_Template::locate_template( |
|
251 | + $templates_relative_path . 'invoice_header.template.php', |
|
252 | + $template_args |
|
253 | + ); |
|
254 | + if ($receipt) { |
|
255 | + $template_body = EEH_Template::locate_template( |
|
256 | + $templates_relative_path . 'receipt_body.template.php', |
|
257 | + $template_args |
|
258 | + ); |
|
259 | + } else { |
|
260 | + $template_body = EEH_Template::locate_template( |
|
261 | + $templates_relative_path . 'invoice_body.template.php', |
|
262 | + $template_args |
|
263 | + ); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + $template_footer = EEH_Template::locate_template( |
|
268 | + $templates_relative_path . 'invoice_footer.template.php', |
|
269 | + $template_args |
|
270 | + ); |
|
271 | + |
|
272 | + $copies = $request->getRequestParam('copies', 1, 'int'); |
|
273 | + |
|
274 | + $content = $this->espresso_replace_invoice_shortcodes($template_header); |
|
275 | + for ($x = 1; $x <= $copies; $x++) { |
|
276 | + $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
|
277 | + } |
|
278 | + $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
|
279 | + |
|
280 | + // Check if debugging or mobile is set |
|
281 | + if ($request->getRequestParam('html')) { |
|
282 | + echo wp_kses($content, AllowedTags::getWithFormTags()); |
|
283 | + exit(0); |
|
284 | + } |
|
285 | + $invoice_name = $template_args['organization'] . ' '; |
|
286 | + $invoice_name .= esc_html__('Invoice #', 'event_espresso'); |
|
287 | + $invoice_name .= $template_args['registration_code']; |
|
288 | + $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name']; |
|
289 | + $invoice_name = str_replace(' ', '_', $invoice_name); |
|
290 | + // Create the PDF |
|
291 | + if ($request->requestParamIsSet('html')) { |
|
292 | + echo wp_kses($content, AllowedTags::getWithFormTags()); |
|
293 | + } else { |
|
294 | + // only load dompdf if nobody else has yet... |
|
295 | + if (! class_exists('Dompdf\Dompdf')) { |
|
296 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
297 | + Dompdf\Autoloader::register(); |
|
298 | + } |
|
299 | + $options = new Dompdf\Options(); |
|
300 | + $options->set('isRemoteEnabled', true); |
|
301 | + $options->set('isJavascriptEnabled', false); |
|
302 | + if (defined('DOMPDF_FONT_DIR')) { |
|
303 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
304 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
305 | + } |
|
306 | + $dompdf = new Dompdf\Dompdf($options); |
|
307 | + $dompdf->loadHtml($content); |
|
308 | + $dompdf->render(); |
|
309 | + $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]); |
|
310 | + } |
|
311 | + exit(0); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Checks if this line item, or any of its children, actually has a description. |
|
317 | + * If none do, then the template can decide to not show any description column |
|
318 | + * |
|
319 | + * @param EE_Line_Item $line_item |
|
320 | + * @return boolean |
|
321 | + * @throws EE_Error |
|
322 | + * @throws ReflectionException |
|
323 | + */ |
|
324 | + public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) |
|
325 | + { |
|
326 | + if ($line_item->desc()) { |
|
327 | + return true; |
|
328 | + } else { |
|
329 | + foreach ($line_item->children() as $child_line_item) { |
|
330 | + if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
331 | + return true; |
|
332 | + } |
|
333 | + } |
|
334 | + // well, if I and my children don't have descriptions, I guess not |
|
335 | + return false; |
|
336 | + } |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + /** |
|
341 | + * Perform the shortcode replacement |
|
342 | + * |
|
343 | + * @param $content |
|
344 | + * @return array|string|string[] |
|
345 | + * @throws EE_Error |
|
346 | + * @throws ReflectionException |
|
347 | + */ |
|
348 | + public function espresso_replace_invoice_shortcodes($content) |
|
349 | + { |
|
350 | + |
|
351 | + $EE = EE_Registry::instance(); |
|
352 | + // Create the logo |
|
353 | + $invoice_logo_url = $this->invoice_payment_method->get_extra_meta( |
|
354 | + 'pdf_logo_image', |
|
355 | + true, |
|
356 | + $EE->CFG->organization->logo_url |
|
357 | + ); |
|
358 | + if (! empty($invoice_logo_url)) { |
|
359 | + $image_size = getimagesize($invoice_logo_url); |
|
360 | + $invoice_logo_image = |
|
361 | + '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
362 | + } else { |
|
363 | + $invoice_logo_image = ''; |
|
364 | + } |
|
365 | + $SearchValues = [ |
|
366 | + "[organization]", |
|
367 | + "[registration_code]", |
|
368 | + "[transaction_id]", |
|
369 | + "[name]", |
|
370 | + "[base_url]", |
|
371 | + "[download_link]", |
|
372 | + "[invoice_logo_image]", |
|
373 | + "[street]", |
|
374 | + "[city]", |
|
375 | + "[state]", |
|
376 | + "[zip]", |
|
377 | + "[email]", |
|
378 | + "[vat]", |
|
379 | + "[registration_date]", |
|
380 | + "[instructions]", |
|
381 | + ]; |
|
382 | + $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
383 | + $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
384 | + if ($org_state) { |
|
385 | + $org_state_name = $org_state->name(); |
|
386 | + } else { |
|
387 | + $org_state_name = ''; |
|
388 | + } |
|
389 | + $ReplaceValues = [ |
|
390 | + $EE->CFG->organization->get_pretty('name'), |
|
391 | + $this->registration->reg_code(), |
|
392 | + $this->transaction->ID(), |
|
393 | + $primary_attendee->full_name(), |
|
394 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) |
|
395 | + ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
396 | + : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
397 | + $this->registration->invoice_url(), |
|
398 | + // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
399 | + $invoice_logo_image, |
|
400 | + empty($EE->CFG->organization->address_2) |
|
401 | + ? $EE->CFG->organization->get_pretty('address_1') |
|
402 | + : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
403 | + 'address_2' |
|
404 | + ), |
|
405 | + $EE->CFG->organization->get_pretty('city'), |
|
406 | + $org_state_name, |
|
407 | + $EE->CFG->organization->get_pretty('zip'), |
|
408 | + $EE->CFG->organization->get_pretty('email'), |
|
409 | + $EE->CFG->organization->vat, |
|
410 | + $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
411 | + $this->invoice_payment_method->get_extra_meta('pdf_instructions', true), |
|
412 | + ]; |
|
413 | + |
|
414 | + return str_replace($SearchValues, $ReplaceValues, $content); |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + public function espressoLoadData($items) |
|
419 | + { |
|
420 | + $lines = $items; |
|
421 | + $data = []; |
|
422 | + foreach ($lines as $line) { |
|
423 | + $data[] = explode(';', chop($line)); |
|
424 | + } |
|
425 | + |
|
426 | + return $data; |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + public function espressoInvoiceTotals($text, $total_cost) |
|
431 | + { |
|
432 | + $html = ''; |
|
433 | + if ($total_cost < 0) { |
|
434 | + $total_cost = (-1) * $total_cost; |
|
435 | + } |
|
436 | + $find = [' ']; |
|
437 | + $replace = ['-']; |
|
438 | + $row_id = strtolower(str_replace($find, $replace, $text)); |
|
439 | + $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
440 | + $html .= '<td class="item_r">' . $text . '</td>'; |
|
441 | + $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
442 | + $html .= '</tr>'; |
|
443 | + return $html; |
|
444 | + } |
|
445 | 445 | } |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | 7 => "union.css", |
98 | 98 | ]; |
99 | 99 | // Get the CSS file |
100 | - if (isset($themes[ $theme_requested ])) { |
|
101 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
100 | + if (isset($themes[$theme_requested])) { |
|
101 | + $template_args['invoice_css'] = $themes[$theme_requested]; |
|
102 | 102 | } else { |
103 | 103 | $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
104 | 104 | 'legacy_invoice_css', |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | ); |
108 | 108 | } |
109 | 109 | |
110 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
111 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
110 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) { |
|
111 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/'; |
|
112 | 112 | } else { |
113 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
113 | + $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/'; |
|
114 | 114 | } |
115 | 115 | $primary_attendee = $this->transaction->primary_registration()->attendee(); |
116 | 116 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | // $this->session_data['cart']['REG']['sub_total'] |
170 | 170 | // ); |
171 | 171 | $tax_items = $this->transaction->tax_items(); |
172 | - if (! empty($tax_items)) { |
|
172 | + if ( ! empty($tax_items)) { |
|
173 | 173 | foreach ($tax_items as $tax) { |
174 | 174 | $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
175 | 175 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
191 | 191 | ) |
192 | 192 | ); |
193 | - $template_args['shameless_plug'] = apply_filters( |
|
193 | + $template_args['shameless_plug'] = apply_filters( |
|
194 | 194 | 'FHEE_Invoice__send_invoice__shameless_plug', |
195 | 195 | true |
196 | 196 | ); |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
208 | 208 | [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]] |
209 | 209 | ); |
210 | - $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
210 | + $ticket_line_items_per_event[$event_id] = $line_items_for_this_event; |
|
211 | 211 | foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
212 | - if (! $line_item instanceof EE_Line_Item) { |
|
212 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | $ticket = $line_item->ticket(); |
216 | 216 | $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
217 | 217 | [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]] |
218 | 218 | ); |
219 | - $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
219 | + $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket; |
|
220 | 220 | } |
221 | 221 | if ($event instanceof EE_Event) { |
222 | 222 | $venues_for_events += $event->venues(); |
@@ -248,24 +248,24 @@ discard block |
||
248 | 248 | // Get the HTML as an object |
249 | 249 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
250 | 250 | $template_header = EEH_Template::locate_template( |
251 | - $templates_relative_path . 'invoice_header.template.php', |
|
251 | + $templates_relative_path.'invoice_header.template.php', |
|
252 | 252 | $template_args |
253 | 253 | ); |
254 | 254 | if ($receipt) { |
255 | 255 | $template_body = EEH_Template::locate_template( |
256 | - $templates_relative_path . 'receipt_body.template.php', |
|
256 | + $templates_relative_path.'receipt_body.template.php', |
|
257 | 257 | $template_args |
258 | 258 | ); |
259 | 259 | } else { |
260 | 260 | $template_body = EEH_Template::locate_template( |
261 | - $templates_relative_path . 'invoice_body.template.php', |
|
261 | + $templates_relative_path.'invoice_body.template.php', |
|
262 | 262 | $template_args |
263 | 263 | ); |
264 | 264 | } |
265 | 265 | |
266 | 266 | |
267 | 267 | $template_footer = EEH_Template::locate_template( |
268 | - $templates_relative_path . 'invoice_footer.template.php', |
|
268 | + $templates_relative_path.'invoice_footer.template.php', |
|
269 | 269 | $template_args |
270 | 270 | ); |
271 | 271 | |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | echo wp_kses($content, AllowedTags::getWithFormTags()); |
283 | 283 | exit(0); |
284 | 284 | } |
285 | - $invoice_name = $template_args['organization'] . ' '; |
|
285 | + $invoice_name = $template_args['organization'].' '; |
|
286 | 286 | $invoice_name .= esc_html__('Invoice #', 'event_espresso'); |
287 | 287 | $invoice_name .= $template_args['registration_code']; |
288 | - $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name']; |
|
288 | + $invoice_name .= esc_html__(' for ', 'event_espresso').$template_args['name']; |
|
289 | 289 | $invoice_name = str_replace(' ', '_', $invoice_name); |
290 | 290 | // Create the PDF |
291 | 291 | if ($request->requestParamIsSet('html')) { |
292 | 292 | echo wp_kses($content, AllowedTags::getWithFormTags()); |
293 | 293 | } else { |
294 | 294 | // only load dompdf if nobody else has yet... |
295 | - if (! class_exists('Dompdf\Dompdf')) { |
|
296 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
295 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
296 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
297 | 297 | Dompdf\Autoloader::register(); |
298 | 298 | } |
299 | 299 | $options = new Dompdf\Options(); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $dompdf = new Dompdf\Dompdf($options); |
307 | 307 | $dompdf->loadHtml($content); |
308 | 308 | $dompdf->render(); |
309 | - $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]); |
|
309 | + $dompdf->stream($invoice_name.".pdf", ['Attachment' => $download]); |
|
310 | 310 | } |
311 | 311 | exit(0); |
312 | 312 | } |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | true, |
356 | 356 | $EE->CFG->organization->logo_url |
357 | 357 | ); |
358 | - if (! empty($invoice_logo_url)) { |
|
358 | + if ( ! empty($invoice_logo_url)) { |
|
359 | 359 | $image_size = getimagesize($invoice_logo_url); |
360 | 360 | $invoice_logo_image = |
361 | - '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
361 | + '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> '; |
|
362 | 362 | } else { |
363 | 363 | $invoice_logo_image = ''; |
364 | 364 | } |
365 | - $SearchValues = [ |
|
365 | + $SearchValues = [ |
|
366 | 366 | "[organization]", |
367 | 367 | "[registration_code]", |
368 | 368 | "[transaction_id]", |
@@ -391,15 +391,15 @@ discard block |
||
391 | 391 | $this->registration->reg_code(), |
392 | 392 | $this->transaction->ID(), |
393 | 393 | $primary_attendee->full_name(), |
394 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) |
|
394 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) |
|
395 | 395 | ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
396 | - : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
396 | + : EE_GATEWAYS_URL.'Invoice/lib/templates/', |
|
397 | 397 | $this->registration->invoice_url(), |
398 | 398 | // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
399 | 399 | $invoice_logo_image, |
400 | 400 | empty($EE->CFG->organization->address_2) |
401 | 401 | ? $EE->CFG->organization->get_pretty('address_1') |
402 | - : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
402 | + : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty( |
|
403 | 403 | 'address_2' |
404 | 404 | ), |
405 | 405 | $EE->CFG->organization->get_pretty('city'), |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | $find = [' ']; |
437 | 437 | $replace = ['-']; |
438 | 438 | $row_id = strtolower(str_replace($find, $replace, $text)); |
439 | - $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
440 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
441 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
439 | + $html .= '<tr id="'.$row_id.'-tr"><td colspan="4"> </td>'; |
|
440 | + $html .= '<td class="item_r">'.$text.'</td>'; |
|
441 | + $html .= '<td class="item_r">'.$total_cost.'</td>'; |
|
442 | 442 | $html .= '</tr>'; |
443 | 443 | return $html; |
444 | 444 | } |