@@ -1612,7 +1612,7 @@ discard block |
||
1612 | 1612 | * @param \EE_Payment $payment |
1613 | 1613 | * @param array $REG_IDs |
1614 | 1614 | * |
1615 | - * @return bool |
|
1615 | + * @return boolean|null |
|
1616 | 1616 | */ |
1617 | 1617 | protected function _update_registration_payments( |
1618 | 1618 | EE_Transaction $transaction, |
@@ -1821,6 +1821,7 @@ discard block |
||
1821 | 1821 | * @access protected |
1822 | 1822 | * |
1823 | 1823 | * @param \EE_Payment | null $payment |
1824 | + * @param EE_Payment $payment |
|
1824 | 1825 | */ |
1825 | 1826 | protected function _maybe_send_notifications($payment = null) |
1826 | 1827 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -27,1971 +27,1971 @@ discard block |
||
27 | 27 | class Transactions_Admin_Page extends EE_Admin_Page |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * @var EE_Transaction |
|
32 | - */ |
|
33 | - private $_transaction; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var EE_Session |
|
37 | - */ |
|
38 | - private $_session; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var array $_txn_status |
|
42 | - */ |
|
43 | - private static $_txn_status; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var array $_pay_status |
|
47 | - */ |
|
48 | - private static $_pay_status; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var array $_existing_reg_payment_REG_IDs |
|
52 | - */ |
|
53 | - protected $_existing_reg_payment_REG_IDs = null; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @Constructor |
|
58 | - * @access public |
|
59 | - * |
|
60 | - * @param bool $routing |
|
61 | - * |
|
62 | - * @return Transactions_Admin_Page |
|
63 | - */ |
|
64 | - public function __construct($routing = true) |
|
65 | - { |
|
66 | - parent::__construct($routing); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * _init_page_props |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - protected function _init_page_props() |
|
75 | - { |
|
76 | - $this->page_slug = TXN_PG_SLUG; |
|
77 | - $this->page_label = esc_html__('Transactions', 'event_espresso'); |
|
78 | - $this->_admin_base_url = TXN_ADMIN_URL; |
|
79 | - $this->_admin_base_path = TXN_ADMIN; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * _ajax_hooks |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - protected function _ajax_hooks() |
|
88 | - { |
|
89 | - add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
90 | - add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
91 | - add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * _define_page_props |
|
97 | - * @return void |
|
98 | - */ |
|
99 | - protected function _define_page_props() |
|
100 | - { |
|
101 | - $this->_admin_page_title = $this->page_label; |
|
102 | - $this->_labels = array( |
|
103 | - 'buttons' => array( |
|
104 | - 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
|
105 | - 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
|
106 | - 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
107 | - ) |
|
108 | - ); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * grab url requests and route them |
|
114 | - * @access private |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public function _set_page_routes() |
|
118 | - { |
|
119 | - |
|
120 | - $this->_set_transaction_status_array(); |
|
121 | - |
|
122 | - $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
123 | - |
|
124 | - $this->_page_routes = array( |
|
125 | - |
|
126 | - 'default' => array( |
|
127 | - 'func' => '_transactions_overview_list_table', |
|
128 | - 'capability' => 'ee_read_transactions' |
|
129 | - ), |
|
130 | - |
|
131 | - 'view_transaction' => array( |
|
132 | - 'func' => '_transaction_details', |
|
133 | - 'capability' => 'ee_read_transaction', |
|
134 | - 'obj_id' => $txn_id |
|
135 | - ), |
|
136 | - |
|
137 | - 'send_payment_reminder' => array( |
|
138 | - 'func' => '_send_payment_reminder', |
|
139 | - 'noheader' => true, |
|
140 | - 'capability' => 'ee_send_message' |
|
141 | - ), |
|
142 | - |
|
143 | - 'espresso_apply_payment' => array( |
|
144 | - 'func' => 'apply_payments_or_refunds', |
|
145 | - 'noheader' => true, |
|
146 | - 'capability' => 'ee_edit_payments' |
|
147 | - ), |
|
148 | - |
|
149 | - 'espresso_apply_refund' => array( |
|
150 | - 'func' => 'apply_payments_or_refunds', |
|
151 | - 'noheader' => true, |
|
152 | - 'capability' => 'ee_edit_payments' |
|
153 | - ), |
|
154 | - |
|
155 | - 'espresso_delete_payment' => array( |
|
156 | - 'func' => 'delete_payment', |
|
157 | - 'noheader' => true, |
|
158 | - 'capability' => 'ee_delete_payments' |
|
159 | - ), |
|
160 | - |
|
161 | - ); |
|
162 | - |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - protected function _set_page_config() |
|
167 | - { |
|
168 | - $this->_page_config = array( |
|
169 | - 'default' => array( |
|
170 | - 'nav' => array( |
|
171 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
172 | - 'order' => 10 |
|
173 | - ), |
|
174 | - 'list_table' => 'EE_Admin_Transactions_List_Table', |
|
175 | - 'help_tabs' => array( |
|
176 | - 'transactions_overview_help_tab' => array( |
|
177 | - 'title' => esc_html__('Transactions Overview', 'event_espresso'), |
|
178 | - 'filename' => 'transactions_overview' |
|
179 | - ), |
|
180 | - 'transactions_overview_table_column_headings_help_tab' => array( |
|
181 | - 'title' => esc_html__('Transactions Table Column Headings', 'event_espresso'), |
|
182 | - 'filename' => 'transactions_overview_table_column_headings' |
|
183 | - ), |
|
184 | - 'transactions_overview_views_filters_help_tab' => array( |
|
185 | - 'title' => esc_html__('Transaction Views & Filters & Search', 'event_espresso'), |
|
186 | - 'filename' => 'transactions_overview_views_filters_search' |
|
187 | - ), |
|
188 | - ), |
|
189 | - 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
190 | - /** |
|
191 | - * commented out because currently we are not displaying tips for transaction list table status but this |
|
192 | - * may change in a later iteration so want to keep the code for then. |
|
193 | - */ |
|
194 | - //'qtips' => array( 'Transactions_List_Table_Tips' ), |
|
195 | - 'require_nonce' => false |
|
196 | - ), |
|
197 | - 'view_transaction' => array( |
|
198 | - 'nav' => array( |
|
199 | - 'label' => esc_html__('View Transaction', 'event_espresso'), |
|
200 | - 'order' => 5, |
|
201 | - 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), |
|
202 | - $this->_current_page_view_url) : $this->_admin_base_url, |
|
203 | - 'persistent' => false |
|
204 | - ), |
|
205 | - 'help_tabs' => array( |
|
206 | - 'transactions_view_transaction_help_tab' => array( |
|
207 | - 'title' => esc_html__('View Transaction', 'event_espresso'), |
|
208 | - 'filename' => 'transactions_view_transaction' |
|
209 | - ), |
|
210 | - 'transactions_view_transaction_transaction_details_table_help_tab' => array( |
|
211 | - 'title' => esc_html__('Transaction Details Table', 'event_espresso'), |
|
212 | - 'filename' => 'transactions_view_transaction_transaction_details_table' |
|
213 | - ), |
|
214 | - 'transactions_view_transaction_attendees_registered_help_tab' => array( |
|
215 | - 'title' => esc_html__('Attendees Registered', 'event_espresso'), |
|
216 | - 'filename' => 'transactions_view_transaction_attendees_registered' |
|
217 | - ), |
|
218 | - 'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array( |
|
219 | - 'title' => esc_html__('Primary Registrant & Billing Information', 'event_espresso'), |
|
220 | - 'filename' => 'transactions_view_transaction_primary_registrant_billing_information' |
|
221 | - ), |
|
222 | - ), |
|
223 | - 'qtips' => array('Transaction_Details_Tips'), |
|
224 | - 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
225 | - 'metaboxes' => array('_transaction_details_metaboxes'), |
|
226 | - |
|
227 | - 'require_nonce' => false |
|
228 | - ) |
|
229 | - ); |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * The below methods aren't used by this class currently |
|
235 | - */ |
|
236 | - protected function _add_screen_options() |
|
237 | - { |
|
238 | - } |
|
239 | - |
|
240 | - protected function _add_feature_pointers() |
|
241 | - { |
|
242 | - } |
|
243 | - |
|
244 | - public function admin_init() |
|
245 | - { |
|
246 | - // IF a registration was JUST added via the admin... |
|
247 | - if ( |
|
248 | - isset( |
|
249 | - $this->_req_data['redirect_from'], |
|
250 | - $this->_req_data['EVT_ID'], |
|
251 | - $this->_req_data['event_name'] |
|
252 | - ) |
|
253 | - ) { |
|
254 | - // then set a cookie so that we can block any attempts to use |
|
255 | - // the back button as a way to enter another registration. |
|
256 | - setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
257 | - // and update the global |
|
258 | - $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
259 | - } |
|
260 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
261 | - 'event_espresso'); |
|
262 | - EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', |
|
263 | - 'event_espresso'); |
|
264 | - EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
265 | - EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
266 | - EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
267 | - EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', |
|
268 | - 'event_espresso'); |
|
269 | - } |
|
270 | - |
|
271 | - public function admin_notices() |
|
272 | - { |
|
273 | - } |
|
274 | - |
|
275 | - public function admin_footer_scripts() |
|
276 | - { |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * _set_transaction_status_array |
|
282 | - * sets list of transaction statuses |
|
283 | - * |
|
284 | - * @access private |
|
285 | - * @return void |
|
286 | - */ |
|
287 | - private function _set_transaction_status_array() |
|
288 | - { |
|
289 | - self::$_txn_status = EEM_Transaction::instance()->status_array(true); |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * get_transaction_status_array |
|
295 | - * return the transaction status array for wp_list_table |
|
296 | - * |
|
297 | - * @access public |
|
298 | - * @return array |
|
299 | - */ |
|
300 | - public function get_transaction_status_array() |
|
301 | - { |
|
302 | - return self::$_txn_status; |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * get list of payment statuses |
|
308 | - * |
|
309 | - * @access private |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - private function _get_payment_status_array() |
|
313 | - { |
|
314 | - self::$_pay_status = EEM_Payment::instance()->status_array(true); |
|
315 | - $this->_template_args['payment_status'] = self::$_pay_status; |
|
316 | - |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * _add_screen_options_default |
|
322 | - * |
|
323 | - * @access protected |
|
324 | - * @return void |
|
325 | - */ |
|
326 | - protected function _add_screen_options_default() |
|
327 | - { |
|
328 | - $this->_per_page_screen_option(); |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * load_scripts_styles |
|
334 | - * |
|
335 | - * @access public |
|
336 | - * @return void |
|
337 | - */ |
|
338 | - public function load_scripts_styles() |
|
339 | - { |
|
340 | - //enqueue style |
|
341 | - wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), |
|
342 | - EVENT_ESPRESSO_VERSION); |
|
343 | - wp_enqueue_style('espresso_txn'); |
|
344 | - //scripts |
|
345 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array( |
|
346 | - 'ee_admin_js', |
|
347 | - 'ee-datepicker', |
|
348 | - 'jquery-ui-datepicker', |
|
349 | - 'jquery-ui-draggable', |
|
350 | - 'ee-dialog', |
|
351 | - 'ee-accounting', |
|
352 | - 'ee-serialize-full-array' |
|
353 | - ), EVENT_ESPRESSO_VERSION, true); |
|
354 | - wp_enqueue_script('espresso_txn'); |
|
355 | - |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * load_scripts_styles_view_transaction |
|
361 | - * |
|
362 | - * @access public |
|
363 | - * @return void |
|
364 | - */ |
|
365 | - public function load_scripts_styles_view_transaction() |
|
366 | - { |
|
367 | - //styles |
|
368 | - wp_enqueue_style('espresso-ui-theme'); |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * load_scripts_styles_default |
|
374 | - * |
|
375 | - * @access public |
|
376 | - * @return void |
|
377 | - */ |
|
378 | - public function load_scripts_styles_default() |
|
379 | - { |
|
380 | - //styles |
|
381 | - wp_enqueue_style('espresso-ui-theme'); |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * _set_list_table_views_default |
|
387 | - * |
|
388 | - * @access protected |
|
389 | - * @return void |
|
390 | - */ |
|
391 | - protected function _set_list_table_views_default() |
|
392 | - { |
|
393 | - $this->_views = array( |
|
394 | - 'all' => array( |
|
395 | - 'slug' => 'all', |
|
396 | - 'label' => esc_html__('View All Transactions', 'event_espresso'), |
|
397 | - 'count' => 0 |
|
398 | - ), |
|
399 | - 'abandoned' => array( |
|
400 | - 'slug' => 'abandoned', |
|
401 | - 'label' => esc_html__('Abandoned Transactions', 'event_espresso'), |
|
402 | - 'count' => 0 |
|
403 | - ), |
|
404 | - 'failed' => array( |
|
405 | - 'slug' => 'failed', |
|
406 | - 'label' => esc_html__('Failed Transactions', 'event_espresso'), |
|
407 | - 'count' => 0 |
|
408 | - ) |
|
409 | - ); |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * _set_transaction_object |
|
415 | - * This sets the _transaction property for the transaction details screen |
|
416 | - * |
|
417 | - * @access private |
|
418 | - * @return void |
|
419 | - */ |
|
420 | - private function _set_transaction_object() |
|
421 | - { |
|
422 | - if (is_object($this->_transaction)) { |
|
423 | - return; |
|
424 | - } //get out we've already set the object |
|
425 | - |
|
426 | - $TXN = EEM_Transaction::instance(); |
|
427 | - |
|
428 | - $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
429 | - |
|
430 | - //get transaction object |
|
431 | - $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
|
432 | - $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : null; |
|
433 | - $this->_transaction->verify_abandoned_transaction_status(); |
|
434 | - |
|
435 | - if (empty($this->_transaction)) { |
|
436 | - $error_msg = esc_html__('An error occurred and the details for Transaction ID #', |
|
437 | - 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
438 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
439 | - } |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * _transaction_legend_items |
|
445 | - * |
|
446 | - * @access protected |
|
447 | - * @return array |
|
448 | - */ |
|
449 | - protected function _transaction_legend_items() |
|
450 | - { |
|
451 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
452 | - $items = array(); |
|
453 | - |
|
454 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
455 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
456 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
457 | - $items['view_related_messages'] = array( |
|
458 | - 'class' => $related_for_icon['css_class'], |
|
459 | - 'desc' => $related_for_icon['label'], |
|
460 | - ); |
|
461 | - } |
|
462 | - } |
|
463 | - |
|
464 | - $items = apply_filters( |
|
465 | - 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
|
466 | - array_merge($items, |
|
467 | - array( |
|
468 | - 'view_details' => array( |
|
469 | - 'class' => 'dashicons dashicons-cart', |
|
470 | - 'desc' => esc_html__('View Transaction Details', 'event_espresso') |
|
471 | - ), |
|
472 | - 'view_invoice' => array( |
|
473 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
474 | - 'desc' => esc_html__('View Transaction Invoice', 'event_espresso') |
|
475 | - ), |
|
476 | - 'view_receipt' => array( |
|
477 | - 'class' => 'dashicons dashicons-media-default', |
|
478 | - 'desc' => esc_html__('View Transaction Receipt', 'event_espresso') |
|
479 | - ), |
|
480 | - 'view_registration' => array( |
|
481 | - 'class' => 'dashicons dashicons-clipboard', |
|
482 | - 'desc' => esc_html__('View Registration Details', 'event_espresso') |
|
483 | - ) |
|
484 | - ) |
|
485 | - ) |
|
486 | - ); |
|
487 | - |
|
488 | - if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
489 | - 'espresso_transactions_send_payment_reminder') |
|
490 | - ) { |
|
491 | - if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
492 | - $items['send_payment_reminder'] = array( |
|
493 | - 'class' => 'dashicons dashicons-email-alt', |
|
494 | - 'desc' => esc_html__('Send Payment Reminder', 'event_espresso') |
|
495 | - ); |
|
496 | - } else { |
|
497 | - $items['blank*'] = array( |
|
498 | - 'class' => '', |
|
499 | - 'desc' => '' |
|
500 | - ); |
|
501 | - } |
|
502 | - } else { |
|
503 | - $items['blank*'] = array( |
|
504 | - 'class' => '', |
|
505 | - 'desc' => '' |
|
506 | - ); |
|
507 | - } |
|
508 | - $more_items = apply_filters( |
|
509 | - 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
|
510 | - array( |
|
511 | - 'overpaid' => array( |
|
512 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
513 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence') |
|
514 | - ), |
|
515 | - 'complete' => array( |
|
516 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
517 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence') |
|
518 | - ), |
|
519 | - 'incomplete' => array( |
|
520 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
521 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence') |
|
522 | - ), |
|
523 | - 'abandoned' => array( |
|
524 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
525 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence') |
|
526 | - ), |
|
527 | - 'failed' => array( |
|
528 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
529 | - 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence') |
|
530 | - ) |
|
531 | - ) |
|
532 | - ); |
|
533 | - |
|
534 | - return array_merge($items, $more_items); |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * _transactions_overview_list_table |
|
540 | - * |
|
541 | - * @access protected |
|
542 | - * @return void |
|
543 | - */ |
|
544 | - protected function _transactions_overview_list_table() |
|
545 | - { |
|
546 | - $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
547 | - $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null; |
|
548 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', |
|
549 | - 'event_espresso'), '<h3>', |
|
550 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
551 | - EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event', |
|
552 | - 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : ''; |
|
553 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
554 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * _transaction_details |
|
560 | - * generates HTML for the View Transaction Details Admin page |
|
561 | - * |
|
562 | - * @access protected |
|
563 | - * @return void |
|
564 | - */ |
|
565 | - protected function _transaction_details() |
|
566 | - { |
|
567 | - do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
568 | - |
|
569 | - $this->_set_transaction_status_array(); |
|
570 | - |
|
571 | - $this->_template_args = array(); |
|
572 | - $this->_template_args['transactions_page'] = $this->_wp_page_slug; |
|
573 | - |
|
574 | - $this->_set_transaction_object(); |
|
575 | - |
|
576 | - $primary_registration = $this->_transaction->primary_registration(); |
|
577 | - $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : null; |
|
578 | - |
|
579 | - $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
|
580 | - $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
581 | - |
|
582 | - $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
|
583 | - $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
584 | - |
|
585 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
586 | - $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
587 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
588 | - |
|
589 | - $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
|
590 | - $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
|
591 | - |
|
592 | - if ( |
|
593 | - $attendee instanceof EE_Attendee |
|
594 | - && EE_Registry::instance()->CAP->current_user_can( |
|
595 | - 'ee_send_message', |
|
596 | - 'espresso_transactions_send_payment_reminder' |
|
597 | - ) |
|
598 | - ) { |
|
599 | - $this->_template_args['send_payment_reminder_button'] = |
|
600 | - EEH_MSG_Template::is_mt_active('payment_reminder') |
|
601 | - && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
|
602 | - && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
|
603 | - ? EEH_Template::get_button_or_link( |
|
604 | - EE_Admin_Page::add_query_args_and_nonce( |
|
605 | - array( |
|
606 | - 'action' => 'send_payment_reminder', |
|
607 | - 'TXN_ID' => $this->_transaction->ID(), |
|
608 | - 'redirect_to' => 'view_transaction' |
|
609 | - ), |
|
610 | - TXN_ADMIN_URL |
|
611 | - ), |
|
612 | - __(' Send Payment Reminder', 'event_espresso'), |
|
613 | - 'button secondary-button right', |
|
614 | - 'dashicons dashicons-email-alt' |
|
615 | - ) |
|
616 | - : ''; |
|
617 | - } else { |
|
618 | - $this->_template_args['send_payment_reminder_button'] = ''; |
|
619 | - } |
|
620 | - |
|
621 | - $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
|
622 | - $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true); |
|
623 | - if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
624 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
625 | - } else { |
|
626 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
627 | - } |
|
628 | - $this->_template_args['amount_due_class'] = ''; |
|
629 | - |
|
630 | - if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
631 | - // paid in full |
|
632 | - $this->_template_args['amount_due'] = false; |
|
633 | - } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
634 | - // overpaid |
|
635 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
636 | - } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
637 | - // monies owing |
|
638 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
639 | - } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
640 | - // no payments made yet |
|
641 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
642 | - } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
643 | - // free event |
|
644 | - $this->_template_args['amount_due'] = false; |
|
645 | - } |
|
646 | - |
|
647 | - $payment_method = $this->_transaction->payment_method(); |
|
648 | - |
|
649 | - $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
|
650 | - ? $payment_method->admin_name() |
|
651 | - : esc_html__('Unknown', 'event_espresso'); |
|
652 | - |
|
653 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
654 | - // link back to overview |
|
655 | - $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
656 | - ? $_SERVER['HTTP_REFERER'] |
|
657 | - : TXN_ADMIN_URL; |
|
658 | - |
|
659 | - |
|
660 | - // next link |
|
661 | - $next_txn = $this->_transaction->next( |
|
662 | - null, |
|
663 | - array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
664 | - 'TXN_ID' |
|
665 | - ); |
|
666 | - $this->_template_args['next_transaction'] = $next_txn |
|
667 | - ? $this->_next_link( |
|
668 | - EE_Admin_Page::add_query_args_and_nonce( |
|
669 | - array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
670 | - TXN_ADMIN_URL |
|
671 | - ), |
|
672 | - 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
673 | - ) |
|
674 | - : ''; |
|
675 | - // previous link |
|
676 | - $previous_txn = $this->_transaction->previous( |
|
677 | - null, |
|
678 | - array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
679 | - 'TXN_ID' |
|
680 | - ); |
|
681 | - $this->_template_args['previous_transaction'] = $previous_txn |
|
682 | - ? $this->_previous_link( |
|
683 | - EE_Admin_Page::add_query_args_and_nonce( |
|
684 | - array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
685 | - TXN_ADMIN_URL |
|
686 | - ), |
|
687 | - 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
688 | - ) |
|
689 | - : ''; |
|
690 | - |
|
691 | - // were we just redirected here after adding a new registration ??? |
|
692 | - if ( |
|
693 | - isset( |
|
694 | - $this->_req_data['redirect_from'], |
|
695 | - $this->_req_data['EVT_ID'], |
|
696 | - $this->_req_data['event_name'] |
|
697 | - ) |
|
698 | - ) { |
|
699 | - if ( |
|
700 | - EE_Registry::instance()->CAP->current_user_can( |
|
701 | - 'ee_edit_registrations', |
|
702 | - 'espresso_registrations_new_registration', |
|
703 | - $this->_req_data['EVT_ID'] |
|
704 | - ) |
|
705 | - ) { |
|
706 | - $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
|
707 | - $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce( |
|
708 | - array( |
|
709 | - 'page' => 'espresso_registrations', |
|
710 | - 'action' => 'new_registration', |
|
711 | - 'return' => 'default', |
|
712 | - 'TXN_ID' => $this->_transaction->ID(), |
|
713 | - 'event_id' => $this->_req_data['EVT_ID'], |
|
714 | - ), |
|
715 | - REG_ADMIN_URL |
|
716 | - ); |
|
717 | - $this->_admin_page_title .= '">'; |
|
718 | - |
|
719 | - $this->_admin_page_title .= sprintf( |
|
720 | - esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
721 | - htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
722 | - ); |
|
723 | - $this->_admin_page_title .= '</a>'; |
|
724 | - } |
|
725 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
726 | - } |
|
727 | - // grab messages at the last second |
|
728 | - $this->_template_args['notices'] = EE_Error::get_notices(); |
|
729 | - // path to template |
|
730 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
731 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
732 | - $this->_template_args, true); |
|
733 | - |
|
734 | - // the details template wrapper |
|
735 | - $this->display_admin_page_with_sidebar(); |
|
736 | - |
|
737 | - } |
|
738 | - |
|
739 | - |
|
740 | - /** |
|
741 | - * _transaction_details_metaboxes |
|
742 | - * |
|
743 | - * @access protected |
|
744 | - * @return void |
|
745 | - */ |
|
746 | - protected function _transaction_details_metaboxes() |
|
747 | - { |
|
748 | - |
|
749 | - $this->_set_transaction_object(); |
|
750 | - |
|
751 | - add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), |
|
752 | - array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
753 | - add_meta_box( |
|
754 | - 'edit-txn-attendees-mbox', |
|
755 | - esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
756 | - array($this, 'txn_attendees_meta_box'), |
|
757 | - $this->_wp_page_slug, |
|
758 | - 'normal', |
|
759 | - 'high', |
|
760 | - array('TXN_ID' => $this->_transaction->ID()) |
|
761 | - ); |
|
762 | - add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), |
|
763 | - array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
764 | - add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), |
|
765 | - array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
766 | - |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - /** |
|
771 | - * txn_details_meta_box |
|
772 | - * generates HTML for the Transaction main meta box |
|
773 | - * |
|
774 | - * @access public |
|
775 | - * @return void |
|
776 | - */ |
|
777 | - public function txn_details_meta_box() |
|
778 | - { |
|
779 | - |
|
780 | - $this->_set_transaction_object(); |
|
781 | - $this->_template_args['TXN_ID'] = $this->_transaction->ID(); |
|
782 | - $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null; |
|
783 | - |
|
784 | - //get line table |
|
785 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
786 | - $Line_Item_Display = new EE_Line_Item_Display('admin_table', |
|
787 | - 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
788 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
789 | - $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
|
790 | - |
|
791 | - // process taxes |
|
792 | - $taxes = $this->_transaction->get_many_related('Line_Item', |
|
793 | - array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
794 | - $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false; |
|
795 | - |
|
796 | - $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), |
|
797 | - false, false); |
|
798 | - $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
|
799 | - $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
|
30 | + /** |
|
31 | + * @var EE_Transaction |
|
32 | + */ |
|
33 | + private $_transaction; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var EE_Session |
|
37 | + */ |
|
38 | + private $_session; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var array $_txn_status |
|
42 | + */ |
|
43 | + private static $_txn_status; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var array $_pay_status |
|
47 | + */ |
|
48 | + private static $_pay_status; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var array $_existing_reg_payment_REG_IDs |
|
52 | + */ |
|
53 | + protected $_existing_reg_payment_REG_IDs = null; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @Constructor |
|
58 | + * @access public |
|
59 | + * |
|
60 | + * @param bool $routing |
|
61 | + * |
|
62 | + * @return Transactions_Admin_Page |
|
63 | + */ |
|
64 | + public function __construct($routing = true) |
|
65 | + { |
|
66 | + parent::__construct($routing); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * _init_page_props |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + protected function _init_page_props() |
|
75 | + { |
|
76 | + $this->page_slug = TXN_PG_SLUG; |
|
77 | + $this->page_label = esc_html__('Transactions', 'event_espresso'); |
|
78 | + $this->_admin_base_url = TXN_ADMIN_URL; |
|
79 | + $this->_admin_base_path = TXN_ADMIN; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * _ajax_hooks |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + protected function _ajax_hooks() |
|
88 | + { |
|
89 | + add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
90 | + add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
91 | + add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * _define_page_props |
|
97 | + * @return void |
|
98 | + */ |
|
99 | + protected function _define_page_props() |
|
100 | + { |
|
101 | + $this->_admin_page_title = $this->page_label; |
|
102 | + $this->_labels = array( |
|
103 | + 'buttons' => array( |
|
104 | + 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
|
105 | + 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
|
106 | + 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
107 | + ) |
|
108 | + ); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * grab url requests and route them |
|
114 | + * @access private |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public function _set_page_routes() |
|
118 | + { |
|
119 | + |
|
120 | + $this->_set_transaction_status_array(); |
|
121 | + |
|
122 | + $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
123 | + |
|
124 | + $this->_page_routes = array( |
|
125 | + |
|
126 | + 'default' => array( |
|
127 | + 'func' => '_transactions_overview_list_table', |
|
128 | + 'capability' => 'ee_read_transactions' |
|
129 | + ), |
|
130 | + |
|
131 | + 'view_transaction' => array( |
|
132 | + 'func' => '_transaction_details', |
|
133 | + 'capability' => 'ee_read_transaction', |
|
134 | + 'obj_id' => $txn_id |
|
135 | + ), |
|
136 | + |
|
137 | + 'send_payment_reminder' => array( |
|
138 | + 'func' => '_send_payment_reminder', |
|
139 | + 'noheader' => true, |
|
140 | + 'capability' => 'ee_send_message' |
|
141 | + ), |
|
142 | + |
|
143 | + 'espresso_apply_payment' => array( |
|
144 | + 'func' => 'apply_payments_or_refunds', |
|
145 | + 'noheader' => true, |
|
146 | + 'capability' => 'ee_edit_payments' |
|
147 | + ), |
|
148 | + |
|
149 | + 'espresso_apply_refund' => array( |
|
150 | + 'func' => 'apply_payments_or_refunds', |
|
151 | + 'noheader' => true, |
|
152 | + 'capability' => 'ee_edit_payments' |
|
153 | + ), |
|
154 | + |
|
155 | + 'espresso_delete_payment' => array( |
|
156 | + 'func' => 'delete_payment', |
|
157 | + 'noheader' => true, |
|
158 | + 'capability' => 'ee_delete_payments' |
|
159 | + ), |
|
160 | + |
|
161 | + ); |
|
162 | + |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + protected function _set_page_config() |
|
167 | + { |
|
168 | + $this->_page_config = array( |
|
169 | + 'default' => array( |
|
170 | + 'nav' => array( |
|
171 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
172 | + 'order' => 10 |
|
173 | + ), |
|
174 | + 'list_table' => 'EE_Admin_Transactions_List_Table', |
|
175 | + 'help_tabs' => array( |
|
176 | + 'transactions_overview_help_tab' => array( |
|
177 | + 'title' => esc_html__('Transactions Overview', 'event_espresso'), |
|
178 | + 'filename' => 'transactions_overview' |
|
179 | + ), |
|
180 | + 'transactions_overview_table_column_headings_help_tab' => array( |
|
181 | + 'title' => esc_html__('Transactions Table Column Headings', 'event_espresso'), |
|
182 | + 'filename' => 'transactions_overview_table_column_headings' |
|
183 | + ), |
|
184 | + 'transactions_overview_views_filters_help_tab' => array( |
|
185 | + 'title' => esc_html__('Transaction Views & Filters & Search', 'event_espresso'), |
|
186 | + 'filename' => 'transactions_overview_views_filters_search' |
|
187 | + ), |
|
188 | + ), |
|
189 | + 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
190 | + /** |
|
191 | + * commented out because currently we are not displaying tips for transaction list table status but this |
|
192 | + * may change in a later iteration so want to keep the code for then. |
|
193 | + */ |
|
194 | + //'qtips' => array( 'Transactions_List_Table_Tips' ), |
|
195 | + 'require_nonce' => false |
|
196 | + ), |
|
197 | + 'view_transaction' => array( |
|
198 | + 'nav' => array( |
|
199 | + 'label' => esc_html__('View Transaction', 'event_espresso'), |
|
200 | + 'order' => 5, |
|
201 | + 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), |
|
202 | + $this->_current_page_view_url) : $this->_admin_base_url, |
|
203 | + 'persistent' => false |
|
204 | + ), |
|
205 | + 'help_tabs' => array( |
|
206 | + 'transactions_view_transaction_help_tab' => array( |
|
207 | + 'title' => esc_html__('View Transaction', 'event_espresso'), |
|
208 | + 'filename' => 'transactions_view_transaction' |
|
209 | + ), |
|
210 | + 'transactions_view_transaction_transaction_details_table_help_tab' => array( |
|
211 | + 'title' => esc_html__('Transaction Details Table', 'event_espresso'), |
|
212 | + 'filename' => 'transactions_view_transaction_transaction_details_table' |
|
213 | + ), |
|
214 | + 'transactions_view_transaction_attendees_registered_help_tab' => array( |
|
215 | + 'title' => esc_html__('Attendees Registered', 'event_espresso'), |
|
216 | + 'filename' => 'transactions_view_transaction_attendees_registered' |
|
217 | + ), |
|
218 | + 'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array( |
|
219 | + 'title' => esc_html__('Primary Registrant & Billing Information', 'event_espresso'), |
|
220 | + 'filename' => 'transactions_view_transaction_primary_registrant_billing_information' |
|
221 | + ), |
|
222 | + ), |
|
223 | + 'qtips' => array('Transaction_Details_Tips'), |
|
224 | + 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
225 | + 'metaboxes' => array('_transaction_details_metaboxes'), |
|
226 | + |
|
227 | + 'require_nonce' => false |
|
228 | + ) |
|
229 | + ); |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * The below methods aren't used by this class currently |
|
235 | + */ |
|
236 | + protected function _add_screen_options() |
|
237 | + { |
|
238 | + } |
|
239 | + |
|
240 | + protected function _add_feature_pointers() |
|
241 | + { |
|
242 | + } |
|
243 | + |
|
244 | + public function admin_init() |
|
245 | + { |
|
246 | + // IF a registration was JUST added via the admin... |
|
247 | + if ( |
|
248 | + isset( |
|
249 | + $this->_req_data['redirect_from'], |
|
250 | + $this->_req_data['EVT_ID'], |
|
251 | + $this->_req_data['event_name'] |
|
252 | + ) |
|
253 | + ) { |
|
254 | + // then set a cookie so that we can block any attempts to use |
|
255 | + // the back button as a way to enter another registration. |
|
256 | + setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
257 | + // and update the global |
|
258 | + $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
259 | + } |
|
260 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
261 | + 'event_espresso'); |
|
262 | + EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', |
|
263 | + 'event_espresso'); |
|
264 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
265 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
266 | + EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
267 | + EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', |
|
268 | + 'event_espresso'); |
|
269 | + } |
|
270 | + |
|
271 | + public function admin_notices() |
|
272 | + { |
|
273 | + } |
|
274 | + |
|
275 | + public function admin_footer_scripts() |
|
276 | + { |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * _set_transaction_status_array |
|
282 | + * sets list of transaction statuses |
|
283 | + * |
|
284 | + * @access private |
|
285 | + * @return void |
|
286 | + */ |
|
287 | + private function _set_transaction_status_array() |
|
288 | + { |
|
289 | + self::$_txn_status = EEM_Transaction::instance()->status_array(true); |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * get_transaction_status_array |
|
295 | + * return the transaction status array for wp_list_table |
|
296 | + * |
|
297 | + * @access public |
|
298 | + * @return array |
|
299 | + */ |
|
300 | + public function get_transaction_status_array() |
|
301 | + { |
|
302 | + return self::$_txn_status; |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * get list of payment statuses |
|
308 | + * |
|
309 | + * @access private |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + private function _get_payment_status_array() |
|
313 | + { |
|
314 | + self::$_pay_status = EEM_Payment::instance()->status_array(true); |
|
315 | + $this->_template_args['payment_status'] = self::$_pay_status; |
|
316 | + |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * _add_screen_options_default |
|
322 | + * |
|
323 | + * @access protected |
|
324 | + * @return void |
|
325 | + */ |
|
326 | + protected function _add_screen_options_default() |
|
327 | + { |
|
328 | + $this->_per_page_screen_option(); |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * load_scripts_styles |
|
334 | + * |
|
335 | + * @access public |
|
336 | + * @return void |
|
337 | + */ |
|
338 | + public function load_scripts_styles() |
|
339 | + { |
|
340 | + //enqueue style |
|
341 | + wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), |
|
342 | + EVENT_ESPRESSO_VERSION); |
|
343 | + wp_enqueue_style('espresso_txn'); |
|
344 | + //scripts |
|
345 | + wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array( |
|
346 | + 'ee_admin_js', |
|
347 | + 'ee-datepicker', |
|
348 | + 'jquery-ui-datepicker', |
|
349 | + 'jquery-ui-draggable', |
|
350 | + 'ee-dialog', |
|
351 | + 'ee-accounting', |
|
352 | + 'ee-serialize-full-array' |
|
353 | + ), EVENT_ESPRESSO_VERSION, true); |
|
354 | + wp_enqueue_script('espresso_txn'); |
|
355 | + |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * load_scripts_styles_view_transaction |
|
361 | + * |
|
362 | + * @access public |
|
363 | + * @return void |
|
364 | + */ |
|
365 | + public function load_scripts_styles_view_transaction() |
|
366 | + { |
|
367 | + //styles |
|
368 | + wp_enqueue_style('espresso-ui-theme'); |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * load_scripts_styles_default |
|
374 | + * |
|
375 | + * @access public |
|
376 | + * @return void |
|
377 | + */ |
|
378 | + public function load_scripts_styles_default() |
|
379 | + { |
|
380 | + //styles |
|
381 | + wp_enqueue_style('espresso-ui-theme'); |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * _set_list_table_views_default |
|
387 | + * |
|
388 | + * @access protected |
|
389 | + * @return void |
|
390 | + */ |
|
391 | + protected function _set_list_table_views_default() |
|
392 | + { |
|
393 | + $this->_views = array( |
|
394 | + 'all' => array( |
|
395 | + 'slug' => 'all', |
|
396 | + 'label' => esc_html__('View All Transactions', 'event_espresso'), |
|
397 | + 'count' => 0 |
|
398 | + ), |
|
399 | + 'abandoned' => array( |
|
400 | + 'slug' => 'abandoned', |
|
401 | + 'label' => esc_html__('Abandoned Transactions', 'event_espresso'), |
|
402 | + 'count' => 0 |
|
403 | + ), |
|
404 | + 'failed' => array( |
|
405 | + 'slug' => 'failed', |
|
406 | + 'label' => esc_html__('Failed Transactions', 'event_espresso'), |
|
407 | + 'count' => 0 |
|
408 | + ) |
|
409 | + ); |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * _set_transaction_object |
|
415 | + * This sets the _transaction property for the transaction details screen |
|
416 | + * |
|
417 | + * @access private |
|
418 | + * @return void |
|
419 | + */ |
|
420 | + private function _set_transaction_object() |
|
421 | + { |
|
422 | + if (is_object($this->_transaction)) { |
|
423 | + return; |
|
424 | + } //get out we've already set the object |
|
425 | + |
|
426 | + $TXN = EEM_Transaction::instance(); |
|
427 | + |
|
428 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
429 | + |
|
430 | + //get transaction object |
|
431 | + $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
|
432 | + $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : null; |
|
433 | + $this->_transaction->verify_abandoned_transaction_status(); |
|
434 | + |
|
435 | + if (empty($this->_transaction)) { |
|
436 | + $error_msg = esc_html__('An error occurred and the details for Transaction ID #', |
|
437 | + 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
438 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
439 | + } |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * _transaction_legend_items |
|
445 | + * |
|
446 | + * @access protected |
|
447 | + * @return array |
|
448 | + */ |
|
449 | + protected function _transaction_legend_items() |
|
450 | + { |
|
451 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
452 | + $items = array(); |
|
453 | + |
|
454 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
455 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
456 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
457 | + $items['view_related_messages'] = array( |
|
458 | + 'class' => $related_for_icon['css_class'], |
|
459 | + 'desc' => $related_for_icon['label'], |
|
460 | + ); |
|
461 | + } |
|
462 | + } |
|
463 | + |
|
464 | + $items = apply_filters( |
|
465 | + 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
|
466 | + array_merge($items, |
|
467 | + array( |
|
468 | + 'view_details' => array( |
|
469 | + 'class' => 'dashicons dashicons-cart', |
|
470 | + 'desc' => esc_html__('View Transaction Details', 'event_espresso') |
|
471 | + ), |
|
472 | + 'view_invoice' => array( |
|
473 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
474 | + 'desc' => esc_html__('View Transaction Invoice', 'event_espresso') |
|
475 | + ), |
|
476 | + 'view_receipt' => array( |
|
477 | + 'class' => 'dashicons dashicons-media-default', |
|
478 | + 'desc' => esc_html__('View Transaction Receipt', 'event_espresso') |
|
479 | + ), |
|
480 | + 'view_registration' => array( |
|
481 | + 'class' => 'dashicons dashicons-clipboard', |
|
482 | + 'desc' => esc_html__('View Registration Details', 'event_espresso') |
|
483 | + ) |
|
484 | + ) |
|
485 | + ) |
|
486 | + ); |
|
487 | + |
|
488 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
489 | + 'espresso_transactions_send_payment_reminder') |
|
490 | + ) { |
|
491 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
492 | + $items['send_payment_reminder'] = array( |
|
493 | + 'class' => 'dashicons dashicons-email-alt', |
|
494 | + 'desc' => esc_html__('Send Payment Reminder', 'event_espresso') |
|
495 | + ); |
|
496 | + } else { |
|
497 | + $items['blank*'] = array( |
|
498 | + 'class' => '', |
|
499 | + 'desc' => '' |
|
500 | + ); |
|
501 | + } |
|
502 | + } else { |
|
503 | + $items['blank*'] = array( |
|
504 | + 'class' => '', |
|
505 | + 'desc' => '' |
|
506 | + ); |
|
507 | + } |
|
508 | + $more_items = apply_filters( |
|
509 | + 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
|
510 | + array( |
|
511 | + 'overpaid' => array( |
|
512 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
513 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence') |
|
514 | + ), |
|
515 | + 'complete' => array( |
|
516 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
517 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence') |
|
518 | + ), |
|
519 | + 'incomplete' => array( |
|
520 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
521 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence') |
|
522 | + ), |
|
523 | + 'abandoned' => array( |
|
524 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
525 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence') |
|
526 | + ), |
|
527 | + 'failed' => array( |
|
528 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
529 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence') |
|
530 | + ) |
|
531 | + ) |
|
532 | + ); |
|
533 | + |
|
534 | + return array_merge($items, $more_items); |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * _transactions_overview_list_table |
|
540 | + * |
|
541 | + * @access protected |
|
542 | + * @return void |
|
543 | + */ |
|
544 | + protected function _transactions_overview_list_table() |
|
545 | + { |
|
546 | + $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
547 | + $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null; |
|
548 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', |
|
549 | + 'event_espresso'), '<h3>', |
|
550 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
551 | + EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event', |
|
552 | + 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : ''; |
|
553 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
554 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * _transaction_details |
|
560 | + * generates HTML for the View Transaction Details Admin page |
|
561 | + * |
|
562 | + * @access protected |
|
563 | + * @return void |
|
564 | + */ |
|
565 | + protected function _transaction_details() |
|
566 | + { |
|
567 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
568 | + |
|
569 | + $this->_set_transaction_status_array(); |
|
570 | + |
|
571 | + $this->_template_args = array(); |
|
572 | + $this->_template_args['transactions_page'] = $this->_wp_page_slug; |
|
573 | + |
|
574 | + $this->_set_transaction_object(); |
|
575 | + |
|
576 | + $primary_registration = $this->_transaction->primary_registration(); |
|
577 | + $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : null; |
|
578 | + |
|
579 | + $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
|
580 | + $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
581 | + |
|
582 | + $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
|
583 | + $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
584 | + |
|
585 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
586 | + $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
587 | + $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
588 | + |
|
589 | + $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
|
590 | + $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
|
591 | + |
|
592 | + if ( |
|
593 | + $attendee instanceof EE_Attendee |
|
594 | + && EE_Registry::instance()->CAP->current_user_can( |
|
595 | + 'ee_send_message', |
|
596 | + 'espresso_transactions_send_payment_reminder' |
|
597 | + ) |
|
598 | + ) { |
|
599 | + $this->_template_args['send_payment_reminder_button'] = |
|
600 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
601 | + && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
|
602 | + && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
|
603 | + ? EEH_Template::get_button_or_link( |
|
604 | + EE_Admin_Page::add_query_args_and_nonce( |
|
605 | + array( |
|
606 | + 'action' => 'send_payment_reminder', |
|
607 | + 'TXN_ID' => $this->_transaction->ID(), |
|
608 | + 'redirect_to' => 'view_transaction' |
|
609 | + ), |
|
610 | + TXN_ADMIN_URL |
|
611 | + ), |
|
612 | + __(' Send Payment Reminder', 'event_espresso'), |
|
613 | + 'button secondary-button right', |
|
614 | + 'dashicons dashicons-email-alt' |
|
615 | + ) |
|
616 | + : ''; |
|
617 | + } else { |
|
618 | + $this->_template_args['send_payment_reminder_button'] = ''; |
|
619 | + } |
|
620 | + |
|
621 | + $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
|
622 | + $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true); |
|
623 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
624 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
625 | + } else { |
|
626 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
627 | + } |
|
628 | + $this->_template_args['amount_due_class'] = ''; |
|
629 | + |
|
630 | + if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
631 | + // paid in full |
|
632 | + $this->_template_args['amount_due'] = false; |
|
633 | + } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
634 | + // overpaid |
|
635 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
636 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
637 | + // monies owing |
|
638 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
639 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
640 | + // no payments made yet |
|
641 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
642 | + } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
643 | + // free event |
|
644 | + $this->_template_args['amount_due'] = false; |
|
645 | + } |
|
646 | + |
|
647 | + $payment_method = $this->_transaction->payment_method(); |
|
648 | + |
|
649 | + $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
|
650 | + ? $payment_method->admin_name() |
|
651 | + : esc_html__('Unknown', 'event_espresso'); |
|
652 | + |
|
653 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
654 | + // link back to overview |
|
655 | + $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
656 | + ? $_SERVER['HTTP_REFERER'] |
|
657 | + : TXN_ADMIN_URL; |
|
658 | + |
|
659 | + |
|
660 | + // next link |
|
661 | + $next_txn = $this->_transaction->next( |
|
662 | + null, |
|
663 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
664 | + 'TXN_ID' |
|
665 | + ); |
|
666 | + $this->_template_args['next_transaction'] = $next_txn |
|
667 | + ? $this->_next_link( |
|
668 | + EE_Admin_Page::add_query_args_and_nonce( |
|
669 | + array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
670 | + TXN_ADMIN_URL |
|
671 | + ), |
|
672 | + 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
673 | + ) |
|
674 | + : ''; |
|
675 | + // previous link |
|
676 | + $previous_txn = $this->_transaction->previous( |
|
677 | + null, |
|
678 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
679 | + 'TXN_ID' |
|
680 | + ); |
|
681 | + $this->_template_args['previous_transaction'] = $previous_txn |
|
682 | + ? $this->_previous_link( |
|
683 | + EE_Admin_Page::add_query_args_and_nonce( |
|
684 | + array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
685 | + TXN_ADMIN_URL |
|
686 | + ), |
|
687 | + 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
688 | + ) |
|
689 | + : ''; |
|
690 | + |
|
691 | + // were we just redirected here after adding a new registration ??? |
|
692 | + if ( |
|
693 | + isset( |
|
694 | + $this->_req_data['redirect_from'], |
|
695 | + $this->_req_data['EVT_ID'], |
|
696 | + $this->_req_data['event_name'] |
|
697 | + ) |
|
698 | + ) { |
|
699 | + if ( |
|
700 | + EE_Registry::instance()->CAP->current_user_can( |
|
701 | + 'ee_edit_registrations', |
|
702 | + 'espresso_registrations_new_registration', |
|
703 | + $this->_req_data['EVT_ID'] |
|
704 | + ) |
|
705 | + ) { |
|
706 | + $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
|
707 | + $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce( |
|
708 | + array( |
|
709 | + 'page' => 'espresso_registrations', |
|
710 | + 'action' => 'new_registration', |
|
711 | + 'return' => 'default', |
|
712 | + 'TXN_ID' => $this->_transaction->ID(), |
|
713 | + 'event_id' => $this->_req_data['EVT_ID'], |
|
714 | + ), |
|
715 | + REG_ADMIN_URL |
|
716 | + ); |
|
717 | + $this->_admin_page_title .= '">'; |
|
718 | + |
|
719 | + $this->_admin_page_title .= sprintf( |
|
720 | + esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
721 | + htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
722 | + ); |
|
723 | + $this->_admin_page_title .= '</a>'; |
|
724 | + } |
|
725 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
726 | + } |
|
727 | + // grab messages at the last second |
|
728 | + $this->_template_args['notices'] = EE_Error::get_notices(); |
|
729 | + // path to template |
|
730 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
731 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
732 | + $this->_template_args, true); |
|
733 | + |
|
734 | + // the details template wrapper |
|
735 | + $this->display_admin_page_with_sidebar(); |
|
736 | + |
|
737 | + } |
|
738 | + |
|
739 | + |
|
740 | + /** |
|
741 | + * _transaction_details_metaboxes |
|
742 | + * |
|
743 | + * @access protected |
|
744 | + * @return void |
|
745 | + */ |
|
746 | + protected function _transaction_details_metaboxes() |
|
747 | + { |
|
748 | + |
|
749 | + $this->_set_transaction_object(); |
|
750 | + |
|
751 | + add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), |
|
752 | + array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
753 | + add_meta_box( |
|
754 | + 'edit-txn-attendees-mbox', |
|
755 | + esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
756 | + array($this, 'txn_attendees_meta_box'), |
|
757 | + $this->_wp_page_slug, |
|
758 | + 'normal', |
|
759 | + 'high', |
|
760 | + array('TXN_ID' => $this->_transaction->ID()) |
|
761 | + ); |
|
762 | + add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), |
|
763 | + array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
764 | + add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), |
|
765 | + array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
766 | + |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + /** |
|
771 | + * txn_details_meta_box |
|
772 | + * generates HTML for the Transaction main meta box |
|
773 | + * |
|
774 | + * @access public |
|
775 | + * @return void |
|
776 | + */ |
|
777 | + public function txn_details_meta_box() |
|
778 | + { |
|
779 | + |
|
780 | + $this->_set_transaction_object(); |
|
781 | + $this->_template_args['TXN_ID'] = $this->_transaction->ID(); |
|
782 | + $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null; |
|
783 | + |
|
784 | + //get line table |
|
785 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
786 | + $Line_Item_Display = new EE_Line_Item_Display('admin_table', |
|
787 | + 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
788 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
789 | + $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
|
790 | + |
|
791 | + // process taxes |
|
792 | + $taxes = $this->_transaction->get_many_related('Line_Item', |
|
793 | + array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
794 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false; |
|
795 | + |
|
796 | + $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), |
|
797 | + false, false); |
|
798 | + $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
|
799 | + $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
|
800 | 800 | |
801 | 801 | // $txn_status_class = 'status-' . $this->_transaction->get('STS_ID'); |
802 | 802 | |
803 | - // process payment details |
|
804 | - $payments = $this->_transaction->get_many_related('Payment'); |
|
805 | - if ( ! empty($payments)) { |
|
806 | - $this->_template_args['payments'] = $payments; |
|
807 | - $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
808 | - } else { |
|
809 | - $this->_template_args['payments'] = false; |
|
810 | - $this->_template_args['existing_reg_payments'] = array(); |
|
811 | - } |
|
812 | - |
|
813 | - $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
814 | - $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), |
|
815 | - TXN_ADMIN_URL); |
|
816 | - |
|
817 | - if (isset($txn_details['invoice_number'])) { |
|
818 | - $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
|
819 | - $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', |
|
820 | - 'event_espresso'); |
|
821 | - } |
|
822 | - |
|
823 | - $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
|
824 | - $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', |
|
825 | - 'event_espresso'); |
|
826 | - |
|
827 | - $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
828 | - $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', |
|
829 | - 'event_espresso'); |
|
830 | - |
|
831 | - $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
832 | - $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
833 | - 'event_espresso'); |
|
834 | - |
|
835 | - $reg_steps = '<ul>'; |
|
836 | - foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
837 | - if ($reg_step_status === true) { |
|
838 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
839 | - ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
840 | - } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
841 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
842 | - esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
843 | - ucwords(str_replace('_', ' ', $reg_step)), |
|
844 | - date(get_option('date_format') . ' ' . get_option('time_format'), |
|
845 | - ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
846 | - ) . '</li>'; |
|
847 | - } else { |
|
848 | - $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated', |
|
849 | - 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
850 | - } |
|
851 | - } |
|
852 | - $reg_steps .= '</ul>'; |
|
853 | - $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
|
854 | - $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', |
|
855 | - 'event_espresso'); |
|
856 | - |
|
857 | - |
|
858 | - $this->_get_registrations_to_apply_payment_to(); |
|
859 | - $this->_get_payment_methods($payments); |
|
860 | - $this->_get_payment_status_array(); |
|
861 | - $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
|
862 | - |
|
863 | - $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
864 | - 'action' => 'edit_transaction', |
|
865 | - 'process' => 'transaction' |
|
866 | - ), TXN_ADMIN_URL); |
|
867 | - $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
868 | - 'page' => 'espresso_transactions', |
|
869 | - 'action' => 'espresso_apply_payment' |
|
870 | - ), WP_AJAX_URL); |
|
871 | - $this->_template_args['delete_payment_form_url'] = add_query_arg(array( |
|
872 | - 'page' => 'espresso_transactions', |
|
873 | - 'action' => 'espresso_delete_payment' |
|
874 | - ), WP_AJAX_URL); |
|
875 | - |
|
876 | - // 'espresso_delete_payment_nonce' |
|
877 | - |
|
878 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
879 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
880 | - |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - /** |
|
885 | - * _get_registration_payment_IDs |
|
886 | - * |
|
887 | - * generates an array of Payment IDs and their corresponding Registration IDs |
|
888 | - * |
|
889 | - * @access protected |
|
890 | - * |
|
891 | - * @param EE_Payment[] $payments |
|
892 | - * |
|
893 | - * @return array |
|
894 | - */ |
|
895 | - protected function _get_registration_payment_IDs($payments = array()) |
|
896 | - { |
|
897 | - $existing_reg_payments = array(); |
|
898 | - // get all reg payments for these payments |
|
899 | - $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
900 | - array( |
|
901 | - 'PAY_ID' => array( |
|
902 | - 'IN', |
|
903 | - array_keys($payments) |
|
904 | - ) |
|
905 | - ) |
|
906 | - )); |
|
907 | - if ( ! empty($reg_payments)) { |
|
908 | - foreach ($payments as $payment) { |
|
909 | - if ( ! $payment instanceof EE_Payment) { |
|
910 | - continue; |
|
911 | - } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
912 | - $existing_reg_payments[$payment->ID()] = array(); |
|
913 | - } |
|
914 | - foreach ($reg_payments as $reg_payment) { |
|
915 | - if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
916 | - $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
917 | - } |
|
918 | - } |
|
919 | - } |
|
920 | - } |
|
921 | - |
|
922 | - return $existing_reg_payments; |
|
923 | - } |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * _get_registrations_to_apply_payment_to |
|
928 | - * generates HTML for displaying a series of checkboxes in the admin payment modal window |
|
929 | - * which allows the admin to only apply the payment to the specific registrations |
|
930 | - * |
|
931 | - * @access protected |
|
932 | - * @return void |
|
933 | - * @throws \EE_Error |
|
934 | - */ |
|
935 | - protected function _get_registrations_to_apply_payment_to() |
|
936 | - { |
|
937 | - // we want any registration with an active status (ie: not deleted or cancelled) |
|
938 | - $query_params = array( |
|
939 | - array( |
|
940 | - 'STS_ID' => array( |
|
941 | - 'IN', |
|
942 | - array( |
|
943 | - EEM_Registration::status_id_approved, |
|
944 | - EEM_Registration::status_id_pending_payment, |
|
945 | - EEM_Registration::status_id_not_approved, |
|
946 | - ) |
|
947 | - ) |
|
948 | - ) |
|
949 | - ); |
|
950 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
951 | - '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
|
952 | - ); |
|
953 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
954 | - $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
955 | - $registrations_to_apply_payment_to .= EEH_HTML::thead( |
|
956 | - EEH_HTML::tr( |
|
957 | - EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
958 | - EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
959 | - EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
960 | - EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
961 | - EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
962 | - EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
963 | - EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
964 | - ) |
|
965 | - ); |
|
966 | - $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
|
967 | - // get registrations for TXN |
|
968 | - $registrations = $this->_transaction->registrations($query_params); |
|
969 | - foreach ($registrations as $registration) { |
|
970 | - if ($registration instanceof EE_Registration) { |
|
971 | - $attendee_name = $registration->attendee() instanceof EE_Attendee |
|
972 | - ? $registration->attendee()->full_name() |
|
973 | - : esc_html__('Unknown Attendee', 'event_espresso'); |
|
974 | - $owing = $registration->final_price() - $registration->paid(); |
|
975 | - $taxable = $registration->ticket()->taxable() |
|
976 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
977 | - : ''; |
|
978 | - $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) |
|
979 | - ? ' checked="checked"' |
|
980 | - : ''; |
|
981 | - $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
982 | - $registrations_to_apply_payment_to .= EEH_HTML::tr( |
|
983 | - EEH_HTML::td($registration->ID()) . |
|
984 | - EEH_HTML::td($attendee_name) . |
|
985 | - EEH_HTML::td( |
|
986 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
987 | - ) . |
|
988 | - EEH_HTML::td($registration->event_name()) . |
|
989 | - EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
990 | - EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
991 | - EEH_HTML::td( |
|
992 | - '<input type="checkbox" value="' . $registration->ID() |
|
993 | - . '" name="txn_admin_payment[registrations]"' |
|
994 | - . $checked . $disabled . '>', |
|
995 | - '', 'jst-cntr' |
|
996 | - ), |
|
997 | - 'apply-payment-registration-row-' . $registration->ID() |
|
998 | - ); |
|
999 | - } |
|
1000 | - } |
|
1001 | - $registrations_to_apply_payment_to .= EEH_HTML::tbodyx(); |
|
1002 | - $registrations_to_apply_payment_to .= EEH_HTML::tablex(); |
|
1003 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1004 | - $registrations_to_apply_payment_to .= EEH_HTML::p( |
|
1005 | - esc_html__( |
|
1006 | - 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', |
|
1007 | - 'event_espresso' |
|
1008 | - ), |
|
1009 | - '', 'clear description' |
|
1010 | - ); |
|
1011 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1012 | - $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * _get_reg_status_selection |
|
1018 | - * |
|
1019 | - * @todo this will need to be adjusted either once MER comes along OR we move default reg status to tickets |
|
1020 | - * instead of events. |
|
1021 | - * @access protected |
|
1022 | - * @return void |
|
1023 | - */ |
|
1024 | - protected function _get_reg_status_selection() |
|
1025 | - { |
|
1026 | - //first get all possible statuses |
|
1027 | - $statuses = EEM_Registration::reg_status_array(array(), true); |
|
1028 | - //let's add a "don't change" option. |
|
1029 | - $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
|
1030 | - $status_array = array_merge($status_array, $statuses); |
|
1031 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', |
|
1032 | - $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
1033 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', |
|
1034 | - $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
1035 | - |
|
1036 | - } |
|
1037 | - |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * _get_payment_methods |
|
1041 | - * Gets all the payment methods available generally, or the ones that are already |
|
1042 | - * selected on these payments (in case their payment methods are no longer active). |
|
1043 | - * Has the side-effect of updating the template args' payment_methods item |
|
1044 | - * @access private |
|
1045 | - * |
|
1046 | - * @param EE_Payment[] to show on this page |
|
1047 | - * |
|
1048 | - * @return void |
|
1049 | - */ |
|
1050 | - private function _get_payment_methods($payments = array()) |
|
1051 | - { |
|
1052 | - $payment_methods_of_payments = array(); |
|
1053 | - foreach ($payments as $payment) { |
|
1054 | - if ($payment instanceof EE_Payment) { |
|
1055 | - $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
1056 | - } |
|
1057 | - } |
|
1058 | - if ($payment_methods_of_payments) { |
|
1059 | - $query_args = array( |
|
1060 | - array( |
|
1061 | - 'OR*payment_method_for_payment' => array( |
|
1062 | - 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
1063 | - 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%') |
|
1064 | - ) |
|
1065 | - ) |
|
1066 | - ); |
|
1067 | - } else { |
|
1068 | - $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))); |
|
1069 | - } |
|
1070 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1071 | - } |
|
1072 | - |
|
1073 | - |
|
1074 | - /** |
|
1075 | - * txn_attendees_meta_box |
|
1076 | - * generates HTML for the Attendees Transaction main meta box |
|
1077 | - * |
|
1078 | - * @access public |
|
1079 | - * |
|
1080 | - * @param WP_Post $post |
|
1081 | - * @param array $metabox |
|
1082 | - * |
|
1083 | - * @return void |
|
1084 | - */ |
|
1085 | - public function txn_attendees_meta_box($post, $metabox = array('args' => array())) |
|
1086 | - { |
|
1087 | - |
|
1088 | - extract($metabox['args']); |
|
1089 | - $this->_template_args['post'] = $post; |
|
1090 | - $this->_template_args['event_attendees'] = array(); |
|
1091 | - // process items in cart |
|
1092 | - $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
1093 | - if ( ! empty($line_items)) { |
|
1094 | - foreach ($line_items as $item) { |
|
1095 | - if ($item instanceof EE_Line_Item) { |
|
1096 | - switch ($item->OBJ_type()) { |
|
1097 | - |
|
1098 | - case 'Event' : |
|
1099 | - break; |
|
1100 | - |
|
1101 | - case 'Ticket' : |
|
1102 | - $ticket = $item->ticket(); |
|
1103 | - //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
|
1104 | - if ( ! $ticket instanceof EE_Ticket) { |
|
1105 | - continue; |
|
1106 | - } |
|
1107 | - try { |
|
1108 | - $event_name = $ticket->get_event_name(); |
|
1109 | - } catch (Exception $e) { |
|
1110 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1111 | - $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1112 | - } |
|
1113 | - $event_name .= ' - ' . $item->get('LIN_name'); |
|
1114 | - $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
1115 | - // now get all of the registrations for this transaction that use this ticket |
|
1116 | - $registrations = $ticket->get_many_related('Registration', |
|
1117 | - array(array('TXN_ID' => $this->_transaction->ID()))); |
|
1118 | - foreach ($registrations as $registration) { |
|
1119 | - if ( ! $registration instanceof EE_Registration) { |
|
1120 | - continue; |
|
1121 | - } |
|
1122 | - $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1123 | - $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1124 | - $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1125 | - $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1126 | - // attendee info |
|
1127 | - $attendee = $registration->get_first_related('Attendee'); |
|
1128 | - if ($attendee instanceof EE_Attendee) { |
|
1129 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1130 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1131 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', |
|
1132 | - 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
1133 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, |
|
1134 | - 'inline', false, false); |
|
1135 | - } else { |
|
1136 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
|
1137 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1138 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
|
1139 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1140 | - } |
|
1141 | - } |
|
1142 | - break; |
|
1143 | - |
|
1144 | - } |
|
1145 | - } |
|
1146 | - } |
|
1147 | - |
|
1148 | - $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
1149 | - 'action' => 'edit_transaction', |
|
1150 | - 'process' => 'attendees' |
|
1151 | - ), TXN_ADMIN_URL); |
|
1152 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
1153 | - $this->_template_args, true); |
|
1154 | - |
|
1155 | - } else { |
|
1156 | - echo sprintf( |
|
1157 | - esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', |
|
1158 | - 'event_espresso'), |
|
1159 | - '<p class="important-notice">', |
|
1160 | - '</p>' |
|
1161 | - ); |
|
1162 | - } |
|
1163 | - } |
|
1164 | - |
|
1165 | - |
|
1166 | - /** |
|
1167 | - * txn_registrant_side_meta_box |
|
1168 | - * generates HTML for the Edit Transaction side meta box |
|
1169 | - * |
|
1170 | - * @access public |
|
1171 | - * @throws \EE_Error |
|
1172 | - * @return void |
|
1173 | - */ |
|
1174 | - public function txn_registrant_side_meta_box() |
|
1175 | - { |
|
1176 | - $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
|
1177 | - if ( ! $primary_att instanceof EE_Attendee) { |
|
1178 | - $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
|
1179 | - 'event_espresso'); |
|
1180 | - $primary_att = EEM_Attendee::instance()->create_default_object(); |
|
1181 | - } |
|
1182 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1183 | - $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
|
1184 | - $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
|
1185 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1186 | - $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
|
1187 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1188 | - 'action' => 'edit_attendee', |
|
1189 | - 'post' => $primary_att->ID() |
|
1190 | - ), REG_ADMIN_URL); |
|
1191 | - // get formatted address for registrant |
|
1192 | - $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1193 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
1194 | - $this->_template_args, true); |
|
1195 | - } |
|
1196 | - |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * txn_billing_info_side_meta_box |
|
1200 | - * generates HTML for the Edit Transaction side meta box |
|
1201 | - * |
|
1202 | - * @access public |
|
1203 | - * @return void |
|
1204 | - */ |
|
1205 | - public function txn_billing_info_side_meta_box() |
|
1206 | - { |
|
1207 | - |
|
1208 | - $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
|
1209 | - $this->_template_args['billing_form_url'] = add_query_arg( |
|
1210 | - array('action' => 'edit_transaction', 'process' => 'billing'), |
|
1211 | - TXN_ADMIN_URL |
|
1212 | - ); |
|
1213 | - |
|
1214 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1215 | - echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/ |
|
1216 | - } |
|
1217 | - |
|
1218 | - |
|
1219 | - /** |
|
1220 | - * apply_payments_or_refunds |
|
1221 | - * registers a payment or refund made towards a transaction |
|
1222 | - * |
|
1223 | - * @access public |
|
1224 | - * @return void |
|
1225 | - */ |
|
1226 | - public function apply_payments_or_refunds() |
|
1227 | - { |
|
1228 | - $json_response_data = array('return_data' => false); |
|
1229 | - $valid_data = $this->_validate_payment_request_data(); |
|
1230 | - if ( ! empty($valid_data)) { |
|
1231 | - $PAY_ID = $valid_data['PAY_ID']; |
|
1232 | - //save the new payment |
|
1233 | - $payment = $this->_create_payment_from_request_data($valid_data); |
|
1234 | - // get the TXN for this payment |
|
1235 | - $transaction = $payment->transaction(); |
|
1236 | - // verify transaction |
|
1237 | - if ($transaction instanceof EE_Transaction) { |
|
1238 | - // calculate_total_payments_and_update_status |
|
1239 | - $this->_process_transaction_payments($transaction); |
|
1240 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1241 | - $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1242 | - // apply payment to registrations (if applicable) |
|
1243 | - if ( ! empty($REG_IDs)) { |
|
1244 | - $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1245 | - $this->_maybe_send_notifications(); |
|
1246 | - // now process status changes for the same registrations |
|
1247 | - $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1248 | - } |
|
1249 | - $this->_maybe_send_notifications($payment); |
|
1250 | - //prepare to render page |
|
1251 | - $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1252 | - do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, |
|
1253 | - $payment); |
|
1254 | - } else { |
|
1255 | - EE_Error::add_error( |
|
1256 | - esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
1257 | - __FILE__, __FUNCTION__, __LINE__ |
|
1258 | - ); |
|
1259 | - } |
|
1260 | - } else { |
|
1261 | - EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', |
|
1262 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1263 | - } |
|
1264 | - |
|
1265 | - $notices = EE_Error::get_notices(false, false, false); |
|
1266 | - $this->_template_args = array( |
|
1267 | - 'data' => $json_response_data, |
|
1268 | - 'error' => $notices['errors'], |
|
1269 | - 'success' => $notices['success'] |
|
1270 | - ); |
|
1271 | - $this->_return_json(); |
|
1272 | - } |
|
1273 | - |
|
1274 | - |
|
1275 | - /** |
|
1276 | - * _validate_payment_request_data |
|
1277 | - * |
|
1278 | - * @return array |
|
1279 | - */ |
|
1280 | - protected function _validate_payment_request_data() |
|
1281 | - { |
|
1282 | - if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
1283 | - return false; |
|
1284 | - } |
|
1285 | - $payment_form = $this->_generate_payment_form_section(); |
|
1286 | - try { |
|
1287 | - if ($payment_form->was_submitted()) { |
|
1288 | - $payment_form->receive_form_submission(); |
|
1289 | - if ( ! $payment_form->is_valid()) { |
|
1290 | - $submission_error_messages = array(); |
|
1291 | - foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1292 | - if ($validation_error instanceof EE_Validation_Error) { |
|
1293 | - $submission_error_messages[] = sprintf( |
|
1294 | - _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1295 | - $validation_error->get_form_section()->html_label_text(), |
|
1296 | - $validation_error->getMessage() |
|
1297 | - ); |
|
1298 | - } |
|
1299 | - } |
|
1300 | - EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1301 | - |
|
1302 | - return array(); |
|
1303 | - } |
|
1304 | - } |
|
1305 | - } catch (EE_Error $e) { |
|
1306 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1307 | - |
|
1308 | - return array(); |
|
1309 | - } |
|
1310 | - |
|
1311 | - return $payment_form->valid_data(); |
|
1312 | - } |
|
1313 | - |
|
1314 | - |
|
1315 | - /** |
|
1316 | - * _generate_payment_form_section |
|
1317 | - * |
|
1318 | - * @return EE_Form_Section_Proper |
|
1319 | - */ |
|
1320 | - protected function _generate_payment_form_section() |
|
1321 | - { |
|
1322 | - return new EE_Form_Section_Proper( |
|
1323 | - array( |
|
1324 | - 'name' => 'txn_admin_payment', |
|
1325 | - 'subsections' => array( |
|
1326 | - 'PAY_ID' => new EE_Text_Input( |
|
1327 | - array( |
|
1328 | - 'default' => 0, |
|
1329 | - 'required' => false, |
|
1330 | - 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1331 | - 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1332 | - ) |
|
1333 | - ), |
|
1334 | - 'TXN_ID' => new EE_Text_Input( |
|
1335 | - array( |
|
1336 | - 'default' => 0, |
|
1337 | - 'required' => true, |
|
1338 | - 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1339 | - 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1340 | - ) |
|
1341 | - ), |
|
1342 | - 'type' => new EE_Text_Input( |
|
1343 | - array( |
|
1344 | - 'default' => 1, |
|
1345 | - 'required' => true, |
|
1346 | - 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1347 | - 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1348 | - ) |
|
1349 | - ), |
|
1350 | - 'amount' => new EE_Text_Input( |
|
1351 | - array( |
|
1352 | - 'default' => 0, |
|
1353 | - 'required' => true, |
|
1354 | - 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1355 | - 'validation_strategies' => array(new EE_Float_Normalization()) |
|
1356 | - ) |
|
1357 | - ), |
|
1358 | - 'status' => new EE_Text_Input( |
|
1359 | - array( |
|
1360 | - 'default' => EEM_Payment::status_id_approved, |
|
1361 | - 'required' => true, |
|
1362 | - 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1363 | - ) |
|
1364 | - ), |
|
1365 | - 'PMD_ID' => new EE_Text_Input( |
|
1366 | - array( |
|
1367 | - 'default' => 2, |
|
1368 | - 'required' => true, |
|
1369 | - 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1370 | - 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1371 | - ) |
|
1372 | - ), |
|
1373 | - 'date' => new EE_Text_Input( |
|
1374 | - array( |
|
1375 | - 'default' => time(), |
|
1376 | - 'required' => true, |
|
1377 | - 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1378 | - ) |
|
1379 | - ), |
|
1380 | - 'txn_id_chq_nmbr' => new EE_Text_Input( |
|
1381 | - array( |
|
1382 | - 'default' => '', |
|
1383 | - 'required' => false, |
|
1384 | - 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1385 | - 'validation_strategies' => array( |
|
1386 | - new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
1387 | - 100), |
|
1388 | - ) |
|
1389 | - ) |
|
1390 | - ), |
|
1391 | - 'po_number' => new EE_Text_Input( |
|
1392 | - array( |
|
1393 | - 'default' => '', |
|
1394 | - 'required' => false, |
|
1395 | - 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1396 | - 'validation_strategies' => array( |
|
1397 | - new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
1398 | - 100), |
|
1399 | - ) |
|
1400 | - ) |
|
1401 | - ), |
|
1402 | - 'accounting' => new EE_Text_Input( |
|
1403 | - array( |
|
1404 | - 'default' => '', |
|
1405 | - 'required' => false, |
|
1406 | - 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1407 | - 'validation_strategies' => array( |
|
1408 | - new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
1409 | - 100), |
|
1410 | - ) |
|
1411 | - ) |
|
1412 | - ), |
|
1413 | - ) |
|
1414 | - ) |
|
1415 | - ); |
|
1416 | - } |
|
1417 | - |
|
1418 | - |
|
1419 | - /** |
|
1420 | - * _create_payment_from_request_data |
|
1421 | - * |
|
1422 | - * @param array $valid_data |
|
1423 | - * |
|
1424 | - * @return EE_Payment |
|
1425 | - */ |
|
1426 | - protected function _create_payment_from_request_data($valid_data) |
|
1427 | - { |
|
1428 | - $PAY_ID = $valid_data['PAY_ID']; |
|
1429 | - // get payment amount |
|
1430 | - $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1431 | - // payments have a type value of 1 and refunds have a type value of -1 |
|
1432 | - // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
|
1433 | - $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1434 | - // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
|
1435 | - $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', |
|
1436 | - current_time('timestamp')); |
|
1437 | - $payment = EE_Payment::new_instance( |
|
1438 | - array( |
|
1439 | - 'TXN_ID' => $valid_data['TXN_ID'], |
|
1440 | - 'STS_ID' => $valid_data['status'], |
|
1441 | - 'PAY_timestamp' => $date, |
|
1442 | - 'PAY_source' => EEM_Payment_Method::scope_admin, |
|
1443 | - 'PMD_ID' => $valid_data['PMD_ID'], |
|
1444 | - 'PAY_amount' => $amount, |
|
1445 | - 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1446 | - 'PAY_po_number' => $valid_data['po_number'], |
|
1447 | - 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1448 | - 'PAY_details' => $valid_data, |
|
1449 | - 'PAY_ID' => $PAY_ID |
|
1450 | - ), |
|
1451 | - '', |
|
1452 | - array('Y-m-d', 'g:i a') |
|
1453 | - ); |
|
1454 | - |
|
1455 | - if ( ! $payment->save()) { |
|
1456 | - EE_Error::add_error( |
|
1457 | - sprintf( |
|
1458 | - esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1459 | - $payment->ID() |
|
1460 | - ), |
|
1461 | - __FILE__, __FUNCTION__, __LINE__ |
|
1462 | - ); |
|
1463 | - } |
|
1464 | - |
|
1465 | - return $payment; |
|
1466 | - } |
|
1467 | - |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * _process_transaction_payments |
|
1471 | - * |
|
1472 | - * @param \EE_Transaction $transaction |
|
1473 | - * |
|
1474 | - * @return array |
|
1475 | - */ |
|
1476 | - protected function _process_transaction_payments(EE_Transaction $transaction) |
|
1477 | - { |
|
1478 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
1479 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1480 | - //update the transaction with this payment |
|
1481 | - if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1482 | - EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), |
|
1483 | - __FILE__, __FUNCTION__, __LINE__); |
|
1484 | - } else { |
|
1485 | - EE_Error::add_error( |
|
1486 | - esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', |
|
1487 | - 'event_espresso') |
|
1488 | - , __FILE__, __FUNCTION__, __LINE__ |
|
1489 | - ); |
|
1490 | - } |
|
1491 | - } |
|
1492 | - |
|
1493 | - |
|
1494 | - /** |
|
1495 | - * _get_REG_IDs_to_apply_payment_to |
|
1496 | - * |
|
1497 | - * returns a list of registration IDs that the payment will apply to |
|
1498 | - * |
|
1499 | - * @param \EE_Payment $payment |
|
1500 | - * |
|
1501 | - * @return array |
|
1502 | - */ |
|
1503 | - protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) |
|
1504 | - { |
|
1505 | - $REG_IDs = array(); |
|
1506 | - // grab array of IDs for specific registrations to apply changes to |
|
1507 | - if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
1508 | - $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations']; |
|
1509 | - } |
|
1510 | - //nothing specified ? then get all reg IDs |
|
1511 | - if (empty($REG_IDs)) { |
|
1512 | - $registrations = $payment->transaction()->registrations(); |
|
1513 | - $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1514 | - } |
|
1515 | - |
|
1516 | - // ensure that REG_IDs are integers and NOT strings |
|
1517 | - return array_map('intval', $REG_IDs); |
|
1518 | - } |
|
1519 | - |
|
1520 | - |
|
1521 | - /** |
|
1522 | - * @return array |
|
1523 | - */ |
|
1524 | - public function existing_reg_payment_REG_IDs() |
|
1525 | - { |
|
1526 | - return $this->_existing_reg_payment_REG_IDs; |
|
1527 | - } |
|
1528 | - |
|
1529 | - |
|
1530 | - /** |
|
1531 | - * @param array $existing_reg_payment_REG_IDs |
|
1532 | - */ |
|
1533 | - public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) |
|
1534 | - { |
|
1535 | - $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
|
1536 | - } |
|
1537 | - |
|
1538 | - |
|
1539 | - /** |
|
1540 | - * _get_existing_reg_payment_REG_IDs |
|
1541 | - * |
|
1542 | - * returns a list of registration IDs that the payment is currently related to |
|
1543 | - * as recorded in the database |
|
1544 | - * |
|
1545 | - * @param \EE_Payment $payment |
|
1546 | - * |
|
1547 | - * @return array |
|
1548 | - */ |
|
1549 | - protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) |
|
1550 | - { |
|
1551 | - if ($this->existing_reg_payment_REG_IDs() === null) { |
|
1552 | - // let's get any existing reg payment records for this payment |
|
1553 | - $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
1554 | - // but we only want the REG IDs, so grab the array keys |
|
1555 | - $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
1556 | - $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
1557 | - } |
|
1558 | - |
|
1559 | - return $this->existing_reg_payment_REG_IDs(); |
|
1560 | - } |
|
1561 | - |
|
1562 | - |
|
1563 | - /** |
|
1564 | - * _remove_existing_registration_payments |
|
1565 | - * |
|
1566 | - * this calculates the difference between existing relations |
|
1567 | - * to the supplied payment and the new list registration IDs, |
|
1568 | - * removes any related registrations that no longer apply, |
|
1569 | - * and then updates the registration paid fields |
|
1570 | - * |
|
1571 | - * @param \EE_Payment $payment |
|
1572 | - * @param int $PAY_ID |
|
1573 | - * |
|
1574 | - * @return bool; |
|
1575 | - */ |
|
1576 | - protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) |
|
1577 | - { |
|
1578 | - // newly created payments will have nothing recorded for $PAY_ID |
|
1579 | - if ($PAY_ID == 0) { |
|
1580 | - return false; |
|
1581 | - } |
|
1582 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1583 | - if (empty($existing_reg_payment_REG_IDs)) { |
|
1584 | - return false; |
|
1585 | - } |
|
1586 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
1587 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1588 | - |
|
1589 | - return $transaction_payments->delete_registration_payments_and_update_registrations( |
|
1590 | - $payment, |
|
1591 | - array( |
|
1592 | - array( |
|
1593 | - 'PAY_ID' => $payment->ID(), |
|
1594 | - 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
1595 | - ) |
|
1596 | - ) |
|
1597 | - ); |
|
1598 | - } |
|
1599 | - |
|
1600 | - |
|
1601 | - /** |
|
1602 | - * _update_registration_payments |
|
1603 | - * |
|
1604 | - * this applies the payments to the selected registrations |
|
1605 | - * but only if they have not already been paid for |
|
1606 | - * |
|
1607 | - * @param EE_Transaction $transaction |
|
1608 | - * @param \EE_Payment $payment |
|
1609 | - * @param array $REG_IDs |
|
1610 | - * |
|
1611 | - * @return bool |
|
1612 | - */ |
|
1613 | - protected function _update_registration_payments( |
|
1614 | - EE_Transaction $transaction, |
|
1615 | - EE_Payment $payment, |
|
1616 | - $REG_IDs = array() |
|
1617 | - ) { |
|
1618 | - // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
|
1619 | - // so let's do that using our set of REG_IDs from the form |
|
1620 | - $registration_query_where_params = array( |
|
1621 | - 'REG_ID' => array('IN', $REG_IDs) |
|
1622 | - ); |
|
1623 | - // but add in some conditions regarding payment, |
|
1624 | - // so that we don't apply payments to registrations that are free or have already been paid for |
|
1625 | - // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
|
1626 | - if ( ! $payment->is_a_refund()) { |
|
1627 | - $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
1628 | - $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
1629 | - } |
|
1630 | - //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
|
1631 | - $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
1632 | - if ( ! empty($registrations)) { |
|
1633 | - /** @type EE_Payment_Processor $payment_processor */ |
|
1634 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1635 | - $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
1636 | - } |
|
1637 | - } |
|
1638 | - |
|
1639 | - |
|
1640 | - /** |
|
1641 | - * _process_registration_status_change |
|
1642 | - * |
|
1643 | - * This processes requested registration status changes for all the registrations |
|
1644 | - * on a given transaction and (optionally) sends out notifications for the changes. |
|
1645 | - * |
|
1646 | - * @param EE_Transaction $transaction |
|
1647 | - * @param array $REG_IDs |
|
1648 | - * |
|
1649 | - * @return bool |
|
1650 | - */ |
|
1651 | - protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) |
|
1652 | - { |
|
1653 | - // first if there is no change in status then we get out. |
|
1654 | - if ( |
|
1655 | - ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
1656 | - || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
|
1657 | - ) { |
|
1658 | - //no error message, no change requested, just nothing to do man. |
|
1659 | - return false; |
|
1660 | - } |
|
1661 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
1662 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1663 | - |
|
1664 | - // made it here dude? Oh WOW. K, let's take care of changing the statuses |
|
1665 | - return $transaction_processor->manually_update_registration_statuses( |
|
1666 | - $transaction, |
|
1667 | - sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
1668 | - array(array('REG_ID' => array('IN', $REG_IDs))) |
|
1669 | - ); |
|
1670 | - } |
|
1671 | - |
|
1672 | - |
|
1673 | - /** |
|
1674 | - * _build_payment_json_response |
|
1675 | - * |
|
1676 | - * @access public |
|
1677 | - * |
|
1678 | - * @param \EE_Payment $payment |
|
1679 | - * @param array $REG_IDs |
|
1680 | - * @param bool | null $delete_txn_reg_status_change |
|
1681 | - * |
|
1682 | - * @return array |
|
1683 | - */ |
|
1684 | - protected function _build_payment_json_response( |
|
1685 | - EE_Payment $payment, |
|
1686 | - $REG_IDs = array(), |
|
1687 | - $delete_txn_reg_status_change = null |
|
1688 | - ) { |
|
1689 | - // was the payment deleted ? |
|
1690 | - if (is_bool($delete_txn_reg_status_change)) { |
|
1691 | - return array( |
|
1692 | - 'PAY_ID' => $payment->ID(), |
|
1693 | - 'amount' => $payment->amount(), |
|
1694 | - 'total_paid' => $payment->transaction()->paid(), |
|
1695 | - 'txn_status' => $payment->transaction()->status_ID(), |
|
1696 | - 'pay_status' => $payment->STS_ID(), |
|
1697 | - 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1698 | - 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
|
1699 | - ); |
|
1700 | - } else { |
|
1701 | - $this->_get_payment_status_array(); |
|
1702 | - |
|
1703 | - return array( |
|
1704 | - 'amount' => $payment->amount(), |
|
1705 | - 'total_paid' => $payment->transaction()->paid(), |
|
1706 | - 'txn_status' => $payment->transaction()->status_ID(), |
|
1707 | - 'pay_status' => $payment->STS_ID(), |
|
1708 | - 'PAY_ID' => $payment->ID(), |
|
1709 | - 'STS_ID' => $payment->STS_ID(), |
|
1710 | - 'status' => self::$_pay_status[$payment->STS_ID()], |
|
1711 | - 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
1712 | - 'method' => strtoupper($payment->source()), |
|
1713 | - 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
|
1714 | - 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", |
|
1715 | - 'event_espresso'), |
|
1716 | - 'gateway_response' => $payment->gateway_response(), |
|
1717 | - 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
|
1718 | - 'po_number' => $payment->po_number(), |
|
1719 | - 'extra_accntng' => $payment->extra_accntng(), |
|
1720 | - 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1721 | - ); |
|
1722 | - } |
|
1723 | - } |
|
1724 | - |
|
1725 | - |
|
1726 | - /** |
|
1727 | - * delete_payment |
|
1728 | - * delete a payment or refund made towards a transaction |
|
1729 | - * |
|
1730 | - * @access public |
|
1731 | - * @return void |
|
1732 | - */ |
|
1733 | - public function delete_payment() |
|
1734 | - { |
|
1735 | - $json_response_data = array('return_data' => false); |
|
1736 | - $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
1737 | - if ($PAY_ID) { |
|
1738 | - $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
1739 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
1740 | - if ($payment instanceof EE_Payment) { |
|
1741 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1742 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
1743 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1744 | - if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
1745 | - $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, |
|
1746 | - $delete_txn_reg_status_change); |
|
1747 | - if ($delete_txn_reg_status_change) { |
|
1748 | - $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
1749 | - //MAKE sure we also add the delete_txn_req_status_change to the |
|
1750 | - //$_REQUEST global because that's how messages will be looking for it. |
|
1751 | - $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
1752 | - $this->_maybe_send_notifications(); |
|
1753 | - $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
1754 | - } |
|
1755 | - } |
|
1756 | - } else { |
|
1757 | - EE_Error::add_error( |
|
1758 | - esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
1759 | - __FILE__, __FUNCTION__, __LINE__ |
|
1760 | - ); |
|
1761 | - } |
|
1762 | - } else { |
|
1763 | - EE_Error::add_error( |
|
1764 | - esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', |
|
1765 | - 'event_espresso'), |
|
1766 | - __FILE__, __FUNCTION__, __LINE__ |
|
1767 | - ); |
|
1768 | - } |
|
1769 | - $notices = EE_Error::get_notices(false, false, false); |
|
1770 | - $this->_template_args = array( |
|
1771 | - 'data' => $json_response_data, |
|
1772 | - 'success' => $notices['success'], |
|
1773 | - 'error' => $notices['errors'], |
|
1774 | - 'attention' => $notices['attention'] |
|
1775 | - ); |
|
1776 | - $this->_return_json(); |
|
1777 | - } |
|
1778 | - |
|
1779 | - |
|
1780 | - /** |
|
1781 | - * _registration_payment_data_array |
|
1782 | - * adds info for 'owing' and 'paid' for each registration to the json response |
|
1783 | - * |
|
1784 | - * @access protected |
|
1785 | - * |
|
1786 | - * @param array $REG_IDs |
|
1787 | - * |
|
1788 | - * @return array |
|
1789 | - */ |
|
1790 | - protected function _registration_payment_data_array($REG_IDs) |
|
1791 | - { |
|
1792 | - $registration_payment_data = array(); |
|
1793 | - //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
|
1794 | - if ( ! empty($REG_IDs)) { |
|
1795 | - $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
1796 | - foreach ($registrations as $registration) { |
|
1797 | - if ($registration instanceof EE_Registration) { |
|
1798 | - $registration_payment_data[$registration->ID()] = array( |
|
1799 | - 'paid' => $registration->pretty_paid(), |
|
1800 | - 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
1801 | - ); |
|
1802 | - } |
|
1803 | - } |
|
1804 | - } |
|
1805 | - |
|
1806 | - return $registration_payment_data; |
|
1807 | - } |
|
1808 | - |
|
1809 | - |
|
1810 | - /** |
|
1811 | - * _maybe_send_notifications |
|
1812 | - * |
|
1813 | - * determines whether or not the admin has indicated that notifications should be sent. |
|
1814 | - * If so, will toggle a filter switch for delivering registration notices. |
|
1815 | - * If passed an EE_Payment object, then it will trigger payment notifications instead. |
|
1816 | - * |
|
1817 | - * @access protected |
|
1818 | - * |
|
1819 | - * @param \EE_Payment | null $payment |
|
1820 | - */ |
|
1821 | - protected function _maybe_send_notifications($payment = null) |
|
1822 | - { |
|
1823 | - switch ($payment instanceof EE_Payment) { |
|
1824 | - // payment notifications |
|
1825 | - case true : |
|
1826 | - if ( |
|
1827 | - isset( |
|
1828 | - $this->_req_data['txn_payments'], |
|
1829 | - $this->_req_data['txn_payments']['send_notifications'] |
|
1830 | - ) && |
|
1831 | - filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1832 | - ) { |
|
1833 | - $this->_process_payment_notification($payment); |
|
1834 | - } |
|
1835 | - break; |
|
1836 | - // registration notifications |
|
1837 | - case false : |
|
1838 | - if ( |
|
1839 | - isset( |
|
1840 | - $this->_req_data['txn_reg_status_change'], |
|
1841 | - $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
1842 | - ) && |
|
1843 | - filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1844 | - ) { |
|
1845 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
1846 | - } |
|
1847 | - break; |
|
1848 | - } |
|
1849 | - } |
|
1850 | - |
|
1851 | - |
|
1852 | - /** |
|
1853 | - * _send_payment_reminder |
|
1854 | - * generates HTML for the View Transaction Details Admin page |
|
1855 | - * |
|
1856 | - * @access protected |
|
1857 | - * @return void |
|
1858 | - */ |
|
1859 | - protected function _send_payment_reminder() |
|
1860 | - { |
|
1861 | - $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
1862 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1863 | - $query_args = isset($this->_req_data['redirect_to']) ? array( |
|
1864 | - 'action' => $this->_req_data['redirect_to'], |
|
1865 | - 'TXN_ID' => $this->_req_data['TXN_ID'] |
|
1866 | - ) : array(); |
|
1867 | - do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
1868 | - $transaction); |
|
1869 | - $this->_redirect_after_action(false, esc_html__('payment reminder', 'event_espresso'), |
|
1870 | - esc_html__('sent', 'event_espresso'), $query_args, true); |
|
1871 | - } |
|
1872 | - |
|
1873 | - |
|
1874 | - /** |
|
1875 | - * get_transactions |
|
1876 | - * get transactions for given parameters (used by list table) |
|
1877 | - * |
|
1878 | - * @param int $perpage how many transactions displayed per page |
|
1879 | - * @param boolean $count return the count or objects |
|
1880 | - * @param string $view |
|
1881 | - * |
|
1882 | - * @return mixed int = count || array of transaction objects |
|
1883 | - */ |
|
1884 | - public function get_transactions($perpage, $count = false, $view = '') |
|
1885 | - { |
|
1886 | - |
|
1887 | - $TXN = EEM_Transaction::instance(); |
|
1888 | - |
|
1889 | - $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
1890 | - strtotime('-10 year')); |
|
1891 | - $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
1892 | - |
|
1893 | - //make sure our timestamps start and end right at the boundaries for each day |
|
1894 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1895 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1896 | - |
|
1897 | - |
|
1898 | - //convert to timestamps |
|
1899 | - $start_date = strtotime($start_date); |
|
1900 | - $end_date = strtotime($end_date); |
|
1901 | - |
|
1902 | - //makes sure start date is the lowest value and vice versa |
|
1903 | - $start_date = min($start_date, $end_date); |
|
1904 | - $end_date = max($start_date, $end_date); |
|
1905 | - |
|
1906 | - //convert to correct format for query |
|
1907 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
1908 | - date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
1909 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
1910 | - date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
1911 | - |
|
1912 | - |
|
1913 | - //set orderby |
|
1914 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
1915 | - |
|
1916 | - switch ($this->_req_data['orderby']) { |
|
1917 | - case 'TXN_ID': |
|
1918 | - $orderby = 'TXN_ID'; |
|
1919 | - break; |
|
1920 | - case 'ATT_fname': |
|
1921 | - $orderby = 'Registration.Attendee.ATT_fname'; |
|
1922 | - break; |
|
1923 | - case 'event_name': |
|
1924 | - $orderby = 'Registration.Event.EVT_name'; |
|
1925 | - break; |
|
1926 | - default: //'TXN_timestamp' |
|
1927 | - $orderby = 'TXN_timestamp'; |
|
1928 | - } |
|
1929 | - |
|
1930 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
1931 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1932 | - $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
1933 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1934 | - |
|
1935 | - $offset = ($current_page - 1) * $per_page; |
|
1936 | - $limit = array($offset, $per_page); |
|
1937 | - |
|
1938 | - $_where = array( |
|
1939 | - 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
1940 | - 'Registration.REG_count' => 1 |
|
1941 | - ); |
|
1942 | - |
|
1943 | - if (isset($this->_req_data['EVT_ID'])) { |
|
1944 | - $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
|
1945 | - } |
|
1946 | - |
|
1947 | - if (isset($this->_req_data['s'])) { |
|
1948 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1949 | - $_where['OR'] = array( |
|
1950 | - 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
1951 | - 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
1952 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
1953 | - 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
1954 | - 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
1955 | - 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
1956 | - 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
1957 | - 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
1958 | - 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
1959 | - 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
1960 | - 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
1961 | - 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
1962 | - 'Registration.REG_code' => array('LIKE', $search_string), |
|
1963 | - 'Registration.REG_count' => array('LIKE', $search_string), |
|
1964 | - 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
1965 | - 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
1966 | - 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
1967 | - 'Payment.PAY_source' => array('LIKE', $search_string), |
|
1968 | - 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
1969 | - 'TXN_session_data' => array('LIKE', $search_string), |
|
1970 | - 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string) |
|
1971 | - ); |
|
1972 | - } |
|
1973 | - |
|
1974 | - //failed transactions |
|
1975 | - $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false; |
|
1976 | - $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false; |
|
1977 | - |
|
1978 | - if ($failed) { |
|
1979 | - $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
1980 | - } else if ($abandoned) { |
|
1981 | - $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
|
1982 | - } else { |
|
1983 | - $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
1984 | - $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
1985 | - } |
|
1986 | - |
|
1987 | - $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit); |
|
1988 | - |
|
1989 | - $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', true) : $TXN->get_all($query_params); |
|
1990 | - |
|
1991 | - |
|
1992 | - return $transactions; |
|
1993 | - |
|
1994 | - } |
|
803 | + // process payment details |
|
804 | + $payments = $this->_transaction->get_many_related('Payment'); |
|
805 | + if ( ! empty($payments)) { |
|
806 | + $this->_template_args['payments'] = $payments; |
|
807 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
808 | + } else { |
|
809 | + $this->_template_args['payments'] = false; |
|
810 | + $this->_template_args['existing_reg_payments'] = array(); |
|
811 | + } |
|
812 | + |
|
813 | + $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
814 | + $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), |
|
815 | + TXN_ADMIN_URL); |
|
816 | + |
|
817 | + if (isset($txn_details['invoice_number'])) { |
|
818 | + $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
|
819 | + $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', |
|
820 | + 'event_espresso'); |
|
821 | + } |
|
822 | + |
|
823 | + $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
|
824 | + $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', |
|
825 | + 'event_espresso'); |
|
826 | + |
|
827 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
828 | + $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', |
|
829 | + 'event_espresso'); |
|
830 | + |
|
831 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
832 | + $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', |
|
833 | + 'event_espresso'); |
|
834 | + |
|
835 | + $reg_steps = '<ul>'; |
|
836 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
837 | + if ($reg_step_status === true) { |
|
838 | + $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
839 | + ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
840 | + } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
841 | + $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
842 | + esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
843 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
844 | + date(get_option('date_format') . ' ' . get_option('time_format'), |
|
845 | + ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
846 | + ) . '</li>'; |
|
847 | + } else { |
|
848 | + $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated', |
|
849 | + 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
850 | + } |
|
851 | + } |
|
852 | + $reg_steps .= '</ul>'; |
|
853 | + $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
|
854 | + $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', |
|
855 | + 'event_espresso'); |
|
856 | + |
|
857 | + |
|
858 | + $this->_get_registrations_to_apply_payment_to(); |
|
859 | + $this->_get_payment_methods($payments); |
|
860 | + $this->_get_payment_status_array(); |
|
861 | + $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
|
862 | + |
|
863 | + $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
864 | + 'action' => 'edit_transaction', |
|
865 | + 'process' => 'transaction' |
|
866 | + ), TXN_ADMIN_URL); |
|
867 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
868 | + 'page' => 'espresso_transactions', |
|
869 | + 'action' => 'espresso_apply_payment' |
|
870 | + ), WP_AJAX_URL); |
|
871 | + $this->_template_args['delete_payment_form_url'] = add_query_arg(array( |
|
872 | + 'page' => 'espresso_transactions', |
|
873 | + 'action' => 'espresso_delete_payment' |
|
874 | + ), WP_AJAX_URL); |
|
875 | + |
|
876 | + // 'espresso_delete_payment_nonce' |
|
877 | + |
|
878 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
879 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
880 | + |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + /** |
|
885 | + * _get_registration_payment_IDs |
|
886 | + * |
|
887 | + * generates an array of Payment IDs and their corresponding Registration IDs |
|
888 | + * |
|
889 | + * @access protected |
|
890 | + * |
|
891 | + * @param EE_Payment[] $payments |
|
892 | + * |
|
893 | + * @return array |
|
894 | + */ |
|
895 | + protected function _get_registration_payment_IDs($payments = array()) |
|
896 | + { |
|
897 | + $existing_reg_payments = array(); |
|
898 | + // get all reg payments for these payments |
|
899 | + $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
900 | + array( |
|
901 | + 'PAY_ID' => array( |
|
902 | + 'IN', |
|
903 | + array_keys($payments) |
|
904 | + ) |
|
905 | + ) |
|
906 | + )); |
|
907 | + if ( ! empty($reg_payments)) { |
|
908 | + foreach ($payments as $payment) { |
|
909 | + if ( ! $payment instanceof EE_Payment) { |
|
910 | + continue; |
|
911 | + } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
912 | + $existing_reg_payments[$payment->ID()] = array(); |
|
913 | + } |
|
914 | + foreach ($reg_payments as $reg_payment) { |
|
915 | + if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
916 | + $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
917 | + } |
|
918 | + } |
|
919 | + } |
|
920 | + } |
|
921 | + |
|
922 | + return $existing_reg_payments; |
|
923 | + } |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * _get_registrations_to_apply_payment_to |
|
928 | + * generates HTML for displaying a series of checkboxes in the admin payment modal window |
|
929 | + * which allows the admin to only apply the payment to the specific registrations |
|
930 | + * |
|
931 | + * @access protected |
|
932 | + * @return void |
|
933 | + * @throws \EE_Error |
|
934 | + */ |
|
935 | + protected function _get_registrations_to_apply_payment_to() |
|
936 | + { |
|
937 | + // we want any registration with an active status (ie: not deleted or cancelled) |
|
938 | + $query_params = array( |
|
939 | + array( |
|
940 | + 'STS_ID' => array( |
|
941 | + 'IN', |
|
942 | + array( |
|
943 | + EEM_Registration::status_id_approved, |
|
944 | + EEM_Registration::status_id_pending_payment, |
|
945 | + EEM_Registration::status_id_not_approved, |
|
946 | + ) |
|
947 | + ) |
|
948 | + ) |
|
949 | + ); |
|
950 | + $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
951 | + '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
|
952 | + ); |
|
953 | + $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
954 | + $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
955 | + $registrations_to_apply_payment_to .= EEH_HTML::thead( |
|
956 | + EEH_HTML::tr( |
|
957 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
958 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
959 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
960 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
961 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
962 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
963 | + EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
964 | + ) |
|
965 | + ); |
|
966 | + $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
|
967 | + // get registrations for TXN |
|
968 | + $registrations = $this->_transaction->registrations($query_params); |
|
969 | + foreach ($registrations as $registration) { |
|
970 | + if ($registration instanceof EE_Registration) { |
|
971 | + $attendee_name = $registration->attendee() instanceof EE_Attendee |
|
972 | + ? $registration->attendee()->full_name() |
|
973 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
974 | + $owing = $registration->final_price() - $registration->paid(); |
|
975 | + $taxable = $registration->ticket()->taxable() |
|
976 | + ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
977 | + : ''; |
|
978 | + $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) |
|
979 | + ? ' checked="checked"' |
|
980 | + : ''; |
|
981 | + $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
982 | + $registrations_to_apply_payment_to .= EEH_HTML::tr( |
|
983 | + EEH_HTML::td($registration->ID()) . |
|
984 | + EEH_HTML::td($attendee_name) . |
|
985 | + EEH_HTML::td( |
|
986 | + $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
987 | + ) . |
|
988 | + EEH_HTML::td($registration->event_name()) . |
|
989 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
990 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
991 | + EEH_HTML::td( |
|
992 | + '<input type="checkbox" value="' . $registration->ID() |
|
993 | + . '" name="txn_admin_payment[registrations]"' |
|
994 | + . $checked . $disabled . '>', |
|
995 | + '', 'jst-cntr' |
|
996 | + ), |
|
997 | + 'apply-payment-registration-row-' . $registration->ID() |
|
998 | + ); |
|
999 | + } |
|
1000 | + } |
|
1001 | + $registrations_to_apply_payment_to .= EEH_HTML::tbodyx(); |
|
1002 | + $registrations_to_apply_payment_to .= EEH_HTML::tablex(); |
|
1003 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1004 | + $registrations_to_apply_payment_to .= EEH_HTML::p( |
|
1005 | + esc_html__( |
|
1006 | + 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', |
|
1007 | + 'event_espresso' |
|
1008 | + ), |
|
1009 | + '', 'clear description' |
|
1010 | + ); |
|
1011 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1012 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * _get_reg_status_selection |
|
1018 | + * |
|
1019 | + * @todo this will need to be adjusted either once MER comes along OR we move default reg status to tickets |
|
1020 | + * instead of events. |
|
1021 | + * @access protected |
|
1022 | + * @return void |
|
1023 | + */ |
|
1024 | + protected function _get_reg_status_selection() |
|
1025 | + { |
|
1026 | + //first get all possible statuses |
|
1027 | + $statuses = EEM_Registration::reg_status_array(array(), true); |
|
1028 | + //let's add a "don't change" option. |
|
1029 | + $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
|
1030 | + $status_array = array_merge($status_array, $statuses); |
|
1031 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', |
|
1032 | + $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
1033 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', |
|
1034 | + $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
1035 | + |
|
1036 | + } |
|
1037 | + |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * _get_payment_methods |
|
1041 | + * Gets all the payment methods available generally, or the ones that are already |
|
1042 | + * selected on these payments (in case their payment methods are no longer active). |
|
1043 | + * Has the side-effect of updating the template args' payment_methods item |
|
1044 | + * @access private |
|
1045 | + * |
|
1046 | + * @param EE_Payment[] to show on this page |
|
1047 | + * |
|
1048 | + * @return void |
|
1049 | + */ |
|
1050 | + private function _get_payment_methods($payments = array()) |
|
1051 | + { |
|
1052 | + $payment_methods_of_payments = array(); |
|
1053 | + foreach ($payments as $payment) { |
|
1054 | + if ($payment instanceof EE_Payment) { |
|
1055 | + $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
1056 | + } |
|
1057 | + } |
|
1058 | + if ($payment_methods_of_payments) { |
|
1059 | + $query_args = array( |
|
1060 | + array( |
|
1061 | + 'OR*payment_method_for_payment' => array( |
|
1062 | + 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
1063 | + 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%') |
|
1064 | + ) |
|
1065 | + ) |
|
1066 | + ); |
|
1067 | + } else { |
|
1068 | + $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))); |
|
1069 | + } |
|
1070 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1071 | + } |
|
1072 | + |
|
1073 | + |
|
1074 | + /** |
|
1075 | + * txn_attendees_meta_box |
|
1076 | + * generates HTML for the Attendees Transaction main meta box |
|
1077 | + * |
|
1078 | + * @access public |
|
1079 | + * |
|
1080 | + * @param WP_Post $post |
|
1081 | + * @param array $metabox |
|
1082 | + * |
|
1083 | + * @return void |
|
1084 | + */ |
|
1085 | + public function txn_attendees_meta_box($post, $metabox = array('args' => array())) |
|
1086 | + { |
|
1087 | + |
|
1088 | + extract($metabox['args']); |
|
1089 | + $this->_template_args['post'] = $post; |
|
1090 | + $this->_template_args['event_attendees'] = array(); |
|
1091 | + // process items in cart |
|
1092 | + $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
1093 | + if ( ! empty($line_items)) { |
|
1094 | + foreach ($line_items as $item) { |
|
1095 | + if ($item instanceof EE_Line_Item) { |
|
1096 | + switch ($item->OBJ_type()) { |
|
1097 | + |
|
1098 | + case 'Event' : |
|
1099 | + break; |
|
1100 | + |
|
1101 | + case 'Ticket' : |
|
1102 | + $ticket = $item->ticket(); |
|
1103 | + //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
|
1104 | + if ( ! $ticket instanceof EE_Ticket) { |
|
1105 | + continue; |
|
1106 | + } |
|
1107 | + try { |
|
1108 | + $event_name = $ticket->get_event_name(); |
|
1109 | + } catch (Exception $e) { |
|
1110 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1111 | + $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1112 | + } |
|
1113 | + $event_name .= ' - ' . $item->get('LIN_name'); |
|
1114 | + $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
1115 | + // now get all of the registrations for this transaction that use this ticket |
|
1116 | + $registrations = $ticket->get_many_related('Registration', |
|
1117 | + array(array('TXN_ID' => $this->_transaction->ID()))); |
|
1118 | + foreach ($registrations as $registration) { |
|
1119 | + if ( ! $registration instanceof EE_Registration) { |
|
1120 | + continue; |
|
1121 | + } |
|
1122 | + $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1123 | + $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1124 | + $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1125 | + $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1126 | + // attendee info |
|
1127 | + $attendee = $registration->get_first_related('Attendee'); |
|
1128 | + if ($attendee instanceof EE_Attendee) { |
|
1129 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1130 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1131 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', |
|
1132 | + 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
1133 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, |
|
1134 | + 'inline', false, false); |
|
1135 | + } else { |
|
1136 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
|
1137 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1138 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
|
1139 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1140 | + } |
|
1141 | + } |
|
1142 | + break; |
|
1143 | + |
|
1144 | + } |
|
1145 | + } |
|
1146 | + } |
|
1147 | + |
|
1148 | + $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
1149 | + 'action' => 'edit_transaction', |
|
1150 | + 'process' => 'attendees' |
|
1151 | + ), TXN_ADMIN_URL); |
|
1152 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
1153 | + $this->_template_args, true); |
|
1154 | + |
|
1155 | + } else { |
|
1156 | + echo sprintf( |
|
1157 | + esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', |
|
1158 | + 'event_espresso'), |
|
1159 | + '<p class="important-notice">', |
|
1160 | + '</p>' |
|
1161 | + ); |
|
1162 | + } |
|
1163 | + } |
|
1164 | + |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * txn_registrant_side_meta_box |
|
1168 | + * generates HTML for the Edit Transaction side meta box |
|
1169 | + * |
|
1170 | + * @access public |
|
1171 | + * @throws \EE_Error |
|
1172 | + * @return void |
|
1173 | + */ |
|
1174 | + public function txn_registrant_side_meta_box() |
|
1175 | + { |
|
1176 | + $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
|
1177 | + if ( ! $primary_att instanceof EE_Attendee) { |
|
1178 | + $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
|
1179 | + 'event_espresso'); |
|
1180 | + $primary_att = EEM_Attendee::instance()->create_default_object(); |
|
1181 | + } |
|
1182 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1183 | + $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
|
1184 | + $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
|
1185 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1186 | + $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
|
1187 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1188 | + 'action' => 'edit_attendee', |
|
1189 | + 'post' => $primary_att->ID() |
|
1190 | + ), REG_ADMIN_URL); |
|
1191 | + // get formatted address for registrant |
|
1192 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1193 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
1194 | + $this->_template_args, true); |
|
1195 | + } |
|
1196 | + |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * txn_billing_info_side_meta_box |
|
1200 | + * generates HTML for the Edit Transaction side meta box |
|
1201 | + * |
|
1202 | + * @access public |
|
1203 | + * @return void |
|
1204 | + */ |
|
1205 | + public function txn_billing_info_side_meta_box() |
|
1206 | + { |
|
1207 | + |
|
1208 | + $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
|
1209 | + $this->_template_args['billing_form_url'] = add_query_arg( |
|
1210 | + array('action' => 'edit_transaction', 'process' => 'billing'), |
|
1211 | + TXN_ADMIN_URL |
|
1212 | + ); |
|
1213 | + |
|
1214 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1215 | + echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/ |
|
1216 | + } |
|
1217 | + |
|
1218 | + |
|
1219 | + /** |
|
1220 | + * apply_payments_or_refunds |
|
1221 | + * registers a payment or refund made towards a transaction |
|
1222 | + * |
|
1223 | + * @access public |
|
1224 | + * @return void |
|
1225 | + */ |
|
1226 | + public function apply_payments_or_refunds() |
|
1227 | + { |
|
1228 | + $json_response_data = array('return_data' => false); |
|
1229 | + $valid_data = $this->_validate_payment_request_data(); |
|
1230 | + if ( ! empty($valid_data)) { |
|
1231 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1232 | + //save the new payment |
|
1233 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
1234 | + // get the TXN for this payment |
|
1235 | + $transaction = $payment->transaction(); |
|
1236 | + // verify transaction |
|
1237 | + if ($transaction instanceof EE_Transaction) { |
|
1238 | + // calculate_total_payments_and_update_status |
|
1239 | + $this->_process_transaction_payments($transaction); |
|
1240 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1241 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1242 | + // apply payment to registrations (if applicable) |
|
1243 | + if ( ! empty($REG_IDs)) { |
|
1244 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1245 | + $this->_maybe_send_notifications(); |
|
1246 | + // now process status changes for the same registrations |
|
1247 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1248 | + } |
|
1249 | + $this->_maybe_send_notifications($payment); |
|
1250 | + //prepare to render page |
|
1251 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1252 | + do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, |
|
1253 | + $payment); |
|
1254 | + } else { |
|
1255 | + EE_Error::add_error( |
|
1256 | + esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
1257 | + __FILE__, __FUNCTION__, __LINE__ |
|
1258 | + ); |
|
1259 | + } |
|
1260 | + } else { |
|
1261 | + EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', |
|
1262 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1263 | + } |
|
1264 | + |
|
1265 | + $notices = EE_Error::get_notices(false, false, false); |
|
1266 | + $this->_template_args = array( |
|
1267 | + 'data' => $json_response_data, |
|
1268 | + 'error' => $notices['errors'], |
|
1269 | + 'success' => $notices['success'] |
|
1270 | + ); |
|
1271 | + $this->_return_json(); |
|
1272 | + } |
|
1273 | + |
|
1274 | + |
|
1275 | + /** |
|
1276 | + * _validate_payment_request_data |
|
1277 | + * |
|
1278 | + * @return array |
|
1279 | + */ |
|
1280 | + protected function _validate_payment_request_data() |
|
1281 | + { |
|
1282 | + if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
1283 | + return false; |
|
1284 | + } |
|
1285 | + $payment_form = $this->_generate_payment_form_section(); |
|
1286 | + try { |
|
1287 | + if ($payment_form->was_submitted()) { |
|
1288 | + $payment_form->receive_form_submission(); |
|
1289 | + if ( ! $payment_form->is_valid()) { |
|
1290 | + $submission_error_messages = array(); |
|
1291 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1292 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1293 | + $submission_error_messages[] = sprintf( |
|
1294 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1295 | + $validation_error->get_form_section()->html_label_text(), |
|
1296 | + $validation_error->getMessage() |
|
1297 | + ); |
|
1298 | + } |
|
1299 | + } |
|
1300 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1301 | + |
|
1302 | + return array(); |
|
1303 | + } |
|
1304 | + } |
|
1305 | + } catch (EE_Error $e) { |
|
1306 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1307 | + |
|
1308 | + return array(); |
|
1309 | + } |
|
1310 | + |
|
1311 | + return $payment_form->valid_data(); |
|
1312 | + } |
|
1313 | + |
|
1314 | + |
|
1315 | + /** |
|
1316 | + * _generate_payment_form_section |
|
1317 | + * |
|
1318 | + * @return EE_Form_Section_Proper |
|
1319 | + */ |
|
1320 | + protected function _generate_payment_form_section() |
|
1321 | + { |
|
1322 | + return new EE_Form_Section_Proper( |
|
1323 | + array( |
|
1324 | + 'name' => 'txn_admin_payment', |
|
1325 | + 'subsections' => array( |
|
1326 | + 'PAY_ID' => new EE_Text_Input( |
|
1327 | + array( |
|
1328 | + 'default' => 0, |
|
1329 | + 'required' => false, |
|
1330 | + 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1331 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1332 | + ) |
|
1333 | + ), |
|
1334 | + 'TXN_ID' => new EE_Text_Input( |
|
1335 | + array( |
|
1336 | + 'default' => 0, |
|
1337 | + 'required' => true, |
|
1338 | + 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1339 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1340 | + ) |
|
1341 | + ), |
|
1342 | + 'type' => new EE_Text_Input( |
|
1343 | + array( |
|
1344 | + 'default' => 1, |
|
1345 | + 'required' => true, |
|
1346 | + 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1347 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1348 | + ) |
|
1349 | + ), |
|
1350 | + 'amount' => new EE_Text_Input( |
|
1351 | + array( |
|
1352 | + 'default' => 0, |
|
1353 | + 'required' => true, |
|
1354 | + 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1355 | + 'validation_strategies' => array(new EE_Float_Normalization()) |
|
1356 | + ) |
|
1357 | + ), |
|
1358 | + 'status' => new EE_Text_Input( |
|
1359 | + array( |
|
1360 | + 'default' => EEM_Payment::status_id_approved, |
|
1361 | + 'required' => true, |
|
1362 | + 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1363 | + ) |
|
1364 | + ), |
|
1365 | + 'PMD_ID' => new EE_Text_Input( |
|
1366 | + array( |
|
1367 | + 'default' => 2, |
|
1368 | + 'required' => true, |
|
1369 | + 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1370 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1371 | + ) |
|
1372 | + ), |
|
1373 | + 'date' => new EE_Text_Input( |
|
1374 | + array( |
|
1375 | + 'default' => time(), |
|
1376 | + 'required' => true, |
|
1377 | + 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1378 | + ) |
|
1379 | + ), |
|
1380 | + 'txn_id_chq_nmbr' => new EE_Text_Input( |
|
1381 | + array( |
|
1382 | + 'default' => '', |
|
1383 | + 'required' => false, |
|
1384 | + 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1385 | + 'validation_strategies' => array( |
|
1386 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
1387 | + 100), |
|
1388 | + ) |
|
1389 | + ) |
|
1390 | + ), |
|
1391 | + 'po_number' => new EE_Text_Input( |
|
1392 | + array( |
|
1393 | + 'default' => '', |
|
1394 | + 'required' => false, |
|
1395 | + 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1396 | + 'validation_strategies' => array( |
|
1397 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
1398 | + 100), |
|
1399 | + ) |
|
1400 | + ) |
|
1401 | + ), |
|
1402 | + 'accounting' => new EE_Text_Input( |
|
1403 | + array( |
|
1404 | + 'default' => '', |
|
1405 | + 'required' => false, |
|
1406 | + 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1407 | + 'validation_strategies' => array( |
|
1408 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), |
|
1409 | + 100), |
|
1410 | + ) |
|
1411 | + ) |
|
1412 | + ), |
|
1413 | + ) |
|
1414 | + ) |
|
1415 | + ); |
|
1416 | + } |
|
1417 | + |
|
1418 | + |
|
1419 | + /** |
|
1420 | + * _create_payment_from_request_data |
|
1421 | + * |
|
1422 | + * @param array $valid_data |
|
1423 | + * |
|
1424 | + * @return EE_Payment |
|
1425 | + */ |
|
1426 | + protected function _create_payment_from_request_data($valid_data) |
|
1427 | + { |
|
1428 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1429 | + // get payment amount |
|
1430 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1431 | + // payments have a type value of 1 and refunds have a type value of -1 |
|
1432 | + // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
|
1433 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1434 | + // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
|
1435 | + $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', |
|
1436 | + current_time('timestamp')); |
|
1437 | + $payment = EE_Payment::new_instance( |
|
1438 | + array( |
|
1439 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
1440 | + 'STS_ID' => $valid_data['status'], |
|
1441 | + 'PAY_timestamp' => $date, |
|
1442 | + 'PAY_source' => EEM_Payment_Method::scope_admin, |
|
1443 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
1444 | + 'PAY_amount' => $amount, |
|
1445 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1446 | + 'PAY_po_number' => $valid_data['po_number'], |
|
1447 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1448 | + 'PAY_details' => $valid_data, |
|
1449 | + 'PAY_ID' => $PAY_ID |
|
1450 | + ), |
|
1451 | + '', |
|
1452 | + array('Y-m-d', 'g:i a') |
|
1453 | + ); |
|
1454 | + |
|
1455 | + if ( ! $payment->save()) { |
|
1456 | + EE_Error::add_error( |
|
1457 | + sprintf( |
|
1458 | + esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1459 | + $payment->ID() |
|
1460 | + ), |
|
1461 | + __FILE__, __FUNCTION__, __LINE__ |
|
1462 | + ); |
|
1463 | + } |
|
1464 | + |
|
1465 | + return $payment; |
|
1466 | + } |
|
1467 | + |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * _process_transaction_payments |
|
1471 | + * |
|
1472 | + * @param \EE_Transaction $transaction |
|
1473 | + * |
|
1474 | + * @return array |
|
1475 | + */ |
|
1476 | + protected function _process_transaction_payments(EE_Transaction $transaction) |
|
1477 | + { |
|
1478 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
1479 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1480 | + //update the transaction with this payment |
|
1481 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1482 | + EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), |
|
1483 | + __FILE__, __FUNCTION__, __LINE__); |
|
1484 | + } else { |
|
1485 | + EE_Error::add_error( |
|
1486 | + esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', |
|
1487 | + 'event_espresso') |
|
1488 | + , __FILE__, __FUNCTION__, __LINE__ |
|
1489 | + ); |
|
1490 | + } |
|
1491 | + } |
|
1492 | + |
|
1493 | + |
|
1494 | + /** |
|
1495 | + * _get_REG_IDs_to_apply_payment_to |
|
1496 | + * |
|
1497 | + * returns a list of registration IDs that the payment will apply to |
|
1498 | + * |
|
1499 | + * @param \EE_Payment $payment |
|
1500 | + * |
|
1501 | + * @return array |
|
1502 | + */ |
|
1503 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) |
|
1504 | + { |
|
1505 | + $REG_IDs = array(); |
|
1506 | + // grab array of IDs for specific registrations to apply changes to |
|
1507 | + if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
1508 | + $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations']; |
|
1509 | + } |
|
1510 | + //nothing specified ? then get all reg IDs |
|
1511 | + if (empty($REG_IDs)) { |
|
1512 | + $registrations = $payment->transaction()->registrations(); |
|
1513 | + $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1514 | + } |
|
1515 | + |
|
1516 | + // ensure that REG_IDs are integers and NOT strings |
|
1517 | + return array_map('intval', $REG_IDs); |
|
1518 | + } |
|
1519 | + |
|
1520 | + |
|
1521 | + /** |
|
1522 | + * @return array |
|
1523 | + */ |
|
1524 | + public function existing_reg_payment_REG_IDs() |
|
1525 | + { |
|
1526 | + return $this->_existing_reg_payment_REG_IDs; |
|
1527 | + } |
|
1528 | + |
|
1529 | + |
|
1530 | + /** |
|
1531 | + * @param array $existing_reg_payment_REG_IDs |
|
1532 | + */ |
|
1533 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) |
|
1534 | + { |
|
1535 | + $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
|
1536 | + } |
|
1537 | + |
|
1538 | + |
|
1539 | + /** |
|
1540 | + * _get_existing_reg_payment_REG_IDs |
|
1541 | + * |
|
1542 | + * returns a list of registration IDs that the payment is currently related to |
|
1543 | + * as recorded in the database |
|
1544 | + * |
|
1545 | + * @param \EE_Payment $payment |
|
1546 | + * |
|
1547 | + * @return array |
|
1548 | + */ |
|
1549 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) |
|
1550 | + { |
|
1551 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
1552 | + // let's get any existing reg payment records for this payment |
|
1553 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
1554 | + // but we only want the REG IDs, so grab the array keys |
|
1555 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
1556 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
1557 | + } |
|
1558 | + |
|
1559 | + return $this->existing_reg_payment_REG_IDs(); |
|
1560 | + } |
|
1561 | + |
|
1562 | + |
|
1563 | + /** |
|
1564 | + * _remove_existing_registration_payments |
|
1565 | + * |
|
1566 | + * this calculates the difference between existing relations |
|
1567 | + * to the supplied payment and the new list registration IDs, |
|
1568 | + * removes any related registrations that no longer apply, |
|
1569 | + * and then updates the registration paid fields |
|
1570 | + * |
|
1571 | + * @param \EE_Payment $payment |
|
1572 | + * @param int $PAY_ID |
|
1573 | + * |
|
1574 | + * @return bool; |
|
1575 | + */ |
|
1576 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) |
|
1577 | + { |
|
1578 | + // newly created payments will have nothing recorded for $PAY_ID |
|
1579 | + if ($PAY_ID == 0) { |
|
1580 | + return false; |
|
1581 | + } |
|
1582 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1583 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
1584 | + return false; |
|
1585 | + } |
|
1586 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
1587 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1588 | + |
|
1589 | + return $transaction_payments->delete_registration_payments_and_update_registrations( |
|
1590 | + $payment, |
|
1591 | + array( |
|
1592 | + array( |
|
1593 | + 'PAY_ID' => $payment->ID(), |
|
1594 | + 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
1595 | + ) |
|
1596 | + ) |
|
1597 | + ); |
|
1598 | + } |
|
1599 | + |
|
1600 | + |
|
1601 | + /** |
|
1602 | + * _update_registration_payments |
|
1603 | + * |
|
1604 | + * this applies the payments to the selected registrations |
|
1605 | + * but only if they have not already been paid for |
|
1606 | + * |
|
1607 | + * @param EE_Transaction $transaction |
|
1608 | + * @param \EE_Payment $payment |
|
1609 | + * @param array $REG_IDs |
|
1610 | + * |
|
1611 | + * @return bool |
|
1612 | + */ |
|
1613 | + protected function _update_registration_payments( |
|
1614 | + EE_Transaction $transaction, |
|
1615 | + EE_Payment $payment, |
|
1616 | + $REG_IDs = array() |
|
1617 | + ) { |
|
1618 | + // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
|
1619 | + // so let's do that using our set of REG_IDs from the form |
|
1620 | + $registration_query_where_params = array( |
|
1621 | + 'REG_ID' => array('IN', $REG_IDs) |
|
1622 | + ); |
|
1623 | + // but add in some conditions regarding payment, |
|
1624 | + // so that we don't apply payments to registrations that are free or have already been paid for |
|
1625 | + // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
|
1626 | + if ( ! $payment->is_a_refund()) { |
|
1627 | + $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
1628 | + $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
1629 | + } |
|
1630 | + //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
|
1631 | + $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
1632 | + if ( ! empty($registrations)) { |
|
1633 | + /** @type EE_Payment_Processor $payment_processor */ |
|
1634 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1635 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
1636 | + } |
|
1637 | + } |
|
1638 | + |
|
1639 | + |
|
1640 | + /** |
|
1641 | + * _process_registration_status_change |
|
1642 | + * |
|
1643 | + * This processes requested registration status changes for all the registrations |
|
1644 | + * on a given transaction and (optionally) sends out notifications for the changes. |
|
1645 | + * |
|
1646 | + * @param EE_Transaction $transaction |
|
1647 | + * @param array $REG_IDs |
|
1648 | + * |
|
1649 | + * @return bool |
|
1650 | + */ |
|
1651 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) |
|
1652 | + { |
|
1653 | + // first if there is no change in status then we get out. |
|
1654 | + if ( |
|
1655 | + ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
1656 | + || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
|
1657 | + ) { |
|
1658 | + //no error message, no change requested, just nothing to do man. |
|
1659 | + return false; |
|
1660 | + } |
|
1661 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
1662 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1663 | + |
|
1664 | + // made it here dude? Oh WOW. K, let's take care of changing the statuses |
|
1665 | + return $transaction_processor->manually_update_registration_statuses( |
|
1666 | + $transaction, |
|
1667 | + sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
1668 | + array(array('REG_ID' => array('IN', $REG_IDs))) |
|
1669 | + ); |
|
1670 | + } |
|
1671 | + |
|
1672 | + |
|
1673 | + /** |
|
1674 | + * _build_payment_json_response |
|
1675 | + * |
|
1676 | + * @access public |
|
1677 | + * |
|
1678 | + * @param \EE_Payment $payment |
|
1679 | + * @param array $REG_IDs |
|
1680 | + * @param bool | null $delete_txn_reg_status_change |
|
1681 | + * |
|
1682 | + * @return array |
|
1683 | + */ |
|
1684 | + protected function _build_payment_json_response( |
|
1685 | + EE_Payment $payment, |
|
1686 | + $REG_IDs = array(), |
|
1687 | + $delete_txn_reg_status_change = null |
|
1688 | + ) { |
|
1689 | + // was the payment deleted ? |
|
1690 | + if (is_bool($delete_txn_reg_status_change)) { |
|
1691 | + return array( |
|
1692 | + 'PAY_ID' => $payment->ID(), |
|
1693 | + 'amount' => $payment->amount(), |
|
1694 | + 'total_paid' => $payment->transaction()->paid(), |
|
1695 | + 'txn_status' => $payment->transaction()->status_ID(), |
|
1696 | + 'pay_status' => $payment->STS_ID(), |
|
1697 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1698 | + 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
|
1699 | + ); |
|
1700 | + } else { |
|
1701 | + $this->_get_payment_status_array(); |
|
1702 | + |
|
1703 | + return array( |
|
1704 | + 'amount' => $payment->amount(), |
|
1705 | + 'total_paid' => $payment->transaction()->paid(), |
|
1706 | + 'txn_status' => $payment->transaction()->status_ID(), |
|
1707 | + 'pay_status' => $payment->STS_ID(), |
|
1708 | + 'PAY_ID' => $payment->ID(), |
|
1709 | + 'STS_ID' => $payment->STS_ID(), |
|
1710 | + 'status' => self::$_pay_status[$payment->STS_ID()], |
|
1711 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
1712 | + 'method' => strtoupper($payment->source()), |
|
1713 | + 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
|
1714 | + 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", |
|
1715 | + 'event_espresso'), |
|
1716 | + 'gateway_response' => $payment->gateway_response(), |
|
1717 | + 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
|
1718 | + 'po_number' => $payment->po_number(), |
|
1719 | + 'extra_accntng' => $payment->extra_accntng(), |
|
1720 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1721 | + ); |
|
1722 | + } |
|
1723 | + } |
|
1724 | + |
|
1725 | + |
|
1726 | + /** |
|
1727 | + * delete_payment |
|
1728 | + * delete a payment or refund made towards a transaction |
|
1729 | + * |
|
1730 | + * @access public |
|
1731 | + * @return void |
|
1732 | + */ |
|
1733 | + public function delete_payment() |
|
1734 | + { |
|
1735 | + $json_response_data = array('return_data' => false); |
|
1736 | + $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
1737 | + if ($PAY_ID) { |
|
1738 | + $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
1739 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
1740 | + if ($payment instanceof EE_Payment) { |
|
1741 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1742 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
1743 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1744 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
1745 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, |
|
1746 | + $delete_txn_reg_status_change); |
|
1747 | + if ($delete_txn_reg_status_change) { |
|
1748 | + $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
1749 | + //MAKE sure we also add the delete_txn_req_status_change to the |
|
1750 | + //$_REQUEST global because that's how messages will be looking for it. |
|
1751 | + $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
|
1752 | + $this->_maybe_send_notifications(); |
|
1753 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
1754 | + } |
|
1755 | + } |
|
1756 | + } else { |
|
1757 | + EE_Error::add_error( |
|
1758 | + esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
1759 | + __FILE__, __FUNCTION__, __LINE__ |
|
1760 | + ); |
|
1761 | + } |
|
1762 | + } else { |
|
1763 | + EE_Error::add_error( |
|
1764 | + esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', |
|
1765 | + 'event_espresso'), |
|
1766 | + __FILE__, __FUNCTION__, __LINE__ |
|
1767 | + ); |
|
1768 | + } |
|
1769 | + $notices = EE_Error::get_notices(false, false, false); |
|
1770 | + $this->_template_args = array( |
|
1771 | + 'data' => $json_response_data, |
|
1772 | + 'success' => $notices['success'], |
|
1773 | + 'error' => $notices['errors'], |
|
1774 | + 'attention' => $notices['attention'] |
|
1775 | + ); |
|
1776 | + $this->_return_json(); |
|
1777 | + } |
|
1778 | + |
|
1779 | + |
|
1780 | + /** |
|
1781 | + * _registration_payment_data_array |
|
1782 | + * adds info for 'owing' and 'paid' for each registration to the json response |
|
1783 | + * |
|
1784 | + * @access protected |
|
1785 | + * |
|
1786 | + * @param array $REG_IDs |
|
1787 | + * |
|
1788 | + * @return array |
|
1789 | + */ |
|
1790 | + protected function _registration_payment_data_array($REG_IDs) |
|
1791 | + { |
|
1792 | + $registration_payment_data = array(); |
|
1793 | + //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
|
1794 | + if ( ! empty($REG_IDs)) { |
|
1795 | + $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
1796 | + foreach ($registrations as $registration) { |
|
1797 | + if ($registration instanceof EE_Registration) { |
|
1798 | + $registration_payment_data[$registration->ID()] = array( |
|
1799 | + 'paid' => $registration->pretty_paid(), |
|
1800 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
1801 | + ); |
|
1802 | + } |
|
1803 | + } |
|
1804 | + } |
|
1805 | + |
|
1806 | + return $registration_payment_data; |
|
1807 | + } |
|
1808 | + |
|
1809 | + |
|
1810 | + /** |
|
1811 | + * _maybe_send_notifications |
|
1812 | + * |
|
1813 | + * determines whether or not the admin has indicated that notifications should be sent. |
|
1814 | + * If so, will toggle a filter switch for delivering registration notices. |
|
1815 | + * If passed an EE_Payment object, then it will trigger payment notifications instead. |
|
1816 | + * |
|
1817 | + * @access protected |
|
1818 | + * |
|
1819 | + * @param \EE_Payment | null $payment |
|
1820 | + */ |
|
1821 | + protected function _maybe_send_notifications($payment = null) |
|
1822 | + { |
|
1823 | + switch ($payment instanceof EE_Payment) { |
|
1824 | + // payment notifications |
|
1825 | + case true : |
|
1826 | + if ( |
|
1827 | + isset( |
|
1828 | + $this->_req_data['txn_payments'], |
|
1829 | + $this->_req_data['txn_payments']['send_notifications'] |
|
1830 | + ) && |
|
1831 | + filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1832 | + ) { |
|
1833 | + $this->_process_payment_notification($payment); |
|
1834 | + } |
|
1835 | + break; |
|
1836 | + // registration notifications |
|
1837 | + case false : |
|
1838 | + if ( |
|
1839 | + isset( |
|
1840 | + $this->_req_data['txn_reg_status_change'], |
|
1841 | + $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
1842 | + ) && |
|
1843 | + filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1844 | + ) { |
|
1845 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
1846 | + } |
|
1847 | + break; |
|
1848 | + } |
|
1849 | + } |
|
1850 | + |
|
1851 | + |
|
1852 | + /** |
|
1853 | + * _send_payment_reminder |
|
1854 | + * generates HTML for the View Transaction Details Admin page |
|
1855 | + * |
|
1856 | + * @access protected |
|
1857 | + * @return void |
|
1858 | + */ |
|
1859 | + protected function _send_payment_reminder() |
|
1860 | + { |
|
1861 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false; |
|
1862 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1863 | + $query_args = isset($this->_req_data['redirect_to']) ? array( |
|
1864 | + 'action' => $this->_req_data['redirect_to'], |
|
1865 | + 'TXN_ID' => $this->_req_data['TXN_ID'] |
|
1866 | + ) : array(); |
|
1867 | + do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
1868 | + $transaction); |
|
1869 | + $this->_redirect_after_action(false, esc_html__('payment reminder', 'event_espresso'), |
|
1870 | + esc_html__('sent', 'event_espresso'), $query_args, true); |
|
1871 | + } |
|
1872 | + |
|
1873 | + |
|
1874 | + /** |
|
1875 | + * get_transactions |
|
1876 | + * get transactions for given parameters (used by list table) |
|
1877 | + * |
|
1878 | + * @param int $perpage how many transactions displayed per page |
|
1879 | + * @param boolean $count return the count or objects |
|
1880 | + * @param string $view |
|
1881 | + * |
|
1882 | + * @return mixed int = count || array of transaction objects |
|
1883 | + */ |
|
1884 | + public function get_transactions($perpage, $count = false, $view = '') |
|
1885 | + { |
|
1886 | + |
|
1887 | + $TXN = EEM_Transaction::instance(); |
|
1888 | + |
|
1889 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
1890 | + strtotime('-10 year')); |
|
1891 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
1892 | + |
|
1893 | + //make sure our timestamps start and end right at the boundaries for each day |
|
1894 | + $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1895 | + $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1896 | + |
|
1897 | + |
|
1898 | + //convert to timestamps |
|
1899 | + $start_date = strtotime($start_date); |
|
1900 | + $end_date = strtotime($end_date); |
|
1901 | + |
|
1902 | + //makes sure start date is the lowest value and vice versa |
|
1903 | + $start_date = min($start_date, $end_date); |
|
1904 | + $end_date = max($start_date, $end_date); |
|
1905 | + |
|
1906 | + //convert to correct format for query |
|
1907 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
1908 | + date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
1909 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', |
|
1910 | + date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
1911 | + |
|
1912 | + |
|
1913 | + //set orderby |
|
1914 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
1915 | + |
|
1916 | + switch ($this->_req_data['orderby']) { |
|
1917 | + case 'TXN_ID': |
|
1918 | + $orderby = 'TXN_ID'; |
|
1919 | + break; |
|
1920 | + case 'ATT_fname': |
|
1921 | + $orderby = 'Registration.Attendee.ATT_fname'; |
|
1922 | + break; |
|
1923 | + case 'event_name': |
|
1924 | + $orderby = 'Registration.Event.EVT_name'; |
|
1925 | + break; |
|
1926 | + default: //'TXN_timestamp' |
|
1927 | + $orderby = 'TXN_timestamp'; |
|
1928 | + } |
|
1929 | + |
|
1930 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
1931 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1932 | + $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
1933 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1934 | + |
|
1935 | + $offset = ($current_page - 1) * $per_page; |
|
1936 | + $limit = array($offset, $per_page); |
|
1937 | + |
|
1938 | + $_where = array( |
|
1939 | + 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
1940 | + 'Registration.REG_count' => 1 |
|
1941 | + ); |
|
1942 | + |
|
1943 | + if (isset($this->_req_data['EVT_ID'])) { |
|
1944 | + $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
|
1945 | + } |
|
1946 | + |
|
1947 | + if (isset($this->_req_data['s'])) { |
|
1948 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1949 | + $_where['OR'] = array( |
|
1950 | + 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
1951 | + 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
1952 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
1953 | + 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
1954 | + 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
1955 | + 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
1956 | + 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
1957 | + 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
1958 | + 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
1959 | + 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
1960 | + 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
1961 | + 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
1962 | + 'Registration.REG_code' => array('LIKE', $search_string), |
|
1963 | + 'Registration.REG_count' => array('LIKE', $search_string), |
|
1964 | + 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
1965 | + 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
1966 | + 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
1967 | + 'Payment.PAY_source' => array('LIKE', $search_string), |
|
1968 | + 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
1969 | + 'TXN_session_data' => array('LIKE', $search_string), |
|
1970 | + 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string) |
|
1971 | + ); |
|
1972 | + } |
|
1973 | + |
|
1974 | + //failed transactions |
|
1975 | + $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false; |
|
1976 | + $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false; |
|
1977 | + |
|
1978 | + if ($failed) { |
|
1979 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
1980 | + } else if ($abandoned) { |
|
1981 | + $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
|
1982 | + } else { |
|
1983 | + $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
1984 | + $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
1985 | + } |
|
1986 | + |
|
1987 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit); |
|
1988 | + |
|
1989 | + $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', true) : $TXN->get_all($query_params); |
|
1990 | + |
|
1991 | + |
|
1992 | + return $transactions; |
|
1993 | + |
|
1994 | + } |
|
1995 | 1995 | |
1996 | 1996 | |
1997 | 1997 | } |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | public function load_scripts_styles() |
339 | 339 | { |
340 | 340 | //enqueue style |
341 | - wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), |
|
341 | + wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), |
|
342 | 342 | EVENT_ESPRESSO_VERSION); |
343 | 343 | wp_enqueue_style('espresso_txn'); |
344 | 344 | //scripts |
345 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array( |
|
345 | + wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array( |
|
346 | 346 | 'ee_admin_js', |
347 | 347 | 'ee-datepicker', |
348 | 348 | 'jquery-ui-datepicker', |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | |
435 | 435 | if (empty($this->_transaction)) { |
436 | 436 | $error_msg = esc_html__('An error occurred and the details for Transaction ID #', |
437 | - 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
437 | + 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso'); |
|
438 | 438 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
439 | 439 | } |
440 | 440 | } |
@@ -509,23 +509,23 @@ discard block |
||
509 | 509 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
510 | 510 | array( |
511 | 511 | 'overpaid' => array( |
512 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
512 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code, |
|
513 | 513 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence') |
514 | 514 | ), |
515 | 515 | 'complete' => array( |
516 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
516 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code, |
|
517 | 517 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence') |
518 | 518 | ), |
519 | 519 | 'incomplete' => array( |
520 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
520 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code, |
|
521 | 521 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence') |
522 | 522 | ), |
523 | 523 | 'abandoned' => array( |
524 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
524 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code, |
|
525 | 525 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence') |
526 | 526 | ), |
527 | 527 | 'failed' => array( |
528 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
528 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code, |
|
529 | 529 | 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence') |
530 | 530 | ) |
531 | 531 | ) |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null; |
548 | 548 | $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', |
549 | 549 | 'event_espresso'), '<h3>', |
550 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
551 | - EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event', |
|
552 | - 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : ''; |
|
553 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
550 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
551 | + EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', |
|
552 | + 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : ''; |
|
553 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
554 | 554 | $this->display_admin_list_table_page_with_no_sidebar(); |
555 | 555 | } |
556 | 556 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
586 | 586 | $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
587 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
587 | + $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID'); |
|
588 | 588 | |
589 | 589 | $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
590 | 590 | $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
622 | 622 | $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true); |
623 | 623 | if (EE_Registry::instance()->CFG->currency->sign_b4) { |
624 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
624 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due']; |
|
625 | 625 | } else { |
626 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
626 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign; |
|
627 | 627 | } |
628 | 628 | $this->_template_args['amount_due_class'] = ''; |
629 | 629 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | |
659 | 659 | |
660 | 660 | // next link |
661 | - $next_txn = $this->_transaction->next( |
|
661 | + $next_txn = $this->_transaction->next( |
|
662 | 662 | null, |
663 | 663 | array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
664 | 664 | 'TXN_ID' |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | ) |
674 | 674 | : ''; |
675 | 675 | // previous link |
676 | - $previous_txn = $this->_transaction->previous( |
|
676 | + $previous_txn = $this->_transaction->previous( |
|
677 | 677 | null, |
678 | 678 | array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
679 | 679 | 'TXN_ID' |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | // grab messages at the last second |
728 | 728 | $this->_template_args['notices'] = EE_Error::get_notices(); |
729 | 729 | // path to template |
730 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
730 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php'; |
|
731 | 731 | $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
732 | 732 | $this->_template_args, true); |
733 | 733 | |
@@ -835,18 +835,18 @@ discard block |
||
835 | 835 | $reg_steps = '<ul>'; |
836 | 836 | foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
837 | 837 | if ($reg_step_status === true) { |
838 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
839 | - ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
838 | + $reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), |
|
839 | + ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
840 | 840 | } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
841 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
841 | + $reg_steps .= '<li style="color:#2EA2CC">'.sprintf( |
|
842 | 842 | esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
843 | 843 | ucwords(str_replace('_', ' ', $reg_step)), |
844 | - date(get_option('date_format') . ' ' . get_option('time_format'), |
|
844 | + date(get_option('date_format').' '.get_option('time_format'), |
|
845 | 845 | ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
846 | - ) . '</li>'; |
|
846 | + ).'</li>'; |
|
847 | 847 | } else { |
848 | - $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated', |
|
849 | - 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>'; |
|
848 | + $reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', |
|
849 | + 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
850 | 850 | } |
851 | 851 | } |
852 | 852 | $reg_steps .= '</ul>'; |
@@ -860,11 +860,11 @@ discard block |
||
860 | 860 | $this->_get_payment_status_array(); |
861 | 861 | $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
862 | 862 | |
863 | - $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
863 | + $this->_template_args['transaction_form_url'] = add_query_arg(array( |
|
864 | 864 | 'action' => 'edit_transaction', |
865 | 865 | 'process' => 'transaction' |
866 | 866 | ), TXN_ADMIN_URL); |
867 | - $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
867 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array( |
|
868 | 868 | 'page' => 'espresso_transactions', |
869 | 869 | 'action' => 'espresso_apply_payment' |
870 | 870 | ), WP_AJAX_URL); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | |
876 | 876 | // 'espresso_delete_payment_nonce' |
877 | 877 | |
878 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
878 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
879 | 879 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
880 | 880 | |
881 | 881 | } |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | protected function _get_registrations_to_apply_payment_to() |
936 | 936 | { |
937 | 937 | // we want any registration with an active status (ie: not deleted or cancelled) |
938 | - $query_params = array( |
|
938 | + $query_params = array( |
|
939 | 939 | array( |
940 | 940 | 'STS_ID' => array( |
941 | 941 | 'IN', |
@@ -947,19 +947,19 @@ discard block |
||
947 | 947 | ) |
948 | 948 | ) |
949 | 949 | ); |
950 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
950 | + $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div( |
|
951 | 951 | '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
952 | 952 | ); |
953 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
953 | + $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
954 | 954 | $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
955 | 955 | $registrations_to_apply_payment_to .= EEH_HTML::thead( |
956 | 956 | EEH_HTML::tr( |
957 | - EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
958 | - EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
959 | - EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
960 | - EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
961 | - EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
962 | - EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
957 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')). |
|
958 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')). |
|
959 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')). |
|
960 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')). |
|
961 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
962 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
963 | 963 | EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
964 | 964 | ) |
965 | 965 | ); |
@@ -973,28 +973,28 @@ discard block |
||
973 | 973 | : esc_html__('Unknown Attendee', 'event_espresso'); |
974 | 974 | $owing = $registration->final_price() - $registration->paid(); |
975 | 975 | $taxable = $registration->ticket()->taxable() |
976 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
976 | + ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>' |
|
977 | 977 | : ''; |
978 | 978 | $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) |
979 | 979 | ? ' checked="checked"' |
980 | 980 | : ''; |
981 | 981 | $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
982 | 982 | $registrations_to_apply_payment_to .= EEH_HTML::tr( |
983 | - EEH_HTML::td($registration->ID()) . |
|
984 | - EEH_HTML::td($attendee_name) . |
|
983 | + EEH_HTML::td($registration->ID()). |
|
984 | + EEH_HTML::td($attendee_name). |
|
985 | 985 | EEH_HTML::td( |
986 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
987 | - ) . |
|
988 | - EEH_HTML::td($registration->event_name()) . |
|
989 | - EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
990 | - EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
986 | + $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable |
|
987 | + ). |
|
988 | + EEH_HTML::td($registration->event_name()). |
|
989 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
990 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
991 | 991 | EEH_HTML::td( |
992 | - '<input type="checkbox" value="' . $registration->ID() |
|
992 | + '<input type="checkbox" value="'.$registration->ID() |
|
993 | 993 | . '" name="txn_admin_payment[registrations]"' |
994 | - . $checked . $disabled . '>', |
|
994 | + . $checked.$disabled.'>', |
|
995 | 995 | '', 'jst-cntr' |
996 | 996 | ), |
997 | - 'apply-payment-registration-row-' . $registration->ID() |
|
997 | + 'apply-payment-registration-row-'.$registration->ID() |
|
998 | 998 | ); |
999 | 999 | } |
1000 | 1000 | } |
@@ -1060,12 +1060,12 @@ discard block |
||
1060 | 1060 | array( |
1061 | 1061 | 'OR*payment_method_for_payment' => array( |
1062 | 1062 | 'PMD_ID' => array('IN', $payment_methods_of_payments), |
1063 | - 'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%') |
|
1063 | + 'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') |
|
1064 | 1064 | ) |
1065 | 1065 | ) |
1066 | 1066 | ); |
1067 | 1067 | } else { |
1068 | - $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'))); |
|
1068 | + $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'))); |
|
1069 | 1069 | } |
1070 | 1070 | $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
1071 | 1071 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
1111 | 1111 | $event_name = esc_html__('Unknown Event', 'event_espresso'); |
1112 | 1112 | } |
1113 | - $event_name .= ' - ' . $item->get('LIN_name'); |
|
1113 | + $event_name .= ' - '.$item->get('LIN_name'); |
|
1114 | 1114 | $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
1115 | 1115 | // now get all of the registrations for this transaction that use this ticket |
1116 | 1116 | $registrations = $ticket->get_many_related('Registration', |
@@ -1128,8 +1128,8 @@ discard block |
||
1128 | 1128 | if ($attendee instanceof EE_Attendee) { |
1129 | 1129 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
1130 | 1130 | $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
1131 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', |
|
1132 | - 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
1131 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', |
|
1132 | + 'event_espresso').'">'.$attendee->email().'</a>'; |
|
1133 | 1133 | $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, |
1134 | 1134 | 'inline', false, false); |
1135 | 1135 | } else { |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | 'action' => 'edit_transaction', |
1150 | 1150 | 'process' => 'attendees' |
1151 | 1151 | ), TXN_ADMIN_URL); |
1152 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
1152 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', |
|
1153 | 1153 | $this->_template_args, true); |
1154 | 1154 | |
1155 | 1155 | } else { |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | ), REG_ADMIN_URL); |
1191 | 1191 | // get formatted address for registrant |
1192 | 1192 | $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
1193 | - echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
1193 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', |
|
1194 | 1194 | $this->_template_args, true); |
1195 | 1195 | } |
1196 | 1196 | |
@@ -1211,8 +1211,8 @@ discard block |
||
1211 | 1211 | TXN_ADMIN_URL |
1212 | 1212 | ); |
1213 | 1213 | |
1214 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1215 | - echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/ |
|
1214 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1215 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); /**/ |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | $REG_IDs = array(); |
1506 | 1506 | // grab array of IDs for specific registrations to apply changes to |
1507 | 1507 | if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
1508 | - $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations']; |
|
1508 | + $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations']; |
|
1509 | 1509 | } |
1510 | 1510 | //nothing specified ? then get all reg IDs |
1511 | 1511 | if (empty($REG_IDs)) { |
@@ -1891,8 +1891,8 @@ discard block |
||
1891 | 1891 | $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
1892 | 1892 | |
1893 | 1893 | //make sure our timestamps start and end right at the boundaries for each day |
1894 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1895 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1894 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
1895 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
1896 | 1896 | |
1897 | 1897 | |
1898 | 1898 | //convert to timestamps |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | } |
1946 | 1946 | |
1947 | 1947 | if (isset($this->_req_data['s'])) { |
1948 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1948 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1949 | 1949 | $_where['OR'] = array( |
1950 | 1950 | 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
1951 | 1951 | 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
@@ -198,7 +198,7 @@ |
||
198 | 198 | * |
199 | 199 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
200 | 200 | * |
201 | - * @return int |
|
201 | + * @return string |
|
202 | 202 | */ |
203 | 203 | private function _revenue_per_event_report($period = '-1 month') |
204 | 204 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -32,224 +32,224 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * This is used to hold the reports template data which is setup early in the request. |
|
37 | - * @type array |
|
38 | - */ |
|
39 | - protected $_reports_template_data = array(); |
|
40 | - |
|
41 | - /** |
|
42 | - * @Constructor |
|
43 | - * @access public |
|
44 | - * |
|
45 | - * @param bool $routing |
|
46 | - * |
|
47 | - * @return \Extend_Transactions_Admin_Page |
|
48 | - */ |
|
49 | - public function __construct($routing = true) |
|
50 | - { |
|
51 | - parent::__construct($routing); |
|
52 | - define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
53 | - define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
54 | - define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * _extend_page_config |
|
60 | - * |
|
61 | - * @access protected |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - protected function _extend_page_config() |
|
65 | - { |
|
66 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
67 | - |
|
68 | - $new_page_routes = array( |
|
69 | - 'reports' => array( |
|
70 | - 'func' => '_transaction_reports', |
|
71 | - 'capability' => 'ee_read_transactions' |
|
72 | - ) |
|
73 | - ); |
|
74 | - |
|
75 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
76 | - |
|
77 | - $new_page_config = array( |
|
78 | - 'reports' => array( |
|
79 | - 'nav' => array( |
|
80 | - 'label' => __('Reports', 'event_espresso'), |
|
81 | - 'order' => 20 |
|
82 | - ), |
|
83 | - 'help_tabs' => array( |
|
84 | - 'transactions_reports_help_tab' => array( |
|
85 | - 'title' => __('Transaction Reports', 'event_espresso'), |
|
86 | - 'filename' => 'transactions_reports' |
|
87 | - ) |
|
88 | - ), |
|
89 | - /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/ |
|
90 | - 'require_nonce' => false |
|
91 | - ) |
|
92 | - ); |
|
93 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * load_scripts_styles_reports |
|
99 | - * |
|
100 | - * @access public |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - public function load_scripts_styles_reports() |
|
104 | - { |
|
105 | - wp_register_script( |
|
106 | - 'ee-txn-reports-js', |
|
107 | - TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
108 | - array('google-charts'), |
|
109 | - EVENT_ESPRESSO_VERSION, |
|
110 | - true |
|
111 | - ); |
|
112 | - wp_enqueue_script('ee-txn-reports-js'); |
|
113 | - $this->_transaction_reports_js_setup(); |
|
114 | - EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
120 | - * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
121 | - */ |
|
122 | - protected function _transaction_reports_js_setup() |
|
123 | - { |
|
124 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
125 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * _transaction_reports |
|
131 | - * generates Business Reports regarding Transactions |
|
132 | - * |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function _transaction_reports() |
|
136 | - { |
|
137 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
138 | - $this->_admin_page_title = __('Transactions', 'event_espresso'); |
|
139 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
140 | - $this->_reports_template_data, true); |
|
141 | - |
|
142 | - // the final template wrapper |
|
143 | - $this->display_admin_page_with_no_sidebar(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * _revenue_per_day_report |
|
149 | - * generates Business Report showing Total Revenue per Day. |
|
150 | - * |
|
151 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - private function _revenue_per_day_report($period = '-1 month') |
|
156 | - { |
|
157 | - |
|
158 | - $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
159 | - |
|
160 | - $TXN = EEM_Transaction::instance(); |
|
161 | - |
|
162 | - $results = $TXN->get_revenue_per_day_report($period); |
|
163 | - $results = (array)$results; |
|
164 | - $revenue = array(); |
|
165 | - $subtitle = ''; |
|
166 | - |
|
167 | - if ($results) { |
|
168 | - $revenue[] = array( |
|
169 | - __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
170 | - __('Total Revenue', 'event_espresso') |
|
171 | - ); |
|
172 | - foreach ($results as $result) { |
|
173 | - $revenue[] = array($result->txnDate, (float)$result->revenue); |
|
174 | - } |
|
175 | - |
|
176 | - //setup the date range. |
|
177 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
178 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
179 | - $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
180 | - $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
181 | - } |
|
182 | - |
|
183 | - $report_title = esc_html__('Total Revenue per Day', 'event_espresso'); |
|
184 | - |
|
185 | - $report_params = array( |
|
186 | - 'title' => $report_title, |
|
187 | - 'subtitle' => $subtitle, |
|
188 | - 'id' => $report_ID, |
|
189 | - 'revenue' => $revenue, |
|
190 | - 'noResults' => empty($revenue) || count($revenue) === 1, |
|
191 | - 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
192 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
193 | - ); |
|
194 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
195 | - |
|
196 | - return $report_ID; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * _revenue_per_event_report |
|
202 | - * generates Business Report showing total revenue per event. |
|
203 | - * |
|
204 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
205 | - * |
|
206 | - * @return int |
|
207 | - */ |
|
208 | - private function _revenue_per_event_report($period = '-1 month') |
|
209 | - { |
|
210 | - |
|
211 | - $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
212 | - |
|
213 | - $TXN = EEM_Transaction::instance(); |
|
214 | - $results = $TXN->get_revenue_per_event_report($period); |
|
215 | - $results = (array)$results; |
|
216 | - $revenue = array(); |
|
217 | - $subtitle = ''; |
|
218 | - |
|
219 | - if ($results) { |
|
220 | - $revenue[] = array( |
|
221 | - __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
222 | - __('Total Revenue', 'event_espresso') |
|
223 | - ); |
|
224 | - foreach ($results as $result) { |
|
225 | - if ($result->revenue > 1) { |
|
226 | - $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
227 | - $event_name = wp_trim_words($event_name, 5, '...'); |
|
228 | - $revenue[] = array($event_name, (float)$result->revenue); |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - //setup the date range. |
|
233 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
234 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
235 | - $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
236 | - $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
237 | - } |
|
238 | - |
|
239 | - $report_title = esc_html__('Total Revenue per Event', 'event_espresso'); |
|
240 | - |
|
241 | - $report_params = array( |
|
242 | - 'title' => $report_title, |
|
243 | - 'subtitle' => $subtitle, |
|
244 | - 'id' => $report_ID, |
|
245 | - 'revenue' => $revenue, |
|
246 | - 'noResults' => empty($revenue), |
|
247 | - 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
248 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
249 | - ); |
|
250 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
251 | - |
|
252 | - return $report_ID; |
|
253 | - } |
|
35 | + /** |
|
36 | + * This is used to hold the reports template data which is setup early in the request. |
|
37 | + * @type array |
|
38 | + */ |
|
39 | + protected $_reports_template_data = array(); |
|
40 | + |
|
41 | + /** |
|
42 | + * @Constructor |
|
43 | + * @access public |
|
44 | + * |
|
45 | + * @param bool $routing |
|
46 | + * |
|
47 | + * @return \Extend_Transactions_Admin_Page |
|
48 | + */ |
|
49 | + public function __construct($routing = true) |
|
50 | + { |
|
51 | + parent::__construct($routing); |
|
52 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
53 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
54 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * _extend_page_config |
|
60 | + * |
|
61 | + * @access protected |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + protected function _extend_page_config() |
|
65 | + { |
|
66 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
67 | + |
|
68 | + $new_page_routes = array( |
|
69 | + 'reports' => array( |
|
70 | + 'func' => '_transaction_reports', |
|
71 | + 'capability' => 'ee_read_transactions' |
|
72 | + ) |
|
73 | + ); |
|
74 | + |
|
75 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
76 | + |
|
77 | + $new_page_config = array( |
|
78 | + 'reports' => array( |
|
79 | + 'nav' => array( |
|
80 | + 'label' => __('Reports', 'event_espresso'), |
|
81 | + 'order' => 20 |
|
82 | + ), |
|
83 | + 'help_tabs' => array( |
|
84 | + 'transactions_reports_help_tab' => array( |
|
85 | + 'title' => __('Transaction Reports', 'event_espresso'), |
|
86 | + 'filename' => 'transactions_reports' |
|
87 | + ) |
|
88 | + ), |
|
89 | + /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/ |
|
90 | + 'require_nonce' => false |
|
91 | + ) |
|
92 | + ); |
|
93 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * load_scripts_styles_reports |
|
99 | + * |
|
100 | + * @access public |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + public function load_scripts_styles_reports() |
|
104 | + { |
|
105 | + wp_register_script( |
|
106 | + 'ee-txn-reports-js', |
|
107 | + TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
108 | + array('google-charts'), |
|
109 | + EVENT_ESPRESSO_VERSION, |
|
110 | + true |
|
111 | + ); |
|
112 | + wp_enqueue_script('ee-txn-reports-js'); |
|
113 | + $this->_transaction_reports_js_setup(); |
|
114 | + EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
120 | + * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
121 | + */ |
|
122 | + protected function _transaction_reports_js_setup() |
|
123 | + { |
|
124 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
125 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * _transaction_reports |
|
131 | + * generates Business Reports regarding Transactions |
|
132 | + * |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function _transaction_reports() |
|
136 | + { |
|
137 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
138 | + $this->_admin_page_title = __('Transactions', 'event_espresso'); |
|
139 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
140 | + $this->_reports_template_data, true); |
|
141 | + |
|
142 | + // the final template wrapper |
|
143 | + $this->display_admin_page_with_no_sidebar(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * _revenue_per_day_report |
|
149 | + * generates Business Report showing Total Revenue per Day. |
|
150 | + * |
|
151 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + private function _revenue_per_day_report($period = '-1 month') |
|
156 | + { |
|
157 | + |
|
158 | + $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
159 | + |
|
160 | + $TXN = EEM_Transaction::instance(); |
|
161 | + |
|
162 | + $results = $TXN->get_revenue_per_day_report($period); |
|
163 | + $results = (array)$results; |
|
164 | + $revenue = array(); |
|
165 | + $subtitle = ''; |
|
166 | + |
|
167 | + if ($results) { |
|
168 | + $revenue[] = array( |
|
169 | + __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
170 | + __('Total Revenue', 'event_espresso') |
|
171 | + ); |
|
172 | + foreach ($results as $result) { |
|
173 | + $revenue[] = array($result->txnDate, (float)$result->revenue); |
|
174 | + } |
|
175 | + |
|
176 | + //setup the date range. |
|
177 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
178 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
179 | + $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
180 | + $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
181 | + } |
|
182 | + |
|
183 | + $report_title = esc_html__('Total Revenue per Day', 'event_espresso'); |
|
184 | + |
|
185 | + $report_params = array( |
|
186 | + 'title' => $report_title, |
|
187 | + 'subtitle' => $subtitle, |
|
188 | + 'id' => $report_ID, |
|
189 | + 'revenue' => $revenue, |
|
190 | + 'noResults' => empty($revenue) || count($revenue) === 1, |
|
191 | + 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
192 | + '<h2>' . $report_title . '</h2><p>', '</p>') |
|
193 | + ); |
|
194 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
195 | + |
|
196 | + return $report_ID; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * _revenue_per_event_report |
|
202 | + * generates Business Report showing total revenue per event. |
|
203 | + * |
|
204 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
205 | + * |
|
206 | + * @return int |
|
207 | + */ |
|
208 | + private function _revenue_per_event_report($period = '-1 month') |
|
209 | + { |
|
210 | + |
|
211 | + $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
212 | + |
|
213 | + $TXN = EEM_Transaction::instance(); |
|
214 | + $results = $TXN->get_revenue_per_event_report($period); |
|
215 | + $results = (array)$results; |
|
216 | + $revenue = array(); |
|
217 | + $subtitle = ''; |
|
218 | + |
|
219 | + if ($results) { |
|
220 | + $revenue[] = array( |
|
221 | + __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
222 | + __('Total Revenue', 'event_espresso') |
|
223 | + ); |
|
224 | + foreach ($results as $result) { |
|
225 | + if ($result->revenue > 1) { |
|
226 | + $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
227 | + $event_name = wp_trim_words($event_name, 5, '...'); |
|
228 | + $revenue[] = array($event_name, (float)$result->revenue); |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + //setup the date range. |
|
233 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
234 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
235 | + $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
|
236 | + $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
|
237 | + } |
|
238 | + |
|
239 | + $report_title = esc_html__('Total Revenue per Event', 'event_espresso'); |
|
240 | + |
|
241 | + $report_params = array( |
|
242 | + 'title' => $report_title, |
|
243 | + 'subtitle' => $subtitle, |
|
244 | + 'id' => $report_ID, |
|
245 | + 'revenue' => $revenue, |
|
246 | + 'noResults' => empty($revenue), |
|
247 | + 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
|
248 | + '<h2>' . $report_title . '</h2><p>', '</p>') |
|
249 | + ); |
|
250 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
251 | + |
|
252 | + return $report_ID; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | public function __construct($routing = true) |
50 | 50 | { |
51 | 51 | parent::__construct($routing); |
52 | - define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
53 | - define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
54 | - define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
52 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/'); |
|
53 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/'); |
|
54 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function _extend_page_config() |
65 | 65 | { |
66 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
66 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions'; |
|
67 | 67 | |
68 | 68 | $new_page_routes = array( |
69 | 69 | 'reports' => array( |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | wp_register_script( |
106 | 106 | 'ee-txn-reports-js', |
107 | - TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
107 | + TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js', |
|
108 | 108 | array('google-charts'), |
109 | 109 | EVENT_ESPRESSO_VERSION, |
110 | 110 | true |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function _transaction_reports() |
136 | 136 | { |
137 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
137 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
138 | 138 | $this->_admin_page_title = __('Transactions', 'event_espresso'); |
139 | 139 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
140 | 140 | $this->_reports_template_data, true); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $TXN = EEM_Transaction::instance(); |
161 | 161 | |
162 | 162 | $results = $TXN->get_revenue_per_day_report($period); |
163 | - $results = (array)$results; |
|
163 | + $results = (array) $results; |
|
164 | 164 | $revenue = array(); |
165 | 165 | $subtitle = ''; |
166 | 166 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | __('Total Revenue', 'event_espresso') |
171 | 171 | ); |
172 | 172 | foreach ($results as $result) { |
173 | - $revenue[] = array($result->txnDate, (float)$result->revenue); |
|
173 | + $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | //setup the date range. |
177 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
177 | + $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
178 | 178 | $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
179 | 179 | $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
180 | 180 | $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'revenue' => $revenue, |
190 | 190 | 'noResults' => empty($revenue) || count($revenue) === 1, |
191 | 191 | 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
192 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
192 | + '<h2>'.$report_title.'</h2><p>', '</p>') |
|
193 | 193 | ); |
194 | 194 | wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
195 | 195 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $TXN = EEM_Transaction::instance(); |
214 | 214 | $results = $TXN->get_revenue_per_event_report($period); |
215 | - $results = (array)$results; |
|
215 | + $results = (array) $results; |
|
216 | 216 | $revenue = array(); |
217 | 217 | $subtitle = ''; |
218 | 218 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | if ($result->revenue > 1) { |
226 | 226 | $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
227 | 227 | $event_name = wp_trim_words($event_name, 5, '...'); |
228 | - $revenue[] = array($event_name, (float)$result->revenue); |
|
228 | + $revenue[] = array($event_name, (float) $result->revenue); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | //setup the date range. |
233 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
233 | + $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
234 | 234 | $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
235 | 235 | $subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), |
236 | 236 | $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d')); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'revenue' => $revenue, |
246 | 246 | 'noResults' => empty($revenue), |
247 | 247 | 'noTxnMsg' => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'), |
248 | - '<h2>' . $report_title . '</h2><p>', '</p>') |
|
248 | + '<h2>'.$report_title.'</h2><p>', '</p>') |
|
249 | 249 | ); |
250 | 250 | wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
251 | 251 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param array $dir_ref original array of paths |
93 | 93 | * |
94 | - * @return array appended paths |
|
94 | + * @return string[] appended paths |
|
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param EE_Question[] $questions An array of questions indexed by answer id. |
702 | 702 | * @param EE_Answer[] $answers An array of answer objects |
703 | 703 | * @param string $template Template content to be parsed. |
704 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
704 | + * @param string[] $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | 705 | * @param array $extra_data Extra data that might be used when parsing the template. |
706 | 706 | */ |
707 | 707 | protected function _parse_question_list_for_primary_or_recipient_registration( |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.2 |
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -22,735 +22,735 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * constructor. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - $this->_caf_hooks(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | - * |
|
37 | - * @since 4.3.2 |
|
38 | - * |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - private function _caf_hooks() |
|
42 | - { |
|
43 | - add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | - add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | - 5, 2); |
|
46 | - add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | - 2); |
|
48 | - add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | - 2); |
|
50 | - add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | - 2); |
|
52 | - add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | - add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | - 2); |
|
55 | - add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | - array($this, 'new_default_templates'), 5, 7); |
|
57 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | - 2); |
|
59 | - |
|
60 | - //shortcode parsers |
|
61 | - add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | - add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | - array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | - array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | - array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | - array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | - |
|
72 | - /** |
|
73 | - * @since 4.2.0 |
|
74 | - */ |
|
75 | - add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | - add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | - |
|
78 | - /** |
|
79 | - * @since 4.3.0 |
|
80 | - */ |
|
81 | - //eat our own dog food! |
|
82 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | - do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | - * messages system. |
|
91 | - * |
|
92 | - * @param array $dir_ref original array of paths |
|
93 | - * |
|
94 | - * @return array appended paths |
|
95 | - */ |
|
96 | - public function messages_autoload_paths($dir_ref) |
|
97 | - { |
|
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | - |
|
100 | - return $dir_ref; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | - { |
|
106 | - $validator_config['attendee_list'] = array( |
|
107 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | - 'required' => array('[ATTENDEE_LIST]') |
|
109 | - ); |
|
110 | - $validator_config['question_list'] = array( |
|
111 | - 'shortcodes' => array('question'), |
|
112 | - 'required' => array('[QUESTION_LIST]') |
|
113 | - ); |
|
114 | - |
|
115 | - return $validator_config; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | - { |
|
121 | - $validator_config['attendee_list'] = array( |
|
122 | - 'shortcodes' => array('attendee', 'question_list'), |
|
123 | - 'required' => array('[ATTENDEE_LIST]') |
|
124 | - ); |
|
125 | - $validator_config['question_list'] = array( |
|
126 | - 'shortcodes' => array('question'), |
|
127 | - 'required' => array('[QUESTION_LIST]') |
|
128 | - ); |
|
129 | - |
|
130 | - return $validator_config; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | - { |
|
136 | - $validator_config['attendee_list'] = array( |
|
137 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | - 'required' => array('[ATTENDEE_LIST]') |
|
139 | - ); |
|
140 | - $validator_config['question_list'] = array( |
|
141 | - 'shortcodes' => array('question'), |
|
142 | - 'required' => array('[QUESTION_LIST]') |
|
143 | - ); |
|
144 | - |
|
145 | - return $validator_config; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | - { |
|
151 | - $template_fields['extra']['content']['question_list'] = array( |
|
152 | - 'input' => 'textarea', |
|
153 | - 'label' => '[QUESTION_LIST]', |
|
154 | - 'type' => 'string', |
|
155 | - 'required' => true, |
|
156 | - 'validation' => true, |
|
157 | - 'format' => '%s', |
|
158 | - 'css_class' => 'large-text', |
|
159 | - 'rows' => '5', |
|
160 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | - ); |
|
162 | - |
|
163 | - return $template_fields; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | - { |
|
169 | - $template_fields['extra']['content']['question_list'] = array( |
|
170 | - 'input' => 'textarea', |
|
171 | - 'label' => '[QUESTION_LIST]', |
|
172 | - 'type' => 'string', |
|
173 | - 'required' => true, |
|
174 | - 'validation' => true, |
|
175 | - 'format' => '%s', |
|
176 | - 'css_class' => 'large-text', |
|
177 | - 'rows' => '5', |
|
178 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | - ); |
|
180 | - |
|
181 | - return $template_fields; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | - { |
|
187 | - $template_fields['extra']['content']['question_list'] = array( |
|
188 | - 'input' => 'textarea', |
|
189 | - 'label' => '[QUESTION_LIST]', |
|
190 | - 'type' => 'string', |
|
191 | - 'required' => true, |
|
192 | - 'validation' => true, |
|
193 | - 'format' => '%s', |
|
194 | - 'css_class' => 'large-text', |
|
195 | - 'rows' => '5', |
|
196 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | - ); |
|
198 | - |
|
199 | - return $template_fields; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - public function new_default_templates( |
|
204 | - $contents, |
|
205 | - $actual_path, |
|
206 | - EE_messenger $messenger, |
|
207 | - EE_message_type $message_type, |
|
208 | - $field, |
|
209 | - $context, |
|
210 | - EE_Messages_Template_Pack $template_pack |
|
211 | - ) { |
|
212 | - |
|
213 | - //we're only modifying templates for the default template pack |
|
214 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | - return $contents; |
|
216 | - } |
|
217 | - |
|
218 | - //the template file name we're replacing contents for. |
|
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | - |
|
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | - |
|
224 | - if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
25 | + /** |
|
26 | + * constructor. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + $this->_caf_hooks(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | + * |
|
37 | + * @since 4.3.2 |
|
38 | + * |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + private function _caf_hooks() |
|
42 | + { |
|
43 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | + add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | + 5, 2); |
|
46 | + add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | + 2); |
|
48 | + add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | + 2); |
|
50 | + add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | + 2); |
|
52 | + add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | + add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | + 2); |
|
55 | + add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | + array($this, 'new_default_templates'), 5, 7); |
|
57 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | + 2); |
|
59 | + |
|
60 | + //shortcode parsers |
|
61 | + add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | + add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | + array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | + array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | + array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | + array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | + |
|
72 | + /** |
|
73 | + * @since 4.2.0 |
|
74 | + */ |
|
75 | + add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | + add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | + |
|
78 | + /** |
|
79 | + * @since 4.3.0 |
|
80 | + */ |
|
81 | + //eat our own dog food! |
|
82 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | + do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | + * messages system. |
|
91 | + * |
|
92 | + * @param array $dir_ref original array of paths |
|
93 | + * |
|
94 | + * @return array appended paths |
|
95 | + */ |
|
96 | + public function messages_autoload_paths($dir_ref) |
|
97 | + { |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | + |
|
100 | + return $dir_ref; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | + { |
|
106 | + $validator_config['attendee_list'] = array( |
|
107 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | + 'required' => array('[ATTENDEE_LIST]') |
|
109 | + ); |
|
110 | + $validator_config['question_list'] = array( |
|
111 | + 'shortcodes' => array('question'), |
|
112 | + 'required' => array('[QUESTION_LIST]') |
|
113 | + ); |
|
114 | + |
|
115 | + return $validator_config; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | + { |
|
121 | + $validator_config['attendee_list'] = array( |
|
122 | + 'shortcodes' => array('attendee', 'question_list'), |
|
123 | + 'required' => array('[ATTENDEE_LIST]') |
|
124 | + ); |
|
125 | + $validator_config['question_list'] = array( |
|
126 | + 'shortcodes' => array('question'), |
|
127 | + 'required' => array('[QUESTION_LIST]') |
|
128 | + ); |
|
129 | + |
|
130 | + return $validator_config; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | + { |
|
136 | + $validator_config['attendee_list'] = array( |
|
137 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | + 'required' => array('[ATTENDEE_LIST]') |
|
139 | + ); |
|
140 | + $validator_config['question_list'] = array( |
|
141 | + 'shortcodes' => array('question'), |
|
142 | + 'required' => array('[QUESTION_LIST]') |
|
143 | + ); |
|
144 | + |
|
145 | + return $validator_config; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | + { |
|
151 | + $template_fields['extra']['content']['question_list'] = array( |
|
152 | + 'input' => 'textarea', |
|
153 | + 'label' => '[QUESTION_LIST]', |
|
154 | + 'type' => 'string', |
|
155 | + 'required' => true, |
|
156 | + 'validation' => true, |
|
157 | + 'format' => '%s', |
|
158 | + 'css_class' => 'large-text', |
|
159 | + 'rows' => '5', |
|
160 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | + ); |
|
162 | + |
|
163 | + return $template_fields; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | + { |
|
169 | + $template_fields['extra']['content']['question_list'] = array( |
|
170 | + 'input' => 'textarea', |
|
171 | + 'label' => '[QUESTION_LIST]', |
|
172 | + 'type' => 'string', |
|
173 | + 'required' => true, |
|
174 | + 'validation' => true, |
|
175 | + 'format' => '%s', |
|
176 | + 'css_class' => 'large-text', |
|
177 | + 'rows' => '5', |
|
178 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | + ); |
|
180 | + |
|
181 | + return $template_fields; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | + { |
|
187 | + $template_fields['extra']['content']['question_list'] = array( |
|
188 | + 'input' => 'textarea', |
|
189 | + 'label' => '[QUESTION_LIST]', |
|
190 | + 'type' => 'string', |
|
191 | + 'required' => true, |
|
192 | + 'validation' => true, |
|
193 | + 'format' => '%s', |
|
194 | + 'css_class' => 'large-text', |
|
195 | + 'rows' => '5', |
|
196 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | + ); |
|
198 | + |
|
199 | + return $template_fields; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + public function new_default_templates( |
|
204 | + $contents, |
|
205 | + $actual_path, |
|
206 | + EE_messenger $messenger, |
|
207 | + EE_message_type $message_type, |
|
208 | + $field, |
|
209 | + $context, |
|
210 | + EE_Messages_Template_Pack $template_pack |
|
211 | + ) { |
|
212 | + |
|
213 | + //we're only modifying templates for the default template pack |
|
214 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | + return $contents; |
|
216 | + } |
|
217 | + |
|
218 | + //the template file name we're replacing contents for. |
|
219 | + $template_file_prefix = $field . '_' . $context; |
|
220 | + $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | + |
|
222 | + $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | + |
|
224 | + if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
225 | 225 | |
226 | - switch ($template_file_prefix) { |
|
226 | + switch ($template_file_prefix) { |
|
227 | 227 | |
228 | - case 'question_list_admin' : |
|
229 | - case 'question_list_attendee' : |
|
230 | - case 'question_list_primary_attendee' : |
|
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | - $contents = EEH_Template::display_template($path, array(), true); |
|
233 | - break; |
|
228 | + case 'question_list_admin' : |
|
229 | + case 'question_list_attendee' : |
|
230 | + case 'question_list_primary_attendee' : |
|
231 | + $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | + $contents = EEH_Template::display_template($path, array(), true); |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'attendee_list_primary_attendee' : |
|
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | - $contents = EEH_Template::display_template($path, array(), true); |
|
238 | - break; |
|
235 | + case 'attendee_list_primary_attendee' : |
|
236 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | + $contents = EEH_Template::display_template($path, array(), true); |
|
238 | + break; |
|
239 | 239 | |
240 | - case 'attendee_list_admin' : |
|
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | - $contents = EEH_Template::display_template($path, |
|
243 | - array(), true); |
|
244 | - break; |
|
240 | + case 'attendee_list_admin' : |
|
241 | + $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | + $contents = EEH_Template::display_template($path, |
|
243 | + array(), true); |
|
244 | + break; |
|
245 | 245 | |
246 | - case 'attendee_list_attendee' : |
|
247 | - $contents = ''; |
|
248 | - break; |
|
246 | + case 'attendee_list_attendee' : |
|
247 | + $contents = ''; |
|
248 | + break; |
|
249 | 249 | |
250 | - case 'event_list_attendee' : |
|
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | - $contents = EEH_Template::display_template($path, array(), true); |
|
253 | - break; |
|
254 | - } |
|
255 | - } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | - switch ($template_file_prefix) { |
|
250 | + case 'event_list_attendee' : |
|
251 | + $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | + $contents = EEH_Template::display_template($path, array(), true); |
|
253 | + break; |
|
254 | + } |
|
255 | + } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | + switch ($template_file_prefix) { |
|
257 | 257 | |
258 | - case 'content_attendee' : |
|
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | - $contents = EEH_Template::display_template($path, array(), true); |
|
261 | - break; |
|
258 | + case 'content_attendee' : |
|
259 | + $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | + $contents = EEH_Template::display_template($path, array(), true); |
|
261 | + break; |
|
262 | 262 | |
263 | - case 'newsletter_content_attendee' : |
|
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | - $contents = EEH_Template::display_template($path, array(), true); |
|
266 | - break; |
|
263 | + case 'newsletter_content_attendee' : |
|
264 | + $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | + $contents = EEH_Template::display_template($path, array(), true); |
|
266 | + break; |
|
267 | 267 | |
268 | - case 'newsletter_subject_attendee' : |
|
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | - $contents = EEH_Template::display_template($path, array(), true); |
|
271 | - break; |
|
272 | - } |
|
273 | - } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | - switch ($template_file_prefix) { |
|
275 | - case 'attendee_list_purchaser' : |
|
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | - $contents = EEH_Template::display_template($path, array(), true); |
|
278 | - break; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - return $contents; |
|
283 | - |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | - { |
|
289 | - //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | - $include_with = array( |
|
291 | - 'registration', |
|
292 | - 'cancelled_registration', |
|
293 | - 'declined_registration', |
|
294 | - 'not_approved_registration', |
|
295 | - 'payment_declined', |
|
296 | - 'payment_failed', |
|
297 | - 'payment_cancelled', |
|
298 | - 'payment', |
|
299 | - 'payment_reminder', |
|
300 | - 'pending_approval', |
|
301 | - 'registration_summary', |
|
302 | - 'invoice', |
|
303 | - 'receipt' |
|
304 | - ); |
|
305 | - if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | - $contexts = array_keys($msg->get_contexts()); |
|
307 | - foreach ($contexts as $context) { |
|
308 | - $valid_shortcodes[$context][] = 'question_list'; |
|
309 | - $valid_shortcodes[$context][] = 'question'; |
|
310 | - } |
|
311 | - } |
|
312 | - |
|
313 | - return $valid_shortcodes; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | - { |
|
319 | - $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | - 'event_espresso'); |
|
321 | - |
|
322 | - return $shortcodes; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | - { |
|
328 | - |
|
329 | - if (strpos($shortcode, |
|
330 | - '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | - ) { |
|
332 | - return $parsed; |
|
333 | - } |
|
334 | - |
|
335 | - //let's get the question from the code. |
|
336 | - $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | - |
|
339 | - $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | - $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | - |
|
342 | - $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | - |
|
345 | - if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | - return $parsed; |
|
347 | - } |
|
348 | - |
|
349 | - //now let's figure out which question has this text. |
|
350 | - foreach ($aee->questions as $ansid => $question) { |
|
351 | - if ( |
|
352 | - $question instanceof EE_Question |
|
353 | - && trim($question->display_text()) == trim($shortcode) |
|
354 | - && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | - ) { |
|
356 | - return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | - 'no_wpautop'); |
|
358 | - } |
|
359 | - } |
|
360 | - |
|
361 | - //nothing! |
|
362 | - return $parsed; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | - * |
|
369 | - * @since 4.2 |
|
370 | - * |
|
371 | - * @param array $shortcodes array of shortcodes and |
|
372 | - * descriptions |
|
373 | - * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | - * |
|
375 | - * @return array array of shortcodes and |
|
376 | - * descriptions |
|
377 | - */ |
|
378 | - public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | - { |
|
380 | - $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | - 'event_espresso'); |
|
382 | - $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | - 'event_espresso'); |
|
384 | - $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | - 'event_espresso'); |
|
386 | - |
|
387 | - return $shortcodes; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | - * Datetime shortcodes |
|
394 | - * |
|
395 | - * @since 4.2 |
|
396 | - * |
|
397 | - * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | - * @param string $shortcode The shortcode being parsed. |
|
399 | - * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | - * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | - * Parser. |
|
402 | - * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | - * |
|
404 | - * @return string The new parsed string. |
|
405 | - */ |
|
406 | - public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | - { |
|
408 | - |
|
409 | - if ( ! $data instanceof EE_Datetime) { |
|
410 | - return ''; //get out because we can only parse with the datetime object. |
|
411 | - } |
|
412 | - |
|
413 | - switch ($shortcode) { |
|
414 | - case '[DTT_NAME]' : |
|
415 | - return $data->name(); |
|
416 | - break; |
|
417 | - case '[DTT_DESCRIPTION]' : |
|
418 | - return $data->description(); |
|
419 | - break; |
|
420 | - case '[DTT_NAME_OR_DATES]' : |
|
421 | - return $data->get_dtt_display_name(true); |
|
422 | - break; |
|
423 | - default : |
|
424 | - return $parsed; |
|
425 | - break; |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | - { |
|
432 | - $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | - 'event_espresso'); |
|
434 | - |
|
435 | - return $shortcodes; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | - * |
|
442 | - * @param string $parsed The original parsed content for the shortcode |
|
443 | - * @param string $shortcode The shortcode being parsed |
|
444 | - * @param array $data The shortcode parser data array |
|
445 | - * @param array $extra_data The shortcode parser extra data array |
|
446 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | - * |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | - { |
|
452 | - |
|
453 | - if (array($data) && ! isset($data['data'])) { |
|
454 | - return $parsed; |
|
455 | - } |
|
456 | - |
|
457 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | - |
|
460 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | - return $parsed; |
|
462 | - } |
|
463 | - |
|
464 | - switch ($shortcode) { |
|
465 | - case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | - $att = $recipient->att_obj; |
|
467 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | - $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | - $answers = array(); |
|
268 | + case 'newsletter_subject_attendee' : |
|
269 | + $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | + $contents = EEH_Template::display_template($path, array(), true); |
|
271 | + break; |
|
272 | + } |
|
273 | + } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | + switch ($template_file_prefix) { |
|
275 | + case 'attendee_list_purchaser' : |
|
276 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | + $contents = EEH_Template::display_template($path, array(), true); |
|
278 | + break; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + return $contents; |
|
283 | + |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | + { |
|
289 | + //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | + $include_with = array( |
|
291 | + 'registration', |
|
292 | + 'cancelled_registration', |
|
293 | + 'declined_registration', |
|
294 | + 'not_approved_registration', |
|
295 | + 'payment_declined', |
|
296 | + 'payment_failed', |
|
297 | + 'payment_cancelled', |
|
298 | + 'payment', |
|
299 | + 'payment_reminder', |
|
300 | + 'pending_approval', |
|
301 | + 'registration_summary', |
|
302 | + 'invoice', |
|
303 | + 'receipt' |
|
304 | + ); |
|
305 | + if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | + $contexts = array_keys($msg->get_contexts()); |
|
307 | + foreach ($contexts as $context) { |
|
308 | + $valid_shortcodes[$context][] = 'question_list'; |
|
309 | + $valid_shortcodes[$context][] = 'question'; |
|
310 | + } |
|
311 | + } |
|
312 | + |
|
313 | + return $valid_shortcodes; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | + { |
|
319 | + $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | + 'event_espresso'); |
|
321 | + |
|
322 | + return $shortcodes; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | + { |
|
328 | + |
|
329 | + if (strpos($shortcode, |
|
330 | + '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | + ) { |
|
332 | + return $parsed; |
|
333 | + } |
|
334 | + |
|
335 | + //let's get the question from the code. |
|
336 | + $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | + |
|
339 | + $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | + $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | + |
|
342 | + $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | + |
|
345 | + if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | + return $parsed; |
|
347 | + } |
|
348 | + |
|
349 | + //now let's figure out which question has this text. |
|
350 | + foreach ($aee->questions as $ansid => $question) { |
|
351 | + if ( |
|
352 | + $question instanceof EE_Question |
|
353 | + && trim($question->display_text()) == trim($shortcode) |
|
354 | + && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | + ) { |
|
356 | + return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | + 'no_wpautop'); |
|
358 | + } |
|
359 | + } |
|
360 | + |
|
361 | + //nothing! |
|
362 | + return $parsed; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | + * |
|
369 | + * @since 4.2 |
|
370 | + * |
|
371 | + * @param array $shortcodes array of shortcodes and |
|
372 | + * descriptions |
|
373 | + * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | + * |
|
375 | + * @return array array of shortcodes and |
|
376 | + * descriptions |
|
377 | + */ |
|
378 | + public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | + { |
|
380 | + $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | + 'event_espresso'); |
|
382 | + $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | + 'event_espresso'); |
|
384 | + $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | + 'event_espresso'); |
|
386 | + |
|
387 | + return $shortcodes; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | + * Datetime shortcodes |
|
394 | + * |
|
395 | + * @since 4.2 |
|
396 | + * |
|
397 | + * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | + * @param string $shortcode The shortcode being parsed. |
|
399 | + * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | + * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | + * Parser. |
|
402 | + * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | + * |
|
404 | + * @return string The new parsed string. |
|
405 | + */ |
|
406 | + public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | + { |
|
408 | + |
|
409 | + if ( ! $data instanceof EE_Datetime) { |
|
410 | + return ''; //get out because we can only parse with the datetime object. |
|
411 | + } |
|
412 | + |
|
413 | + switch ($shortcode) { |
|
414 | + case '[DTT_NAME]' : |
|
415 | + return $data->name(); |
|
416 | + break; |
|
417 | + case '[DTT_DESCRIPTION]' : |
|
418 | + return $data->description(); |
|
419 | + break; |
|
420 | + case '[DTT_NAME_OR_DATES]' : |
|
421 | + return $data->get_dtt_display_name(true); |
|
422 | + break; |
|
423 | + default : |
|
424 | + return $parsed; |
|
425 | + break; |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | + { |
|
432 | + $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | + 'event_espresso'); |
|
434 | + |
|
435 | + return $shortcodes; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | + * |
|
442 | + * @param string $parsed The original parsed content for the shortcode |
|
443 | + * @param string $shortcode The shortcode being parsed |
|
444 | + * @param array $data The shortcode parser data array |
|
445 | + * @param array $extra_data The shortcode parser extra data array |
|
446 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | + * |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | + { |
|
452 | + |
|
453 | + if (array($data) && ! isset($data['data'])) { |
|
454 | + return $parsed; |
|
455 | + } |
|
456 | + |
|
457 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | + |
|
460 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | + return $parsed; |
|
462 | + } |
|
463 | + |
|
464 | + switch ($shortcode) { |
|
465 | + case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | + $att = $recipient->att_obj; |
|
467 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | + $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | + $answers = array(); |
|
470 | 470 | |
471 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | - $valid_shortcodes = array('question'); |
|
471 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | + $valid_shortcodes = array('question'); |
|
473 | 473 | |
474 | - //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | - if ($data['data'] instanceof EE_Messages_Addressee) { |
|
474 | + //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | + if ($data['data'] instanceof EE_Messages_Addressee) { |
|
476 | 476 | |
477 | - foreach ($registrations_on_attendee as $reg) { |
|
478 | - if ($reg instanceof EE_Registration) { |
|
479 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | - foreach ($anss as $ans) { |
|
481 | - if ($ans instanceof EE_Answer) { |
|
482 | - $answers[$ans->ID()] = $ans; |
|
483 | - } |
|
484 | - } |
|
485 | - } |
|
486 | - } |
|
487 | - } |
|
477 | + foreach ($registrations_on_attendee as $reg) { |
|
478 | + if ($reg instanceof EE_Registration) { |
|
479 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | + foreach ($anss as $ans) { |
|
481 | + if ($ans instanceof EE_Answer) { |
|
482 | + $answers[$ans->ID()] = $ans; |
|
483 | + } |
|
484 | + } |
|
485 | + } |
|
486 | + } |
|
487 | + } |
|
488 | 488 | |
489 | - //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | - if ($data['data'] instanceof EE_Event) { |
|
491 | - $event = $data['data']; |
|
492 | - foreach ($registrations_on_attendee as $reg) { |
|
493 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | - foreach ($anss as $ans) { |
|
496 | - if ($ans instanceof EE_Answer) { |
|
497 | - $answers[$ans->ID()] = $ans; |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
489 | + //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | + if ($data['data'] instanceof EE_Event) { |
|
491 | + $event = $data['data']; |
|
492 | + foreach ($registrations_on_attendee as $reg) { |
|
493 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | + foreach ($anss as $ans) { |
|
496 | + if ($ans instanceof EE_Answer) { |
|
497 | + $answers[$ans->ID()] = $ans; |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
504 | + $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
505 | 505 | |
506 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | - //object on it. |
|
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
509 | - $extra_data['data'] = $recipient; |
|
510 | - } |
|
506 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | + //object on it. |
|
508 | + if ( ! isset( $extra_data['data'] ) ) { |
|
509 | + $extra_data['data'] = $recipient; |
|
510 | + } |
|
511 | 511 | |
512 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | - $shortcode_parser, |
|
514 | - $questions, |
|
515 | - $answers, |
|
516 | - $template, |
|
517 | - $valid_shortcodes, |
|
518 | - $extra_data |
|
519 | - ); |
|
520 | - break; |
|
512 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | + $shortcode_parser, |
|
514 | + $questions, |
|
515 | + $answers, |
|
516 | + $template, |
|
517 | + $valid_shortcodes, |
|
518 | + $extra_data |
|
519 | + ); |
|
520 | + break; |
|
521 | 521 | |
522 | - default : |
|
523 | - return $parsed; |
|
524 | - break; |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | - { |
|
531 | - $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | - 'event_espresso'); |
|
533 | - |
|
534 | - return $shortcodes; |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | - * |
|
541 | - * @param string $parsed The original parsed content for the shortcode |
|
542 | - * @param string $shortcode The shortcode being parsed |
|
543 | - * @param array $data The shortcode parser data array |
|
544 | - * @param array $extra_data The shortcode parser extra data array |
|
545 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | - * |
|
547 | - * @return string |
|
548 | - */ |
|
549 | - public function additional_primary_registration_details_parser( |
|
550 | - $parsed, |
|
551 | - $shortcode, |
|
552 | - $data, |
|
553 | - $extra_data, |
|
554 | - $shortcode_parser |
|
555 | - ) { |
|
556 | - if (array($data) && ! isset($data['data'])) { |
|
557 | - return $parsed; |
|
558 | - } |
|
559 | - |
|
560 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | - |
|
563 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | - return $parsed; |
|
565 | - } |
|
566 | - |
|
567 | - switch ($shortcode) { |
|
568 | - case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | - if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | - return ''; |
|
571 | - } |
|
572 | - $registration = $recipient->primary_reg_obj; |
|
573 | - $answers = isset($recipient->registrations[$registration->ID()]['ans_objs']) |
|
574 | - ? $recipient->registrations[$registration->ID()]['ans_objs'] |
|
575 | - : array(); |
|
576 | - if (empty($answers)) { |
|
577 | - return ''; |
|
578 | - } |
|
579 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
580 | - $valid_shortcodes = array('question'); |
|
581 | - $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
582 | - $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
583 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
584 | - //object on it. |
|
585 | - if ( ! isset( $extra_data['data'] ) ){ |
|
586 | - $extra_data['data'] = $recipient; |
|
587 | - } |
|
588 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
589 | - $shortcode_parser, |
|
590 | - $questions, |
|
591 | - $answers, |
|
592 | - $template, |
|
593 | - $valid_shortcodes, |
|
594 | - $extra_data |
|
595 | - ); |
|
596 | - break; |
|
522 | + default : |
|
523 | + return $parsed; |
|
524 | + break; |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | + { |
|
531 | + $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | + 'event_espresso'); |
|
533 | + |
|
534 | + return $shortcodes; |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | + * |
|
541 | + * @param string $parsed The original parsed content for the shortcode |
|
542 | + * @param string $shortcode The shortcode being parsed |
|
543 | + * @param array $data The shortcode parser data array |
|
544 | + * @param array $extra_data The shortcode parser extra data array |
|
545 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | + * |
|
547 | + * @return string |
|
548 | + */ |
|
549 | + public function additional_primary_registration_details_parser( |
|
550 | + $parsed, |
|
551 | + $shortcode, |
|
552 | + $data, |
|
553 | + $extra_data, |
|
554 | + $shortcode_parser |
|
555 | + ) { |
|
556 | + if (array($data) && ! isset($data['data'])) { |
|
557 | + return $parsed; |
|
558 | + } |
|
559 | + |
|
560 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | + |
|
563 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | + return $parsed; |
|
565 | + } |
|
566 | + |
|
567 | + switch ($shortcode) { |
|
568 | + case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | + if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | + return ''; |
|
571 | + } |
|
572 | + $registration = $recipient->primary_reg_obj; |
|
573 | + $answers = isset($recipient->registrations[$registration->ID()]['ans_objs']) |
|
574 | + ? $recipient->registrations[$registration->ID()]['ans_objs'] |
|
575 | + : array(); |
|
576 | + if (empty($answers)) { |
|
577 | + return ''; |
|
578 | + } |
|
579 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
580 | + $valid_shortcodes = array('question'); |
|
581 | + $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
582 | + $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
583 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
584 | + //object on it. |
|
585 | + if ( ! isset( $extra_data['data'] ) ){ |
|
586 | + $extra_data['data'] = $recipient; |
|
587 | + } |
|
588 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
589 | + $shortcode_parser, |
|
590 | + $questions, |
|
591 | + $answers, |
|
592 | + $template, |
|
593 | + $valid_shortcodes, |
|
594 | + $extra_data |
|
595 | + ); |
|
596 | + break; |
|
597 | 597 | |
598 | - default : |
|
599 | - return $parsed; |
|
600 | - break; |
|
601 | - } |
|
602 | - } |
|
603 | - |
|
604 | - |
|
605 | - /** |
|
606 | - * Takes care of registering the message types that are only available in caffeinated EE. |
|
607 | - * |
|
608 | - * @since 4.3.2 |
|
609 | - * |
|
610 | - * @return void |
|
611 | - */ |
|
612 | - public function register_caf_message_types() |
|
613 | - { |
|
614 | - //register newsletter message type |
|
615 | - $setup_args = array( |
|
616 | - 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
617 | - 'autoloadpaths' => array( |
|
618 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
619 | - ), |
|
620 | - 'messengers_to_activate_with' => array('email'), |
|
621 | - 'messengers_to_validate_with' => array('email'), |
|
622 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
623 | - ); |
|
624 | - EE_Register_Message_Type::register('newsletter', $setup_args); |
|
625 | - |
|
626 | - //register payment reminder message type |
|
627 | - $setup_args = array( |
|
628 | - 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
629 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
630 | - 'messengers_to_activate_with' => array('email'), |
|
631 | - 'messengers_to_validate_with' => array('email'), |
|
632 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
633 | - ); |
|
634 | - EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
635 | - |
|
636 | - //register payment declined message type |
|
637 | - $setup_args = array( |
|
638 | - 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
639 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
640 | - 'messengers_to_activate_with' => array('email'), |
|
641 | - 'messengers_to_validate_with' => array('email'), |
|
642 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
643 | - ); |
|
644 | - EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
645 | - |
|
646 | - //register registration declined message type |
|
647 | - $setup_args = array( |
|
648 | - 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
650 | - 'messengers_to_activate_with' => array('email'), |
|
651 | - 'messengers_to_validate_with' => array('email'), |
|
652 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
653 | - ); |
|
654 | - EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
655 | - |
|
656 | - //register registration cancelled message type |
|
657 | - $setup_args = array( |
|
658 | - 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
660 | - 'messengers_to_activate_with' => array('email'), |
|
661 | - 'messengers_to_validate_with' => array('email'), |
|
662 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
663 | - ); |
|
664 | - EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
665 | - |
|
666 | - |
|
667 | - //register payment failed message type |
|
668 | - $setup_args = array( |
|
669 | - 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
670 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
671 | - 'messengers_to_activate_with' => array('email'), |
|
672 | - 'messengers_to_validate_with' => array('email'), |
|
673 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
674 | - ); |
|
675 | - EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
676 | - |
|
677 | - //register payment declined message type |
|
678 | - $setup_args = array( |
|
679 | - 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
680 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
681 | - 'messengers_to_activate_with' => array('email'), |
|
682 | - 'messengers_to_validate_with' => array('email'), |
|
683 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
684 | - ); |
|
685 | - EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
686 | - } |
|
687 | - |
|
688 | - |
|
689 | - /** |
|
690 | - * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
691 | - * |
|
692 | - * @since 4.3.2 |
|
693 | - * |
|
694 | - * @return void |
|
695 | - */ |
|
696 | - public function register_caf_shortcodes() |
|
697 | - { |
|
698 | - $setup_args = array( |
|
699 | - 'autoloadpaths' => array( |
|
700 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
701 | - ), |
|
702 | - 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
703 | - 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
704 | - 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
705 | - ); |
|
706 | - EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
707 | - } |
|
708 | - |
|
709 | - |
|
710 | - /** |
|
711 | - * Parses a question list shortcode using given data and template |
|
712 | - * |
|
713 | - * @param \EE_Shortcodes $shortcode_parser |
|
714 | - * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
715 | - * @param EE_Answer[] $answers An array of answer objects |
|
716 | - * @param string $template Template content to be parsed. |
|
717 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
718 | - * @param array $extra_data Extra data that might be used when parsing the template. |
|
719 | - */ |
|
720 | - protected function _parse_question_list_for_primary_or_recipient_registration( |
|
721 | - $shortcode_parser, |
|
722 | - $questions, |
|
723 | - $answers, |
|
724 | - $template, |
|
725 | - $valid_shortcodes, |
|
726 | - $extra_data |
|
727 | - ) { |
|
728 | - $question_list = ''; |
|
729 | - /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
730 | - $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
731 | - foreach ($answers as $answer) { |
|
732 | - if ($answer instanceof EE_Answer) { |
|
733 | - //first see if the question is in our $questions array. If not then try to get from answer object. |
|
734 | - $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
735 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
736 | - if ( |
|
737 | - ! $question instanceof EE_Question |
|
738 | - || ( |
|
739 | - $question instanceof EE_Question |
|
740 | - && $question->admin_only() |
|
741 | - ) |
|
742 | - ) { |
|
743 | - continue; |
|
744 | - } |
|
745 | - $question_list .= $shortcode_helper->parse_question_list_template( |
|
746 | - $template, |
|
747 | - $answer, |
|
748 | - $valid_shortcodes, |
|
749 | - $extra_data |
|
750 | - ); |
|
751 | - } |
|
752 | - } |
|
753 | - |
|
754 | - return $question_list; |
|
755 | - } |
|
598 | + default : |
|
599 | + return $parsed; |
|
600 | + break; |
|
601 | + } |
|
602 | + } |
|
603 | + |
|
604 | + |
|
605 | + /** |
|
606 | + * Takes care of registering the message types that are only available in caffeinated EE. |
|
607 | + * |
|
608 | + * @since 4.3.2 |
|
609 | + * |
|
610 | + * @return void |
|
611 | + */ |
|
612 | + public function register_caf_message_types() |
|
613 | + { |
|
614 | + //register newsletter message type |
|
615 | + $setup_args = array( |
|
616 | + 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
617 | + 'autoloadpaths' => array( |
|
618 | + EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
619 | + ), |
|
620 | + 'messengers_to_activate_with' => array('email'), |
|
621 | + 'messengers_to_validate_with' => array('email'), |
|
622 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
623 | + ); |
|
624 | + EE_Register_Message_Type::register('newsletter', $setup_args); |
|
625 | + |
|
626 | + //register payment reminder message type |
|
627 | + $setup_args = array( |
|
628 | + 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
629 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
630 | + 'messengers_to_activate_with' => array('email'), |
|
631 | + 'messengers_to_validate_with' => array('email'), |
|
632 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
633 | + ); |
|
634 | + EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
635 | + |
|
636 | + //register payment declined message type |
|
637 | + $setup_args = array( |
|
638 | + 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
639 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
640 | + 'messengers_to_activate_with' => array('email'), |
|
641 | + 'messengers_to_validate_with' => array('email'), |
|
642 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
643 | + ); |
|
644 | + EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
645 | + |
|
646 | + //register registration declined message type |
|
647 | + $setup_args = array( |
|
648 | + 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
650 | + 'messengers_to_activate_with' => array('email'), |
|
651 | + 'messengers_to_validate_with' => array('email'), |
|
652 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
653 | + ); |
|
654 | + EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
655 | + |
|
656 | + //register registration cancelled message type |
|
657 | + $setup_args = array( |
|
658 | + 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
660 | + 'messengers_to_activate_with' => array('email'), |
|
661 | + 'messengers_to_validate_with' => array('email'), |
|
662 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
663 | + ); |
|
664 | + EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
665 | + |
|
666 | + |
|
667 | + //register payment failed message type |
|
668 | + $setup_args = array( |
|
669 | + 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
670 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
671 | + 'messengers_to_activate_with' => array('email'), |
|
672 | + 'messengers_to_validate_with' => array('email'), |
|
673 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
674 | + ); |
|
675 | + EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
676 | + |
|
677 | + //register payment declined message type |
|
678 | + $setup_args = array( |
|
679 | + 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
680 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
681 | + 'messengers_to_activate_with' => array('email'), |
|
682 | + 'messengers_to_validate_with' => array('email'), |
|
683 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
684 | + ); |
|
685 | + EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
686 | + } |
|
687 | + |
|
688 | + |
|
689 | + /** |
|
690 | + * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
691 | + * |
|
692 | + * @since 4.3.2 |
|
693 | + * |
|
694 | + * @return void |
|
695 | + */ |
|
696 | + public function register_caf_shortcodes() |
|
697 | + { |
|
698 | + $setup_args = array( |
|
699 | + 'autoloadpaths' => array( |
|
700 | + EE_CAF_LIBRARIES . 'shortcodes/' |
|
701 | + ), |
|
702 | + 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
703 | + 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
704 | + 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
705 | + ); |
|
706 | + EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
707 | + } |
|
708 | + |
|
709 | + |
|
710 | + /** |
|
711 | + * Parses a question list shortcode using given data and template |
|
712 | + * |
|
713 | + * @param \EE_Shortcodes $shortcode_parser |
|
714 | + * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
715 | + * @param EE_Answer[] $answers An array of answer objects |
|
716 | + * @param string $template Template content to be parsed. |
|
717 | + * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
718 | + * @param array $extra_data Extra data that might be used when parsing the template. |
|
719 | + */ |
|
720 | + protected function _parse_question_list_for_primary_or_recipient_registration( |
|
721 | + $shortcode_parser, |
|
722 | + $questions, |
|
723 | + $answers, |
|
724 | + $template, |
|
725 | + $valid_shortcodes, |
|
726 | + $extra_data |
|
727 | + ) { |
|
728 | + $question_list = ''; |
|
729 | + /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
730 | + $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
731 | + foreach ($answers as $answer) { |
|
732 | + if ($answer instanceof EE_Answer) { |
|
733 | + //first see if the question is in our $questions array. If not then try to get from answer object. |
|
734 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
735 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
736 | + if ( |
|
737 | + ! $question instanceof EE_Question |
|
738 | + || ( |
|
739 | + $question instanceof EE_Question |
|
740 | + && $question->admin_only() |
|
741 | + ) |
|
742 | + ) { |
|
743 | + continue; |
|
744 | + } |
|
745 | + $question_list .= $shortcode_helper->parse_question_list_template( |
|
746 | + $template, |
|
747 | + $answer, |
|
748 | + $valid_shortcodes, |
|
749 | + $extra_data |
|
750 | + ); |
|
751 | + } |
|
752 | + } |
|
753 | + |
|
754 | + return $question_list; |
|
755 | + } |
|
756 | 756 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/'; |
|
99 | 99 | |
100 | 100 | return $dir_ref; |
101 | 101 | } |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | //the template file name we're replacing contents for. |
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
219 | + $template_file_prefix = $field.'_'.$context; |
|
220 | + $msg_prefix = $messenger->name.'_'.$message_type->name.'_'; |
|
221 | 221 | |
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
222 | + $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/'; |
|
223 | 223 | |
224 | 224 | if ($messenger->name == 'email' && $message_type->name == 'registration') { |
225 | 225 | |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | case 'question_list_admin' : |
229 | 229 | case 'question_list_attendee' : |
230 | 230 | case 'question_list_primary_attendee' : |
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
231 | + $path = $base_path.$msg_prefix.'question_list.template.php'; |
|
232 | 232 | $contents = EEH_Template::display_template($path, array(), true); |
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'attendee_list_primary_attendee' : |
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
236 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
237 | 237 | $contents = EEH_Template::display_template($path, array(), true); |
238 | 238 | break; |
239 | 239 | |
240 | 240 | case 'attendee_list_admin' : |
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
241 | + $path = $base_path.$msg_prefix.'attendee_list_admin.template.php'; |
|
242 | 242 | $contents = EEH_Template::display_template($path, |
243 | 243 | array(), true); |
244 | 244 | break; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'event_list_attendee' : |
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
251 | + $path = $base_path.$msg_prefix.'event_list_attendee.template.php'; |
|
252 | 252 | $contents = EEH_Template::display_template($path, array(), true); |
253 | 253 | break; |
254 | 254 | } |
@@ -256,24 +256,24 @@ discard block |
||
256 | 256 | switch ($template_file_prefix) { |
257 | 257 | |
258 | 258 | case 'content_attendee' : |
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
259 | + $path = $base_path.$msg_prefix.'content.template.php'; |
|
260 | 260 | $contents = EEH_Template::display_template($path, array(), true); |
261 | 261 | break; |
262 | 262 | |
263 | 263 | case 'newsletter_content_attendee' : |
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
264 | + $path = $base_path.$msg_prefix.'newsletter_content.template.php'; |
|
265 | 265 | $contents = EEH_Template::display_template($path, array(), true); |
266 | 266 | break; |
267 | 267 | |
268 | 268 | case 'newsletter_subject_attendee' : |
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
269 | + $path = $base_path.$msg_prefix.'subject.template.php'; |
|
270 | 270 | $contents = EEH_Template::display_template($path, array(), true); |
271 | 271 | break; |
272 | 272 | } |
273 | 273 | } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
274 | 274 | switch ($template_file_prefix) { |
275 | 275 | case 'attendee_list_purchaser' : |
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
276 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
277 | 277 | $contents = EEH_Template::display_template($path, array(), true); |
278 | 278 | break; |
279 | 279 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
507 | 507 | //object on it. |
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
508 | + if ( ! isset($extra_data['data'])) { |
|
509 | 509 | $extra_data['data'] = $recipient; |
510 | 510 | } |
511 | 511 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
570 | 570 | return ''; |
571 | 571 | } |
572 | - $registration = $recipient->primary_reg_obj; |
|
572 | + $registration = $recipient->primary_reg_obj; |
|
573 | 573 | $answers = isset($recipient->registrations[$registration->ID()]['ans_objs']) |
574 | 574 | ? $recipient->registrations[$registration->ID()]['ans_objs'] |
575 | 575 | : array(); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $questions = isset($recipient->questions) ? $recipient->questions : array(); |
583 | 583 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
584 | 584 | //object on it. |
585 | - if ( ! isset( $extra_data['data'] ) ){ |
|
585 | + if ( ! isset($extra_data['data'])) { |
|
586 | 586 | $extra_data['data'] = $recipient; |
587 | 587 | } |
588 | 588 | return $this->_parse_question_list_for_primary_or_recipient_registration( |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | $setup_args = array( |
616 | 616 | 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
617 | 617 | 'autoloadpaths' => array( |
618 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
618 | + EE_CAF_LIBRARIES.'messages/message_type/newsletter/' |
|
619 | 619 | ), |
620 | 620 | 'messengers_to_activate_with' => array('email'), |
621 | 621 | 'messengers_to_validate_with' => array('email'), |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | //register payment reminder message type |
627 | 627 | $setup_args = array( |
628 | 628 | 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
629 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
629 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'), |
|
630 | 630 | 'messengers_to_activate_with' => array('email'), |
631 | 631 | 'messengers_to_validate_with' => array('email'), |
632 | 632 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | //register payment declined message type |
637 | 637 | $setup_args = array( |
638 | 638 | 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
639 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
639 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'), |
|
640 | 640 | 'messengers_to_activate_with' => array('email'), |
641 | 641 | 'messengers_to_validate_with' => array('email'), |
642 | 642 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | //register registration declined message type |
647 | 647 | $setup_args = array( |
648 | 648 | 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'), |
|
650 | 650 | 'messengers_to_activate_with' => array('email'), |
651 | 651 | 'messengers_to_validate_with' => array('email'), |
652 | 652 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | //register registration cancelled message type |
657 | 657 | $setup_args = array( |
658 | 658 | 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'), |
|
660 | 660 | 'messengers_to_activate_with' => array('email'), |
661 | 661 | 'messengers_to_validate_with' => array('email'), |
662 | 662 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | //register payment failed message type |
668 | 668 | $setup_args = array( |
669 | 669 | 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
670 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
670 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'), |
|
671 | 671 | 'messengers_to_activate_with' => array('email'), |
672 | 672 | 'messengers_to_validate_with' => array('email'), |
673 | 673 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | //register payment declined message type |
678 | 678 | $setup_args = array( |
679 | 679 | 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
680 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
680 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'), |
|
681 | 681 | 'messengers_to_activate_with' => array('email'), |
682 | 682 | 'messengers_to_validate_with' => array('email'), |
683 | 683 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | { |
698 | 698 | $setup_args = array( |
699 | 699 | 'autoloadpaths' => array( |
700 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
700 | + EE_CAF_LIBRARIES.'shortcodes/' |
|
701 | 701 | ), |
702 | 702 | 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
703 | 703 | 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('NO direct script access allowed'); |
|
4 | + exit('NO direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -24,585 +24,585 @@ discard block |
||
24 | 24 | class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data |
25 | 25 | { |
26 | 26 | |
27 | - //some specific properties we need for this class |
|
28 | - private $_events = array(); |
|
29 | - private $_attendees = array(); |
|
30 | - private $_registrations = array(); |
|
27 | + //some specific properties we need for this class |
|
28 | + private $_events = array(); |
|
29 | + private $_attendees = array(); |
|
30 | + private $_registrations = array(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
35 | - * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
36 | - * we'll get the first three published events from the users database and use that as a source. |
|
37 | - * |
|
38 | - * @param array $data |
|
39 | - */ |
|
40 | - public function __construct($data = array()) |
|
41 | - { |
|
42 | - $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
43 | - $this->_setup_attendees_events(); |
|
44 | - parent::__construct($data); |
|
45 | - } |
|
33 | + /** |
|
34 | + * For the constructor of this special preview class. We're either looking for an event id or empty data. If we |
|
35 | + * have an event id (or ids) then we'll use that as the source for the "dummy" data. If the data is empty then |
|
36 | + * we'll get the first three published events from the users database and use that as a source. |
|
37 | + * |
|
38 | + * @param array $data |
|
39 | + */ |
|
40 | + public function __construct($data = array()) |
|
41 | + { |
|
42 | + $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array(); |
|
43 | + $this->_setup_attendees_events(); |
|
44 | + parent::__construct($data); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Returns database safe representation of the data later used to when instantiating this object. |
|
50 | - * |
|
51 | - * @param array $data The incoming data to be prepped. |
|
52 | - * |
|
53 | - * @return array The prepped data for db |
|
54 | - */ |
|
55 | - static public function convert_data_for_persistent_storage($data) |
|
56 | - { |
|
57 | - return $data; |
|
58 | - } |
|
48 | + /** |
|
49 | + * Returns database safe representation of the data later used to when instantiating this object. |
|
50 | + * |
|
51 | + * @param array $data The incoming data to be prepped. |
|
52 | + * |
|
53 | + * @return array The prepped data for db |
|
54 | + */ |
|
55 | + static public function convert_data_for_persistent_storage($data) |
|
56 | + { |
|
57 | + return $data; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
63 | - * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
64 | - * |
|
65 | - * @param array $data |
|
66 | - * |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - static public function convert_data_from_persistent_storage($data) |
|
70 | - { |
|
71 | - return $data; |
|
72 | - } |
|
61 | + /** |
|
62 | + * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage |
|
63 | + * can be sent into this method and converted back into the format used for instantiating with this data handler. |
|
64 | + * |
|
65 | + * @param array $data |
|
66 | + * |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + static public function convert_data_from_persistent_storage($data) |
|
70 | + { |
|
71 | + return $data; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * This will just setup the _events property in the expected format. |
|
77 | - * |
|
78 | - * @throws \EE_Error |
|
79 | - */ |
|
80 | - private function _setup_attendees_events() |
|
81 | - { |
|
82 | - |
|
83 | - //setup some attendee objects |
|
84 | - $attendees = $this->_get_some_attendees(); |
|
85 | - |
|
86 | - //if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
|
87 | - $events = $this->_get_some_events($this->_data); |
|
88 | - |
|
89 | - $answers_n_questions = $this->_get_some_q_and_as(); |
|
90 | - |
|
91 | - if (count($events) < 1) { |
|
92 | - throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database', |
|
93 | - 'event_espresso')); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - //now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
98 | - |
|
99 | - |
|
100 | - //we'll actually use the generated line_item identifiers for our loop |
|
101 | - $dtts = $tkts = array(); |
|
102 | - foreach ($events as $id => $event) { |
|
103 | - if ( ! $event instanceof EE_Event) { |
|
104 | - continue; |
|
105 | - } |
|
106 | - $this->_events[$id]['ID'] = $id; |
|
107 | - $this->_events[$id]['name'] = $event->get('EVT_name'); |
|
108 | - $datetime = $event->get_first_related('Datetime'); |
|
109 | - $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket', |
|
110 | - array('default_where_conditions' => 'none')) : array(); |
|
111 | - $this->_events[$id]['event'] = $event; |
|
112 | - $this->_events[$id]['reg_objs'] = array(); |
|
113 | - $this->_events[$id]['tkt_objs'] = $tickets; |
|
114 | - $this->_events[$id]['dtt_objs'] = array(); |
|
75 | + /** |
|
76 | + * This will just setup the _events property in the expected format. |
|
77 | + * |
|
78 | + * @throws \EE_Error |
|
79 | + */ |
|
80 | + private function _setup_attendees_events() |
|
81 | + { |
|
82 | + |
|
83 | + //setup some attendee objects |
|
84 | + $attendees = $this->_get_some_attendees(); |
|
85 | + |
|
86 | + //if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids. |
|
87 | + $events = $this->_get_some_events($this->_data); |
|
88 | + |
|
89 | + $answers_n_questions = $this->_get_some_q_and_as(); |
|
90 | + |
|
91 | + if (count($events) < 1) { |
|
92 | + throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database', |
|
93 | + 'event_espresso')); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + //now let's loop and set up the _events property. At the same time we'll set up attendee properties. |
|
98 | + |
|
99 | + |
|
100 | + //we'll actually use the generated line_item identifiers for our loop |
|
101 | + $dtts = $tkts = array(); |
|
102 | + foreach ($events as $id => $event) { |
|
103 | + if ( ! $event instanceof EE_Event) { |
|
104 | + continue; |
|
105 | + } |
|
106 | + $this->_events[$id]['ID'] = $id; |
|
107 | + $this->_events[$id]['name'] = $event->get('EVT_name'); |
|
108 | + $datetime = $event->get_first_related('Datetime'); |
|
109 | + $tickets = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket', |
|
110 | + array('default_where_conditions' => 'none')) : array(); |
|
111 | + $this->_events[$id]['event'] = $event; |
|
112 | + $this->_events[$id]['reg_objs'] = array(); |
|
113 | + $this->_events[$id]['tkt_objs'] = $tickets; |
|
114 | + $this->_events[$id]['dtt_objs'] = array(); |
|
115 | 115 | |
116 | - $dttcache = array(); |
|
117 | - $tkts = array(); |
|
118 | - foreach ($tickets as $ticket) { |
|
119 | - if ( ! $ticket instanceof EE_Ticket) { |
|
120 | - continue; |
|
121 | - } |
|
122 | - $reldatetime = $ticket->datetimes(); |
|
123 | - $tkts[$ticket->ID()] = array(); |
|
124 | - $tkts[$ticket->ID()]['ticket'] = $ticket; |
|
125 | - $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime; |
|
126 | - $tkts[$ticket->ID()]['att_objs'] = $attendees; |
|
127 | - $tkts[$ticket->ID()]['count'] = count($attendees); |
|
128 | - $tkts[$ticket->ID()]['EE_Event'] = $event; |
|
129 | - foreach ($reldatetime as $datetime) { |
|
130 | - if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) { |
|
131 | - $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime; |
|
132 | - $dtts[$datetime->ID()]['datetime'] = $datetime; |
|
133 | - $dtts[$datetime->ID()]['tkt_objs'][] = $ticket; |
|
134 | - $dtts[$datetime->ID()]['evt_objs'][] = $event; |
|
135 | - $dttcache[$datetime->ID()] = $datetime; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
116 | + $dttcache = array(); |
|
117 | + $tkts = array(); |
|
118 | + foreach ($tickets as $ticket) { |
|
119 | + if ( ! $ticket instanceof EE_Ticket) { |
|
120 | + continue; |
|
121 | + } |
|
122 | + $reldatetime = $ticket->datetimes(); |
|
123 | + $tkts[$ticket->ID()] = array(); |
|
124 | + $tkts[$ticket->ID()]['ticket'] = $ticket; |
|
125 | + $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime; |
|
126 | + $tkts[$ticket->ID()]['att_objs'] = $attendees; |
|
127 | + $tkts[$ticket->ID()]['count'] = count($attendees); |
|
128 | + $tkts[$ticket->ID()]['EE_Event'] = $event; |
|
129 | + foreach ($reldatetime as $datetime) { |
|
130 | + if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) { |
|
131 | + $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime; |
|
132 | + $dtts[$datetime->ID()]['datetime'] = $datetime; |
|
133 | + $dtts[$datetime->ID()]['tkt_objs'][] = $ticket; |
|
134 | + $dtts[$datetime->ID()]['evt_objs'][] = $event; |
|
135 | + $dttcache[$datetime->ID()] = $datetime; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - $this->_events[$id]['total_attendees'] = count($attendees); |
|
141 | - $this->_events[$id]['att_objs'] = $attendees; |
|
140 | + $this->_events[$id]['total_attendees'] = count($attendees); |
|
141 | + $this->_events[$id]['att_objs'] = $attendees; |
|
142 | 142 | |
143 | - //let's also setup the dummy attendees property! |
|
144 | - foreach ($attendees as $att_key => $attendee) { |
|
145 | - if ( ! $attendee instanceof EE_Attendee) { |
|
146 | - continue; |
|
147 | - } |
|
148 | - $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for! |
|
149 | - $this->_attendees[$att_key]['evt_objs'][] = $event; |
|
150 | - $this->_attendees[$att_key]['att_obj'] = $attendee; |
|
151 | - //$this->_attendees[$att_key]['registration_id'] = 0; |
|
152 | - $this->_attendees[$att_key]['attendee_email'] = $attendee->email(); |
|
153 | - $this->_attendees[$att_key]['tkt_objs'] = $tickets; |
|
154 | - if ($att_key == 999999991) { |
|
155 | - $this->_attendees[$att_key]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | - $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | - $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | - } elseif ($att_key == 999999992) { |
|
159 | - $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | - $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | - $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | - } elseif ($att_key == 999999993) { |
|
163 | - $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | - $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | - $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - $this->tickets = $tkts; |
|
171 | - $this->datetimes = $dtts; |
|
172 | - $this->answers = $answers_n_questions['answers']; |
|
173 | - $this->questions = $answers_n_questions['questions']; |
|
174 | - $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
175 | - |
|
176 | - } |
|
143 | + //let's also setup the dummy attendees property! |
|
144 | + foreach ($attendees as $att_key => $attendee) { |
|
145 | + if ( ! $attendee instanceof EE_Attendee) { |
|
146 | + continue; |
|
147 | + } |
|
148 | + $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for! |
|
149 | + $this->_attendees[$att_key]['evt_objs'][] = $event; |
|
150 | + $this->_attendees[$att_key]['att_obj'] = $attendee; |
|
151 | + //$this->_attendees[$att_key]['registration_id'] = 0; |
|
152 | + $this->_attendees[$att_key]['attendee_email'] = $attendee->email(); |
|
153 | + $this->_attendees[$att_key]['tkt_objs'] = $tickets; |
|
154 | + if ($att_key == 999999991) { |
|
155 | + $this->_attendees[$att_key]['ans_objs'][999] = $answers_n_questions['answers'][999]; |
|
156 | + $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002]; |
|
157 | + $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005]; |
|
158 | + } elseif ($att_key == 999999992) { |
|
159 | + $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000]; |
|
160 | + $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003]; |
|
161 | + $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006]; |
|
162 | + } elseif ($att_key == 999999993) { |
|
163 | + $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001]; |
|
164 | + $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004]; |
|
165 | + $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007]; |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + $this->tickets = $tkts; |
|
171 | + $this->datetimes = $dtts; |
|
172 | + $this->answers = $answers_n_questions['answers']; |
|
173 | + $this->questions = $answers_n_questions['questions']; |
|
174 | + $this->total_ticket_count = count($tkts) * count($this->_attendees); |
|
175 | + |
|
176 | + } |
|
177 | 177 | |
178 | 178 | |
179 | - /** |
|
180 | - * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
181 | - * |
|
182 | - * @access private |
|
183 | - * @return array an array of attendee objects |
|
184 | - */ |
|
185 | - private function _get_some_attendees() |
|
186 | - { |
|
187 | - //let's just setup a dummy array of various attendee details |
|
188 | - $dummy_attendees = array( |
|
189 | - 0 => array( |
|
190 | - 'Luke', |
|
191 | - 'Skywalker', |
|
192 | - '[email protected]', |
|
193 | - '804 Bantha Dr.', |
|
194 | - 'Complex 8', |
|
195 | - 'Mos Eisley', |
|
196 | - 32, |
|
197 | - 'US', |
|
198 | - 'f0r3e', |
|
199 | - '222-333-4763', |
|
200 | - false, |
|
201 | - '999999991' |
|
202 | - ), |
|
203 | - 1 => array( |
|
204 | - 'Princess', |
|
205 | - 'Leia', |
|
206 | - '[email protected]', |
|
207 | - '1456 Valley Way Boulevard', |
|
208 | - 'Suite 9', |
|
209 | - 'Alderaan', |
|
210 | - 15, |
|
211 | - 'US', |
|
212 | - 'c1h2c', |
|
213 | - '78-123-111-1111', |
|
214 | - false, |
|
215 | - '999999992' |
|
216 | - ), |
|
217 | - 2 => array( |
|
218 | - 'Yoda', |
|
219 | - 'I Am', |
|
220 | - '[email protected]', |
|
221 | - '4th Tree', |
|
222 | - '5th Knot', |
|
223 | - 'Marsh', |
|
224 | - 22, |
|
225 | - 'US', |
|
226 | - 'l18n', |
|
227 | - '999-999-9999', |
|
228 | - false, |
|
229 | - '999999993' |
|
230 | - ), |
|
231 | - ); |
|
232 | - |
|
233 | - //let's generate the attendee objects |
|
234 | - $attendees = array(); |
|
235 | - $var_array = array( |
|
236 | - 'fname', |
|
237 | - 'lname', |
|
238 | - 'email', |
|
239 | - 'address', |
|
240 | - 'address2', |
|
241 | - 'city', |
|
242 | - 'staid', |
|
243 | - 'cntry', |
|
244 | - 'zip', |
|
245 | - 'phone', |
|
246 | - 'deleted', |
|
247 | - 'attid' |
|
248 | - ); |
|
249 | - |
|
250 | - //EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
251 | - foreach ($dummy_attendees as $dummy) { |
|
252 | - $att = array_combine($var_array, $dummy); |
|
253 | - extract($att); |
|
254 | - /** @var $fname string */ |
|
255 | - /** @var $lname string */ |
|
256 | - /** @var $address string */ |
|
257 | - /** @var $address2 string */ |
|
258 | - /** @var $city string */ |
|
259 | - /** @var $staid string */ |
|
260 | - /** @var $cntry string */ |
|
261 | - /** @var $zip string */ |
|
262 | - /** @var $email string */ |
|
263 | - /** @var $phone string */ |
|
264 | - /** @var $attid string */ |
|
265 | - $attendees[$attid] = EE_Attendee::new_instance( |
|
266 | - array( |
|
267 | - 'ATT_fname' => $fname, |
|
268 | - 'ATT_lname' => $lname, |
|
269 | - 'ATT_address' => $address, |
|
270 | - 'ATT_address2' => $address2, |
|
271 | - 'ATT_city' => $city, |
|
272 | - 'STA_ID' => $staid, |
|
273 | - 'CNT_ISO' => $cntry, |
|
274 | - 'ATT_zip' => $zip, |
|
275 | - 'ATT_email' => $email, |
|
276 | - 'ATT_phone' => $phone, |
|
277 | - 'ATT_ID' => $attid |
|
278 | - ) |
|
279 | - ); |
|
280 | - } |
|
281 | - |
|
282 | - return $attendees; |
|
283 | - } |
|
179 | + /** |
|
180 | + * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data |
|
181 | + * |
|
182 | + * @access private |
|
183 | + * @return array an array of attendee objects |
|
184 | + */ |
|
185 | + private function _get_some_attendees() |
|
186 | + { |
|
187 | + //let's just setup a dummy array of various attendee details |
|
188 | + $dummy_attendees = array( |
|
189 | + 0 => array( |
|
190 | + 'Luke', |
|
191 | + 'Skywalker', |
|
192 | + '[email protected]', |
|
193 | + '804 Bantha Dr.', |
|
194 | + 'Complex 8', |
|
195 | + 'Mos Eisley', |
|
196 | + 32, |
|
197 | + 'US', |
|
198 | + 'f0r3e', |
|
199 | + '222-333-4763', |
|
200 | + false, |
|
201 | + '999999991' |
|
202 | + ), |
|
203 | + 1 => array( |
|
204 | + 'Princess', |
|
205 | + 'Leia', |
|
206 | + '[email protected]', |
|
207 | + '1456 Valley Way Boulevard', |
|
208 | + 'Suite 9', |
|
209 | + 'Alderaan', |
|
210 | + 15, |
|
211 | + 'US', |
|
212 | + 'c1h2c', |
|
213 | + '78-123-111-1111', |
|
214 | + false, |
|
215 | + '999999992' |
|
216 | + ), |
|
217 | + 2 => array( |
|
218 | + 'Yoda', |
|
219 | + 'I Am', |
|
220 | + '[email protected]', |
|
221 | + '4th Tree', |
|
222 | + '5th Knot', |
|
223 | + 'Marsh', |
|
224 | + 22, |
|
225 | + 'US', |
|
226 | + 'l18n', |
|
227 | + '999-999-9999', |
|
228 | + false, |
|
229 | + '999999993' |
|
230 | + ), |
|
231 | + ); |
|
232 | + |
|
233 | + //let's generate the attendee objects |
|
234 | + $attendees = array(); |
|
235 | + $var_array = array( |
|
236 | + 'fname', |
|
237 | + 'lname', |
|
238 | + 'email', |
|
239 | + 'address', |
|
240 | + 'address2', |
|
241 | + 'city', |
|
242 | + 'staid', |
|
243 | + 'cntry', |
|
244 | + 'zip', |
|
245 | + 'phone', |
|
246 | + 'deleted', |
|
247 | + 'attid' |
|
248 | + ); |
|
249 | + |
|
250 | + //EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE ); |
|
251 | + foreach ($dummy_attendees as $dummy) { |
|
252 | + $att = array_combine($var_array, $dummy); |
|
253 | + extract($att); |
|
254 | + /** @var $fname string */ |
|
255 | + /** @var $lname string */ |
|
256 | + /** @var $address string */ |
|
257 | + /** @var $address2 string */ |
|
258 | + /** @var $city string */ |
|
259 | + /** @var $staid string */ |
|
260 | + /** @var $cntry string */ |
|
261 | + /** @var $zip string */ |
|
262 | + /** @var $email string */ |
|
263 | + /** @var $phone string */ |
|
264 | + /** @var $attid string */ |
|
265 | + $attendees[$attid] = EE_Attendee::new_instance( |
|
266 | + array( |
|
267 | + 'ATT_fname' => $fname, |
|
268 | + 'ATT_lname' => $lname, |
|
269 | + 'ATT_address' => $address, |
|
270 | + 'ATT_address2' => $address2, |
|
271 | + 'ATT_city' => $city, |
|
272 | + 'STA_ID' => $staid, |
|
273 | + 'CNT_ISO' => $cntry, |
|
274 | + 'ATT_zip' => $zip, |
|
275 | + 'ATT_email' => $email, |
|
276 | + 'ATT_phone' => $phone, |
|
277 | + 'ATT_ID' => $attid |
|
278 | + ) |
|
279 | + ); |
|
280 | + } |
|
281 | + |
|
282 | + return $attendees; |
|
283 | + } |
|
284 | 284 | |
285 | 285 | |
286 | - /** |
|
287 | - * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
288 | - * This will be used in our dummy data setup |
|
289 | - * @return array |
|
290 | - */ |
|
291 | - private function _get_some_q_and_as() |
|
292 | - { |
|
293 | - |
|
294 | - |
|
295 | - $quests_array = array( |
|
296 | - 0 => array( |
|
297 | - 555, |
|
298 | - __('What is your favorite planet?', 'event_espresso'), |
|
299 | - 0 |
|
300 | - ), |
|
301 | - 1 => array( |
|
302 | - 556, |
|
303 | - __('What is your favorite food?', 'event_espresso'), |
|
304 | - 0 |
|
305 | - ), |
|
306 | - 2 => array( |
|
307 | - 557, |
|
308 | - __('How many lightyears have you travelled', 'event_espresso'), |
|
309 | - 0 |
|
310 | - ) |
|
311 | - ); |
|
312 | - |
|
313 | - |
|
314 | - $ans_array = array( |
|
315 | - 0 => array( |
|
316 | - 999, |
|
317 | - 555, |
|
318 | - 'Tattoine' |
|
319 | - ), |
|
320 | - 1 => array( |
|
321 | - 1000, |
|
322 | - 555, |
|
323 | - 'Alderaan' |
|
324 | - ), |
|
325 | - 2 => array( |
|
326 | - 1001, |
|
327 | - 555, |
|
328 | - 'Dantooine' |
|
329 | - ), |
|
330 | - 3 => array( |
|
331 | - 1002, |
|
332 | - 556, |
|
333 | - 'Fish Fingers' |
|
334 | - ), |
|
335 | - 4 => array( |
|
336 | - 1003, |
|
337 | - 556, |
|
338 | - 'Sushi' |
|
339 | - ), |
|
340 | - 5 => array( |
|
341 | - 1004, |
|
342 | - 556, |
|
343 | - 'Water' |
|
344 | - ), |
|
345 | - 6 => array( |
|
346 | - 1005, |
|
347 | - 557, |
|
348 | - 'A lot', |
|
349 | - ), |
|
350 | - 7 => array( |
|
351 | - 1006, |
|
352 | - 557, |
|
353 | - "That's none of your business." |
|
354 | - ), |
|
355 | - 8 => array( |
|
356 | - 1007, |
|
357 | - 557, |
|
358 | - "People less travel me then." |
|
359 | - ) |
|
360 | - ); |
|
361 | - |
|
362 | - $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
363 | - $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
364 | - |
|
365 | - //EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
366 | - //EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
367 | - |
|
368 | - $qsts = array(); |
|
369 | - //first the questions |
|
370 | - foreach ($quests_array as $qst) { |
|
371 | - $qstobj = array_combine($qst_columns, $qst); |
|
372 | - $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj); |
|
373 | - } |
|
374 | - |
|
375 | - //now the answers (and we'll setup our arrays) |
|
376 | - $q_n_as = array(); |
|
377 | - foreach ($ans_array as $ans) { |
|
378 | - $ansobj = array_combine($ans_columns, $ans); |
|
379 | - $ansobj = EE_Answer::new_instance($ansobj); |
|
380 | - $q_n_as['answers'][$ansobj->ID()] = $ansobj; |
|
381 | - $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')]; |
|
382 | - } |
|
383 | - |
|
384 | - return $q_n_as; |
|
385 | - |
|
386 | - } |
|
286 | + /** |
|
287 | + * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id. |
|
288 | + * This will be used in our dummy data setup |
|
289 | + * @return array |
|
290 | + */ |
|
291 | + private function _get_some_q_and_as() |
|
292 | + { |
|
293 | + |
|
294 | + |
|
295 | + $quests_array = array( |
|
296 | + 0 => array( |
|
297 | + 555, |
|
298 | + __('What is your favorite planet?', 'event_espresso'), |
|
299 | + 0 |
|
300 | + ), |
|
301 | + 1 => array( |
|
302 | + 556, |
|
303 | + __('What is your favorite food?', 'event_espresso'), |
|
304 | + 0 |
|
305 | + ), |
|
306 | + 2 => array( |
|
307 | + 557, |
|
308 | + __('How many lightyears have you travelled', 'event_espresso'), |
|
309 | + 0 |
|
310 | + ) |
|
311 | + ); |
|
312 | + |
|
313 | + |
|
314 | + $ans_array = array( |
|
315 | + 0 => array( |
|
316 | + 999, |
|
317 | + 555, |
|
318 | + 'Tattoine' |
|
319 | + ), |
|
320 | + 1 => array( |
|
321 | + 1000, |
|
322 | + 555, |
|
323 | + 'Alderaan' |
|
324 | + ), |
|
325 | + 2 => array( |
|
326 | + 1001, |
|
327 | + 555, |
|
328 | + 'Dantooine' |
|
329 | + ), |
|
330 | + 3 => array( |
|
331 | + 1002, |
|
332 | + 556, |
|
333 | + 'Fish Fingers' |
|
334 | + ), |
|
335 | + 4 => array( |
|
336 | + 1003, |
|
337 | + 556, |
|
338 | + 'Sushi' |
|
339 | + ), |
|
340 | + 5 => array( |
|
341 | + 1004, |
|
342 | + 556, |
|
343 | + 'Water' |
|
344 | + ), |
|
345 | + 6 => array( |
|
346 | + 1005, |
|
347 | + 557, |
|
348 | + 'A lot', |
|
349 | + ), |
|
350 | + 7 => array( |
|
351 | + 1006, |
|
352 | + 557, |
|
353 | + "That's none of your business." |
|
354 | + ), |
|
355 | + 8 => array( |
|
356 | + 1007, |
|
357 | + 557, |
|
358 | + "People less travel me then." |
|
359 | + ) |
|
360 | + ); |
|
361 | + |
|
362 | + $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system'); |
|
363 | + $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value'); |
|
364 | + |
|
365 | + //EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE ); |
|
366 | + //EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE ); |
|
367 | + |
|
368 | + $qsts = array(); |
|
369 | + //first the questions |
|
370 | + foreach ($quests_array as $qst) { |
|
371 | + $qstobj = array_combine($qst_columns, $qst); |
|
372 | + $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj); |
|
373 | + } |
|
374 | + |
|
375 | + //now the answers (and we'll setup our arrays) |
|
376 | + $q_n_as = array(); |
|
377 | + foreach ($ans_array as $ans) { |
|
378 | + $ansobj = array_combine($ans_columns, $ans); |
|
379 | + $ansobj = EE_Answer::new_instance($ansobj); |
|
380 | + $q_n_as['answers'][$ansobj->ID()] = $ansobj; |
|
381 | + $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')]; |
|
382 | + } |
|
383 | + |
|
384 | + return $q_n_as; |
|
385 | + |
|
386 | + } |
|
387 | 387 | |
388 | 388 | |
389 | - /** |
|
390 | - * Return an array of event objects from the database |
|
391 | - * |
|
392 | - * If event ids are not included then we'll just retrieve the first published event from the database. |
|
393 | - * |
|
394 | - * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
395 | - * |
|
396 | - * @return array An array of event objects from the db. |
|
397 | - */ |
|
398 | - private function _get_some_events($event_ids = array()) |
|
399 | - { |
|
400 | - |
|
401 | - //HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
|
402 | - $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
403 | - ? array($_REQUEST['evt_id']) |
|
404 | - : $event_ids; |
|
405 | - |
|
406 | - $limit = ! empty($event_ids) |
|
407 | - ? null |
|
408 | - : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
409 | - |
|
410 | - $where = ! empty($event_ids) |
|
411 | - ? array( |
|
412 | - 'EVT_ID' => array('IN', $event_ids), |
|
413 | - 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
414 | - ) |
|
415 | - : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
416 | - |
|
417 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
418 | - |
|
419 | - return $events; |
|
420 | - } |
|
389 | + /** |
|
390 | + * Return an array of event objects from the database |
|
391 | + * |
|
392 | + * If event ids are not included then we'll just retrieve the first published event from the database. |
|
393 | + * |
|
394 | + * @param array $event_ids if set, this will be an array of event ids to obtain events for. |
|
395 | + * |
|
396 | + * @return array An array of event objects from the db. |
|
397 | + */ |
|
398 | + private function _get_some_events($event_ids = array()) |
|
399 | + { |
|
400 | + |
|
401 | + //HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed); |
|
402 | + $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id']) |
|
403 | + ? array($_REQUEST['evt_id']) |
|
404 | + : $event_ids; |
|
405 | + |
|
406 | + $limit = ! empty($event_ids) |
|
407 | + ? null |
|
408 | + : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1'); |
|
409 | + |
|
410 | + $where = ! empty($event_ids) |
|
411 | + ? array( |
|
412 | + 'EVT_ID' => array('IN', $event_ids), |
|
413 | + 'Datetime.Ticket.TKT_ID' => array('>', 1) |
|
414 | + ) |
|
415 | + : array('Datetime.Ticket.TKT_ID' => array('>', 1)); |
|
416 | + |
|
417 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit)); |
|
418 | + |
|
419 | + return $events; |
|
420 | + } |
|
421 | 421 | |
422 | 422 | |
423 | - protected function _setup_data() |
|
424 | - { |
|
425 | - |
|
426 | - //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
427 | - if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
428 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
429 | - $session = EE_Registry::instance()->SSN; |
|
430 | - } else { |
|
431 | - $session = EE_Registry::instance()->load_core('Session'); |
|
432 | - } |
|
433 | - $cart = EE_Cart::instance(null, $session); |
|
434 | - |
|
435 | - |
|
436 | - //add tickets to cart |
|
437 | - foreach ($this->tickets as $ticket) { |
|
438 | - $cart->add_ticket_to_cart($ticket['ticket']); |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - //setup txn property |
|
443 | - $this->txn = EE_Transaction::new_instance( |
|
444 | - array( |
|
445 | - 'TXN_timestamp' => time(), //unix timestamp |
|
446 | - 'TXN_total' => 0, //txn_total |
|
447 | - 'TXN_paid' => 0, //txn_paid |
|
448 | - 'STS_ID' => EEM_Transaction::incomplete_status_code, //sts_id |
|
449 | - 'TXN_session_data' => null, //dump of txn session object (we're just going to leave blank here) |
|
450 | - 'TXN_hash_salt' => null, //hash salt blank as well |
|
451 | - 'TXN_ID' => 999999 |
|
452 | - ) |
|
453 | - ); |
|
454 | - |
|
455 | - |
|
456 | - //setup reg_objects |
|
457 | - //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
458 | - $this->reg_objs = array(); |
|
459 | - $regid = 9999990; |
|
460 | - foreach ($this->_attendees as $key => $attendee) { |
|
461 | - //note we need to setup reg_objects for each event this attendee belongs to |
|
462 | - $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
463 | - $regtxn = $this->txn->ID(); |
|
464 | - $regcnt = 1; |
|
465 | - foreach ($attendee['line_ref'] as $evtid) { |
|
466 | - foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) { |
|
467 | - if ( ! $ticket instanceof EE_Ticket) { |
|
468 | - continue; |
|
469 | - } |
|
470 | - $reg_array = array( |
|
471 | - 'EVT_ID' => $evtid, |
|
472 | - 'ATT_ID' => $regatt, |
|
473 | - 'TXN_ID' => $regtxn, |
|
474 | - 'TKT_ID' => $ticket->ID(), |
|
475 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
476 | - 'REG_date' => time(), |
|
477 | - 'REG_final_price' => $ticket->get('TKT_price'), |
|
478 | - 'REG_session' => 'dummy_session_id', |
|
479 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
480 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
481 | - 'REG_count' => $regcnt, |
|
482 | - 'REG_group_size' => $this->_events[$evtid]['total_attendees'], |
|
483 | - 'REG_att_is_going' => true, |
|
484 | - 'REG_ID' => $regid |
|
485 | - ); |
|
486 | - $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
487 | - $this->_attendees[$key]['reg_objs'][$regid] = $REG_OBJ; |
|
488 | - $this->_events[$evtid]['reg_objs'][] = $REG_OBJ; |
|
489 | - $this->reg_objs[] = $REG_OBJ; |
|
490 | - $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ; |
|
423 | + protected function _setup_data() |
|
424 | + { |
|
425 | + |
|
426 | + //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it! |
|
427 | + if (EE_Registry::instance()->SSN instanceof EE_Session) { |
|
428 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
429 | + $session = EE_Registry::instance()->SSN; |
|
430 | + } else { |
|
431 | + $session = EE_Registry::instance()->load_core('Session'); |
|
432 | + } |
|
433 | + $cart = EE_Cart::instance(null, $session); |
|
434 | + |
|
435 | + |
|
436 | + //add tickets to cart |
|
437 | + foreach ($this->tickets as $ticket) { |
|
438 | + $cart->add_ticket_to_cart($ticket['ticket']); |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + //setup txn property |
|
443 | + $this->txn = EE_Transaction::new_instance( |
|
444 | + array( |
|
445 | + 'TXN_timestamp' => time(), //unix timestamp |
|
446 | + 'TXN_total' => 0, //txn_total |
|
447 | + 'TXN_paid' => 0, //txn_paid |
|
448 | + 'STS_ID' => EEM_Transaction::incomplete_status_code, //sts_id |
|
449 | + 'TXN_session_data' => null, //dump of txn session object (we're just going to leave blank here) |
|
450 | + 'TXN_hash_salt' => null, //hash salt blank as well |
|
451 | + 'TXN_ID' => 999999 |
|
452 | + ) |
|
453 | + ); |
|
454 | + |
|
455 | + |
|
456 | + //setup reg_objects |
|
457 | + //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array. |
|
458 | + $this->reg_objs = array(); |
|
459 | + $regid = 9999990; |
|
460 | + foreach ($this->_attendees as $key => $attendee) { |
|
461 | + //note we need to setup reg_objects for each event this attendee belongs to |
|
462 | + $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null; |
|
463 | + $regtxn = $this->txn->ID(); |
|
464 | + $regcnt = 1; |
|
465 | + foreach ($attendee['line_ref'] as $evtid) { |
|
466 | + foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) { |
|
467 | + if ( ! $ticket instanceof EE_Ticket) { |
|
468 | + continue; |
|
469 | + } |
|
470 | + $reg_array = array( |
|
471 | + 'EVT_ID' => $evtid, |
|
472 | + 'ATT_ID' => $regatt, |
|
473 | + 'TXN_ID' => $regtxn, |
|
474 | + 'TKT_ID' => $ticket->ID(), |
|
475 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
476 | + 'REG_date' => time(), |
|
477 | + 'REG_final_price' => $ticket->get('TKT_price'), |
|
478 | + 'REG_session' => 'dummy_session_id', |
|
479 | + 'REG_code' => $regid . '-dummy-generated-code', |
|
480 | + 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
481 | + 'REG_count' => $regcnt, |
|
482 | + 'REG_group_size' => $this->_events[$evtid]['total_attendees'], |
|
483 | + 'REG_att_is_going' => true, |
|
484 | + 'REG_ID' => $regid |
|
485 | + ); |
|
486 | + $REG_OBJ = EE_Registration::new_instance($reg_array); |
|
487 | + $this->_attendees[$key]['reg_objs'][$regid] = $REG_OBJ; |
|
488 | + $this->_events[$evtid]['reg_objs'][] = $REG_OBJ; |
|
489 | + $this->reg_objs[] = $REG_OBJ; |
|
490 | + $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ; |
|
491 | 491 | |
492 | - $regcnt++; |
|
493 | - $regid++; |
|
494 | - } |
|
495 | - } |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - //setup line items! |
|
500 | - $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
501 | - |
|
502 | - //add tickets |
|
503 | - foreach ($this->tickets as $tktid => $item) { |
|
504 | - $qty = $item['count']; |
|
505 | - $ticket = $item['ticket']; |
|
506 | - EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
507 | - } |
|
508 | - |
|
509 | - $shipping_line_item = EE_Line_Item::new_instance(array( |
|
510 | - 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
511 | - 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
512 | - 'LIN_unit_price' => 20, |
|
513 | - 'LIN_quantity' => 1, |
|
514 | - 'LIN_is_taxable' => true, |
|
515 | - 'LIN_total' => 20, |
|
516 | - 'LIN_type' => EEM_Line_Item::type_line_item |
|
517 | - )); |
|
518 | - EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
519 | - $this->additional_line_items = array($shipping_line_item); |
|
520 | - |
|
521 | - //now let's add taxes |
|
522 | - EEH_Line_Item::apply_taxes($line_item_total); |
|
523 | - |
|
524 | - //now we should be able to get the items we need from this object |
|
525 | - $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
526 | - $line_items = array(); |
|
527 | - foreach ($event_line_items as $line_id => $line_item) { |
|
528 | - if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
529 | - continue; |
|
530 | - } |
|
531 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
532 | - foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
533 | - if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
534 | - continue; |
|
535 | - } |
|
536 | - $this->tickets[$ticket_line_item->OBJ_ID()]['line_item'] = $ticket_line_item; |
|
537 | - $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children(); |
|
538 | - $line_items[$ticket_line_item->ID()]['children'] = $ticket_line_item->children(); |
|
539 | - $line_items[$ticket_line_item->ID()]['EE_Ticket'] = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket']; |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - $this->line_items_with_children = $line_items; |
|
544 | - $this->tax_line_items = $line_item_total->tax_descendants(); |
|
545 | - |
|
546 | - //add proper total to transaction object. |
|
547 | - $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
548 | - $this->grand_total_line_item = $line_item_total; |
|
549 | - $this->txn->set_total($grand_total); |
|
550 | - |
|
551 | - |
|
552 | - //add additional details for each registration |
|
553 | - foreach ($this->reg_objs as $reg) { |
|
554 | - if ( ! $reg instanceof EE_Registration) { |
|
555 | - continue; |
|
556 | - } |
|
557 | - $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket']; |
|
558 | - $this->_registrations[$reg->ID()]['evt_obj'] = $this->_events[$reg->get('EVT_ID')]['event']; |
|
559 | - $this->_registrations[$reg->ID()]['reg_obj'] = $reg; |
|
560 | - $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs']; |
|
561 | - $this->_registrations[$reg->ID()]['att_obj'] = $this->_attendees[$reg->get('ATT_ID')]['att_obj']; |
|
562 | - $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs']; |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - //events and attendees |
|
567 | - $this->events = $this->_events; |
|
568 | - $this->attendees = $this->_attendees; |
|
569 | - $this->registrations = $this->_registrations; |
|
570 | - |
|
571 | - $attendees_to_shift = $this->_attendees; |
|
572 | - |
|
573 | - //setup primary attendee property |
|
574 | - $this->primary_attendee_data = array( |
|
575 | - 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
576 | - ? $this->_attendees[999999991]['att_obj']->fname() |
|
577 | - : '', |
|
492 | + $regcnt++; |
|
493 | + $regid++; |
|
494 | + } |
|
495 | + } |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + //setup line items! |
|
500 | + $line_item_total = EEH_Line_Item::create_total_line_item($this->txn); |
|
501 | + |
|
502 | + //add tickets |
|
503 | + foreach ($this->tickets as $tktid => $item) { |
|
504 | + $qty = $item['count']; |
|
505 | + $ticket = $item['ticket']; |
|
506 | + EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty); |
|
507 | + } |
|
508 | + |
|
509 | + $shipping_line_item = EE_Line_Item::new_instance(array( |
|
510 | + 'LIN_name' => __('Shipping Surcharge', 'event_espresso'), |
|
511 | + 'LIN_desc' => __('Sent via Millenium Falcon', 'event_espresso'), |
|
512 | + 'LIN_unit_price' => 20, |
|
513 | + 'LIN_quantity' => 1, |
|
514 | + 'LIN_is_taxable' => true, |
|
515 | + 'LIN_total' => 20, |
|
516 | + 'LIN_type' => EEM_Line_Item::type_line_item |
|
517 | + )); |
|
518 | + EEH_Line_Item::add_item($line_item_total, $shipping_line_item); |
|
519 | + $this->additional_line_items = array($shipping_line_item); |
|
520 | + |
|
521 | + //now let's add taxes |
|
522 | + EEH_Line_Item::apply_taxes($line_item_total); |
|
523 | + |
|
524 | + //now we should be able to get the items we need from this object |
|
525 | + $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children(); |
|
526 | + $line_items = array(); |
|
527 | + foreach ($event_line_items as $line_id => $line_item) { |
|
528 | + if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') { |
|
529 | + continue; |
|
530 | + } |
|
531 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item); |
|
532 | + foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) { |
|
533 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
534 | + continue; |
|
535 | + } |
|
536 | + $this->tickets[$ticket_line_item->OBJ_ID()]['line_item'] = $ticket_line_item; |
|
537 | + $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children(); |
|
538 | + $line_items[$ticket_line_item->ID()]['children'] = $ticket_line_item->children(); |
|
539 | + $line_items[$ticket_line_item->ID()]['EE_Ticket'] = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket']; |
|
540 | + } |
|
541 | + } |
|
542 | + |
|
543 | + $this->line_items_with_children = $line_items; |
|
544 | + $this->tax_line_items = $line_item_total->tax_descendants(); |
|
545 | + |
|
546 | + //add proper total to transaction object. |
|
547 | + $grand_total = $line_item_total->recalculate_total_including_taxes(); |
|
548 | + $this->grand_total_line_item = $line_item_total; |
|
549 | + $this->txn->set_total($grand_total); |
|
550 | + |
|
551 | + |
|
552 | + //add additional details for each registration |
|
553 | + foreach ($this->reg_objs as $reg) { |
|
554 | + if ( ! $reg instanceof EE_Registration) { |
|
555 | + continue; |
|
556 | + } |
|
557 | + $this->_registrations[$reg->ID()]['tkt_obj'] = $this->tickets[$reg->get('TKT_ID')]['ticket']; |
|
558 | + $this->_registrations[$reg->ID()]['evt_obj'] = $this->_events[$reg->get('EVT_ID')]['event']; |
|
559 | + $this->_registrations[$reg->ID()]['reg_obj'] = $reg; |
|
560 | + $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs']; |
|
561 | + $this->_registrations[$reg->ID()]['att_obj'] = $this->_attendees[$reg->get('ATT_ID')]['att_obj']; |
|
562 | + $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs']; |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + //events and attendees |
|
567 | + $this->events = $this->_events; |
|
568 | + $this->attendees = $this->_attendees; |
|
569 | + $this->registrations = $this->_registrations; |
|
570 | + |
|
571 | + $attendees_to_shift = $this->_attendees; |
|
572 | + |
|
573 | + //setup primary attendee property |
|
574 | + $this->primary_attendee_data = array( |
|
575 | + 'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
576 | + ? $this->_attendees[999999991]['att_obj']->fname() |
|
577 | + : '', |
|
578 | 578 | |
579 | - 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
580 | - ? $this->_attendees[999999991]['att_obj']->lname() |
|
581 | - : '', |
|
579 | + 'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
580 | + ? $this->_attendees[999999991]['att_obj']->lname() |
|
581 | + : '', |
|
582 | 582 | |
583 | - 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
584 | - ? $this->_attendees[999999991]['att_obj']->email() |
|
585 | - : '', |
|
583 | + 'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee |
|
584 | + ? $this->_attendees[999999991]['att_obj']->email() |
|
585 | + : '', |
|
586 | 586 | |
587 | - 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
587 | + 'att_obj' => $this->_attendees[999999991]['att_obj'], |
|
588 | 588 | |
589 | - 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
590 | - ); |
|
589 | + 'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs']) |
|
590 | + ); |
|
591 | 591 | |
592 | - //reg_info property |
|
593 | - //note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
594 | - $this->reg_info = array(); |
|
592 | + //reg_info property |
|
593 | + //note this isn't referenced by any shortcode parsers so we'll ignore for now. |
|
594 | + $this->reg_info = array(); |
|
595 | 595 | |
596 | - //let's set a reg_obj for messengers expecting one. |
|
597 | - $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']); |
|
596 | + //let's set a reg_obj for messengers expecting one. |
|
597 | + $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']); |
|
598 | 598 | |
599 | 599 | |
600 | - //the below are just dummy items. |
|
601 | - $this->user_id = 1; |
|
602 | - $this->ip_address = '192.0.2.1'; |
|
603 | - $this->user_agent = ''; |
|
604 | - $this->init_access = time(); |
|
605 | - $this->last_access = time(); |
|
606 | - } |
|
600 | + //the below are just dummy items. |
|
601 | + $this->user_id = 1; |
|
602 | + $this->ip_address = '192.0.2.1'; |
|
603 | + $this->user_agent = ''; |
|
604 | + $this->init_access = time(); |
|
605 | + $this->last_access = time(); |
|
606 | + } |
|
607 | 607 | |
608 | 608 | } //end EE_Messages_Preview_incoming_data class |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if ( ! $attendee instanceof EE_Attendee) { |
146 | 146 | continue; |
147 | 147 | } |
148 | - $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for! |
|
148 | + $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for! |
|
149 | 149 | $this->_attendees[$att_key]['evt_objs'][] = $event; |
150 | 150 | $this->_attendees[$att_key]['att_obj'] = $attendee; |
151 | 151 | //$this->_attendees[$att_key]['registration_id'] = 0; |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | if ( ! $ticket instanceof EE_Ticket) { |
468 | 468 | continue; |
469 | 469 | } |
470 | - $reg_array = array( |
|
470 | + $reg_array = array( |
|
471 | 471 | 'EVT_ID' => $evtid, |
472 | 472 | 'ATT_ID' => $regatt, |
473 | 473 | 'TXN_ID' => $regtxn, |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | 'REG_date' => time(), |
477 | 477 | 'REG_final_price' => $ticket->get('TKT_price'), |
478 | 478 | 'REG_session' => 'dummy_session_id', |
479 | - 'REG_code' => $regid . '-dummy-generated-code', |
|
480 | - 'REG_url_link' => $regcnt . '-daafpapasdlfakasdfpqasdfasdf', |
|
479 | + 'REG_code' => $regid.'-dummy-generated-code', |
|
480 | + 'REG_url_link' => $regcnt.'-daafpapasdlfakasdfpqasdfasdf', |
|
481 | 481 | 'REG_count' => $regcnt, |
482 | 482 | 'REG_group_size' => $this->_events[$evtid]['total_attendees'], |
483 | 483 | 'REG_att_is_going' => true, |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('NO direct script access allowed'); |
|
4 | + exit('NO direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -36,80 +36,80 @@ discard block |
||
36 | 36 | { |
37 | 37 | |
38 | 38 | |
39 | - public function __construct() |
|
40 | - { |
|
41 | - parent::__construct(); |
|
42 | - } |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + parent::__construct(); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - protected function _init_props() |
|
46 | - { |
|
47 | - $this->label = __('Questions and Answers Shortcodes', 'event_espresso'); |
|
48 | - $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso'); |
|
49 | - $this->_shortcodes = array( |
|
50 | - '[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant. You place this within the "[attendee_list]" field.', |
|
51 | - 'event_espresso') |
|
52 | - ); |
|
53 | - } |
|
45 | + protected function _init_props() |
|
46 | + { |
|
47 | + $this->label = __('Questions and Answers Shortcodes', 'event_espresso'); |
|
48 | + $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso'); |
|
49 | + $this->_shortcodes = array( |
|
50 | + '[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant. You place this within the "[attendee_list]" field.', |
|
51 | + 'event_espresso') |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - protected function _parser($shortcode) |
|
57 | - { |
|
56 | + protected function _parser($shortcode) |
|
57 | + { |
|
58 | 58 | |
59 | 59 | |
60 | - switch ($shortcode) { |
|
61 | - case '[QUESTION_LIST]' : |
|
62 | - return $this->_get_question_list(); |
|
63 | - break; |
|
64 | - } |
|
60 | + switch ($shortcode) { |
|
61 | + case '[QUESTION_LIST]' : |
|
62 | + return $this->_get_question_list(); |
|
63 | + break; |
|
64 | + } |
|
65 | 65 | |
66 | - return ''; |
|
67 | - } |
|
66 | + return ''; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - protected function _get_question_list() |
|
71 | - { |
|
72 | - $this->_validate_list_requirements(); |
|
70 | + protected function _get_question_list() |
|
71 | + { |
|
72 | + $this->_validate_list_requirements(); |
|
73 | 73 | |
74 | - //for when [QUESTION_LIST] is used in the [attendee_list] field. |
|
75 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
76 | - return $this->_get_question_answer_list_for_attendee(); |
|
77 | - } //for when [QUESTION_LIST] is used in the main content field. |
|
78 | - else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) { |
|
79 | - return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj); |
|
80 | - } else { |
|
81 | - return ''; |
|
82 | - } |
|
83 | - } |
|
74 | + //for when [QUESTION_LIST] is used in the [attendee_list] field. |
|
75 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
76 | + return $this->_get_question_answer_list_for_attendee(); |
|
77 | + } //for when [QUESTION_LIST] is used in the main content field. |
|
78 | + else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) { |
|
79 | + return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj); |
|
80 | + } else { |
|
81 | + return ''; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of |
|
88 | - * answers for that attendee since that is what we really need (we can derive the questions from the answers); |
|
89 | - * @return string parsed template. |
|
90 | - */ |
|
91 | - private function _get_question_answer_list_for_attendee($reg_obj = null) |
|
92 | - { |
|
93 | - $valid_shortcodes = array('question'); |
|
94 | - $reg_obj = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data']; |
|
95 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : ''; |
|
96 | - $template = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template; |
|
97 | - $ans_result = ''; |
|
98 | - $answers = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array(); |
|
99 | - $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array(); |
|
100 | - foreach ($answers as $answer) { |
|
101 | - //first see if the question is in our $questions array. If not then try to get from answer object |
|
102 | - $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null; |
|
103 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
104 | - if ($question instanceof EE_Question and $question->admin_only()) { |
|
105 | - continue; |
|
106 | - } |
|
107 | - $ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes, |
|
108 | - $this->_extra_data); |
|
109 | - } |
|
86 | + /** |
|
87 | + * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of |
|
88 | + * answers for that attendee since that is what we really need (we can derive the questions from the answers); |
|
89 | + * @return string parsed template. |
|
90 | + */ |
|
91 | + private function _get_question_answer_list_for_attendee($reg_obj = null) |
|
92 | + { |
|
93 | + $valid_shortcodes = array('question'); |
|
94 | + $reg_obj = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data']; |
|
95 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : ''; |
|
96 | + $template = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template; |
|
97 | + $ans_result = ''; |
|
98 | + $answers = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array(); |
|
99 | + $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array(); |
|
100 | + foreach ($answers as $answer) { |
|
101 | + //first see if the question is in our $questions array. If not then try to get from answer object |
|
102 | + $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null; |
|
103 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
104 | + if ($question instanceof EE_Question and $question->admin_only()) { |
|
105 | + continue; |
|
106 | + } |
|
107 | + $ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes, |
|
108 | + $this->_extra_data); |
|
109 | + } |
|
110 | 110 | |
111 | - return $ans_result; |
|
112 | - } |
|
111 | + return $ans_result; |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | } //end EE_Question_List_Shortcodes class |
@@ -99,7 +99,7 @@ |
||
99 | 99 | $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array(); |
100 | 100 | foreach ($answers as $answer) { |
101 | 101 | //first see if the question is in our $questions array. If not then try to get from answer object |
102 | - $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null; |
|
102 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
103 | 103 | $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
104 | 104 | if ($question instanceof EE_Question and $question->admin_only()) { |
105 | 105 | continue; |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | |
27 | 27 | <p class="contact-details-buttons"> |
28 | 28 | <?php if ( |
29 | - $att_check instanceof EE_Attendee |
|
30 | - && EE_Registry::instance()->CAP->current_user_can( |
|
31 | - 'ee_edit_contact', |
|
32 | - 'view_or_edit_contact_button', |
|
33 | - $att_check->ID() |
|
34 | - ) |
|
35 | - ) : ?> |
|
29 | + $att_check instanceof EE_Attendee |
|
30 | + && EE_Registry::instance()->CAP->current_user_can( |
|
31 | + 'ee_edit_contact', |
|
32 | + 'view_or_edit_contact_button', |
|
33 | + $att_check->ID() |
|
34 | + ) |
|
35 | + ) : ?> |
|
36 | 36 | <a class="button button-small" href="<?php echo $att_edit_link; ?>" |
37 | 37 | title="<?php echo esc_attr($att_edit_label); ?>"> |
38 | 38 | <span class="ee-icon ee-icon-user-edit"></span><?php echo $att_edit_label; ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | <?php if (! empty($create_link)) : ?> |
41 | 41 | <a class="button button-small" href="<?php echo $create_link; ?>" |
42 | 42 | title="<?php esc_attr_e('This registration shares the contact details for the primary registration in this group. If you\'d like this registration to have its own details, you can do so by clicking this button', |
43 | - 'event_espresso'); ?>"> |
|
43 | + 'event_espresso'); ?>"> |
|
44 | 44 | <span class="ee-icon ee-icon-user-add-new"></span><?php echo $create_label; ?> |
45 | 45 | </a> |
46 | 46 | <?php endif; ?> |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | <p class="clearfix"> |
3 | 3 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left"> |
4 | 4 | <?php _e('Name', 'event_espresso'); ?> |
5 | - </span><?php echo $fname . ' ' . $lname; ?> |
|
5 | + </span><?php echo $fname.' '.$lname; ?> |
|
6 | 6 | </p> |
7 | 7 | <p class="clearfix"> |
8 | 8 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Email', 'event_espresso'); ?></span><a |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | title="<?php echo esc_attr($att_edit_label); ?>"> |
38 | 38 | <span class="ee-icon ee-icon-user-edit"></span><?php echo $att_edit_label; ?> |
39 | 39 | </a> |
40 | - <?php if (! empty($create_link)) : ?> |
|
40 | + <?php if ( ! empty($create_link)) : ?> |
|
41 | 41 | <a class="button button-small" href="<?php echo $create_link; ?>" |
42 | 42 | title="<?php esc_attr_e('This registration shares the contact details for the primary registration in this group. If you\'d like this registration to have its own details, you can do so by clicking this button', |
43 | 43 | 'event_espresso'); ?>"> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -18,130 +18,130 @@ discard block |
||
18 | 18 | class Registration_Form_Question_Groups_Help_Tour extends EE_Help_Tour |
19 | 19 | { |
20 | 20 | |
21 | - protected function _set_tour_properties() |
|
22 | - { |
|
23 | - $this->_label = __('Question Groups Tour', 'event_espresso'); |
|
24 | - $this->_slug = $this->_is_caf ? 'question-groups-caf-overview-joyride' : 'question-groups-overview-joyride'; |
|
25 | - } |
|
21 | + protected function _set_tour_properties() |
|
22 | + { |
|
23 | + $this->_label = __('Question Groups Tour', 'event_espresso'); |
|
24 | + $this->_slug = $this->_is_caf ? 'question-groups-caf-overview-joyride' : 'question-groups-overview-joyride'; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - protected function _set_tour_stops() |
|
29 | - { |
|
30 | - $this->_stops = array( |
|
31 | - 10 => array( |
|
32 | - 'content' => $this->_start(), |
|
33 | - ) |
|
34 | - ); |
|
28 | + protected function _set_tour_stops() |
|
29 | + { |
|
30 | + $this->_stops = array( |
|
31 | + 10 => array( |
|
32 | + 'content' => $this->_start(), |
|
33 | + ) |
|
34 | + ); |
|
35 | 35 | |
36 | - if ($this->_is_caf) { |
|
37 | - $this->_stops[20] = array( |
|
38 | - 'id' => 'name', |
|
39 | - 'content' => $this->_name_stop(), |
|
40 | - 'options' => array( |
|
41 | - 'tipLocation' => 'top', |
|
42 | - 'tipAdjustmentY' => -30, |
|
43 | - 'tipAdjustmentX' => 25 |
|
44 | - ) |
|
45 | - ); |
|
46 | - $this->_stops[30] = array( |
|
47 | - 'id' => 'description', |
|
48 | - 'content' => $this->_description_stop(), |
|
49 | - 'options' => array( |
|
50 | - 'tipLocation' => 'top', |
|
51 | - 'tipAdjustmentY' => -30, |
|
52 | - 'tipAdjustmentX' => 20 |
|
53 | - ) |
|
54 | - ); |
|
55 | - $this->_stops[40] = array( |
|
56 | - 'id' => 'show_group_name', |
|
57 | - 'content' => $this->_show_group_name_stop(), |
|
58 | - 'options' => array( |
|
59 | - 'tipLocation' => 'top', |
|
60 | - 'tipAdjustmentY' => -30, |
|
61 | - 'tipAdjustmentX' => 20 |
|
62 | - ) |
|
63 | - ); |
|
64 | - $this->_stops[50] = array( |
|
65 | - 'id' => 'show_group_desc', |
|
66 | - 'content' => $this->_show_group_description_stop(), |
|
67 | - 'options' => array( |
|
68 | - 'tipLocation' => 'top', |
|
69 | - 'tipAdjustmentY' => -30, |
|
70 | - 'tipAdjustmentX' => 20 |
|
71 | - ) |
|
72 | - ); |
|
73 | - $this->_stops[60] = array( |
|
74 | - 'class' => 'bulkactions', |
|
75 | - 'content' => $this->_bulk_actions_stop(), |
|
76 | - 'options' => array( |
|
77 | - 'tipLocation' => 'left', |
|
78 | - 'tipAdjustmentY' => -50, |
|
79 | - 'tipAdjustmentX' => -80 |
|
80 | - ) |
|
81 | - ); |
|
82 | - $this->_stops[70] = array( |
|
83 | - 'id' => 'add-new-question-group', |
|
84 | - 'content' => $this->_add_new_question_group_stop(), |
|
85 | - 'options' => array( |
|
86 | - 'tipLocation' => 'right', |
|
87 | - 'tipAdjustmentY' => -50, |
|
88 | - 'tipAdjustmentX' => 15 |
|
89 | - ) |
|
90 | - ); |
|
91 | - } |
|
92 | - } |
|
36 | + if ($this->_is_caf) { |
|
37 | + $this->_stops[20] = array( |
|
38 | + 'id' => 'name', |
|
39 | + 'content' => $this->_name_stop(), |
|
40 | + 'options' => array( |
|
41 | + 'tipLocation' => 'top', |
|
42 | + 'tipAdjustmentY' => -30, |
|
43 | + 'tipAdjustmentX' => 25 |
|
44 | + ) |
|
45 | + ); |
|
46 | + $this->_stops[30] = array( |
|
47 | + 'id' => 'description', |
|
48 | + 'content' => $this->_description_stop(), |
|
49 | + 'options' => array( |
|
50 | + 'tipLocation' => 'top', |
|
51 | + 'tipAdjustmentY' => -30, |
|
52 | + 'tipAdjustmentX' => 20 |
|
53 | + ) |
|
54 | + ); |
|
55 | + $this->_stops[40] = array( |
|
56 | + 'id' => 'show_group_name', |
|
57 | + 'content' => $this->_show_group_name_stop(), |
|
58 | + 'options' => array( |
|
59 | + 'tipLocation' => 'top', |
|
60 | + 'tipAdjustmentY' => -30, |
|
61 | + 'tipAdjustmentX' => 20 |
|
62 | + ) |
|
63 | + ); |
|
64 | + $this->_stops[50] = array( |
|
65 | + 'id' => 'show_group_desc', |
|
66 | + 'content' => $this->_show_group_description_stop(), |
|
67 | + 'options' => array( |
|
68 | + 'tipLocation' => 'top', |
|
69 | + 'tipAdjustmentY' => -30, |
|
70 | + 'tipAdjustmentX' => 20 |
|
71 | + ) |
|
72 | + ); |
|
73 | + $this->_stops[60] = array( |
|
74 | + 'class' => 'bulkactions', |
|
75 | + 'content' => $this->_bulk_actions_stop(), |
|
76 | + 'options' => array( |
|
77 | + 'tipLocation' => 'left', |
|
78 | + 'tipAdjustmentY' => -50, |
|
79 | + 'tipAdjustmentX' => -80 |
|
80 | + ) |
|
81 | + ); |
|
82 | + $this->_stops[70] = array( |
|
83 | + 'id' => 'add-new-question-group', |
|
84 | + 'content' => $this->_add_new_question_group_stop(), |
|
85 | + 'options' => array( |
|
86 | + 'tipLocation' => 'right', |
|
87 | + 'tipAdjustmentY' => -50, |
|
88 | + 'tipAdjustmentX' => 15 |
|
89 | + ) |
|
90 | + ); |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - protected function _start() |
|
96 | - { |
|
97 | - $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>'; |
|
98 | - if ($this->_is_caf) { |
|
99 | - $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | - 'event_espresso') . '</p>'; |
|
101 | - } else { |
|
102 | - $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.', |
|
103 | - 'event_espresso') . '</p>'; |
|
104 | - } |
|
95 | + protected function _start() |
|
96 | + { |
|
97 | + $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>'; |
|
98 | + if ($this->_is_caf) { |
|
99 | + $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | + 'event_espresso') . '</p>'; |
|
101 | + } else { |
|
102 | + $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.', |
|
103 | + 'event_espresso') . '</p>'; |
|
104 | + } |
|
105 | 105 | |
106 | - return $content; |
|
107 | - } |
|
106 | + return $content; |
|
107 | + } |
|
108 | 108 | |
109 | - protected function _name_stop() |
|
110 | - { |
|
111 | - return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.', |
|
112 | - 'event_espresso') . '</p>'; |
|
113 | - } |
|
109 | + protected function _name_stop() |
|
110 | + { |
|
111 | + return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.', |
|
112 | + 'event_espresso') . '</p>'; |
|
113 | + } |
|
114 | 114 | |
115 | - protected function _description_stop() |
|
116 | - { |
|
117 | - return '<p>' . __('View the question group description.', 'event_espresso') . '</p>'; |
|
118 | - } |
|
115 | + protected function _description_stop() |
|
116 | + { |
|
117 | + return '<p>' . __('View the question group description.', 'event_espresso') . '</p>'; |
|
118 | + } |
|
119 | 119 | |
120 | - protected function _show_group_name_stop() |
|
121 | - { |
|
122 | - return '<p>' . __('View if the name of the question group should be shown to customers.', |
|
123 | - 'event_espresso') . '</p>'; |
|
124 | - } |
|
120 | + protected function _show_group_name_stop() |
|
121 | + { |
|
122 | + return '<p>' . __('View if the name of the question group should be shown to customers.', |
|
123 | + 'event_espresso') . '</p>'; |
|
124 | + } |
|
125 | 125 | |
126 | - protected function _show_group_description_stop() |
|
127 | - { |
|
128 | - return '<p>' . __('View if the description of the question group should be shown to customers.', |
|
129 | - 'event_espresso') . '</p>'; |
|
130 | - } |
|
126 | + protected function _show_group_description_stop() |
|
127 | + { |
|
128 | + return '<p>' . __('View if the description of the question group should be shown to customers.', |
|
129 | + 'event_espresso') . '</p>'; |
|
130 | + } |
|
131 | 131 | |
132 | - protected function _bulk_actions_stop() |
|
133 | - { |
|
134 | - return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>'; |
|
135 | - } |
|
132 | + protected function _bulk_actions_stop() |
|
133 | + { |
|
134 | + return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>'; |
|
135 | + } |
|
136 | 136 | |
137 | - protected function _search_stop() |
|
138 | - { |
|
139 | - return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.', |
|
140 | - 'event_espresso') . '</p>'; |
|
141 | - } |
|
137 | + protected function _search_stop() |
|
138 | + { |
|
139 | + return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.', |
|
140 | + 'event_espresso') . '</p>'; |
|
141 | + } |
|
142 | 142 | |
143 | - protected function _add_new_question_group_stop() |
|
144 | - { |
|
145 | - return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>'; |
|
146 | - } |
|
143 | + protected function _add_new_question_group_stop() |
|
144 | + { |
|
145 | + return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>'; |
|
146 | + } |
|
147 | 147 | } |
148 | 148 | \ No newline at end of file |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | |
95 | 95 | protected function _start() |
96 | 96 | { |
97 | - $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>'; |
|
97 | + $content = '<h3>'.__('Question Groups', 'event_espresso').'</h3>'; |
|
98 | 98 | if ($this->_is_caf) { |
99 | - $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | - 'event_espresso') . '</p>'; |
|
99 | + $content .= '<p>'.__('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | + 'event_espresso').'</p>'; |
|
101 | 101 | } else { |
102 | - $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.', |
|
103 | - 'event_espresso') . '</p>'; |
|
102 | + $content .= '<p>'.__('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.', |
|
103 | + 'event_espresso').'</p>'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | return $content; |
@@ -108,40 +108,40 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function _name_stop() |
110 | 110 | { |
111 | - return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.', |
|
112 | - 'event_espresso') . '</p>'; |
|
111 | + return '<p>'.__('View available questions groups. You can reorder your questions by dragging and dropping them.', |
|
112 | + 'event_espresso').'</p>'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | protected function _description_stop() |
116 | 116 | { |
117 | - return '<p>' . __('View the question group description.', 'event_espresso') . '</p>'; |
|
117 | + return '<p>'.__('View the question group description.', 'event_espresso').'</p>'; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | protected function _show_group_name_stop() |
121 | 121 | { |
122 | - return '<p>' . __('View if the name of the question group should be shown to customers.', |
|
123 | - 'event_espresso') . '</p>'; |
|
122 | + return '<p>'.__('View if the name of the question group should be shown to customers.', |
|
123 | + 'event_espresso').'</p>'; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | protected function _show_group_description_stop() |
127 | 127 | { |
128 | - return '<p>' . __('View if the description of the question group should be shown to customers.', |
|
129 | - 'event_espresso') . '</p>'; |
|
128 | + return '<p>'.__('View if the description of the question group should be shown to customers.', |
|
129 | + 'event_espresso').'</p>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | protected function _bulk_actions_stop() |
133 | 133 | { |
134 | - return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>'; |
|
134 | + return '<p>'.__('Perform bulk actions to multiple question groups.', 'event_espresso').'</p>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function _search_stop() |
138 | 138 | { |
139 | - return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.', |
|
140 | - 'event_espresso') . '</p>'; |
|
139 | + return '<p>'.__('Search through questions. The following sources will be searched: question group name and question group description.', |
|
140 | + 'event_espresso').'</p>'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | protected function _add_new_question_group_stop() |
144 | 144 | { |
145 | - return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>'; |
|
145 | + return '<p>'.__('Click here to create a new question group.', 'event_espresso').'</p>'; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -18,121 +18,121 @@ discard block |
||
18 | 18 | class Your_Organization_Help_Tour extends EE_Help_Tour |
19 | 19 | { |
20 | 20 | |
21 | - protected function _set_tour_properties() |
|
22 | - { |
|
23 | - $this->_label = __('Your Organization Tour', 'event_espresso'); |
|
24 | - $this->_slug = 'your-organization-joyride'; |
|
25 | - } |
|
21 | + protected function _set_tour_properties() |
|
22 | + { |
|
23 | + $this->_label = __('Your Organization Tour', 'event_espresso'); |
|
24 | + $this->_slug = 'your-organization-joyride'; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - protected function _set_tour_stops() |
|
29 | - { |
|
30 | - $this->_stops = array( |
|
31 | - 10 => array( |
|
32 | - 'content' => $this->_start(), |
|
33 | - ), |
|
34 | - 30 => array( |
|
35 | - 'id' => 'contact_info_h4', |
|
36 | - 'content' => $this->_contact_information_stop(), |
|
37 | - 'options' => array( |
|
38 | - 'tipLocation' => 'left', |
|
39 | - 'tipAdjustmentY' => -50, |
|
40 | - 'tipAdjustmentX' => 15 |
|
41 | - ) |
|
42 | - ), |
|
43 | - 40 => array( |
|
44 | - 'id' => 'upload_image', |
|
45 | - 'content' => $this->_upload_image_stop(), |
|
46 | - 'options' => array( |
|
47 | - 'tipLocation' => 'right', |
|
48 | - 'tipAdjustmentY' => -50, |
|
49 | - 'tipAdjustmentX' => 15 |
|
50 | - ) |
|
51 | - ), |
|
52 | - 50 => array( |
|
53 | - 'id' => 'organization_facebook', |
|
54 | - 'content' => $this->_organization_facebook_stop(), |
|
55 | - 'options' => array( |
|
56 | - 'tipLocation' => 'right', |
|
57 | - 'tipAdjustmentY' => -50, |
|
58 | - 'tipAdjustmentX' => 15 |
|
59 | - ) |
|
60 | - ), |
|
61 | - 60 => array( |
|
62 | - 'id' => 'ueip_optin', |
|
63 | - 'content' => $this->_ueip_option_stop(), |
|
64 | - 'options' => array( |
|
65 | - 'tipLocation' => 'right', |
|
66 | - 'tipAdjustmentY' => -50, |
|
67 | - 'tipAdjustmentX' => 15 |
|
68 | - ) |
|
69 | - ), |
|
70 | - 70 => array( |
|
71 | - 'id' => 'espresso_major_buttons_wrapper', |
|
72 | - 'content' => $this->_end_tour_stop(), |
|
73 | - 'options' => array( |
|
74 | - 'tipLocation' => 'right', |
|
75 | - 'tipAdjustmentY' => -50, |
|
76 | - 'tipAdjustmentX' => 185 |
|
77 | - ) |
|
78 | - ) |
|
79 | - ); |
|
28 | + protected function _set_tour_stops() |
|
29 | + { |
|
30 | + $this->_stops = array( |
|
31 | + 10 => array( |
|
32 | + 'content' => $this->_start(), |
|
33 | + ), |
|
34 | + 30 => array( |
|
35 | + 'id' => 'contact_info_h4', |
|
36 | + 'content' => $this->_contact_information_stop(), |
|
37 | + 'options' => array( |
|
38 | + 'tipLocation' => 'left', |
|
39 | + 'tipAdjustmentY' => -50, |
|
40 | + 'tipAdjustmentX' => 15 |
|
41 | + ) |
|
42 | + ), |
|
43 | + 40 => array( |
|
44 | + 'id' => 'upload_image', |
|
45 | + 'content' => $this->_upload_image_stop(), |
|
46 | + 'options' => array( |
|
47 | + 'tipLocation' => 'right', |
|
48 | + 'tipAdjustmentY' => -50, |
|
49 | + 'tipAdjustmentX' => 15 |
|
50 | + ) |
|
51 | + ), |
|
52 | + 50 => array( |
|
53 | + 'id' => 'organization_facebook', |
|
54 | + 'content' => $this->_organization_facebook_stop(), |
|
55 | + 'options' => array( |
|
56 | + 'tipLocation' => 'right', |
|
57 | + 'tipAdjustmentY' => -50, |
|
58 | + 'tipAdjustmentX' => 15 |
|
59 | + ) |
|
60 | + ), |
|
61 | + 60 => array( |
|
62 | + 'id' => 'ueip_optin', |
|
63 | + 'content' => $this->_ueip_option_stop(), |
|
64 | + 'options' => array( |
|
65 | + 'tipLocation' => 'right', |
|
66 | + 'tipAdjustmentY' => -50, |
|
67 | + 'tipAdjustmentX' => 15 |
|
68 | + ) |
|
69 | + ), |
|
70 | + 70 => array( |
|
71 | + 'id' => 'espresso_major_buttons_wrapper', |
|
72 | + 'content' => $this->_end_tour_stop(), |
|
73 | + 'options' => array( |
|
74 | + 'tipLocation' => 'right', |
|
75 | + 'tipAdjustmentY' => -50, |
|
76 | + 'tipAdjustmentX' => 185 |
|
77 | + ) |
|
78 | + ) |
|
79 | + ); |
|
80 | 80 | |
81 | - if (is_main_site()) { |
|
82 | - $this->_stops[20] = array( |
|
83 | - 'id' => 'site_license_key', |
|
84 | - 'content' => $this->_site_license_key_stop(), |
|
85 | - 'options' => array( |
|
86 | - 'tipLocation' => 'right', |
|
87 | - 'tipAdjustmentY' => -50, |
|
88 | - 'tipAdjustmentX' => 15 |
|
89 | - ) |
|
90 | - ); |
|
91 | - } |
|
92 | - ksort( $this->_stops ); |
|
93 | - } |
|
81 | + if (is_main_site()) { |
|
82 | + $this->_stops[20] = array( |
|
83 | + 'id' => 'site_license_key', |
|
84 | + 'content' => $this->_site_license_key_stop(), |
|
85 | + 'options' => array( |
|
86 | + 'tipLocation' => 'right', |
|
87 | + 'tipAdjustmentY' => -50, |
|
88 | + 'tipAdjustmentX' => 15 |
|
89 | + ) |
|
90 | + ); |
|
91 | + } |
|
92 | + ksort( $this->_stops ); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - protected function _start() |
|
97 | - { |
|
98 | - $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>'; |
|
99 | - $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | - 'event_espresso') . '</p>'; |
|
96 | + protected function _start() |
|
97 | + { |
|
98 | + $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>'; |
|
99 | + $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | + 'event_espresso') . '</p>'; |
|
101 | 101 | |
102 | - return $content; |
|
103 | - } |
|
102 | + return $content; |
|
103 | + } |
|
104 | 104 | |
105 | - protected function _site_license_key_stop() |
|
106 | - { |
|
107 | - return '<p>' . __('Enter your support license key here to enable one-click updates.', |
|
108 | - 'event_espresso') . '</p>'; |
|
109 | - } |
|
105 | + protected function _site_license_key_stop() |
|
106 | + { |
|
107 | + return '<p>' . __('Enter your support license key here to enable one-click updates.', |
|
108 | + 'event_espresso') . '</p>'; |
|
109 | + } |
|
110 | 110 | |
111 | - protected function _contact_information_stop() |
|
112 | - { |
|
113 | - return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.', |
|
114 | - 'event_espresso') . '</p>'; |
|
115 | - } |
|
111 | + protected function _contact_information_stop() |
|
112 | + { |
|
113 | + return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.', |
|
114 | + 'event_espresso') . '</p>'; |
|
115 | + } |
|
116 | 116 | |
117 | - protected function _upload_image_stop() |
|
118 | - { |
|
119 | - return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>'; |
|
120 | - } |
|
117 | + protected function _upload_image_stop() |
|
118 | + { |
|
119 | + return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>'; |
|
120 | + } |
|
121 | 121 | |
122 | - protected function _organization_facebook_stop() |
|
123 | - { |
|
124 | - return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>'; |
|
125 | - } |
|
122 | + protected function _organization_facebook_stop() |
|
123 | + { |
|
124 | + return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>'; |
|
125 | + } |
|
126 | 126 | |
127 | - protected function _ueip_option_stop() |
|
128 | - { |
|
129 | - return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.', |
|
130 | - 'event_espresso') . '</p>'; |
|
131 | - } |
|
127 | + protected function _ueip_option_stop() |
|
128 | + { |
|
129 | + return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.', |
|
130 | + 'event_espresso') . '</p>'; |
|
131 | + } |
|
132 | 132 | |
133 | - protected function _end_tour_stop() |
|
134 | - { |
|
135 | - return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.', |
|
136 | - 'event_espresso') . '</p>'; |
|
137 | - } |
|
133 | + protected function _end_tour_stop() |
|
134 | + { |
|
135 | + return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.', |
|
136 | + 'event_espresso') . '</p>'; |
|
137 | + } |
|
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -89,50 +89,50 @@ |
||
89 | 89 | ) |
90 | 90 | ); |
91 | 91 | } |
92 | - ksort( $this->_stops ); |
|
92 | + ksort($this->_stops); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | protected function _start() |
97 | 97 | { |
98 | - $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>'; |
|
99 | - $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | - 'event_espresso') . '</p>'; |
|
98 | + $content = '<h3>'.__('Organization Settings', 'event_espresso').'</h3>'; |
|
99 | + $content .= '<p>'.__('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.', |
|
100 | + 'event_espresso').'</p>'; |
|
101 | 101 | |
102 | 102 | return $content; |
103 | 103 | } |
104 | 104 | |
105 | 105 | protected function _site_license_key_stop() |
106 | 106 | { |
107 | - return '<p>' . __('Enter your support license key here to enable one-click updates.', |
|
108 | - 'event_espresso') . '</p>'; |
|
107 | + return '<p>'.__('Enter your support license key here to enable one-click updates.', |
|
108 | + 'event_espresso').'</p>'; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | protected function _contact_information_stop() |
112 | 112 | { |
113 | - return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.', |
|
114 | - 'event_espresso') . '</p>'; |
|
113 | + return '<p>'.__('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.', |
|
114 | + 'event_espresso').'</p>'; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | protected function _upload_image_stop() |
118 | 118 | { |
119 | - return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>'; |
|
119 | + return '<p>'.__('Add a logo. This can be used for invoices and tickets.', 'event_espresso').'</p>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | protected function _organization_facebook_stop() |
123 | 123 | { |
124 | - return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>'; |
|
124 | + return '<p>'.__('Add links to various social media networks.', 'event_espresso').'</p>'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function _ueip_option_stop() |
128 | 128 | { |
129 | - return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.', |
|
130 | - 'event_espresso') . '</p>'; |
|
129 | + return '<p>'.__('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.', |
|
130 | + 'event_espresso').'</p>'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | protected function _end_tour_stop() |
134 | 134 | { |
135 | - return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.', |
|
136 | - 'event_espresso') . '</p>'; |
|
135 | + return '<p>'.__('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.', |
|
136 | + 'event_espresso').'</p>'; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | <span class="dashicons dashicons-admin-tools"></span> |
27 | 27 | <?php esc_html_e("Migration Options", "event_espresso"); ?> |
28 | 28 | <span class="tiny-text lt-grey-text"> <?php esc_html_e(' to migrate or not to migrate?', |
29 | - "event_espresso"); ?></span> |
|
29 | + "event_espresso"); ?></span> |
|
30 | 30 | </h2> |
31 | 31 | <div class="ee-table-wrap"> |
32 | 32 | <table> |
@@ -35,24 +35,24 @@ discard block |
||
35 | 35 | <td><h3><?php esc_html_e('1', 'event_espresso'); ?></h3></td> |
36 | 36 | <td> |
37 | 37 | <?php |
38 | - echo apply_filters( |
|
39 | - 'FHEE__ee_migration_page__option_1_main', |
|
40 | - sprintf( |
|
41 | - esc_html__('%1$sYes. I have backed up my database%2$s, %3$sunderstand the risks involved%4$s, and am ready to migrate my existing %5$s data to %6$s.', |
|
42 | - "event_espresso"), |
|
43 | - '<strong>', |
|
44 | - '</strong>', |
|
45 | - '<a id="migration-risks" class="" title="' |
|
46 | - . esc_attr__('click for more details', "event_espresso") |
|
47 | - . '">', |
|
48 | - '</a>', |
|
49 | - $current_db_state, |
|
50 | - $next_db_state |
|
51 | - ), |
|
52 | - $current_db_state, |
|
53 | - $next_db_state |
|
54 | - ); |
|
55 | - ?> |
|
38 | + echo apply_filters( |
|
39 | + 'FHEE__ee_migration_page__option_1_main', |
|
40 | + sprintf( |
|
41 | + esc_html__('%1$sYes. I have backed up my database%2$s, %3$sunderstand the risks involved%4$s, and am ready to migrate my existing %5$s data to %6$s.', |
|
42 | + "event_espresso"), |
|
43 | + '<strong>', |
|
44 | + '</strong>', |
|
45 | + '<a id="migration-risks" class="" title="' |
|
46 | + . esc_attr__('click for more details', "event_espresso") |
|
47 | + . '">', |
|
48 | + '</a>', |
|
49 | + $current_db_state, |
|
50 | + $next_db_state |
|
51 | + ), |
|
52 | + $current_db_state, |
|
53 | + $next_db_state |
|
54 | + ); |
|
55 | + ?> |
|
56 | 56 | <a id="display-migration-details" |
57 | 57 | class="display-the-hidden lt-grey-text smaller-text hide-if-no-js" |
58 | 58 | rel="migration-details"><?php esc_html_e('click for more details', "event_espresso"); ?> |
@@ -61,37 +61,37 @@ discard block |
||
61 | 61 | class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js" |
62 | 62 | rel="migration-details" |
63 | 63 | style="display:none;"><?php echo sprintf(esc_html__('hide%1$sdetails%1$s-', |
64 | - 'event_espresso'), ' '); ?></a> |
|
64 | + 'event_espresso'), ' '); ?></a> |
|
65 | 65 | </td> |
66 | 66 | <td> |
67 | 67 | <a id="db-backed-up" |
68 | 68 | class="toggle-migration-monitor button-primary"><?php echo apply_filters('FHEE__ee_migration_page__option_1_button_text', |
69 | - sprintf(esc_html__("Migrate My %s Data to %s", "event_espresso"), $current_db_state, |
|
70 | - $next_db_state), $current_db_state, $next_db_state); ?></a> |
|
69 | + sprintf(esc_html__("Migrate My %s Data to %s", "event_espresso"), $current_db_state, |
|
70 | + $next_db_state), $current_db_state, $next_db_state); ?></a> |
|
71 | 71 | </td> |
72 | 72 | </tr> |
73 | 73 | <tr> |
74 | 74 | <td colspan="3" style="padding: 0"> |
75 | 75 | <div id="migration-details-dv" style="display: none; padding: 1em;"> |
76 | 76 | <span class="reminder-spn"><?php printf(esc_html__("%s Important: %s Before migrating, please back up your database and files.", |
77 | - "event_espresso"), "<b>", "</b>"); ?></span> |
|
77 | + "event_espresso"), "<b>", "</b>"); ?></span> |
|
78 | 78 | <p> |
79 | 79 | <?php |
80 | - printf( |
|
81 | - esc_html__('%1$sNot sure how to backup your existing data?%2$s Here is %3$sWordPress\'s explanation%7$s, and here\'s %6$sour explanation%7$s.%8$sYou can also search the WordPress plugin database for %4$s database backup plugins %7$s,%8$sor have one of our dedicated support technicians help you by purchasing a %5$sPriority Support Token%7$s.', |
|
82 | - "event_espresso"), |
|
83 | - '<b>', |
|
84 | - '</b>', |
|
85 | - "<a href='http://codex.wordpress.org/Backing_Up_Your_Database'>", |
|
86 | - "<a href='" |
|
87 | - . admin_url('plugin-install.php?tab=search&type=term&s=database+backup&plugin-search-input=Search+Plugins') |
|
88 | - . "'>", |
|
89 | - "<a href='http://eventespresso.com/product/priority-support-tokens/'>", |
|
90 | - '<a href="http://eventespresso.com/wiki/how-to-back-up-your-site/">', |
|
91 | - "</a>", |
|
92 | - '<br/>' |
|
93 | - ); |
|
94 | - ?> |
|
80 | + printf( |
|
81 | + esc_html__('%1$sNot sure how to backup your existing data?%2$s Here is %3$sWordPress\'s explanation%7$s, and here\'s %6$sour explanation%7$s.%8$sYou can also search the WordPress plugin database for %4$s database backup plugins %7$s,%8$sor have one of our dedicated support technicians help you by purchasing a %5$sPriority Support Token%7$s.', |
|
82 | + "event_espresso"), |
|
83 | + '<b>', |
|
84 | + '</b>', |
|
85 | + "<a href='http://codex.wordpress.org/Backing_Up_Your_Database'>", |
|
86 | + "<a href='" |
|
87 | + . admin_url('plugin-install.php?tab=search&type=term&s=database+backup&plugin-search-input=Search+Plugins') |
|
88 | + . "'>", |
|
89 | + "<a href='http://eventespresso.com/product/priority-support-tokens/'>", |
|
90 | + '<a href="http://eventespresso.com/wiki/how-to-back-up-your-site/">', |
|
91 | + "</a>", |
|
92 | + '<br/>' |
|
93 | + ); |
|
94 | + ?> |
|
95 | 95 | </p> |
96 | 96 | <?php do_action('AHEE__ee_migration_page__option_1_extra_details'); ?> |
97 | 97 | </div> |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | <td><h3><?php esc_html_e('2', 'event_espresso'); ?></h3></td> |
102 | 102 | <td> |
103 | 103 | <?php echo apply_filters('FHEE__ee_migration_page__option_2_main', |
104 | - sprintf(esc_html__('I do NOT want to migrate my %1$s data to %2$s at this time and just want to use %3$s without migrating data.', |
|
105 | - "event_espresso"), $current_db_state, $next_db_state, |
|
106 | - $ultimate_db_state), $current_db_state, $next_db_state, |
|
107 | - $ultimate_db_state); ?><br/> |
|
104 | + sprintf(esc_html__('I do NOT want to migrate my %1$s data to %2$s at this time and just want to use %3$s without migrating data.', |
|
105 | + "event_espresso"), $current_db_state, $next_db_state, |
|
106 | + $ultimate_db_state), $current_db_state, $next_db_state, |
|
107 | + $ultimate_db_state); ?><br/> |
|
108 | 108 | <span class="reminder-spn"><?php esc_html_e('Please Note: In order to avoid errors, any existing Event Espresso data (events, ticket, registrations, etc) in your db will be erased! Regular WP data will NOT be affected.', |
109 | - 'event_espresso'); ?></span> |
|
109 | + 'event_espresso'); ?></span> |
|
110 | 110 | <a id="display-no-migration-details" |
111 | 111 | class="display-the-hidden lt-grey-text smaller-text hide-if-no-js" |
112 | 112 | rel="no-migration-details"><?php esc_html_e('click for more details', "event_espresso"); ?> |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js" |
116 | 116 | rel="no-migration-details" |
117 | 117 | style="display:none;"><?php echo sprintf(esc_html__('hide%1$sdetails%1$s-', |
118 | - 'event_espresso'), ' '); ?></a> |
|
118 | + 'event_espresso'), ' '); ?></a> |
|
119 | 119 | </td> |
120 | 120 | <td> |
121 | 121 | <a id="do-not-migrate" class="do-not-migrate button-primary" |
122 | 122 | href="<?php echo $reset_db_page_link; ?>"><?php echo apply_filters('FHEE__ee_migration_page__option_2_button_text', |
123 | - sprintf(esc_html__("Just Start %s and Delete Existing Data", "event_espresso"), |
|
124 | - $ultimate_db_state), $ultimate_db_state); ?></a> |
|
123 | + sprintf(esc_html__("Just Start %s and Delete Existing Data", "event_espresso"), |
|
124 | + $ultimate_db_state), $ultimate_db_state); ?></a> |
|
125 | 125 | </td> |
126 | 126 | </tr> |
127 | 127 | <tr> |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | <div id="no-migration-details-dv" style="display: none; padding: 1em;"> |
130 | 130 | <p> |
131 | 131 | <?php echo apply_filters('FHEE__ee_migration_page__option_2_details', |
132 | - sprintf(esc_html__("If your existing Event and Registration Data is no longer relevant nor required, you can just start up %s without performing a data migration.", |
|
133 | - "event_espresso"), $ultimate_db_state), $ultimate_db_state); ?> |
|
132 | + sprintf(esc_html__("If your existing Event and Registration Data is no longer relevant nor required, you can just start up %s without performing a data migration.", |
|
133 | + "event_espresso"), $ultimate_db_state), $ultimate_db_state); ?> |
|
134 | 134 | </p> |
135 | 135 | </div> |
136 | 136 | </td> |