@@ -15,171 +15,171 @@ |
||
15 | 15 | */ |
16 | 16 | class Tickets_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
21 | - $this->_data = $this->_admin_page->get_default_tickets($this->_per_page, false, $trashed); |
|
22 | - $this->_all_data_count = $this->_admin_page->get_default_tickets($this->_per_page, true, false); |
|
23 | - $this->_trashed_count = $this->_admin_page->get_default_tickets($this->_per_page, true, true); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _set_properties() |
|
28 | - { |
|
29 | - $this->_wp_list_args = array( |
|
30 | - 'singular' => esc_html__('ticket', 'event_espresso'), |
|
31 | - 'plural' => esc_html__('tickets', 'event_espresso'), |
|
32 | - 'ajax' => true, |
|
33 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
34 | - ); |
|
35 | - |
|
36 | - $this->_columns = array( |
|
37 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
38 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
39 | - 'TKT_name' => esc_html__('Name', 'event_espresso'), |
|
40 | - 'TKT_description' => esc_html__('Description', 'event_espresso'), |
|
41 | - 'TKT_qty' => esc_html__('Quantity', 'event_espresso'), |
|
42 | - 'TKT_uses' => esc_html__('Datetimes', 'event_espresso'), |
|
43 | - 'TKT_min' => esc_html__('Minimum', 'event_espresso'), |
|
44 | - 'TKT_max' => esc_html__('Maximum', 'event_espresso'), |
|
45 | - 'TKT_price' => esc_html__('Price', 'event_espresso'), |
|
46 | - 'TKT_taxable' => esc_html__('Taxable', 'event_espresso'), |
|
47 | - ); |
|
48 | - |
|
49 | - $this->_sortable_columns = array( |
|
50 | - // TRUE means its already sorted |
|
51 | - 'id' => array('TKT_ID', false), |
|
52 | - 'TKT_name' => array('TKT_name' => true), |
|
53 | - 'TKT_description' => array('TKT_description' => false), |
|
54 | - 'TKT_qty' => array('TKT_qty' => false), |
|
55 | - 'TKT_uses' => array('TKT_uses' => false), |
|
56 | - 'TKT_min' => array('TKT_min' => false), |
|
57 | - 'TKT_max' => array('TKT_max' => false), |
|
58 | - 'TKT_price' => array('TKT_price' => false), |
|
59 | - ); |
|
60 | - |
|
61 | - $this->_hidden_columns = array(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - protected function _get_table_filters() |
|
66 | - { |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - protected function _add_view_counts() |
|
71 | - { |
|
72 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
73 | - $this->_views['trashed']['count'] = $this->_trashed_count; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - public function column_cb($item) |
|
78 | - { |
|
79 | - return $item->ID() === 1 |
|
80 | - ? '<span class="dashicons dashicons-lock"></span>' |
|
81 | - : sprintf( |
|
82 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
83 | - $item->ID() |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param EE_Ticket $item |
|
90 | - * @return string |
|
91 | - * @throws EE_Error |
|
92 | - * @throws ReflectionException |
|
93 | - */ |
|
94 | - public function column_id($item): string |
|
95 | - { |
|
96 | - $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
97 | - $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
98 | - return $this->columnContent('id', $content, 'end'); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - public function column_TKT_name(EE_Ticket $ticket, bool $prep_content = true): string |
|
103 | - { |
|
104 | - // build row actions |
|
105 | - $actions = array(); |
|
106 | - |
|
107 | - // trash links |
|
108 | - if ($ticket->ID() !== 1) { |
|
109 | - if ($this->_view == 'all') { |
|
110 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
111 | - 'action' => 'trash_ticket', |
|
112 | - 'TKT_ID' => $ticket->ID(), |
|
113 | - ), EVENTS_ADMIN_URL); |
|
114 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
115 | - . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
116 | - . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
117 | - } else { |
|
118 | - // restore price link |
|
119 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
120 | - 'action' => 'restore_ticket', |
|
121 | - 'TKT_ID' => $ticket->ID(), |
|
122 | - ), EVENTS_ADMIN_URL); |
|
123 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
124 | - . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
125 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
126 | - // delete price link |
|
127 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
128 | - 'action' => 'delete_ticket', |
|
129 | - 'TKT_ID' => $ticket->ID(), |
|
130 | - ), EVENTS_ADMIN_URL); |
|
131 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
132 | - . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
133 | - . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
138 | - return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - public function column_TKT_description(EE_Ticket $ticket): string |
|
143 | - { |
|
144 | - return $this->columnContent('TKT_description', $ticket->description()); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - public function column_TKT_qty(EE_Ticket $ticket): string |
|
149 | - { |
|
150 | - return $this->columnContent('TKT_qty', $ticket->qty(), 'end'); |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - public function column_TKT_uses(EE_Ticket $ticket): string |
|
155 | - { |
|
156 | - return $this->columnContent('TKT_uses', $ticket->uses(), 'end'); |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - public function column_TKT_min(EE_Ticket $ticket): string |
|
161 | - { |
|
162 | - return $this->columnContent('TKT_min', $ticket->min(), 'end'); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - public function column_TKT_max(EE_Ticket $ticket): string |
|
167 | - { |
|
168 | - return $this->columnContent('TKT_max', $ticket->max(), 'end'); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - public function column_TKT_price(EE_Ticket $ticket): string |
|
173 | - { |
|
174 | - return $this->columnContent('TKT_price', $ticket->pretty_price(), 'end'); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - public function column_TKT_taxable(EE_Ticket $ticket): string |
|
179 | - { |
|
180 | - $content = $ticket->taxable() |
|
181 | - ? esc_html__('Yes', 'event_espresso') |
|
182 | - : esc_html__('No', 'event_espresso'); |
|
183 | - return $this->columnContent('TKT_taxable', $content, 'center'); |
|
184 | - } |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false; |
|
21 | + $this->_data = $this->_admin_page->get_default_tickets($this->_per_page, false, $trashed); |
|
22 | + $this->_all_data_count = $this->_admin_page->get_default_tickets($this->_per_page, true, false); |
|
23 | + $this->_trashed_count = $this->_admin_page->get_default_tickets($this->_per_page, true, true); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _set_properties() |
|
28 | + { |
|
29 | + $this->_wp_list_args = array( |
|
30 | + 'singular' => esc_html__('ticket', 'event_espresso'), |
|
31 | + 'plural' => esc_html__('tickets', 'event_espresso'), |
|
32 | + 'ajax' => true, |
|
33 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
34 | + ); |
|
35 | + |
|
36 | + $this->_columns = array( |
|
37 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
38 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
39 | + 'TKT_name' => esc_html__('Name', 'event_espresso'), |
|
40 | + 'TKT_description' => esc_html__('Description', 'event_espresso'), |
|
41 | + 'TKT_qty' => esc_html__('Quantity', 'event_espresso'), |
|
42 | + 'TKT_uses' => esc_html__('Datetimes', 'event_espresso'), |
|
43 | + 'TKT_min' => esc_html__('Minimum', 'event_espresso'), |
|
44 | + 'TKT_max' => esc_html__('Maximum', 'event_espresso'), |
|
45 | + 'TKT_price' => esc_html__('Price', 'event_espresso'), |
|
46 | + 'TKT_taxable' => esc_html__('Taxable', 'event_espresso'), |
|
47 | + ); |
|
48 | + |
|
49 | + $this->_sortable_columns = array( |
|
50 | + // TRUE means its already sorted |
|
51 | + 'id' => array('TKT_ID', false), |
|
52 | + 'TKT_name' => array('TKT_name' => true), |
|
53 | + 'TKT_description' => array('TKT_description' => false), |
|
54 | + 'TKT_qty' => array('TKT_qty' => false), |
|
55 | + 'TKT_uses' => array('TKT_uses' => false), |
|
56 | + 'TKT_min' => array('TKT_min' => false), |
|
57 | + 'TKT_max' => array('TKT_max' => false), |
|
58 | + 'TKT_price' => array('TKT_price' => false), |
|
59 | + ); |
|
60 | + |
|
61 | + $this->_hidden_columns = array(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + protected function _get_table_filters() |
|
66 | + { |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + protected function _add_view_counts() |
|
71 | + { |
|
72 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
73 | + $this->_views['trashed']['count'] = $this->_trashed_count; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + public function column_cb($item) |
|
78 | + { |
|
79 | + return $item->ID() === 1 |
|
80 | + ? '<span class="dashicons dashicons-lock"></span>' |
|
81 | + : sprintf( |
|
82 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
83 | + $item->ID() |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param EE_Ticket $item |
|
90 | + * @return string |
|
91 | + * @throws EE_Error |
|
92 | + * @throws ReflectionException |
|
93 | + */ |
|
94 | + public function column_id($item): string |
|
95 | + { |
|
96 | + $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
97 | + $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
98 | + return $this->columnContent('id', $content, 'end'); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + public function column_TKT_name(EE_Ticket $ticket, bool $prep_content = true): string |
|
103 | + { |
|
104 | + // build row actions |
|
105 | + $actions = array(); |
|
106 | + |
|
107 | + // trash links |
|
108 | + if ($ticket->ID() !== 1) { |
|
109 | + if ($this->_view == 'all') { |
|
110 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
111 | + 'action' => 'trash_ticket', |
|
112 | + 'TKT_ID' => $ticket->ID(), |
|
113 | + ), EVENTS_ADMIN_URL); |
|
114 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
115 | + . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
116 | + . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
117 | + } else { |
|
118 | + // restore price link |
|
119 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
120 | + 'action' => 'restore_ticket', |
|
121 | + 'TKT_ID' => $ticket->ID(), |
|
122 | + ), EVENTS_ADMIN_URL); |
|
123 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
124 | + . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
125 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
126 | + // delete price link |
|
127 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
128 | + 'action' => 'delete_ticket', |
|
129 | + 'TKT_ID' => $ticket->ID(), |
|
130 | + ), EVENTS_ADMIN_URL); |
|
131 | + $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
132 | + . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
133 | + . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
138 | + return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + public function column_TKT_description(EE_Ticket $ticket): string |
|
143 | + { |
|
144 | + return $this->columnContent('TKT_description', $ticket->description()); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + public function column_TKT_qty(EE_Ticket $ticket): string |
|
149 | + { |
|
150 | + return $this->columnContent('TKT_qty', $ticket->qty(), 'end'); |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + public function column_TKT_uses(EE_Ticket $ticket): string |
|
155 | + { |
|
156 | + return $this->columnContent('TKT_uses', $ticket->uses(), 'end'); |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + public function column_TKT_min(EE_Ticket $ticket): string |
|
161 | + { |
|
162 | + return $this->columnContent('TKT_min', $ticket->min(), 'end'); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + public function column_TKT_max(EE_Ticket $ticket): string |
|
167 | + { |
|
168 | + return $this->columnContent('TKT_max', $ticket->max(), 'end'); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + public function column_TKT_price(EE_Ticket $ticket): string |
|
173 | + { |
|
174 | + return $this->columnContent('TKT_price', $ticket->pretty_price(), 'end'); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + public function column_TKT_taxable(EE_Ticket $ticket): string |
|
179 | + { |
|
180 | + $content = $ticket->taxable() |
|
181 | + ? esc_html__('Yes', 'event_espresso') |
|
182 | + : esc_html__('No', 'event_espresso'); |
|
183 | + return $this->columnContent('TKT_taxable', $content, 'center'); |
|
184 | + } |
|
185 | 185 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function column_id($item): string |
95 | 95 | { |
96 | - $content = '<span class="ee-entity-id">' . $item->ID() . '</span>'; |
|
97 | - $content .= '<span class="show-on-mobile-view-only">' . $this->column_TKT_name($item, false) . '</span>'; |
|
96 | + $content = '<span class="ee-entity-id">'.$item->ID().'</span>'; |
|
97 | + $content .= '<span class="show-on-mobile-view-only">'.$this->column_TKT_name($item, false).'</span>'; |
|
98 | 98 | return $this->columnContent('id', $content, 'end'); |
99 | 99 | } |
100 | 100 | |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | 'action' => 'trash_ticket', |
112 | 112 | 'TKT_ID' => $ticket->ID(), |
113 | 113 | ), EVENTS_ADMIN_URL); |
114 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" aria-label="' |
|
115 | - . esc_attr__('Move Ticket to trash', 'event_espresso') . '">' |
|
116 | - . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
114 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" aria-label="' |
|
115 | + . esc_attr__('Move Ticket to trash', 'event_espresso').'">' |
|
116 | + . esc_html__('Trash', 'event_espresso').'</a>'; |
|
117 | 117 | } else { |
118 | 118 | // restore price link |
119 | 119 | $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
120 | 120 | 'action' => 'restore_ticket', |
121 | 121 | 'TKT_ID' => $ticket->ID(), |
122 | 122 | ), EVENTS_ADMIN_URL); |
123 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" aria-label="' |
|
124 | - . esc_attr__('Restore Ticket', 'event_espresso') . '">' |
|
125 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
123 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" aria-label="' |
|
124 | + . esc_attr__('Restore Ticket', 'event_espresso').'">' |
|
125 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
126 | 126 | // delete price link |
127 | 127 | $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
128 | 128 | 'action' => 'delete_ticket', |
129 | 129 | 'TKT_ID' => $ticket->ID(), |
130 | 130 | ), EVENTS_ADMIN_URL); |
131 | - $actions['delete'] = '<a href="' . $delete_lnk_url . '" aria-label="' |
|
132 | - . esc_attr__('Delete Ticket Permanently', 'event_espresso') . '">' |
|
133 | - . esc_html__('Delete Permanently', 'event_espresso') . '</a>'; |
|
131 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" aria-label="' |
|
132 | + . esc_attr__('Delete Ticket Permanently', 'event_espresso').'">' |
|
133 | + . esc_html__('Delete Permanently', 'event_espresso').'</a>'; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - $content = $prep_content ? $ticket->name() . $this->row_actions($actions) : $ticket->name(); |
|
137 | + $content = $prep_content ? $ticket->name().$this->row_actions($actions) : $ticket->name(); |
|
138 | 138 | return $prep_content ? $this->columnContent('TKT_name', $content) : $content; |
139 | 139 | } |
140 | 140 |
@@ -14,1368 +14,1368 @@ |
||
14 | 14 | */ |
15 | 15 | class Extend_Events_Admin_Page extends Events_Admin_Page |
16 | 16 | { |
17 | - /** |
|
18 | - * @var EE_Admin_Config |
|
19 | - */ |
|
20 | - protected $admin_config; |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * Extend_Events_Admin_Page constructor. |
|
25 | - * |
|
26 | - * @param bool $routing |
|
27 | - * @throws EE_Error |
|
28 | - * @throws ReflectionException |
|
29 | - */ |
|
30 | - public function __construct($routing = true) |
|
31 | - { |
|
32 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
34 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
35 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
36 | - } |
|
37 | - parent::__construct($routing); |
|
38 | - $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Sets routes. |
|
44 | - * |
|
45 | - * @throws EE_Error |
|
46 | - */ |
|
47 | - protected function _extend_page_config() |
|
48 | - { |
|
49 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
50 | - // is there a evt_id in the request? |
|
51 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
52 | - $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
53 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
54 | - $new_page_routes = [ |
|
55 | - 'duplicate_event' => [ |
|
56 | - 'func' => '_duplicate_event', |
|
57 | - 'capability' => 'ee_edit_event', |
|
58 | - 'obj_id' => $EVT_ID, |
|
59 | - 'noheader' => true, |
|
60 | - ], |
|
61 | - 'import_page' => [ |
|
62 | - 'func' => '_import_page', |
|
63 | - 'capability' => 'import', |
|
64 | - ], |
|
65 | - 'import' => [ |
|
66 | - 'func' => '_import_events', |
|
67 | - 'capability' => 'import', |
|
68 | - 'noheader' => true, |
|
69 | - ], |
|
70 | - 'import_events' => [ |
|
71 | - 'func' => '_import_events', |
|
72 | - 'capability' => 'import', |
|
73 | - 'noheader' => true, |
|
74 | - ], |
|
75 | - 'export_events' => [ |
|
76 | - 'func' => '_events_export', |
|
77 | - 'capability' => 'export', |
|
78 | - 'noheader' => true, |
|
79 | - ], |
|
80 | - 'export_categories' => [ |
|
81 | - 'func' => '_categories_export', |
|
82 | - 'capability' => 'export', |
|
83 | - 'noheader' => true, |
|
84 | - ], |
|
85 | - 'sample_export_file' => [ |
|
86 | - 'func' => '_sample_export_file', |
|
87 | - 'capability' => 'export', |
|
88 | - 'noheader' => true, |
|
89 | - ], |
|
90 | - 'update_template_settings' => [ |
|
91 | - 'func' => '_update_template_settings', |
|
92 | - 'capability' => 'manage_options', |
|
93 | - 'noheader' => true, |
|
94 | - ], |
|
95 | - 'ticket_list_table' => [ |
|
96 | - 'func' => '_tickets_overview_list_table', |
|
97 | - 'capability' => 'ee_read_default_tickets', |
|
98 | - ], |
|
99 | - ]; |
|
100 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
101 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
102 | - // don't load these meta boxes if using the advanced editor |
|
103 | - if ( |
|
104 | - ! $this->admin_config->useAdvancedEditor() |
|
105 | - || ! $this->feature->allowed('use_default_ticket_manager') |
|
106 | - ) { |
|
107 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
108 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
109 | - |
|
110 | - $legacy_editor_page_routes = [ |
|
111 | - 'trash_ticket' => [ |
|
112 | - 'func' => '_trash_or_restore_ticket', |
|
113 | - 'capability' => 'ee_delete_default_ticket', |
|
114 | - 'obj_id' => $TKT_ID, |
|
115 | - 'noheader' => true, |
|
116 | - 'args' => ['trash' => true], |
|
117 | - ], |
|
118 | - 'trash_tickets' => [ |
|
119 | - 'func' => '_trash_or_restore_ticket', |
|
120 | - 'capability' => 'ee_delete_default_tickets', |
|
121 | - 'noheader' => true, |
|
122 | - 'args' => ['trash' => true], |
|
123 | - ], |
|
124 | - 'restore_ticket' => [ |
|
125 | - 'func' => '_trash_or_restore_ticket', |
|
126 | - 'capability' => 'ee_delete_default_ticket', |
|
127 | - 'obj_id' => $TKT_ID, |
|
128 | - 'noheader' => true, |
|
129 | - ], |
|
130 | - 'restore_tickets' => [ |
|
131 | - 'func' => '_trash_or_restore_ticket', |
|
132 | - 'capability' => 'ee_delete_default_tickets', |
|
133 | - 'noheader' => true, |
|
134 | - ], |
|
135 | - 'delete_ticket' => [ |
|
136 | - 'func' => '_delete_ticket', |
|
137 | - 'capability' => 'ee_delete_default_ticket', |
|
138 | - 'obj_id' => $TKT_ID, |
|
139 | - 'noheader' => true, |
|
140 | - ], |
|
141 | - 'delete_tickets' => [ |
|
142 | - 'func' => '_delete_ticket', |
|
143 | - 'capability' => 'ee_delete_default_tickets', |
|
144 | - 'noheader' => true, |
|
145 | - ], |
|
146 | - ]; |
|
147 | - $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
148 | - } |
|
149 | - |
|
150 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
151 | - // partial route/config override |
|
152 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
153 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
154 | - // add tickets tab but only if there are more than one default ticket! |
|
155 | - $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
156 | - [['TKT_is_default' => 1]], |
|
157 | - 'TKT_ID', |
|
158 | - true |
|
159 | - ); |
|
160 | - if ($ticket_count > 1) { |
|
161 | - $new_page_config = [ |
|
162 | - 'ticket_list_table' => [ |
|
163 | - 'nav' => [ |
|
164 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
165 | - 'icon' => 'dashicons-tickets-alt', |
|
166 | - 'order' => 60, |
|
167 | - ], |
|
168 | - 'list_table' => 'Tickets_List_Table', |
|
169 | - 'require_nonce' => false, |
|
170 | - ], |
|
171 | - ]; |
|
172 | - } |
|
173 | - // template settings |
|
174 | - $new_page_config['template_settings'] = [ |
|
175 | - 'nav' => [ |
|
176 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
177 | - 'icon' => 'dashicons-layout', |
|
178 | - 'order' => 30, |
|
179 | - ], |
|
180 | - 'metaboxes' => array_merge(['_publish_post_box'], $this->_default_espresso_metaboxes), |
|
181 | - 'help_tabs' => [ |
|
182 | - 'general_settings_templates_help_tab' => [ |
|
183 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
184 | - 'filename' => 'general_settings_templates', |
|
185 | - ], |
|
186 | - ], |
|
187 | - 'require_nonce' => false, |
|
188 | - ]; |
|
189 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
190 | - // add filters and actions |
|
191 | - // modifying _views |
|
192 | - add_filter( |
|
193 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
194 | - [$this, 'add_additional_datetime_button'], |
|
195 | - 10, |
|
196 | - 2 |
|
197 | - ); |
|
198 | - add_filter( |
|
199 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
200 | - [$this, 'add_datetime_clone_button'], |
|
201 | - 10, |
|
202 | - 2 |
|
203 | - ); |
|
204 | - add_filter( |
|
205 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
206 | - [$this, 'datetime_timezones_template'], |
|
207 | - 10, |
|
208 | - 2 |
|
209 | - ); |
|
210 | - // filters for event list table |
|
211 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2); |
|
212 | - add_filter( |
|
213 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
214 | - [$this, 'extra_list_table_actions'], |
|
215 | - 10, |
|
216 | - 2 |
|
217 | - ); |
|
218 | - // legend item |
|
219 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']); |
|
220 | - add_action('admin_init', [$this, 'admin_init']); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * admin_init |
|
226 | - */ |
|
227 | - public function admin_init() |
|
228 | - { |
|
229 | - EE_Registry::$i18n_js_strings = array_merge( |
|
230 | - EE_Registry::$i18n_js_strings, |
|
231 | - [ |
|
232 | - 'image_confirm' => esc_html__( |
|
233 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
234 | - 'event_espresso' |
|
235 | - ), |
|
236 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
237 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
238 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
239 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
240 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
241 | - ] |
|
242 | - ); |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * Add per page screen options to the default ticket list table view. |
|
248 | - * |
|
249 | - * @throws InvalidArgumentException |
|
250 | - * @throws InvalidDataTypeException |
|
251 | - * @throws InvalidInterfaceException |
|
252 | - */ |
|
253 | - protected function _add_screen_options_ticket_list_table() |
|
254 | - { |
|
255 | - $this->_per_page_screen_option(); |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * @param string $return |
|
261 | - * @param int $id |
|
262 | - * @param string $new_title |
|
263 | - * @param string $new_slug |
|
264 | - * @return string |
|
265 | - */ |
|
266 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
267 | - { |
|
268 | - $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
269 | - // make sure this is only when editing |
|
270 | - if (! empty($id)) { |
|
271 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
272 | - ['action' => 'duplicate_event', 'EVT_ID' => $id], |
|
273 | - $this->_admin_base_url |
|
274 | - ); |
|
275 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
276 | - $return .= '<a href="' |
|
277 | - . $href |
|
278 | - . '" aria-label="' |
|
279 | - . $title |
|
280 | - . '" id="ee-duplicate-event-button" class="button button--small button--secondary" value="duplicate_event">' |
|
281 | - . $title |
|
282 | - . '</a>'; |
|
283 | - } |
|
284 | - return $return; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * Set the list table views for the default ticket list table view. |
|
290 | - */ |
|
291 | - public function _set_list_table_views_ticket_list_table() |
|
292 | - { |
|
293 | - $this->_views = [ |
|
294 | - 'all' => [ |
|
295 | - 'slug' => 'all', |
|
296 | - 'label' => esc_html__('All', 'event_espresso'), |
|
297 | - 'count' => 0, |
|
298 | - 'bulk_action' => [ |
|
299 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
300 | - ], |
|
301 | - ], |
|
302 | - 'trashed' => [ |
|
303 | - 'slug' => 'trashed', |
|
304 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
305 | - 'count' => 0, |
|
306 | - 'bulk_action' => [ |
|
307 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
308 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
309 | - ], |
|
310 | - ], |
|
311 | - ]; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Enqueue scripts and styles for the event editor. |
|
317 | - */ |
|
318 | - public function load_scripts_styles_edit() |
|
319 | - { |
|
320 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
321 | - wp_register_script( |
|
322 | - 'ee-event-editor-heartbeat', |
|
323 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
324 | - ['ee_admin_js', 'heartbeat'], |
|
325 | - EVENT_ESPRESSO_VERSION, |
|
326 | - true |
|
327 | - ); |
|
328 | - wp_enqueue_script('ee-accounting'); |
|
329 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
330 | - } |
|
331 | - wp_enqueue_script('event_editor_js'); |
|
332 | - // styles |
|
333 | - wp_enqueue_style('espresso-ui-theme'); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * Returns template for the additional datetime. |
|
339 | - * |
|
340 | - * @param string $template |
|
341 | - * @param array $template_args |
|
342 | - * @return string |
|
343 | - * @throws DomainException |
|
344 | - */ |
|
345 | - public function add_additional_datetime_button($template, $template_args) |
|
346 | - { |
|
347 | - return EEH_Template::display_template( |
|
348 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
349 | - $template_args, |
|
350 | - true |
|
351 | - ); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * Returns the template for cloning a datetime. |
|
357 | - * |
|
358 | - * @param $template |
|
359 | - * @param $template_args |
|
360 | - * @return string |
|
361 | - * @throws DomainException |
|
362 | - */ |
|
363 | - public function add_datetime_clone_button($template, $template_args) |
|
364 | - { |
|
365 | - return EEH_Template::display_template( |
|
366 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
367 | - $template_args, |
|
368 | - true |
|
369 | - ); |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * Returns the template for datetime timezones. |
|
375 | - * |
|
376 | - * @param $template |
|
377 | - * @param $template_args |
|
378 | - * @return string |
|
379 | - * @throws DomainException |
|
380 | - */ |
|
381 | - public function datetime_timezones_template($template, $template_args) |
|
382 | - { |
|
383 | - return EEH_Template::display_template( |
|
384 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
385 | - $template_args, |
|
386 | - true |
|
387 | - ); |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Sets the views for the default list table view. |
|
393 | - * |
|
394 | - * @throws EE_Error |
|
395 | - */ |
|
396 | - protected function _set_list_table_views_default() |
|
397 | - { |
|
398 | - parent::_set_list_table_views_default(); |
|
399 | - $new_views = [ |
|
400 | - 'today' => [ |
|
401 | - 'slug' => 'today', |
|
402 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
403 | - 'count' => $this->total_events_today(), |
|
404 | - 'bulk_action' => [ |
|
405 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
406 | - ], |
|
407 | - ], |
|
408 | - 'month' => [ |
|
409 | - 'slug' => 'month', |
|
410 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
411 | - 'count' => $this->total_events_this_month(), |
|
412 | - 'bulk_action' => [ |
|
413 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
414 | - ], |
|
415 | - ], |
|
416 | - ]; |
|
417 | - $this->_views = array_merge($this->_views, $new_views); |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * Returns the extra action links for the default list table view. |
|
423 | - * |
|
424 | - * @param array $action_links |
|
425 | - * @param EE_Event $event |
|
426 | - * @return array |
|
427 | - * @throws EE_Error |
|
428 | - * @throws ReflectionException |
|
429 | - */ |
|
430 | - public function extra_list_table_actions(array $action_links, EE_Event $event) |
|
431 | - { |
|
432 | - if ( |
|
433 | - EE_Registry::instance()->CAP->current_user_can( |
|
434 | - 'ee_read_registrations', |
|
435 | - 'espresso_registrations_reports', |
|
436 | - $event->ID() |
|
437 | - ) |
|
438 | - ) { |
|
439 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( |
|
440 | - [ |
|
441 | - 'action' => 'reports', |
|
442 | - 'EVT_ID' => $event->ID(), |
|
443 | - ], |
|
444 | - REG_ADMIN_URL |
|
445 | - ); |
|
446 | - |
|
447 | - $action_links[] = ' |
|
17 | + /** |
|
18 | + * @var EE_Admin_Config |
|
19 | + */ |
|
20 | + protected $admin_config; |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * Extend_Events_Admin_Page constructor. |
|
25 | + * |
|
26 | + * @param bool $routing |
|
27 | + * @throws EE_Error |
|
28 | + * @throws ReflectionException |
|
29 | + */ |
|
30 | + public function __construct($routing = true) |
|
31 | + { |
|
32 | + if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
34 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
35 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
36 | + } |
|
37 | + parent::__construct($routing); |
|
38 | + $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Sets routes. |
|
44 | + * |
|
45 | + * @throws EE_Error |
|
46 | + */ |
|
47 | + protected function _extend_page_config() |
|
48 | + { |
|
49 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
50 | + // is there a evt_id in the request? |
|
51 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
52 | + $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
53 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
54 | + $new_page_routes = [ |
|
55 | + 'duplicate_event' => [ |
|
56 | + 'func' => '_duplicate_event', |
|
57 | + 'capability' => 'ee_edit_event', |
|
58 | + 'obj_id' => $EVT_ID, |
|
59 | + 'noheader' => true, |
|
60 | + ], |
|
61 | + 'import_page' => [ |
|
62 | + 'func' => '_import_page', |
|
63 | + 'capability' => 'import', |
|
64 | + ], |
|
65 | + 'import' => [ |
|
66 | + 'func' => '_import_events', |
|
67 | + 'capability' => 'import', |
|
68 | + 'noheader' => true, |
|
69 | + ], |
|
70 | + 'import_events' => [ |
|
71 | + 'func' => '_import_events', |
|
72 | + 'capability' => 'import', |
|
73 | + 'noheader' => true, |
|
74 | + ], |
|
75 | + 'export_events' => [ |
|
76 | + 'func' => '_events_export', |
|
77 | + 'capability' => 'export', |
|
78 | + 'noheader' => true, |
|
79 | + ], |
|
80 | + 'export_categories' => [ |
|
81 | + 'func' => '_categories_export', |
|
82 | + 'capability' => 'export', |
|
83 | + 'noheader' => true, |
|
84 | + ], |
|
85 | + 'sample_export_file' => [ |
|
86 | + 'func' => '_sample_export_file', |
|
87 | + 'capability' => 'export', |
|
88 | + 'noheader' => true, |
|
89 | + ], |
|
90 | + 'update_template_settings' => [ |
|
91 | + 'func' => '_update_template_settings', |
|
92 | + 'capability' => 'manage_options', |
|
93 | + 'noheader' => true, |
|
94 | + ], |
|
95 | + 'ticket_list_table' => [ |
|
96 | + 'func' => '_tickets_overview_list_table', |
|
97 | + 'capability' => 'ee_read_default_tickets', |
|
98 | + ], |
|
99 | + ]; |
|
100 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
101 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
102 | + // don't load these meta boxes if using the advanced editor |
|
103 | + if ( |
|
104 | + ! $this->admin_config->useAdvancedEditor() |
|
105 | + || ! $this->feature->allowed('use_default_ticket_manager') |
|
106 | + ) { |
|
107 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
108 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
109 | + |
|
110 | + $legacy_editor_page_routes = [ |
|
111 | + 'trash_ticket' => [ |
|
112 | + 'func' => '_trash_or_restore_ticket', |
|
113 | + 'capability' => 'ee_delete_default_ticket', |
|
114 | + 'obj_id' => $TKT_ID, |
|
115 | + 'noheader' => true, |
|
116 | + 'args' => ['trash' => true], |
|
117 | + ], |
|
118 | + 'trash_tickets' => [ |
|
119 | + 'func' => '_trash_or_restore_ticket', |
|
120 | + 'capability' => 'ee_delete_default_tickets', |
|
121 | + 'noheader' => true, |
|
122 | + 'args' => ['trash' => true], |
|
123 | + ], |
|
124 | + 'restore_ticket' => [ |
|
125 | + 'func' => '_trash_or_restore_ticket', |
|
126 | + 'capability' => 'ee_delete_default_ticket', |
|
127 | + 'obj_id' => $TKT_ID, |
|
128 | + 'noheader' => true, |
|
129 | + ], |
|
130 | + 'restore_tickets' => [ |
|
131 | + 'func' => '_trash_or_restore_ticket', |
|
132 | + 'capability' => 'ee_delete_default_tickets', |
|
133 | + 'noheader' => true, |
|
134 | + ], |
|
135 | + 'delete_ticket' => [ |
|
136 | + 'func' => '_delete_ticket', |
|
137 | + 'capability' => 'ee_delete_default_ticket', |
|
138 | + 'obj_id' => $TKT_ID, |
|
139 | + 'noheader' => true, |
|
140 | + ], |
|
141 | + 'delete_tickets' => [ |
|
142 | + 'func' => '_delete_ticket', |
|
143 | + 'capability' => 'ee_delete_default_tickets', |
|
144 | + 'noheader' => true, |
|
145 | + ], |
|
146 | + ]; |
|
147 | + $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
148 | + } |
|
149 | + |
|
150 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
151 | + // partial route/config override |
|
152 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
153 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
154 | + // add tickets tab but only if there are more than one default ticket! |
|
155 | + $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
156 | + [['TKT_is_default' => 1]], |
|
157 | + 'TKT_ID', |
|
158 | + true |
|
159 | + ); |
|
160 | + if ($ticket_count > 1) { |
|
161 | + $new_page_config = [ |
|
162 | + 'ticket_list_table' => [ |
|
163 | + 'nav' => [ |
|
164 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
165 | + 'icon' => 'dashicons-tickets-alt', |
|
166 | + 'order' => 60, |
|
167 | + ], |
|
168 | + 'list_table' => 'Tickets_List_Table', |
|
169 | + 'require_nonce' => false, |
|
170 | + ], |
|
171 | + ]; |
|
172 | + } |
|
173 | + // template settings |
|
174 | + $new_page_config['template_settings'] = [ |
|
175 | + 'nav' => [ |
|
176 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
177 | + 'icon' => 'dashicons-layout', |
|
178 | + 'order' => 30, |
|
179 | + ], |
|
180 | + 'metaboxes' => array_merge(['_publish_post_box'], $this->_default_espresso_metaboxes), |
|
181 | + 'help_tabs' => [ |
|
182 | + 'general_settings_templates_help_tab' => [ |
|
183 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
184 | + 'filename' => 'general_settings_templates', |
|
185 | + ], |
|
186 | + ], |
|
187 | + 'require_nonce' => false, |
|
188 | + ]; |
|
189 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
190 | + // add filters and actions |
|
191 | + // modifying _views |
|
192 | + add_filter( |
|
193 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
194 | + [$this, 'add_additional_datetime_button'], |
|
195 | + 10, |
|
196 | + 2 |
|
197 | + ); |
|
198 | + add_filter( |
|
199 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
200 | + [$this, 'add_datetime_clone_button'], |
|
201 | + 10, |
|
202 | + 2 |
|
203 | + ); |
|
204 | + add_filter( |
|
205 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
206 | + [$this, 'datetime_timezones_template'], |
|
207 | + 10, |
|
208 | + 2 |
|
209 | + ); |
|
210 | + // filters for event list table |
|
211 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2); |
|
212 | + add_filter( |
|
213 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
214 | + [$this, 'extra_list_table_actions'], |
|
215 | + 10, |
|
216 | + 2 |
|
217 | + ); |
|
218 | + // legend item |
|
219 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']); |
|
220 | + add_action('admin_init', [$this, 'admin_init']); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * admin_init |
|
226 | + */ |
|
227 | + public function admin_init() |
|
228 | + { |
|
229 | + EE_Registry::$i18n_js_strings = array_merge( |
|
230 | + EE_Registry::$i18n_js_strings, |
|
231 | + [ |
|
232 | + 'image_confirm' => esc_html__( |
|
233 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
234 | + 'event_espresso' |
|
235 | + ), |
|
236 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
237 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
238 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
239 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
240 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
241 | + ] |
|
242 | + ); |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * Add per page screen options to the default ticket list table view. |
|
248 | + * |
|
249 | + * @throws InvalidArgumentException |
|
250 | + * @throws InvalidDataTypeException |
|
251 | + * @throws InvalidInterfaceException |
|
252 | + */ |
|
253 | + protected function _add_screen_options_ticket_list_table() |
|
254 | + { |
|
255 | + $this->_per_page_screen_option(); |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * @param string $return |
|
261 | + * @param int $id |
|
262 | + * @param string $new_title |
|
263 | + * @param string $new_slug |
|
264 | + * @return string |
|
265 | + */ |
|
266 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
267 | + { |
|
268 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
269 | + // make sure this is only when editing |
|
270 | + if (! empty($id)) { |
|
271 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
272 | + ['action' => 'duplicate_event', 'EVT_ID' => $id], |
|
273 | + $this->_admin_base_url |
|
274 | + ); |
|
275 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
276 | + $return .= '<a href="' |
|
277 | + . $href |
|
278 | + . '" aria-label="' |
|
279 | + . $title |
|
280 | + . '" id="ee-duplicate-event-button" class="button button--small button--secondary" value="duplicate_event">' |
|
281 | + . $title |
|
282 | + . '</a>'; |
|
283 | + } |
|
284 | + return $return; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * Set the list table views for the default ticket list table view. |
|
290 | + */ |
|
291 | + public function _set_list_table_views_ticket_list_table() |
|
292 | + { |
|
293 | + $this->_views = [ |
|
294 | + 'all' => [ |
|
295 | + 'slug' => 'all', |
|
296 | + 'label' => esc_html__('All', 'event_espresso'), |
|
297 | + 'count' => 0, |
|
298 | + 'bulk_action' => [ |
|
299 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
300 | + ], |
|
301 | + ], |
|
302 | + 'trashed' => [ |
|
303 | + 'slug' => 'trashed', |
|
304 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
305 | + 'count' => 0, |
|
306 | + 'bulk_action' => [ |
|
307 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
308 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
309 | + ], |
|
310 | + ], |
|
311 | + ]; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Enqueue scripts and styles for the event editor. |
|
317 | + */ |
|
318 | + public function load_scripts_styles_edit() |
|
319 | + { |
|
320 | + if (! $this->admin_config->useAdvancedEditor()) { |
|
321 | + wp_register_script( |
|
322 | + 'ee-event-editor-heartbeat', |
|
323 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
324 | + ['ee_admin_js', 'heartbeat'], |
|
325 | + EVENT_ESPRESSO_VERSION, |
|
326 | + true |
|
327 | + ); |
|
328 | + wp_enqueue_script('ee-accounting'); |
|
329 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
330 | + } |
|
331 | + wp_enqueue_script('event_editor_js'); |
|
332 | + // styles |
|
333 | + wp_enqueue_style('espresso-ui-theme'); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * Returns template for the additional datetime. |
|
339 | + * |
|
340 | + * @param string $template |
|
341 | + * @param array $template_args |
|
342 | + * @return string |
|
343 | + * @throws DomainException |
|
344 | + */ |
|
345 | + public function add_additional_datetime_button($template, $template_args) |
|
346 | + { |
|
347 | + return EEH_Template::display_template( |
|
348 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
349 | + $template_args, |
|
350 | + true |
|
351 | + ); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * Returns the template for cloning a datetime. |
|
357 | + * |
|
358 | + * @param $template |
|
359 | + * @param $template_args |
|
360 | + * @return string |
|
361 | + * @throws DomainException |
|
362 | + */ |
|
363 | + public function add_datetime_clone_button($template, $template_args) |
|
364 | + { |
|
365 | + return EEH_Template::display_template( |
|
366 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
367 | + $template_args, |
|
368 | + true |
|
369 | + ); |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * Returns the template for datetime timezones. |
|
375 | + * |
|
376 | + * @param $template |
|
377 | + * @param $template_args |
|
378 | + * @return string |
|
379 | + * @throws DomainException |
|
380 | + */ |
|
381 | + public function datetime_timezones_template($template, $template_args) |
|
382 | + { |
|
383 | + return EEH_Template::display_template( |
|
384 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
385 | + $template_args, |
|
386 | + true |
|
387 | + ); |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Sets the views for the default list table view. |
|
393 | + * |
|
394 | + * @throws EE_Error |
|
395 | + */ |
|
396 | + protected function _set_list_table_views_default() |
|
397 | + { |
|
398 | + parent::_set_list_table_views_default(); |
|
399 | + $new_views = [ |
|
400 | + 'today' => [ |
|
401 | + 'slug' => 'today', |
|
402 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
403 | + 'count' => $this->total_events_today(), |
|
404 | + 'bulk_action' => [ |
|
405 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
406 | + ], |
|
407 | + ], |
|
408 | + 'month' => [ |
|
409 | + 'slug' => 'month', |
|
410 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
411 | + 'count' => $this->total_events_this_month(), |
|
412 | + 'bulk_action' => [ |
|
413 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
414 | + ], |
|
415 | + ], |
|
416 | + ]; |
|
417 | + $this->_views = array_merge($this->_views, $new_views); |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * Returns the extra action links for the default list table view. |
|
423 | + * |
|
424 | + * @param array $action_links |
|
425 | + * @param EE_Event $event |
|
426 | + * @return array |
|
427 | + * @throws EE_Error |
|
428 | + * @throws ReflectionException |
|
429 | + */ |
|
430 | + public function extra_list_table_actions(array $action_links, EE_Event $event) |
|
431 | + { |
|
432 | + if ( |
|
433 | + EE_Registry::instance()->CAP->current_user_can( |
|
434 | + 'ee_read_registrations', |
|
435 | + 'espresso_registrations_reports', |
|
436 | + $event->ID() |
|
437 | + ) |
|
438 | + ) { |
|
439 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce( |
|
440 | + [ |
|
441 | + 'action' => 'reports', |
|
442 | + 'EVT_ID' => $event->ID(), |
|
443 | + ], |
|
444 | + REG_ADMIN_URL |
|
445 | + ); |
|
446 | + |
|
447 | + $action_links[] = ' |
|
448 | 448 | <a href="' . $reports_link . '" |
449 | 449 | aria-label="' . esc_attr__('View Report', 'event_espresso') . '" |
450 | 450 | class="ee-aria-tooltip button button--icon-only" |
451 | 451 | > |
452 | 452 | <span class="dashicons dashicons-chart-bar"></span> |
453 | 453 | </a>'; |
454 | - } |
|
455 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
456 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
457 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
458 | - 'see_notifications_for', |
|
459 | - null, |
|
460 | - ['EVT_ID' => $event->ID()] |
|
461 | - ); |
|
462 | - } |
|
463 | - return $action_links; |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * @param $items |
|
469 | - * @return mixed |
|
470 | - */ |
|
471 | - public function additional_legend_items($items) |
|
472 | - { |
|
473 | - if ( |
|
474 | - EE_Registry::instance()->CAP->current_user_can( |
|
475 | - 'ee_read_registrations', |
|
476 | - 'espresso_registrations_reports' |
|
477 | - ) |
|
478 | - ) { |
|
479 | - $items['reports'] = [ |
|
480 | - 'class' => 'dashicons dashicons-chart-bar', |
|
481 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
482 | - ]; |
|
483 | - } |
|
484 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
485 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
486 | - // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
487 | - // (can only use numeric offsets when treating strings as arrays) |
|
488 | - if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
489 | - $items['view_related_messages'] = [ |
|
490 | - 'class' => $related_for_icon['css_class'], |
|
491 | - 'desc' => $related_for_icon['label'], |
|
492 | - ]; |
|
493 | - } |
|
494 | - } |
|
495 | - return $items; |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * This is the callback method for the duplicate event route |
|
501 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
502 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
503 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
504 | - * After duplication the redirect is to the new event edit page. |
|
505 | - * |
|
506 | - * @return void |
|
507 | - * @throws EE_Error If EE_Event is not available with given ID |
|
508 | - * @throws ReflectionException |
|
509 | - * @access protected |
|
510 | - */ |
|
511 | - protected function _duplicate_event() |
|
512 | - { |
|
513 | - // first make sure the ID for the event is in the request. |
|
514 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
515 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
516 | - if (! $EVT_ID) { |
|
517 | - EE_Error::add_error( |
|
518 | - esc_html__( |
|
519 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
520 | - 'event_espresso' |
|
521 | - ), |
|
522 | - __FILE__, |
|
523 | - __FUNCTION__, |
|
524 | - __LINE__ |
|
525 | - ); |
|
526 | - $this->_redirect_after_action(false, '', '', [], true); |
|
527 | - return; |
|
528 | - } |
|
529 | - // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
530 | - $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
531 | - if (! $orig_event instanceof EE_Event) { |
|
532 | - throw new EE_Error( |
|
533 | - sprintf( |
|
534 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
535 | - $EVT_ID |
|
536 | - ) |
|
537 | - ); |
|
538 | - } |
|
539 | - // k now let's clone the $orig_event before getting relations |
|
540 | - $new_event = clone $orig_event; |
|
541 | - // original datetimes |
|
542 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
543 | - // other original relations |
|
544 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
545 | - // reset the ID and modify other details to make it clear this is a dupe |
|
546 | - $new_event->set('EVT_ID', 0); |
|
547 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
548 | - $new_event->set('EVT_name', $new_name); |
|
549 | - $new_event->set( |
|
550 | - 'EVT_slug', |
|
551 | - wp_unique_post_slug( |
|
552 | - sanitize_title($orig_event->name()), |
|
553 | - 0, |
|
554 | - 'publish', |
|
555 | - 'espresso_events', |
|
556 | - 0 |
|
557 | - ) |
|
558 | - ); |
|
559 | - $new_event->set('status', 'draft'); |
|
560 | - // duplicate discussion settings |
|
561 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
562 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
563 | - // save the new event |
|
564 | - $new_event->save(); |
|
565 | - // venues |
|
566 | - foreach ($orig_ven as $ven) { |
|
567 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
568 | - } |
|
569 | - $new_event->save(); |
|
570 | - // now we need to get the question group relations and handle that |
|
571 | - // first primary question groups |
|
572 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
573 | - 'Question_Group', |
|
574 | - [['Event_Question_Group.EQG_primary' => true]] |
|
575 | - ); |
|
576 | - if (! empty($orig_primary_qgs)) { |
|
577 | - foreach ($orig_primary_qgs as $obj) { |
|
578 | - if ($obj instanceof EE_Question_Group) { |
|
579 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
580 | - } |
|
581 | - } |
|
582 | - } |
|
583 | - // next additional attendee question groups |
|
584 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
585 | - 'Question_Group', |
|
586 | - [['Event_Question_Group.EQG_additional' => true]] |
|
587 | - ); |
|
588 | - if (! empty($orig_additional_qgs)) { |
|
589 | - foreach ($orig_additional_qgs as $obj) { |
|
590 | - if ($obj instanceof EE_Question_Group) { |
|
591 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
592 | - } |
|
593 | - } |
|
594 | - } |
|
595 | - |
|
596 | - $new_event->save(); |
|
597 | - |
|
598 | - // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
599 | - $cloned_tickets = []; |
|
600 | - foreach ($orig_datetimes as $orig_dtt) { |
|
601 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
602 | - continue; |
|
603 | - } |
|
604 | - $new_dtt = clone $orig_dtt; |
|
605 | - $orig_tickets = $orig_dtt->tickets(); |
|
606 | - // save new dtt then add to event |
|
607 | - $new_dtt->set('DTT_ID', 0); |
|
608 | - $new_dtt->set('DTT_sold', 0); |
|
609 | - $new_dtt->set_reserved(0); |
|
610 | - $new_dtt->save(); |
|
611 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
612 | - $new_event->save(); |
|
613 | - // now let's get the ticket relations setup. |
|
614 | - foreach ((array) $orig_tickets as $orig_ticket) { |
|
615 | - // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
616 | - if (! $orig_ticket instanceof EE_Ticket) { |
|
617 | - continue; |
|
618 | - } |
|
619 | - // is this ticket archived? If it is then let's skip |
|
620 | - if ($orig_ticket->get('TKT_deleted')) { |
|
621 | - continue; |
|
622 | - } |
|
623 | - // does this original ticket already exist in the clone_tickets cache? |
|
624 | - // If so we'll just use the new ticket from it. |
|
625 | - if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
626 | - $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
627 | - } else { |
|
628 | - $new_ticket = clone $orig_ticket; |
|
629 | - // get relations on the $orig_ticket that we need to setup. |
|
630 | - $orig_prices = $orig_ticket->prices(); |
|
631 | - $new_ticket->set('TKT_ID', 0); |
|
632 | - $new_ticket->set('TKT_sold', 0); |
|
633 | - $new_ticket->set('TKT_reserved', 0); |
|
634 | - $new_ticket->save(); // make sure new ticket has ID. |
|
635 | - // price relations on new ticket need to be setup. |
|
636 | - foreach ($orig_prices as $orig_price) { |
|
637 | - $new_price = clone $orig_price; |
|
638 | - $new_price->set('PRC_ID', 0); |
|
639 | - $new_price->save(); |
|
640 | - $new_ticket->_add_relation_to($new_price, 'Price'); |
|
641 | - $new_ticket->save(); |
|
642 | - } |
|
643 | - |
|
644 | - do_action( |
|
645 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
646 | - $orig_ticket, |
|
647 | - $new_ticket, |
|
648 | - $orig_prices, |
|
649 | - $orig_event, |
|
650 | - $orig_dtt, |
|
651 | - $new_dtt |
|
652 | - ); |
|
653 | - } |
|
654 | - // k now we can add the new ticket as a relation to the new datetime |
|
655 | - // and make sure its added to our cached $cloned_tickets array |
|
656 | - // for use with later datetimes that have the same ticket. |
|
657 | - $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
|
658 | - $new_dtt->save(); |
|
659 | - $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
660 | - } |
|
661 | - } |
|
662 | - // clone taxonomy information |
|
663 | - $taxonomies_to_clone_with = apply_filters( |
|
664 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
665 | - ['espresso_event_categories', 'espresso_event_type', 'post_tag'] |
|
666 | - ); |
|
667 | - // get terms for original event (notice) |
|
668 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
669 | - // loop through terms and add them to new event. |
|
670 | - foreach ($orig_terms as $term) { |
|
671 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
672 | - } |
|
673 | - |
|
674 | - // duplicate other core WP_Post items for this event. |
|
675 | - // post thumbnail (feature image). |
|
676 | - $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
677 | - if ($feature_image_id) { |
|
678 | - update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
679 | - } |
|
680 | - |
|
681 | - // duplicate page_template setting |
|
682 | - $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
683 | - if ($page_template) { |
|
684 | - update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
685 | - } |
|
686 | - |
|
687 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
688 | - // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
689 | - if ($new_event->ID()) { |
|
690 | - $redirect_args = [ |
|
691 | - 'post' => $new_event->ID(), |
|
692 | - 'action' => 'edit', |
|
693 | - ]; |
|
694 | - EE_Error::add_success( |
|
695 | - esc_html__( |
|
696 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
697 | - 'event_espresso' |
|
698 | - ) |
|
699 | - ); |
|
700 | - } else { |
|
701 | - $redirect_args = [ |
|
702 | - 'action' => 'default', |
|
703 | - ]; |
|
704 | - EE_Error::add_error( |
|
705 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
706 | - __FILE__, |
|
707 | - __FUNCTION__, |
|
708 | - __LINE__ |
|
709 | - ); |
|
710 | - } |
|
711 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
712 | - } |
|
713 | - |
|
714 | - |
|
715 | - /** |
|
716 | - * Generates output for the import page. |
|
717 | - * |
|
718 | - * @throws EE_Error |
|
719 | - */ |
|
720 | - protected function _import_page() |
|
721 | - { |
|
722 | - $title = esc_html__('Import', 'event_espresso'); |
|
723 | - $intro = esc_html__( |
|
724 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
725 | - 'event_espresso' |
|
726 | - ); |
|
727 | - |
|
728 | - $form_url = EVENTS_ADMIN_URL; |
|
729 | - $action = 'import_events'; |
|
730 | - $type = 'csv'; |
|
731 | - |
|
732 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
733 | - $title, |
|
734 | - $intro, |
|
735 | - $form_url, |
|
736 | - $action, |
|
737 | - $type |
|
738 | - ); |
|
739 | - |
|
740 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
741 | - ['action' => 'sample_export_file'], |
|
742 | - $this->_admin_base_url |
|
743 | - ); |
|
744 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
745 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
746 | - $this->_template_args, |
|
747 | - true |
|
748 | - ); |
|
749 | - $this->display_admin_page_with_sidebar(); |
|
750 | - } |
|
751 | - |
|
752 | - |
|
753 | - /** |
|
754 | - * _import_events |
|
755 | - * This handles displaying the screen and running imports for importing events. |
|
756 | - * |
|
757 | - * @return void |
|
758 | - * @throws EE_Error |
|
759 | - */ |
|
760 | - protected function _import_events() |
|
761 | - { |
|
762 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
763 | - $success = EE_Import::instance()->import(); |
|
764 | - $this->_redirect_after_action( |
|
765 | - $success, |
|
766 | - esc_html__('Import File', 'event_espresso'), |
|
767 | - 'ran', |
|
768 | - ['action' => 'import_page'], |
|
769 | - true |
|
770 | - ); |
|
771 | - } |
|
772 | - |
|
773 | - |
|
774 | - /** |
|
775 | - * _events_export |
|
776 | - * Will export all (or just the given event) to a Excel compatible file. |
|
777 | - * |
|
778 | - * @access protected |
|
779 | - * @return void |
|
780 | - */ |
|
781 | - protected function _events_export() |
|
782 | - { |
|
783 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
784 | - $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int'); |
|
785 | - $this->request->mergeRequestParams( |
|
786 | - [ |
|
787 | - 'export' => 'report', |
|
788 | - 'action' => 'all_event_data', |
|
789 | - 'EVT_ID' => $EVT_ID, |
|
790 | - ] |
|
791 | - ); |
|
792 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
793 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
794 | - $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
795 | - $EE_Export->export(); |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - /** |
|
801 | - * handle category exports() |
|
802 | - * |
|
803 | - * @return void |
|
804 | - */ |
|
805 | - protected function _categories_export() |
|
806 | - { |
|
807 | - $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
808 | - $this->request->mergeRequestParams( |
|
809 | - [ |
|
810 | - 'export' => 'report', |
|
811 | - 'action' => 'categories', |
|
812 | - 'EVT_ID' => $EVT_ID, |
|
813 | - ] |
|
814 | - ); |
|
815 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
816 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
817 | - $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
818 | - $EE_Export->export(); |
|
819 | - } |
|
820 | - } |
|
821 | - |
|
822 | - |
|
823 | - /** |
|
824 | - * Creates a sample CSV file for importing |
|
825 | - */ |
|
826 | - protected function _sample_export_file() |
|
827 | - { |
|
828 | - $EE_Export = EE_Export::instance(); |
|
829 | - if ($EE_Export instanceof EE_Export) { |
|
830 | - $EE_Export->export(); |
|
831 | - } |
|
832 | - } |
|
833 | - |
|
834 | - |
|
835 | - /************* Template Settings *************/ |
|
836 | - /** |
|
837 | - * Generates template settings page output |
|
838 | - * |
|
839 | - * @throws DomainException |
|
840 | - * @throws EE_Error |
|
841 | - * @throws InvalidArgumentException |
|
842 | - * @throws InvalidDataTypeException |
|
843 | - * @throws InvalidInterfaceException |
|
844 | - */ |
|
845 | - protected function _template_settings() |
|
846 | - { |
|
847 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
848 | - /** |
|
849 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
850 | - * from General_Settings_Admin_Page to here. |
|
851 | - */ |
|
852 | - $this->_template_args = apply_filters( |
|
853 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
854 | - $this->_template_args |
|
855 | - ); |
|
856 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
857 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
858 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
859 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
860 | - $this->_template_args, |
|
861 | - true |
|
862 | - ); |
|
863 | - $this->display_admin_page_with_sidebar(); |
|
864 | - } |
|
865 | - |
|
866 | - |
|
867 | - /** |
|
868 | - * Handler for updating template settings. |
|
869 | - * |
|
870 | - * @throws EE_Error |
|
871 | - */ |
|
872 | - protected function _update_template_settings() |
|
873 | - { |
|
874 | - /** |
|
875 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
876 | - * from General_Settings_Admin_Page to here. |
|
877 | - */ |
|
878 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
879 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
880 | - EE_Registry::instance()->CFG->template_settings, |
|
881 | - $this->request->requestParams() |
|
882 | - ); |
|
883 | - // update custom post type slugs and detect if we need to flush rewrite rules |
|
884 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
885 | - |
|
886 | - $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug'); |
|
887 | - |
|
888 | - EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug |
|
889 | - ? EEH_URL::slugify($event_cpt_slug, 'events') |
|
890 | - : EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
891 | - |
|
892 | - $what = esc_html__('Template Settings', 'event_espresso'); |
|
893 | - $success = $this->_update_espresso_configuration( |
|
894 | - $what, |
|
895 | - EE_Registry::instance()->CFG->template_settings, |
|
896 | - __FILE__, |
|
897 | - __FUNCTION__, |
|
898 | - __LINE__ |
|
899 | - ); |
|
900 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
901 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
902 | - $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
903 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
904 | - ); |
|
905 | - $rewrite_rules->flush(); |
|
906 | - } |
|
907 | - $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']); |
|
908 | - } |
|
909 | - |
|
910 | - |
|
911 | - /** |
|
912 | - * _premium_event_editor_meta_boxes |
|
913 | - * add all metaboxes related to the event_editor |
|
914 | - * |
|
915 | - * @access protected |
|
916 | - * @return void |
|
917 | - * @throws EE_Error |
|
918 | - * @throws ReflectionException |
|
919 | - */ |
|
920 | - protected function _premium_event_editor_meta_boxes() |
|
921 | - { |
|
922 | - $this->verify_cpt_object(); |
|
923 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
924 | - if ( |
|
925 | - ! $this->admin_config->useAdvancedEditor() |
|
926 | - || ! $this->feature->allowed('use_reg_options_meta_box') |
|
927 | - ) { |
|
928 | - $this->addMetaBox( |
|
929 | - 'espresso_event_editor_event_options', |
|
930 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
931 | - [$this, 'registration_options_meta_box'], |
|
932 | - $this->page_slug, |
|
933 | - 'side', |
|
934 | - 'core' |
|
935 | - ); |
|
936 | - } |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - /** |
|
941 | - * override caf metabox |
|
942 | - * |
|
943 | - * @return void |
|
944 | - * @throws EE_Error |
|
945 | - * @throws ReflectionException |
|
946 | - */ |
|
947 | - public function registration_options_meta_box() |
|
948 | - { |
|
949 | - $yes_no_values = [ |
|
950 | - ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
951 | - ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
952 | - ]; |
|
953 | - |
|
954 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
955 | - [ |
|
956 | - EEM_Registration::status_id_cancelled, |
|
957 | - EEM_Registration::status_id_declined, |
|
958 | - EEM_Registration::status_id_incomplete, |
|
959 | - EEM_Registration::status_id_wait_list, |
|
960 | - ], |
|
961 | - true |
|
962 | - ); |
|
963 | - |
|
964 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
965 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
966 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
967 | - |
|
968 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
969 | - 'default_reg_status', |
|
970 | - $default_reg_status_values, |
|
971 | - $this->_cpt_model_obj->default_registration_status() |
|
972 | - ); |
|
973 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
974 | - 'display_desc', |
|
975 | - $yes_no_values, |
|
976 | - $this->_cpt_model_obj->display_description() |
|
977 | - ); |
|
978 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
979 | - 'display_ticket_selector', |
|
980 | - $yes_no_values, |
|
981 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
982 | - '', |
|
983 | - '', |
|
984 | - false |
|
985 | - ); |
|
986 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
987 | - 'EVT_default_registration_status', |
|
988 | - $default_reg_status_values, |
|
989 | - $this->_cpt_model_obj->default_registration_status() |
|
990 | - ); |
|
991 | - $template_args['additional_registration_options'] = apply_filters( |
|
992 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
993 | - '', |
|
994 | - $template_args, |
|
995 | - $yes_no_values, |
|
996 | - $default_reg_status_values |
|
997 | - ); |
|
998 | - EEH_Template::display_template( |
|
999 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1000 | - $template_args |
|
1001 | - ); |
|
1002 | - } |
|
1003 | - |
|
1004 | - |
|
1005 | - |
|
1006 | - /** |
|
1007 | - * wp_list_table_mods for caf |
|
1008 | - * ============================ |
|
1009 | - */ |
|
1010 | - /** |
|
1011 | - * hook into list table filters and provide filters for caffeinated list table |
|
1012 | - * |
|
1013 | - * @param array $old_filters any existing filters present |
|
1014 | - * @param array $list_table_obj the list table object |
|
1015 | - * @return array new filters |
|
1016 | - * @throws EE_Error |
|
1017 | - * @throws ReflectionException |
|
1018 | - */ |
|
1019 | - public function list_table_filters($old_filters, $list_table_obj) |
|
1020 | - { |
|
1021 | - $filters = []; |
|
1022 | - // first month/year filters |
|
1023 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
1024 | - $status = $this->request->getRequestParam('status'); |
|
1025 | - // active status dropdown |
|
1026 | - if ($status !== 'draft') { |
|
1027 | - $filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status')); |
|
1028 | - $filters[] = $this->venuesDropdown($this->request->getRequestParam('venue')); |
|
1029 | - } |
|
1030 | - // category filter |
|
1031 | - $filters[] = $this->category_dropdown(); |
|
1032 | - return array_merge($old_filters, $filters); |
|
1033 | - } |
|
1034 | - |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * espresso_event_months_dropdown |
|
1038 | - * |
|
1039 | - * @access public |
|
1040 | - * @return string dropdown listing month/year selections for events. |
|
1041 | - * @throws EE_Error |
|
1042 | - */ |
|
1043 | - public function espresso_event_months_dropdown() |
|
1044 | - { |
|
1045 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
1046 | - // Note we need to include any other filters that are set! |
|
1047 | - return EEH_Form_Fields::generate_event_months_dropdown( |
|
1048 | - $this->request->getRequestParam('month_range'), |
|
1049 | - $this->request->getRequestParam('status'), |
|
1050 | - $this->request->getRequestParam('EVT_CAT', 0, 'int'), |
|
1051 | - $this->request->getRequestParam('active_status') |
|
1052 | - ); |
|
1053 | - } |
|
1054 | - |
|
1055 | - |
|
1056 | - /** |
|
1057 | - * returns a list of "active" statuses on the event |
|
1058 | - * |
|
1059 | - * @param string $current_value whatever the current active status is |
|
1060 | - * @return string |
|
1061 | - */ |
|
1062 | - public function active_status_dropdown($current_value = '') |
|
1063 | - { |
|
1064 | - $select_name = 'active_status'; |
|
1065 | - $values = [ |
|
1066 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1067 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
1068 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1069 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1070 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1071 | - ]; |
|
1072 | - |
|
1073 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
1074 | - } |
|
1075 | - |
|
1076 | - |
|
1077 | - /** |
|
1078 | - * returns a list of "venues" |
|
1079 | - * |
|
1080 | - * @param string $current_value whatever the current active status is |
|
1081 | - * @return string |
|
1082 | - * @throws EE_Error |
|
1083 | - * @throws ReflectionException |
|
1084 | - */ |
|
1085 | - protected function venuesDropdown($current_value = '') |
|
1086 | - { |
|
1087 | - $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
1088 | - // populate the list of venues. |
|
1089 | - $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
1090 | - |
|
1091 | - foreach ($venues as $venue) { |
|
1092 | - $values[ $venue->ID() ] = $venue->name(); |
|
1093 | - } |
|
1094 | - |
|
1095 | - return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
1096 | - } |
|
1097 | - |
|
1098 | - |
|
1099 | - /** |
|
1100 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
1101 | - * |
|
1102 | - * @access public |
|
1103 | - * @return string html |
|
1104 | - * @throws EE_Error |
|
1105 | - * @throws ReflectionException |
|
1106 | - */ |
|
1107 | - public function category_dropdown() |
|
1108 | - { |
|
1109 | - return EEH_Form_Fields::generate_event_category_dropdown( |
|
1110 | - $this->request->getRequestParam('EVT_CAT', -1, 'int') |
|
1111 | - ); |
|
1112 | - } |
|
1113 | - |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * get total number of events today |
|
1117 | - * |
|
1118 | - * @access public |
|
1119 | - * @return int |
|
1120 | - * @throws EE_Error |
|
1121 | - * @throws InvalidArgumentException |
|
1122 | - * @throws InvalidDataTypeException |
|
1123 | - * @throws InvalidInterfaceException |
|
1124 | - */ |
|
1125 | - public function total_events_today() |
|
1126 | - { |
|
1127 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1128 | - 'DTT_EVT_start', |
|
1129 | - date('Y-m-d') . ' 00:00:00', |
|
1130 | - 'Y-m-d H:i:s', |
|
1131 | - 'UTC' |
|
1132 | - ); |
|
1133 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1134 | - 'DTT_EVT_start', |
|
1135 | - date('Y-m-d') . ' 23:59:59', |
|
1136 | - 'Y-m-d H:i:s', |
|
1137 | - 'UTC' |
|
1138 | - ); |
|
1139 | - $where = [ |
|
1140 | - 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1141 | - ]; |
|
1142 | - return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1143 | - } |
|
1144 | - |
|
1145 | - |
|
1146 | - /** |
|
1147 | - * get total number of events this month |
|
1148 | - * |
|
1149 | - * @access public |
|
1150 | - * @return int |
|
1151 | - * @throws EE_Error |
|
1152 | - * @throws InvalidArgumentException |
|
1153 | - * @throws InvalidDataTypeException |
|
1154 | - * @throws InvalidInterfaceException |
|
1155 | - */ |
|
1156 | - public function total_events_this_month() |
|
1157 | - { |
|
1158 | - // Dates |
|
1159 | - $this_year_r = date('Y'); |
|
1160 | - $this_month_r = date('m'); |
|
1161 | - $days_this_month = date('t'); |
|
1162 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1163 | - 'DTT_EVT_start', |
|
1164 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1165 | - 'Y-m-d H:i:s', |
|
1166 | - 'UTC' |
|
1167 | - ); |
|
1168 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1169 | - 'DTT_EVT_start', |
|
1170 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1171 | - 'Y-m-d H:i:s', |
|
1172 | - 'UTC' |
|
1173 | - ); |
|
1174 | - $where = [ |
|
1175 | - 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1176 | - ]; |
|
1177 | - return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1178 | - } |
|
1179 | - |
|
1180 | - |
|
1181 | - /** DEFAULT TICKETS STUFF **/ |
|
1182 | - |
|
1183 | - /** |
|
1184 | - * Output default tickets list table view. |
|
1185 | - * |
|
1186 | - * @throws EE_Error |
|
1187 | - */ |
|
1188 | - public function _tickets_overview_list_table() |
|
1189 | - { |
|
1190 | - if ( |
|
1191 | - $this->admin_config->useAdvancedEditor() |
|
1192 | - && $this->feature->allowed('use_default_ticket_manager') |
|
1193 | - ) { |
|
1194 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
1195 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1196 | - EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
1197 | - [], |
|
1198 | - true |
|
1199 | - ); |
|
1200 | - $this->display_admin_page_with_no_sidebar(); |
|
1201 | - } else { |
|
1202 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1203 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1204 | - } |
|
1205 | - } |
|
1206 | - |
|
1207 | - |
|
1208 | - /** |
|
1209 | - * @param int $per_page |
|
1210 | - * @param bool $count |
|
1211 | - * @param bool $trashed |
|
1212 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1213 | - * @throws EE_Error |
|
1214 | - */ |
|
1215 | - public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1216 | - { |
|
1217 | - $orderby = $this->request->getRequestParam('orderby', 'TKT_name'); |
|
1218 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
1219 | - switch ($orderby) { |
|
1220 | - case 'TKT_name': |
|
1221 | - $orderby = ['TKT_name' => $order]; |
|
1222 | - break; |
|
1223 | - case 'TKT_price': |
|
1224 | - $orderby = ['TKT_price' => $order]; |
|
1225 | - break; |
|
1226 | - case 'TKT_uses': |
|
1227 | - $orderby = ['TKT_uses' => $order]; |
|
1228 | - break; |
|
1229 | - case 'TKT_min': |
|
1230 | - $orderby = ['TKT_min' => $order]; |
|
1231 | - break; |
|
1232 | - case 'TKT_max': |
|
1233 | - $orderby = ['TKT_max' => $order]; |
|
1234 | - break; |
|
1235 | - case 'TKT_qty': |
|
1236 | - $orderby = ['TKT_qty' => $order]; |
|
1237 | - break; |
|
1238 | - } |
|
1239 | - |
|
1240 | - $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
1241 | - $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
1242 | - $offset = ($current_page - 1) * $per_page; |
|
1243 | - |
|
1244 | - $where = [ |
|
1245 | - 'TKT_is_default' => 1, |
|
1246 | - 'TKT_deleted' => $trashed, |
|
1247 | - ]; |
|
1248 | - |
|
1249 | - $search_term = $this->request->getRequestParam('s'); |
|
1250 | - if ($search_term) { |
|
1251 | - $search_term = '%' . $search_term . '%'; |
|
1252 | - $where['OR'] = [ |
|
1253 | - 'TKT_name' => ['LIKE', $search_term], |
|
1254 | - 'TKT_description' => ['LIKE', $search_term], |
|
1255 | - ]; |
|
1256 | - } |
|
1257 | - |
|
1258 | - return $count |
|
1259 | - ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where]) |
|
1260 | - : EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
1261 | - [ |
|
1262 | - $where, |
|
1263 | - 'order_by' => $orderby, |
|
1264 | - 'limit' => [$offset, $per_page], |
|
1265 | - 'group_by' => 'TKT_ID', |
|
1266 | - ] |
|
1267 | - ); |
|
1268 | - } |
|
1269 | - |
|
1270 | - |
|
1271 | - /** |
|
1272 | - * @param bool $trash |
|
1273 | - * @throws EE_Error |
|
1274 | - * @throws InvalidArgumentException |
|
1275 | - * @throws InvalidDataTypeException |
|
1276 | - * @throws InvalidInterfaceException |
|
1277 | - */ |
|
1278 | - protected function _trash_or_restore_ticket($trash = false) |
|
1279 | - { |
|
1280 | - $success = 1; |
|
1281 | - $TKT = EEM_Ticket::instance(); |
|
1282 | - // checkboxes? |
|
1283 | - $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1284 | - if (! empty($checkboxes)) { |
|
1285 | - // if array has more than one element then success message should be plural |
|
1286 | - $success = count($checkboxes) > 1 ? 2 : 1; |
|
1287 | - // cycle thru the boxes |
|
1288 | - while (list($TKT_ID, $value) = each($checkboxes)) { |
|
1289 | - if ($trash) { |
|
1290 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1291 | - $success = 0; |
|
1292 | - } |
|
1293 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1294 | - $success = 0; |
|
1295 | - } |
|
1296 | - } |
|
1297 | - } else { |
|
1298 | - // grab single id and trash |
|
1299 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1300 | - if ($trash) { |
|
1301 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1302 | - $success = 0; |
|
1303 | - } |
|
1304 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1305 | - $success = 0; |
|
1306 | - } |
|
1307 | - } |
|
1308 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1309 | - $query_args = [ |
|
1310 | - 'action' => 'ticket_list_table', |
|
1311 | - 'status' => $trash ? '' : 'trashed', |
|
1312 | - ]; |
|
1313 | - $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1314 | - } |
|
1315 | - |
|
1316 | - |
|
1317 | - /** |
|
1318 | - * Handles trashing default ticket. |
|
1319 | - * |
|
1320 | - * @throws EE_Error |
|
1321 | - * @throws ReflectionException |
|
1322 | - */ |
|
1323 | - protected function _delete_ticket() |
|
1324 | - { |
|
1325 | - $success = 1; |
|
1326 | - // checkboxes? |
|
1327 | - $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1328 | - if (! empty($checkboxes)) { |
|
1329 | - // if array has more than one element then success message should be plural |
|
1330 | - $success = count($checkboxes) > 1 ? 2 : 1; |
|
1331 | - // cycle thru the boxes |
|
1332 | - while (list($TKT_ID, $value) = each($checkboxes)) { |
|
1333 | - // delete |
|
1334 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1335 | - $success = 0; |
|
1336 | - } |
|
1337 | - } |
|
1338 | - } else { |
|
1339 | - // grab single id and trash |
|
1340 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1341 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1342 | - $success = 0; |
|
1343 | - } |
|
1344 | - } |
|
1345 | - $action_desc = 'deleted'; |
|
1346 | - $query_args = [ |
|
1347 | - 'action' => 'ticket_list_table', |
|
1348 | - 'status' => 'trashed', |
|
1349 | - ]; |
|
1350 | - // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1351 | - if ( |
|
1352 | - EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1353 | - [['TKT_is_default' => 1]], |
|
1354 | - 'TKT_ID', |
|
1355 | - true |
|
1356 | - ) |
|
1357 | - ) { |
|
1358 | - $query_args = []; |
|
1359 | - } |
|
1360 | - $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1361 | - } |
|
1362 | - |
|
1363 | - |
|
1364 | - /** |
|
1365 | - * @param int $TKT_ID |
|
1366 | - * @return bool|int |
|
1367 | - * @throws EE_Error |
|
1368 | - * @throws ReflectionException |
|
1369 | - */ |
|
1370 | - protected function _delete_the_ticket($TKT_ID) |
|
1371 | - { |
|
1372 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1373 | - if (! $ticket instanceof EE_Ticket) { |
|
1374 | - return false; |
|
1375 | - } |
|
1376 | - $ticket->_remove_relations('Datetime'); |
|
1377 | - // delete all related prices first |
|
1378 | - $ticket->delete_related_permanently('Price'); |
|
1379 | - return $ticket->delete_permanently(); |
|
1380 | - } |
|
454 | + } |
|
455 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
456 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
457 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
458 | + 'see_notifications_for', |
|
459 | + null, |
|
460 | + ['EVT_ID' => $event->ID()] |
|
461 | + ); |
|
462 | + } |
|
463 | + return $action_links; |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * @param $items |
|
469 | + * @return mixed |
|
470 | + */ |
|
471 | + public function additional_legend_items($items) |
|
472 | + { |
|
473 | + if ( |
|
474 | + EE_Registry::instance()->CAP->current_user_can( |
|
475 | + 'ee_read_registrations', |
|
476 | + 'espresso_registrations_reports' |
|
477 | + ) |
|
478 | + ) { |
|
479 | + $items['reports'] = [ |
|
480 | + 'class' => 'dashicons dashicons-chart-bar', |
|
481 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
482 | + ]; |
|
483 | + } |
|
484 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
485 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
486 | + // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
487 | + // (can only use numeric offsets when treating strings as arrays) |
|
488 | + if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
489 | + $items['view_related_messages'] = [ |
|
490 | + 'class' => $related_for_icon['css_class'], |
|
491 | + 'desc' => $related_for_icon['label'], |
|
492 | + ]; |
|
493 | + } |
|
494 | + } |
|
495 | + return $items; |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * This is the callback method for the duplicate event route |
|
501 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
502 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
503 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
504 | + * After duplication the redirect is to the new event edit page. |
|
505 | + * |
|
506 | + * @return void |
|
507 | + * @throws EE_Error If EE_Event is not available with given ID |
|
508 | + * @throws ReflectionException |
|
509 | + * @access protected |
|
510 | + */ |
|
511 | + protected function _duplicate_event() |
|
512 | + { |
|
513 | + // first make sure the ID for the event is in the request. |
|
514 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
515 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
516 | + if (! $EVT_ID) { |
|
517 | + EE_Error::add_error( |
|
518 | + esc_html__( |
|
519 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
520 | + 'event_espresso' |
|
521 | + ), |
|
522 | + __FILE__, |
|
523 | + __FUNCTION__, |
|
524 | + __LINE__ |
|
525 | + ); |
|
526 | + $this->_redirect_after_action(false, '', '', [], true); |
|
527 | + return; |
|
528 | + } |
|
529 | + // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
530 | + $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
531 | + if (! $orig_event instanceof EE_Event) { |
|
532 | + throw new EE_Error( |
|
533 | + sprintf( |
|
534 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
535 | + $EVT_ID |
|
536 | + ) |
|
537 | + ); |
|
538 | + } |
|
539 | + // k now let's clone the $orig_event before getting relations |
|
540 | + $new_event = clone $orig_event; |
|
541 | + // original datetimes |
|
542 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
543 | + // other original relations |
|
544 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
545 | + // reset the ID and modify other details to make it clear this is a dupe |
|
546 | + $new_event->set('EVT_ID', 0); |
|
547 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
548 | + $new_event->set('EVT_name', $new_name); |
|
549 | + $new_event->set( |
|
550 | + 'EVT_slug', |
|
551 | + wp_unique_post_slug( |
|
552 | + sanitize_title($orig_event->name()), |
|
553 | + 0, |
|
554 | + 'publish', |
|
555 | + 'espresso_events', |
|
556 | + 0 |
|
557 | + ) |
|
558 | + ); |
|
559 | + $new_event->set('status', 'draft'); |
|
560 | + // duplicate discussion settings |
|
561 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
562 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
563 | + // save the new event |
|
564 | + $new_event->save(); |
|
565 | + // venues |
|
566 | + foreach ($orig_ven as $ven) { |
|
567 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
568 | + } |
|
569 | + $new_event->save(); |
|
570 | + // now we need to get the question group relations and handle that |
|
571 | + // first primary question groups |
|
572 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
573 | + 'Question_Group', |
|
574 | + [['Event_Question_Group.EQG_primary' => true]] |
|
575 | + ); |
|
576 | + if (! empty($orig_primary_qgs)) { |
|
577 | + foreach ($orig_primary_qgs as $obj) { |
|
578 | + if ($obj instanceof EE_Question_Group) { |
|
579 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
580 | + } |
|
581 | + } |
|
582 | + } |
|
583 | + // next additional attendee question groups |
|
584 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
585 | + 'Question_Group', |
|
586 | + [['Event_Question_Group.EQG_additional' => true]] |
|
587 | + ); |
|
588 | + if (! empty($orig_additional_qgs)) { |
|
589 | + foreach ($orig_additional_qgs as $obj) { |
|
590 | + if ($obj instanceof EE_Question_Group) { |
|
591 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
592 | + } |
|
593 | + } |
|
594 | + } |
|
595 | + |
|
596 | + $new_event->save(); |
|
597 | + |
|
598 | + // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
599 | + $cloned_tickets = []; |
|
600 | + foreach ($orig_datetimes as $orig_dtt) { |
|
601 | + if (! $orig_dtt instanceof EE_Datetime) { |
|
602 | + continue; |
|
603 | + } |
|
604 | + $new_dtt = clone $orig_dtt; |
|
605 | + $orig_tickets = $orig_dtt->tickets(); |
|
606 | + // save new dtt then add to event |
|
607 | + $new_dtt->set('DTT_ID', 0); |
|
608 | + $new_dtt->set('DTT_sold', 0); |
|
609 | + $new_dtt->set_reserved(0); |
|
610 | + $new_dtt->save(); |
|
611 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
612 | + $new_event->save(); |
|
613 | + // now let's get the ticket relations setup. |
|
614 | + foreach ((array) $orig_tickets as $orig_ticket) { |
|
615 | + // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
616 | + if (! $orig_ticket instanceof EE_Ticket) { |
|
617 | + continue; |
|
618 | + } |
|
619 | + // is this ticket archived? If it is then let's skip |
|
620 | + if ($orig_ticket->get('TKT_deleted')) { |
|
621 | + continue; |
|
622 | + } |
|
623 | + // does this original ticket already exist in the clone_tickets cache? |
|
624 | + // If so we'll just use the new ticket from it. |
|
625 | + if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
626 | + $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
627 | + } else { |
|
628 | + $new_ticket = clone $orig_ticket; |
|
629 | + // get relations on the $orig_ticket that we need to setup. |
|
630 | + $orig_prices = $orig_ticket->prices(); |
|
631 | + $new_ticket->set('TKT_ID', 0); |
|
632 | + $new_ticket->set('TKT_sold', 0); |
|
633 | + $new_ticket->set('TKT_reserved', 0); |
|
634 | + $new_ticket->save(); // make sure new ticket has ID. |
|
635 | + // price relations on new ticket need to be setup. |
|
636 | + foreach ($orig_prices as $orig_price) { |
|
637 | + $new_price = clone $orig_price; |
|
638 | + $new_price->set('PRC_ID', 0); |
|
639 | + $new_price->save(); |
|
640 | + $new_ticket->_add_relation_to($new_price, 'Price'); |
|
641 | + $new_ticket->save(); |
|
642 | + } |
|
643 | + |
|
644 | + do_action( |
|
645 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
646 | + $orig_ticket, |
|
647 | + $new_ticket, |
|
648 | + $orig_prices, |
|
649 | + $orig_event, |
|
650 | + $orig_dtt, |
|
651 | + $new_dtt |
|
652 | + ); |
|
653 | + } |
|
654 | + // k now we can add the new ticket as a relation to the new datetime |
|
655 | + // and make sure its added to our cached $cloned_tickets array |
|
656 | + // for use with later datetimes that have the same ticket. |
|
657 | + $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
|
658 | + $new_dtt->save(); |
|
659 | + $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
660 | + } |
|
661 | + } |
|
662 | + // clone taxonomy information |
|
663 | + $taxonomies_to_clone_with = apply_filters( |
|
664 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
665 | + ['espresso_event_categories', 'espresso_event_type', 'post_tag'] |
|
666 | + ); |
|
667 | + // get terms for original event (notice) |
|
668 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
669 | + // loop through terms and add them to new event. |
|
670 | + foreach ($orig_terms as $term) { |
|
671 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
672 | + } |
|
673 | + |
|
674 | + // duplicate other core WP_Post items for this event. |
|
675 | + // post thumbnail (feature image). |
|
676 | + $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
677 | + if ($feature_image_id) { |
|
678 | + update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
679 | + } |
|
680 | + |
|
681 | + // duplicate page_template setting |
|
682 | + $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
683 | + if ($page_template) { |
|
684 | + update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
685 | + } |
|
686 | + |
|
687 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
688 | + // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
689 | + if ($new_event->ID()) { |
|
690 | + $redirect_args = [ |
|
691 | + 'post' => $new_event->ID(), |
|
692 | + 'action' => 'edit', |
|
693 | + ]; |
|
694 | + EE_Error::add_success( |
|
695 | + esc_html__( |
|
696 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
697 | + 'event_espresso' |
|
698 | + ) |
|
699 | + ); |
|
700 | + } else { |
|
701 | + $redirect_args = [ |
|
702 | + 'action' => 'default', |
|
703 | + ]; |
|
704 | + EE_Error::add_error( |
|
705 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
706 | + __FILE__, |
|
707 | + __FUNCTION__, |
|
708 | + __LINE__ |
|
709 | + ); |
|
710 | + } |
|
711 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
712 | + } |
|
713 | + |
|
714 | + |
|
715 | + /** |
|
716 | + * Generates output for the import page. |
|
717 | + * |
|
718 | + * @throws EE_Error |
|
719 | + */ |
|
720 | + protected function _import_page() |
|
721 | + { |
|
722 | + $title = esc_html__('Import', 'event_espresso'); |
|
723 | + $intro = esc_html__( |
|
724 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
725 | + 'event_espresso' |
|
726 | + ); |
|
727 | + |
|
728 | + $form_url = EVENTS_ADMIN_URL; |
|
729 | + $action = 'import_events'; |
|
730 | + $type = 'csv'; |
|
731 | + |
|
732 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
733 | + $title, |
|
734 | + $intro, |
|
735 | + $form_url, |
|
736 | + $action, |
|
737 | + $type |
|
738 | + ); |
|
739 | + |
|
740 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
741 | + ['action' => 'sample_export_file'], |
|
742 | + $this->_admin_base_url |
|
743 | + ); |
|
744 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
745 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
746 | + $this->_template_args, |
|
747 | + true |
|
748 | + ); |
|
749 | + $this->display_admin_page_with_sidebar(); |
|
750 | + } |
|
751 | + |
|
752 | + |
|
753 | + /** |
|
754 | + * _import_events |
|
755 | + * This handles displaying the screen and running imports for importing events. |
|
756 | + * |
|
757 | + * @return void |
|
758 | + * @throws EE_Error |
|
759 | + */ |
|
760 | + protected function _import_events() |
|
761 | + { |
|
762 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
763 | + $success = EE_Import::instance()->import(); |
|
764 | + $this->_redirect_after_action( |
|
765 | + $success, |
|
766 | + esc_html__('Import File', 'event_espresso'), |
|
767 | + 'ran', |
|
768 | + ['action' => 'import_page'], |
|
769 | + true |
|
770 | + ); |
|
771 | + } |
|
772 | + |
|
773 | + |
|
774 | + /** |
|
775 | + * _events_export |
|
776 | + * Will export all (or just the given event) to a Excel compatible file. |
|
777 | + * |
|
778 | + * @access protected |
|
779 | + * @return void |
|
780 | + */ |
|
781 | + protected function _events_export() |
|
782 | + { |
|
783 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
784 | + $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int'); |
|
785 | + $this->request->mergeRequestParams( |
|
786 | + [ |
|
787 | + 'export' => 'report', |
|
788 | + 'action' => 'all_event_data', |
|
789 | + 'EVT_ID' => $EVT_ID, |
|
790 | + ] |
|
791 | + ); |
|
792 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
793 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
794 | + $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
795 | + $EE_Export->export(); |
|
796 | + } |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + /** |
|
801 | + * handle category exports() |
|
802 | + * |
|
803 | + * @return void |
|
804 | + */ |
|
805 | + protected function _categories_export() |
|
806 | + { |
|
807 | + $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
808 | + $this->request->mergeRequestParams( |
|
809 | + [ |
|
810 | + 'export' => 'report', |
|
811 | + 'action' => 'categories', |
|
812 | + 'EVT_ID' => $EVT_ID, |
|
813 | + ] |
|
814 | + ); |
|
815 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
816 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
817 | + $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
818 | + $EE_Export->export(); |
|
819 | + } |
|
820 | + } |
|
821 | + |
|
822 | + |
|
823 | + /** |
|
824 | + * Creates a sample CSV file for importing |
|
825 | + */ |
|
826 | + protected function _sample_export_file() |
|
827 | + { |
|
828 | + $EE_Export = EE_Export::instance(); |
|
829 | + if ($EE_Export instanceof EE_Export) { |
|
830 | + $EE_Export->export(); |
|
831 | + } |
|
832 | + } |
|
833 | + |
|
834 | + |
|
835 | + /************* Template Settings *************/ |
|
836 | + /** |
|
837 | + * Generates template settings page output |
|
838 | + * |
|
839 | + * @throws DomainException |
|
840 | + * @throws EE_Error |
|
841 | + * @throws InvalidArgumentException |
|
842 | + * @throws InvalidDataTypeException |
|
843 | + * @throws InvalidInterfaceException |
|
844 | + */ |
|
845 | + protected function _template_settings() |
|
846 | + { |
|
847 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
848 | + /** |
|
849 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
850 | + * from General_Settings_Admin_Page to here. |
|
851 | + */ |
|
852 | + $this->_template_args = apply_filters( |
|
853 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
854 | + $this->_template_args |
|
855 | + ); |
|
856 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
857 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
858 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
859 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
860 | + $this->_template_args, |
|
861 | + true |
|
862 | + ); |
|
863 | + $this->display_admin_page_with_sidebar(); |
|
864 | + } |
|
865 | + |
|
866 | + |
|
867 | + /** |
|
868 | + * Handler for updating template settings. |
|
869 | + * |
|
870 | + * @throws EE_Error |
|
871 | + */ |
|
872 | + protected function _update_template_settings() |
|
873 | + { |
|
874 | + /** |
|
875 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
876 | + * from General_Settings_Admin_Page to here. |
|
877 | + */ |
|
878 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
879 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
880 | + EE_Registry::instance()->CFG->template_settings, |
|
881 | + $this->request->requestParams() |
|
882 | + ); |
|
883 | + // update custom post type slugs and detect if we need to flush rewrite rules |
|
884 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
885 | + |
|
886 | + $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug'); |
|
887 | + |
|
888 | + EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug |
|
889 | + ? EEH_URL::slugify($event_cpt_slug, 'events') |
|
890 | + : EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
891 | + |
|
892 | + $what = esc_html__('Template Settings', 'event_espresso'); |
|
893 | + $success = $this->_update_espresso_configuration( |
|
894 | + $what, |
|
895 | + EE_Registry::instance()->CFG->template_settings, |
|
896 | + __FILE__, |
|
897 | + __FUNCTION__, |
|
898 | + __LINE__ |
|
899 | + ); |
|
900 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
901 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
902 | + $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
903 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
904 | + ); |
|
905 | + $rewrite_rules->flush(); |
|
906 | + } |
|
907 | + $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']); |
|
908 | + } |
|
909 | + |
|
910 | + |
|
911 | + /** |
|
912 | + * _premium_event_editor_meta_boxes |
|
913 | + * add all metaboxes related to the event_editor |
|
914 | + * |
|
915 | + * @access protected |
|
916 | + * @return void |
|
917 | + * @throws EE_Error |
|
918 | + * @throws ReflectionException |
|
919 | + */ |
|
920 | + protected function _premium_event_editor_meta_boxes() |
|
921 | + { |
|
922 | + $this->verify_cpt_object(); |
|
923 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
924 | + if ( |
|
925 | + ! $this->admin_config->useAdvancedEditor() |
|
926 | + || ! $this->feature->allowed('use_reg_options_meta_box') |
|
927 | + ) { |
|
928 | + $this->addMetaBox( |
|
929 | + 'espresso_event_editor_event_options', |
|
930 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
931 | + [$this, 'registration_options_meta_box'], |
|
932 | + $this->page_slug, |
|
933 | + 'side', |
|
934 | + 'core' |
|
935 | + ); |
|
936 | + } |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + /** |
|
941 | + * override caf metabox |
|
942 | + * |
|
943 | + * @return void |
|
944 | + * @throws EE_Error |
|
945 | + * @throws ReflectionException |
|
946 | + */ |
|
947 | + public function registration_options_meta_box() |
|
948 | + { |
|
949 | + $yes_no_values = [ |
|
950 | + ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
951 | + ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
952 | + ]; |
|
953 | + |
|
954 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
955 | + [ |
|
956 | + EEM_Registration::status_id_cancelled, |
|
957 | + EEM_Registration::status_id_declined, |
|
958 | + EEM_Registration::status_id_incomplete, |
|
959 | + EEM_Registration::status_id_wait_list, |
|
960 | + ], |
|
961 | + true |
|
962 | + ); |
|
963 | + |
|
964 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
965 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
966 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
967 | + |
|
968 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
969 | + 'default_reg_status', |
|
970 | + $default_reg_status_values, |
|
971 | + $this->_cpt_model_obj->default_registration_status() |
|
972 | + ); |
|
973 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
974 | + 'display_desc', |
|
975 | + $yes_no_values, |
|
976 | + $this->_cpt_model_obj->display_description() |
|
977 | + ); |
|
978 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
979 | + 'display_ticket_selector', |
|
980 | + $yes_no_values, |
|
981 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
982 | + '', |
|
983 | + '', |
|
984 | + false |
|
985 | + ); |
|
986 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
987 | + 'EVT_default_registration_status', |
|
988 | + $default_reg_status_values, |
|
989 | + $this->_cpt_model_obj->default_registration_status() |
|
990 | + ); |
|
991 | + $template_args['additional_registration_options'] = apply_filters( |
|
992 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
993 | + '', |
|
994 | + $template_args, |
|
995 | + $yes_no_values, |
|
996 | + $default_reg_status_values |
|
997 | + ); |
|
998 | + EEH_Template::display_template( |
|
999 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1000 | + $template_args |
|
1001 | + ); |
|
1002 | + } |
|
1003 | + |
|
1004 | + |
|
1005 | + |
|
1006 | + /** |
|
1007 | + * wp_list_table_mods for caf |
|
1008 | + * ============================ |
|
1009 | + */ |
|
1010 | + /** |
|
1011 | + * hook into list table filters and provide filters for caffeinated list table |
|
1012 | + * |
|
1013 | + * @param array $old_filters any existing filters present |
|
1014 | + * @param array $list_table_obj the list table object |
|
1015 | + * @return array new filters |
|
1016 | + * @throws EE_Error |
|
1017 | + * @throws ReflectionException |
|
1018 | + */ |
|
1019 | + public function list_table_filters($old_filters, $list_table_obj) |
|
1020 | + { |
|
1021 | + $filters = []; |
|
1022 | + // first month/year filters |
|
1023 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
1024 | + $status = $this->request->getRequestParam('status'); |
|
1025 | + // active status dropdown |
|
1026 | + if ($status !== 'draft') { |
|
1027 | + $filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status')); |
|
1028 | + $filters[] = $this->venuesDropdown($this->request->getRequestParam('venue')); |
|
1029 | + } |
|
1030 | + // category filter |
|
1031 | + $filters[] = $this->category_dropdown(); |
|
1032 | + return array_merge($old_filters, $filters); |
|
1033 | + } |
|
1034 | + |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * espresso_event_months_dropdown |
|
1038 | + * |
|
1039 | + * @access public |
|
1040 | + * @return string dropdown listing month/year selections for events. |
|
1041 | + * @throws EE_Error |
|
1042 | + */ |
|
1043 | + public function espresso_event_months_dropdown() |
|
1044 | + { |
|
1045 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
1046 | + // Note we need to include any other filters that are set! |
|
1047 | + return EEH_Form_Fields::generate_event_months_dropdown( |
|
1048 | + $this->request->getRequestParam('month_range'), |
|
1049 | + $this->request->getRequestParam('status'), |
|
1050 | + $this->request->getRequestParam('EVT_CAT', 0, 'int'), |
|
1051 | + $this->request->getRequestParam('active_status') |
|
1052 | + ); |
|
1053 | + } |
|
1054 | + |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * returns a list of "active" statuses on the event |
|
1058 | + * |
|
1059 | + * @param string $current_value whatever the current active status is |
|
1060 | + * @return string |
|
1061 | + */ |
|
1062 | + public function active_status_dropdown($current_value = '') |
|
1063 | + { |
|
1064 | + $select_name = 'active_status'; |
|
1065 | + $values = [ |
|
1066 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1067 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
1068 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1069 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1070 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1071 | + ]; |
|
1072 | + |
|
1073 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
1074 | + } |
|
1075 | + |
|
1076 | + |
|
1077 | + /** |
|
1078 | + * returns a list of "venues" |
|
1079 | + * |
|
1080 | + * @param string $current_value whatever the current active status is |
|
1081 | + * @return string |
|
1082 | + * @throws EE_Error |
|
1083 | + * @throws ReflectionException |
|
1084 | + */ |
|
1085 | + protected function venuesDropdown($current_value = '') |
|
1086 | + { |
|
1087 | + $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
1088 | + // populate the list of venues. |
|
1089 | + $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
1090 | + |
|
1091 | + foreach ($venues as $venue) { |
|
1092 | + $values[ $venue->ID() ] = $venue->name(); |
|
1093 | + } |
|
1094 | + |
|
1095 | + return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
1096 | + } |
|
1097 | + |
|
1098 | + |
|
1099 | + /** |
|
1100 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
1101 | + * |
|
1102 | + * @access public |
|
1103 | + * @return string html |
|
1104 | + * @throws EE_Error |
|
1105 | + * @throws ReflectionException |
|
1106 | + */ |
|
1107 | + public function category_dropdown() |
|
1108 | + { |
|
1109 | + return EEH_Form_Fields::generate_event_category_dropdown( |
|
1110 | + $this->request->getRequestParam('EVT_CAT', -1, 'int') |
|
1111 | + ); |
|
1112 | + } |
|
1113 | + |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * get total number of events today |
|
1117 | + * |
|
1118 | + * @access public |
|
1119 | + * @return int |
|
1120 | + * @throws EE_Error |
|
1121 | + * @throws InvalidArgumentException |
|
1122 | + * @throws InvalidDataTypeException |
|
1123 | + * @throws InvalidInterfaceException |
|
1124 | + */ |
|
1125 | + public function total_events_today() |
|
1126 | + { |
|
1127 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1128 | + 'DTT_EVT_start', |
|
1129 | + date('Y-m-d') . ' 00:00:00', |
|
1130 | + 'Y-m-d H:i:s', |
|
1131 | + 'UTC' |
|
1132 | + ); |
|
1133 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1134 | + 'DTT_EVT_start', |
|
1135 | + date('Y-m-d') . ' 23:59:59', |
|
1136 | + 'Y-m-d H:i:s', |
|
1137 | + 'UTC' |
|
1138 | + ); |
|
1139 | + $where = [ |
|
1140 | + 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1141 | + ]; |
|
1142 | + return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1143 | + } |
|
1144 | + |
|
1145 | + |
|
1146 | + /** |
|
1147 | + * get total number of events this month |
|
1148 | + * |
|
1149 | + * @access public |
|
1150 | + * @return int |
|
1151 | + * @throws EE_Error |
|
1152 | + * @throws InvalidArgumentException |
|
1153 | + * @throws InvalidDataTypeException |
|
1154 | + * @throws InvalidInterfaceException |
|
1155 | + */ |
|
1156 | + public function total_events_this_month() |
|
1157 | + { |
|
1158 | + // Dates |
|
1159 | + $this_year_r = date('Y'); |
|
1160 | + $this_month_r = date('m'); |
|
1161 | + $days_this_month = date('t'); |
|
1162 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1163 | + 'DTT_EVT_start', |
|
1164 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1165 | + 'Y-m-d H:i:s', |
|
1166 | + 'UTC' |
|
1167 | + ); |
|
1168 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1169 | + 'DTT_EVT_start', |
|
1170 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1171 | + 'Y-m-d H:i:s', |
|
1172 | + 'UTC' |
|
1173 | + ); |
|
1174 | + $where = [ |
|
1175 | + 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
1176 | + ]; |
|
1177 | + return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
1178 | + } |
|
1179 | + |
|
1180 | + |
|
1181 | + /** DEFAULT TICKETS STUFF **/ |
|
1182 | + |
|
1183 | + /** |
|
1184 | + * Output default tickets list table view. |
|
1185 | + * |
|
1186 | + * @throws EE_Error |
|
1187 | + */ |
|
1188 | + public function _tickets_overview_list_table() |
|
1189 | + { |
|
1190 | + if ( |
|
1191 | + $this->admin_config->useAdvancedEditor() |
|
1192 | + && $this->feature->allowed('use_default_ticket_manager') |
|
1193 | + ) { |
|
1194 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
1195 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1196 | + EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
1197 | + [], |
|
1198 | + true |
|
1199 | + ); |
|
1200 | + $this->display_admin_page_with_no_sidebar(); |
|
1201 | + } else { |
|
1202 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1203 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1204 | + } |
|
1205 | + } |
|
1206 | + |
|
1207 | + |
|
1208 | + /** |
|
1209 | + * @param int $per_page |
|
1210 | + * @param bool $count |
|
1211 | + * @param bool $trashed |
|
1212 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1213 | + * @throws EE_Error |
|
1214 | + */ |
|
1215 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1216 | + { |
|
1217 | + $orderby = $this->request->getRequestParam('orderby', 'TKT_name'); |
|
1218 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
1219 | + switch ($orderby) { |
|
1220 | + case 'TKT_name': |
|
1221 | + $orderby = ['TKT_name' => $order]; |
|
1222 | + break; |
|
1223 | + case 'TKT_price': |
|
1224 | + $orderby = ['TKT_price' => $order]; |
|
1225 | + break; |
|
1226 | + case 'TKT_uses': |
|
1227 | + $orderby = ['TKT_uses' => $order]; |
|
1228 | + break; |
|
1229 | + case 'TKT_min': |
|
1230 | + $orderby = ['TKT_min' => $order]; |
|
1231 | + break; |
|
1232 | + case 'TKT_max': |
|
1233 | + $orderby = ['TKT_max' => $order]; |
|
1234 | + break; |
|
1235 | + case 'TKT_qty': |
|
1236 | + $orderby = ['TKT_qty' => $order]; |
|
1237 | + break; |
|
1238 | + } |
|
1239 | + |
|
1240 | + $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
1241 | + $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
1242 | + $offset = ($current_page - 1) * $per_page; |
|
1243 | + |
|
1244 | + $where = [ |
|
1245 | + 'TKT_is_default' => 1, |
|
1246 | + 'TKT_deleted' => $trashed, |
|
1247 | + ]; |
|
1248 | + |
|
1249 | + $search_term = $this->request->getRequestParam('s'); |
|
1250 | + if ($search_term) { |
|
1251 | + $search_term = '%' . $search_term . '%'; |
|
1252 | + $where['OR'] = [ |
|
1253 | + 'TKT_name' => ['LIKE', $search_term], |
|
1254 | + 'TKT_description' => ['LIKE', $search_term], |
|
1255 | + ]; |
|
1256 | + } |
|
1257 | + |
|
1258 | + return $count |
|
1259 | + ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where]) |
|
1260 | + : EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
1261 | + [ |
|
1262 | + $where, |
|
1263 | + 'order_by' => $orderby, |
|
1264 | + 'limit' => [$offset, $per_page], |
|
1265 | + 'group_by' => 'TKT_ID', |
|
1266 | + ] |
|
1267 | + ); |
|
1268 | + } |
|
1269 | + |
|
1270 | + |
|
1271 | + /** |
|
1272 | + * @param bool $trash |
|
1273 | + * @throws EE_Error |
|
1274 | + * @throws InvalidArgumentException |
|
1275 | + * @throws InvalidDataTypeException |
|
1276 | + * @throws InvalidInterfaceException |
|
1277 | + */ |
|
1278 | + protected function _trash_or_restore_ticket($trash = false) |
|
1279 | + { |
|
1280 | + $success = 1; |
|
1281 | + $TKT = EEM_Ticket::instance(); |
|
1282 | + // checkboxes? |
|
1283 | + $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1284 | + if (! empty($checkboxes)) { |
|
1285 | + // if array has more than one element then success message should be plural |
|
1286 | + $success = count($checkboxes) > 1 ? 2 : 1; |
|
1287 | + // cycle thru the boxes |
|
1288 | + while (list($TKT_ID, $value) = each($checkboxes)) { |
|
1289 | + if ($trash) { |
|
1290 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1291 | + $success = 0; |
|
1292 | + } |
|
1293 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1294 | + $success = 0; |
|
1295 | + } |
|
1296 | + } |
|
1297 | + } else { |
|
1298 | + // grab single id and trash |
|
1299 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1300 | + if ($trash) { |
|
1301 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1302 | + $success = 0; |
|
1303 | + } |
|
1304 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1305 | + $success = 0; |
|
1306 | + } |
|
1307 | + } |
|
1308 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1309 | + $query_args = [ |
|
1310 | + 'action' => 'ticket_list_table', |
|
1311 | + 'status' => $trash ? '' : 'trashed', |
|
1312 | + ]; |
|
1313 | + $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1314 | + } |
|
1315 | + |
|
1316 | + |
|
1317 | + /** |
|
1318 | + * Handles trashing default ticket. |
|
1319 | + * |
|
1320 | + * @throws EE_Error |
|
1321 | + * @throws ReflectionException |
|
1322 | + */ |
|
1323 | + protected function _delete_ticket() |
|
1324 | + { |
|
1325 | + $success = 1; |
|
1326 | + // checkboxes? |
|
1327 | + $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
1328 | + if (! empty($checkboxes)) { |
|
1329 | + // if array has more than one element then success message should be plural |
|
1330 | + $success = count($checkboxes) > 1 ? 2 : 1; |
|
1331 | + // cycle thru the boxes |
|
1332 | + while (list($TKT_ID, $value) = each($checkboxes)) { |
|
1333 | + // delete |
|
1334 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1335 | + $success = 0; |
|
1336 | + } |
|
1337 | + } |
|
1338 | + } else { |
|
1339 | + // grab single id and trash |
|
1340 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
1341 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1342 | + $success = 0; |
|
1343 | + } |
|
1344 | + } |
|
1345 | + $action_desc = 'deleted'; |
|
1346 | + $query_args = [ |
|
1347 | + 'action' => 'ticket_list_table', |
|
1348 | + 'status' => 'trashed', |
|
1349 | + ]; |
|
1350 | + // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1351 | + if ( |
|
1352 | + EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1353 | + [['TKT_is_default' => 1]], |
|
1354 | + 'TKT_ID', |
|
1355 | + true |
|
1356 | + ) |
|
1357 | + ) { |
|
1358 | + $query_args = []; |
|
1359 | + } |
|
1360 | + $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
1361 | + } |
|
1362 | + |
|
1363 | + |
|
1364 | + /** |
|
1365 | + * @param int $TKT_ID |
|
1366 | + * @return bool|int |
|
1367 | + * @throws EE_Error |
|
1368 | + * @throws ReflectionException |
|
1369 | + */ |
|
1370 | + protected function _delete_the_ticket($TKT_ID) |
|
1371 | + { |
|
1372 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1373 | + if (! $ticket instanceof EE_Ticket) { |
|
1374 | + return false; |
|
1375 | + } |
|
1376 | + $ticket->_remove_relations('Datetime'); |
|
1377 | + // delete all related prices first |
|
1378 | + $ticket->delete_related_permanently('Price'); |
|
1379 | + return $ticket->delete_permanently(); |
|
1380 | + } |
|
1381 | 1381 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct($routing = true) |
31 | 31 | { |
32 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
34 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
35 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
32 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
33 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
34 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
35 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
36 | 36 | } |
37 | 37 | parent::__construct($routing); |
38 | 38 | $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function _extend_page_config() |
48 | 48 | { |
49 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
49 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
50 | 50 | // is there a evt_id in the request? |
51 | 51 | $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
52 | 52 | $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'noheader' => true, |
145 | 145 | ], |
146 | 146 | ]; |
147 | - $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
147 | + $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | ], |
187 | 187 | 'require_nonce' => false, |
188 | 188 | ]; |
189 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
189 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
190 | 190 | // add filters and actions |
191 | 191 | // modifying _views |
192 | 192 | add_filter( |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | { |
268 | 268 | $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
269 | 269 | // make sure this is only when editing |
270 | - if (! empty($id)) { |
|
271 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
270 | + if ( ! empty($id)) { |
|
271 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
272 | 272 | ['action' => 'duplicate_event', 'EVT_ID' => $id], |
273 | 273 | $this->_admin_base_url |
274 | 274 | ); |
275 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
275 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
276 | 276 | $return .= '<a href="' |
277 | 277 | . $href |
278 | 278 | . '" aria-label="' |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function load_scripts_styles_edit() |
319 | 319 | { |
320 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
320 | + if ( ! $this->admin_config->useAdvancedEditor()) { |
|
321 | 321 | wp_register_script( |
322 | 322 | 'ee-event-editor-heartbeat', |
323 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
323 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
324 | 324 | ['ee_admin_js', 'heartbeat'], |
325 | 325 | EVENT_ESPRESSO_VERSION, |
326 | 326 | true |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | public function add_additional_datetime_button($template, $template_args) |
346 | 346 | { |
347 | 347 | return EEH_Template::display_template( |
348 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
348 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', |
|
349 | 349 | $template_args, |
350 | 350 | true |
351 | 351 | ); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | public function add_datetime_clone_button($template, $template_args) |
364 | 364 | { |
365 | 365 | return EEH_Template::display_template( |
366 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
366 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', |
|
367 | 367 | $template_args, |
368 | 368 | true |
369 | 369 | ); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | public function datetime_timezones_template($template, $template_args) |
382 | 382 | { |
383 | 383 | return EEH_Template::display_template( |
384 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
384 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', |
|
385 | 385 | $template_args, |
386 | 386 | true |
387 | 387 | ); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | protected function _set_list_table_views_default() |
397 | 397 | { |
398 | 398 | parent::_set_list_table_views_default(); |
399 | - $new_views = [ |
|
399 | + $new_views = [ |
|
400 | 400 | 'today' => [ |
401 | 401 | 'slug' => 'today', |
402 | 402 | 'label' => esc_html__('Today', 'event_espresso'), |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | REG_ADMIN_URL |
445 | 445 | ); |
446 | 446 | |
447 | - $action_links[] = ' |
|
448 | - <a href="' . $reports_link . '" |
|
449 | - aria-label="' . esc_attr__('View Report', 'event_espresso') . '" |
|
447 | + $action_links[] = ' |
|
448 | + <a href="' . $reports_link.'" |
|
449 | + aria-label="' . esc_attr__('View Report', 'event_espresso').'" |
|
450 | 450 | class="ee-aria-tooltip button button--icon-only" |
451 | 451 | > |
452 | 452 | <span class="dashicons dashicons-chart-bar"></span> |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | // first make sure the ID for the event is in the request. |
514 | 514 | // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
515 | 515 | $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
516 | - if (! $EVT_ID) { |
|
516 | + if ( ! $EVT_ID) { |
|
517 | 517 | EE_Error::add_error( |
518 | 518 | esc_html__( |
519 | 519 | 'In order to duplicate an event an Event ID is required. None was given.', |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | } |
529 | 529 | // k we've got EVT_ID so let's use that to get the event we'll duplicate |
530 | 530 | $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
531 | - if (! $orig_event instanceof EE_Event) { |
|
531 | + if ( ! $orig_event instanceof EE_Event) { |
|
532 | 532 | throw new EE_Error( |
533 | 533 | sprintf( |
534 | 534 | esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $orig_ven = $orig_event->get_many_related('Venue'); |
545 | 545 | // reset the ID and modify other details to make it clear this is a dupe |
546 | 546 | $new_event->set('EVT_ID', 0); |
547 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
547 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
548 | 548 | $new_event->set('EVT_name', $new_name); |
549 | 549 | $new_event->set( |
550 | 550 | 'EVT_slug', |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | 'Question_Group', |
574 | 574 | [['Event_Question_Group.EQG_primary' => true]] |
575 | 575 | ); |
576 | - if (! empty($orig_primary_qgs)) { |
|
576 | + if ( ! empty($orig_primary_qgs)) { |
|
577 | 577 | foreach ($orig_primary_qgs as $obj) { |
578 | 578 | if ($obj instanceof EE_Question_Group) { |
579 | 579 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | 'Question_Group', |
586 | 586 | [['Event_Question_Group.EQG_additional' => true]] |
587 | 587 | ); |
588 | - if (! empty($orig_additional_qgs)) { |
|
588 | + if ( ! empty($orig_additional_qgs)) { |
|
589 | 589 | foreach ($orig_additional_qgs as $obj) { |
590 | 590 | if ($obj instanceof EE_Question_Group) { |
591 | 591 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
599 | 599 | $cloned_tickets = []; |
600 | 600 | foreach ($orig_datetimes as $orig_dtt) { |
601 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
601 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
602 | 602 | continue; |
603 | 603 | } |
604 | 604 | $new_dtt = clone $orig_dtt; |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | // now let's get the ticket relations setup. |
614 | 614 | foreach ((array) $orig_tickets as $orig_ticket) { |
615 | 615 | // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
616 | - if (! $orig_ticket instanceof EE_Ticket) { |
|
616 | + if ( ! $orig_ticket instanceof EE_Ticket) { |
|
617 | 617 | continue; |
618 | 618 | } |
619 | 619 | // is this ticket archived? If it is then let's skip |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | } |
623 | 623 | // does this original ticket already exist in the clone_tickets cache? |
624 | 624 | // If so we'll just use the new ticket from it. |
625 | - if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
626 | - $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
625 | + if (isset($cloned_tickets[$orig_ticket->ID()])) { |
|
626 | + $new_ticket = $cloned_tickets[$orig_ticket->ID()]; |
|
627 | 627 | } else { |
628 | 628 | $new_ticket = clone $orig_ticket; |
629 | 629 | // get relations on the $orig_ticket that we need to setup. |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | // for use with later datetimes that have the same ticket. |
657 | 657 | $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
658 | 658 | $new_dtt->save(); |
659 | - $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
659 | + $cloned_tickets[$orig_ticket->ID()] = $new_ticket; |
|
660 | 660 | } |
661 | 661 | } |
662 | 662 | // clone taxonomy information |
@@ -737,12 +737,12 @@ discard block |
||
737 | 737 | $type |
738 | 738 | ); |
739 | 739 | |
740 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
740 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
741 | 741 | ['action' => 'sample_export_file'], |
742 | 742 | $this->_admin_base_url |
743 | 743 | ); |
744 | 744 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
745 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
745 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
746 | 746 | $this->_template_args, |
747 | 747 | true |
748 | 748 | ); |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | */ |
760 | 760 | protected function _import_events() |
761 | 761 | { |
762 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
762 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
763 | 763 | $success = EE_Import::instance()->import(); |
764 | 764 | $this->_redirect_after_action( |
765 | 765 | $success, |
@@ -789,8 +789,8 @@ discard block |
||
789 | 789 | 'EVT_ID' => $EVT_ID, |
790 | 790 | ] |
791 | 791 | ); |
792 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
793 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
792 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
793 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
794 | 794 | $EE_Export = EE_Export::instance($this->request->requestParams()); |
795 | 795 | $EE_Export->export(); |
796 | 796 | } |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | 'EVT_ID' => $EVT_ID, |
813 | 813 | ] |
814 | 814 | ); |
815 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
816 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
815 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
816 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
817 | 817 | $EE_Export = EE_Export::instance($this->request->requestParams()); |
818 | 818 | $EE_Export->export(); |
819 | 819 | } |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | $this->_set_add_edit_form_tags('update_template_settings'); |
857 | 857 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
858 | 858 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
859 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
859 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
860 | 860 | $this->_template_args, |
861 | 861 | true |
862 | 862 | ); |
@@ -965,17 +965,17 @@ discard block |
||
965 | 965 | $template_args['_event'] = $this->_cpt_model_obj; |
966 | 966 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
967 | 967 | |
968 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
968 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
969 | 969 | 'default_reg_status', |
970 | 970 | $default_reg_status_values, |
971 | 971 | $this->_cpt_model_obj->default_registration_status() |
972 | 972 | ); |
973 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
973 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
974 | 974 | 'display_desc', |
975 | 975 | $yes_no_values, |
976 | 976 | $this->_cpt_model_obj->display_description() |
977 | 977 | ); |
978 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
978 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
979 | 979 | 'display_ticket_selector', |
980 | 980 | $yes_no_values, |
981 | 981 | $this->_cpt_model_obj->display_ticket_selector(), |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | $default_reg_status_values |
997 | 997 | ); |
998 | 998 | EEH_Template::display_template( |
999 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
999 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1000 | 1000 | $template_args |
1001 | 1001 | ); |
1002 | 1002 | } |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
1090 | 1090 | |
1091 | 1091 | foreach ($venues as $venue) { |
1092 | - $values[ $venue->ID() ] = $venue->name(); |
|
1092 | + $values[$venue->ID()] = $venue->name(); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | return EEH_Form_Fields::select_input('venue', $values, $current_value); |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | { |
1127 | 1127 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1128 | 1128 | 'DTT_EVT_start', |
1129 | - date('Y-m-d') . ' 00:00:00', |
|
1129 | + date('Y-m-d').' 00:00:00', |
|
1130 | 1130 | 'Y-m-d H:i:s', |
1131 | 1131 | 'UTC' |
1132 | 1132 | ); |
1133 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1133 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1134 | 1134 | 'DTT_EVT_start', |
1135 | - date('Y-m-d') . ' 23:59:59', |
|
1135 | + date('Y-m-d').' 23:59:59', |
|
1136 | 1136 | 'Y-m-d H:i:s', |
1137 | 1137 | 'UTC' |
1138 | 1138 | ); |
@@ -1161,17 +1161,17 @@ discard block |
||
1161 | 1161 | $days_this_month = date('t'); |
1162 | 1162 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1163 | 1163 | 'DTT_EVT_start', |
1164 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1164 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
1165 | 1165 | 'Y-m-d H:i:s', |
1166 | 1166 | 'UTC' |
1167 | 1167 | ); |
1168 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1168 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1169 | 1169 | 'DTT_EVT_start', |
1170 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1170 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
1171 | 1171 | 'Y-m-d H:i:s', |
1172 | 1172 | 'UTC' |
1173 | 1173 | ); |
1174 | - $where = [ |
|
1174 | + $where = [ |
|
1175 | 1175 | 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
1176 | 1176 | ]; |
1177 | 1177 | return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | ) { |
1194 | 1194 | // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
1195 | 1195 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1196 | - EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
1196 | + EVENTS_CAF_TEMPLATE_PATH.'default_tickets_moved_notice.template.php', |
|
1197 | 1197 | [], |
1198 | 1198 | true |
1199 | 1199 | ); |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | |
1249 | 1249 | $search_term = $this->request->getRequestParam('s'); |
1250 | 1250 | if ($search_term) { |
1251 | - $search_term = '%' . $search_term . '%'; |
|
1251 | + $search_term = '%'.$search_term.'%'; |
|
1252 | 1252 | $where['OR'] = [ |
1253 | 1253 | 'TKT_name' => ['LIKE', $search_term], |
1254 | 1254 | 'TKT_description' => ['LIKE', $search_term], |
@@ -1281,16 +1281,16 @@ discard block |
||
1281 | 1281 | $TKT = EEM_Ticket::instance(); |
1282 | 1282 | // checkboxes? |
1283 | 1283 | $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
1284 | - if (! empty($checkboxes)) { |
|
1284 | + if ( ! empty($checkboxes)) { |
|
1285 | 1285 | // if array has more than one element then success message should be plural |
1286 | 1286 | $success = count($checkboxes) > 1 ? 2 : 1; |
1287 | 1287 | // cycle thru the boxes |
1288 | 1288 | while (list($TKT_ID, $value) = each($checkboxes)) { |
1289 | 1289 | if ($trash) { |
1290 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1290 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1291 | 1291 | $success = 0; |
1292 | 1292 | } |
1293 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1293 | + } elseif ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1294 | 1294 | $success = 0; |
1295 | 1295 | } |
1296 | 1296 | } |
@@ -1298,10 +1298,10 @@ discard block |
||
1298 | 1298 | // grab single id and trash |
1299 | 1299 | $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
1300 | 1300 | if ($trash) { |
1301 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1301 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1302 | 1302 | $success = 0; |
1303 | 1303 | } |
1304 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1304 | + } elseif ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1305 | 1305 | $success = 0; |
1306 | 1306 | } |
1307 | 1307 | } |
@@ -1325,20 +1325,20 @@ discard block |
||
1325 | 1325 | $success = 1; |
1326 | 1326 | // checkboxes? |
1327 | 1327 | $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
1328 | - if (! empty($checkboxes)) { |
|
1328 | + if ( ! empty($checkboxes)) { |
|
1329 | 1329 | // if array has more than one element then success message should be plural |
1330 | 1330 | $success = count($checkboxes) > 1 ? 2 : 1; |
1331 | 1331 | // cycle thru the boxes |
1332 | 1332 | while (list($TKT_ID, $value) = each($checkboxes)) { |
1333 | 1333 | // delete |
1334 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1334 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1335 | 1335 | $success = 0; |
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | } else { |
1339 | 1339 | // grab single id and trash |
1340 | 1340 | $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
1341 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1341 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1342 | 1342 | $success = 0; |
1343 | 1343 | } |
1344 | 1344 | } |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | protected function _delete_the_ticket($TKT_ID) |
1371 | 1371 | { |
1372 | 1372 | $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
1373 | - if (! $ticket instanceof EE_Ticket) { |
|
1373 | + if ( ! $ticket instanceof EE_Ticket) { |
|
1374 | 1374 | return false; |
1375 | 1375 | } |
1376 | 1376 | $ticket->_remove_relations('Datetime'); |
@@ -14,1291 +14,1291 @@ |
||
14 | 14 | */ |
15 | 15 | class Extend_Registrations_Admin_Page extends Registrations_Admin_Page |
16 | 16 | { |
17 | - /** |
|
18 | - * This is used to hold the reports template data which is setup early in the request. |
|
19 | - * |
|
20 | - * @type array |
|
21 | - */ |
|
22 | - protected $_reports_template_data = array(); |
|
17 | + /** |
|
18 | + * This is used to hold the reports template data which is setup early in the request. |
|
19 | + * |
|
20 | + * @type array |
|
21 | + */ |
|
22 | + protected $_reports_template_data = array(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Extend_Registrations_Admin_Page constructor. |
|
27 | - * |
|
28 | - * @param bool $routing |
|
29 | - */ |
|
30 | - public function __construct($routing = true) |
|
31 | - { |
|
32 | - parent::__construct($routing); |
|
33 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
37 | - } |
|
38 | - } |
|
25 | + /** |
|
26 | + * Extend_Registrations_Admin_Page constructor. |
|
27 | + * |
|
28 | + * @param bool $routing |
|
29 | + */ |
|
30 | + public function __construct($routing = true) |
|
31 | + { |
|
32 | + parent::__construct($routing); |
|
33 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Extending page configuration. |
|
43 | - */ |
|
44 | - protected function _extend_page_config() |
|
45 | - { |
|
46 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
47 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
48 | - ? $this->_req_data['_REG_ID'] |
|
49 | - : 0; |
|
50 | - $new_page_routes = array( |
|
51 | - 'reports' => array( |
|
52 | - 'func' => '_registration_reports', |
|
53 | - 'capability' => 'ee_read_registrations', |
|
54 | - ), |
|
55 | - 'registration_checkins' => array( |
|
56 | - 'func' => '_registration_checkin_list_table', |
|
57 | - 'capability' => 'ee_read_checkins', |
|
58 | - ), |
|
59 | - 'newsletter_selected_send' => array( |
|
60 | - 'func' => '_newsletter_selected_send', |
|
61 | - 'noheader' => true, |
|
62 | - 'capability' => 'ee_send_message', |
|
63 | - ), |
|
64 | - 'delete_checkin_rows' => array( |
|
65 | - 'func' => '_delete_checkin_rows', |
|
66 | - 'noheader' => true, |
|
67 | - 'capability' => 'ee_delete_checkins', |
|
68 | - ), |
|
69 | - 'delete_checkin_row' => array( |
|
70 | - 'func' => '_delete_checkin_row', |
|
71 | - 'noheader' => true, |
|
72 | - 'capability' => 'ee_delete_checkin', |
|
73 | - 'obj_id' => $reg_id, |
|
74 | - ), |
|
75 | - 'toggle_checkin_status' => array( |
|
76 | - 'func' => '_toggle_checkin_status', |
|
77 | - 'noheader' => true, |
|
78 | - 'capability' => 'ee_edit_checkin', |
|
79 | - 'obj_id' => $reg_id, |
|
80 | - ), |
|
81 | - 'toggle_checkin_status_bulk' => array( |
|
82 | - 'func' => '_toggle_checkin_status', |
|
83 | - 'noheader' => true, |
|
84 | - 'capability' => 'ee_edit_checkins', |
|
85 | - ), |
|
86 | - 'event_registrations' => array( |
|
87 | - 'func' => '_event_registrations_list_table', |
|
88 | - 'capability' => 'ee_read_checkins', |
|
89 | - ), |
|
90 | - 'registrations_checkin_report' => array( |
|
91 | - 'func' => '_registrations_checkin_report', |
|
92 | - 'noheader' => true, |
|
93 | - 'capability' => 'ee_read_registrations', |
|
94 | - ), |
|
95 | - ); |
|
96 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
97 | - $new_page_config = array( |
|
98 | - 'reports' => array( |
|
99 | - 'nav' => array( |
|
100 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
101 | - 'icon' => 'dashicons-chart-bar', |
|
102 | - 'order' => 30, |
|
103 | - ), |
|
104 | - 'help_tabs' => array( |
|
105 | - 'registrations_reports_help_tab' => array( |
|
106 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
107 | - 'filename' => 'registrations_reports', |
|
108 | - ), |
|
109 | - ), |
|
110 | - 'require_nonce' => false, |
|
111 | - ), |
|
112 | - 'event_registrations' => array( |
|
113 | - 'nav' => array( |
|
114 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
115 | - 'icon' => 'dashicons-yes-alt', |
|
116 | - 'order' => 10, |
|
117 | - 'persistent' => true, |
|
118 | - ), |
|
119 | - 'help_tabs' => array( |
|
120 | - 'registrations_event_checkin_help_tab' => array( |
|
121 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
122 | - 'filename' => 'registrations_event_checkin', |
|
123 | - ), |
|
124 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
125 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
126 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
127 | - ), |
|
128 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
129 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
130 | - 'filename' => 'registrations_event_checkin_filters', |
|
131 | - ), |
|
132 | - 'registrations_event_checkin_views_help_tab' => array( |
|
133 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
134 | - 'filename' => 'registrations_event_checkin_views', |
|
135 | - ), |
|
136 | - 'registrations_event_checkin_other_help_tab' => array( |
|
137 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
138 | - 'filename' => 'registrations_event_checkin_other', |
|
139 | - ), |
|
140 | - ), |
|
141 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
142 | - 'metaboxes' => array(), |
|
143 | - 'require_nonce' => false, |
|
144 | - ), |
|
145 | - 'registration_checkins' => array( |
|
146 | - 'nav' => array( |
|
147 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
148 | - 'icon' => 'dashicons-list-view', |
|
149 | - 'order' => 15, |
|
150 | - 'persistent' => false, |
|
151 | - 'url' => '', |
|
152 | - ), |
|
153 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
154 | - 'metaboxes' => array(), |
|
155 | - 'require_nonce' => false, |
|
156 | - ), |
|
157 | - ); |
|
158 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
159 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
160 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
161 | - } |
|
41 | + /** |
|
42 | + * Extending page configuration. |
|
43 | + */ |
|
44 | + protected function _extend_page_config() |
|
45 | + { |
|
46 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
47 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
48 | + ? $this->_req_data['_REG_ID'] |
|
49 | + : 0; |
|
50 | + $new_page_routes = array( |
|
51 | + 'reports' => array( |
|
52 | + 'func' => '_registration_reports', |
|
53 | + 'capability' => 'ee_read_registrations', |
|
54 | + ), |
|
55 | + 'registration_checkins' => array( |
|
56 | + 'func' => '_registration_checkin_list_table', |
|
57 | + 'capability' => 'ee_read_checkins', |
|
58 | + ), |
|
59 | + 'newsletter_selected_send' => array( |
|
60 | + 'func' => '_newsletter_selected_send', |
|
61 | + 'noheader' => true, |
|
62 | + 'capability' => 'ee_send_message', |
|
63 | + ), |
|
64 | + 'delete_checkin_rows' => array( |
|
65 | + 'func' => '_delete_checkin_rows', |
|
66 | + 'noheader' => true, |
|
67 | + 'capability' => 'ee_delete_checkins', |
|
68 | + ), |
|
69 | + 'delete_checkin_row' => array( |
|
70 | + 'func' => '_delete_checkin_row', |
|
71 | + 'noheader' => true, |
|
72 | + 'capability' => 'ee_delete_checkin', |
|
73 | + 'obj_id' => $reg_id, |
|
74 | + ), |
|
75 | + 'toggle_checkin_status' => array( |
|
76 | + 'func' => '_toggle_checkin_status', |
|
77 | + 'noheader' => true, |
|
78 | + 'capability' => 'ee_edit_checkin', |
|
79 | + 'obj_id' => $reg_id, |
|
80 | + ), |
|
81 | + 'toggle_checkin_status_bulk' => array( |
|
82 | + 'func' => '_toggle_checkin_status', |
|
83 | + 'noheader' => true, |
|
84 | + 'capability' => 'ee_edit_checkins', |
|
85 | + ), |
|
86 | + 'event_registrations' => array( |
|
87 | + 'func' => '_event_registrations_list_table', |
|
88 | + 'capability' => 'ee_read_checkins', |
|
89 | + ), |
|
90 | + 'registrations_checkin_report' => array( |
|
91 | + 'func' => '_registrations_checkin_report', |
|
92 | + 'noheader' => true, |
|
93 | + 'capability' => 'ee_read_registrations', |
|
94 | + ), |
|
95 | + ); |
|
96 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
97 | + $new_page_config = array( |
|
98 | + 'reports' => array( |
|
99 | + 'nav' => array( |
|
100 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
101 | + 'icon' => 'dashicons-chart-bar', |
|
102 | + 'order' => 30, |
|
103 | + ), |
|
104 | + 'help_tabs' => array( |
|
105 | + 'registrations_reports_help_tab' => array( |
|
106 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
107 | + 'filename' => 'registrations_reports', |
|
108 | + ), |
|
109 | + ), |
|
110 | + 'require_nonce' => false, |
|
111 | + ), |
|
112 | + 'event_registrations' => array( |
|
113 | + 'nav' => array( |
|
114 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
115 | + 'icon' => 'dashicons-yes-alt', |
|
116 | + 'order' => 10, |
|
117 | + 'persistent' => true, |
|
118 | + ), |
|
119 | + 'help_tabs' => array( |
|
120 | + 'registrations_event_checkin_help_tab' => array( |
|
121 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
122 | + 'filename' => 'registrations_event_checkin', |
|
123 | + ), |
|
124 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
125 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
126 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
127 | + ), |
|
128 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
129 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
130 | + 'filename' => 'registrations_event_checkin_filters', |
|
131 | + ), |
|
132 | + 'registrations_event_checkin_views_help_tab' => array( |
|
133 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
134 | + 'filename' => 'registrations_event_checkin_views', |
|
135 | + ), |
|
136 | + 'registrations_event_checkin_other_help_tab' => array( |
|
137 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
138 | + 'filename' => 'registrations_event_checkin_other', |
|
139 | + ), |
|
140 | + ), |
|
141 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
142 | + 'metaboxes' => array(), |
|
143 | + 'require_nonce' => false, |
|
144 | + ), |
|
145 | + 'registration_checkins' => array( |
|
146 | + 'nav' => array( |
|
147 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
148 | + 'icon' => 'dashicons-list-view', |
|
149 | + 'order' => 15, |
|
150 | + 'persistent' => false, |
|
151 | + 'url' => '', |
|
152 | + ), |
|
153 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
154 | + 'metaboxes' => array(), |
|
155 | + 'require_nonce' => false, |
|
156 | + ), |
|
157 | + ); |
|
158 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
159 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
160 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | - /** |
|
165 | - * Ajax hooks for all routes in this page. |
|
166 | - */ |
|
167 | - protected function _ajax_hooks() |
|
168 | - { |
|
169 | - parent::_ajax_hooks(); |
|
170 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
171 | - } |
|
164 | + /** |
|
165 | + * Ajax hooks for all routes in this page. |
|
166 | + */ |
|
167 | + protected function _ajax_hooks() |
|
168 | + { |
|
169 | + parent::_ajax_hooks(); |
|
170 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | - /** |
|
175 | - * Global scripts for all routes in this page. |
|
176 | - */ |
|
177 | - public function load_scripts_styles() |
|
178 | - { |
|
179 | - parent::load_scripts_styles(); |
|
180 | - // if newsletter message type is active then let's add filter and load js for it. |
|
181 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
182 | - // enqueue newsletter js |
|
183 | - wp_enqueue_script( |
|
184 | - 'ee-newsletter-trigger', |
|
185 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
186 | - array('ee-dialog'), |
|
187 | - EVENT_ESPRESSO_VERSION, |
|
188 | - true |
|
189 | - ); |
|
190 | - wp_enqueue_style( |
|
191 | - 'ee-newsletter-trigger-css', |
|
192 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
193 | - array(), |
|
194 | - EVENT_ESPRESSO_VERSION |
|
195 | - ); |
|
196 | - // hook in buttons for newsletter message type trigger. |
|
197 | - add_action( |
|
198 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
199 | - array($this, 'add_newsletter_action_buttons'), |
|
200 | - 10 |
|
201 | - ); |
|
202 | - } |
|
203 | - } |
|
174 | + /** |
|
175 | + * Global scripts for all routes in this page. |
|
176 | + */ |
|
177 | + public function load_scripts_styles() |
|
178 | + { |
|
179 | + parent::load_scripts_styles(); |
|
180 | + // if newsletter message type is active then let's add filter and load js for it. |
|
181 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
182 | + // enqueue newsletter js |
|
183 | + wp_enqueue_script( |
|
184 | + 'ee-newsletter-trigger', |
|
185 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
186 | + array('ee-dialog'), |
|
187 | + EVENT_ESPRESSO_VERSION, |
|
188 | + true |
|
189 | + ); |
|
190 | + wp_enqueue_style( |
|
191 | + 'ee-newsletter-trigger-css', |
|
192 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
193 | + array(), |
|
194 | + EVENT_ESPRESSO_VERSION |
|
195 | + ); |
|
196 | + // hook in buttons for newsletter message type trigger. |
|
197 | + add_action( |
|
198 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
199 | + array($this, 'add_newsletter_action_buttons'), |
|
200 | + 10 |
|
201 | + ); |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | - /** |
|
207 | - * Scripts and styles for just the reports route. |
|
208 | - */ |
|
209 | - public function load_scripts_styles_reports() |
|
210 | - { |
|
211 | - wp_register_script( |
|
212 | - 'ee-reg-reports-js', |
|
213 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
214 | - array('google-charts'), |
|
215 | - EVENT_ESPRESSO_VERSION, |
|
216 | - true |
|
217 | - ); |
|
218 | - wp_enqueue_script('ee-reg-reports-js'); |
|
219 | - $this->_registration_reports_js_setup(); |
|
220 | - } |
|
206 | + /** |
|
207 | + * Scripts and styles for just the reports route. |
|
208 | + */ |
|
209 | + public function load_scripts_styles_reports() |
|
210 | + { |
|
211 | + wp_register_script( |
|
212 | + 'ee-reg-reports-js', |
|
213 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
214 | + array('google-charts'), |
|
215 | + EVENT_ESPRESSO_VERSION, |
|
216 | + true |
|
217 | + ); |
|
218 | + wp_enqueue_script('ee-reg-reports-js'); |
|
219 | + $this->_registration_reports_js_setup(); |
|
220 | + } |
|
221 | 221 | |
222 | 222 | |
223 | - /** |
|
224 | - * Register screen options for event_registrations route. |
|
225 | - */ |
|
226 | - protected function _add_screen_options_event_registrations() |
|
227 | - { |
|
228 | - $this->_per_page_screen_option(); |
|
229 | - } |
|
223 | + /** |
|
224 | + * Register screen options for event_registrations route. |
|
225 | + */ |
|
226 | + protected function _add_screen_options_event_registrations() |
|
227 | + { |
|
228 | + $this->_per_page_screen_option(); |
|
229 | + } |
|
230 | 230 | |
231 | 231 | |
232 | - /** |
|
233 | - * Register screen options for registration_checkins route |
|
234 | - */ |
|
235 | - protected function _add_screen_options_registration_checkins() |
|
236 | - { |
|
237 | - $page_title = $this->_admin_page_title; |
|
238 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
239 | - $this->_per_page_screen_option(); |
|
240 | - $this->_admin_page_title = $page_title; |
|
241 | - } |
|
232 | + /** |
|
233 | + * Register screen options for registration_checkins route |
|
234 | + */ |
|
235 | + protected function _add_screen_options_registration_checkins() |
|
236 | + { |
|
237 | + $page_title = $this->_admin_page_title; |
|
238 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
239 | + $this->_per_page_screen_option(); |
|
240 | + $this->_admin_page_title = $page_title; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | - /** |
|
245 | - * Set views property for event_registrations route. |
|
246 | - */ |
|
247 | - protected function _set_list_table_views_event_registrations() |
|
248 | - { |
|
249 | - $this->_views = array( |
|
250 | - 'all' => array( |
|
251 | - 'slug' => 'all', |
|
252 | - 'label' => esc_html__('All', 'event_espresso'), |
|
253 | - 'count' => 0, |
|
254 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
255 | - ? array() |
|
256 | - : array( |
|
257 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
258 | - ), |
|
259 | - ), |
|
260 | - ); |
|
261 | - } |
|
244 | + /** |
|
245 | + * Set views property for event_registrations route. |
|
246 | + */ |
|
247 | + protected function _set_list_table_views_event_registrations() |
|
248 | + { |
|
249 | + $this->_views = array( |
|
250 | + 'all' => array( |
|
251 | + 'slug' => 'all', |
|
252 | + 'label' => esc_html__('All', 'event_espresso'), |
|
253 | + 'count' => 0, |
|
254 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
255 | + ? array() |
|
256 | + : array( |
|
257 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
258 | + ), |
|
259 | + ), |
|
260 | + ); |
|
261 | + } |
|
262 | 262 | |
263 | 263 | |
264 | - /** |
|
265 | - * Set views property for registration_checkins route. |
|
266 | - */ |
|
267 | - protected function _set_list_table_views_registration_checkins() |
|
268 | - { |
|
269 | - $this->_views = array( |
|
270 | - 'all' => array( |
|
271 | - 'slug' => 'all', |
|
272 | - 'label' => esc_html__('All', 'event_espresso'), |
|
273 | - 'count' => 0, |
|
274 | - 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
275 | - ), |
|
276 | - ); |
|
277 | - } |
|
264 | + /** |
|
265 | + * Set views property for registration_checkins route. |
|
266 | + */ |
|
267 | + protected function _set_list_table_views_registration_checkins() |
|
268 | + { |
|
269 | + $this->_views = array( |
|
270 | + 'all' => array( |
|
271 | + 'slug' => 'all', |
|
272 | + 'label' => esc_html__('All', 'event_espresso'), |
|
273 | + 'count' => 0, |
|
274 | + 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
275 | + ), |
|
276 | + ); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | |
280 | - /** |
|
281 | - * callback for ajax action. |
|
282 | - * |
|
283 | - * @since 4.3.0 |
|
284 | - * @return void (JSON) |
|
285 | - * @throws EE_Error |
|
286 | - * @throws InvalidArgumentException |
|
287 | - * @throws InvalidDataTypeException |
|
288 | - * @throws InvalidInterfaceException |
|
289 | - */ |
|
290 | - public function get_newsletter_form_content() |
|
291 | - { |
|
292 | - // do a nonce check cause we're not coming in from an normal route here. |
|
293 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
294 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
295 | - ) : ''; |
|
296 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
297 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
298 | - // let's get the mtp for the incoming MTP_ ID |
|
299 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
300 | - EE_Error::add_error( |
|
301 | - esc_html__( |
|
302 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
303 | - 'event_espresso' |
|
304 | - ), |
|
305 | - __FILE__, |
|
306 | - __FUNCTION__, |
|
307 | - __LINE__ |
|
308 | - ); |
|
309 | - $this->_template_args['success'] = false; |
|
310 | - $this->_template_args['error'] = true; |
|
311 | - $this->_return_json(); |
|
312 | - } |
|
313 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
314 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
315 | - EE_Error::add_error( |
|
316 | - sprintf( |
|
317 | - esc_html__( |
|
318 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
319 | - 'event_espresso' |
|
320 | - ), |
|
321 | - $this->_req_data['GRP_ID'] |
|
322 | - ), |
|
323 | - __FILE__, |
|
324 | - __FUNCTION__, |
|
325 | - __LINE__ |
|
326 | - ); |
|
327 | - $this->_template_args['success'] = false; |
|
328 | - $this->_template_args['error'] = true; |
|
329 | - $this->_return_json(); |
|
330 | - } |
|
331 | - $MTPs = $MTPG->context_templates(); |
|
332 | - $MTPs = $MTPs['attendee']; |
|
333 | - $template_fields = array(); |
|
334 | - /** @var EE_Message_Template $MTP */ |
|
335 | - foreach ($MTPs as $MTP) { |
|
336 | - $field = $MTP->get('MTP_template_field'); |
|
337 | - if ($field === 'content') { |
|
338 | - $content = $MTP->get('MTP_content'); |
|
339 | - if (! empty($content['newsletter_content'])) { |
|
340 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
341 | - } |
|
342 | - continue; |
|
343 | - } |
|
344 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
345 | - } |
|
346 | - $this->_template_args['success'] = true; |
|
347 | - $this->_template_args['error'] = false; |
|
348 | - $this->_template_args['data'] = array( |
|
349 | - 'batch_message_from' => isset($template_fields['from']) |
|
350 | - ? $template_fields['from'] |
|
351 | - : '', |
|
352 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
353 | - ? $template_fields['subject'] |
|
354 | - : '', |
|
355 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
356 | - ? $template_fields['newsletter_content'] |
|
357 | - : '', |
|
358 | - ); |
|
359 | - $this->_return_json(); |
|
360 | - } |
|
280 | + /** |
|
281 | + * callback for ajax action. |
|
282 | + * |
|
283 | + * @since 4.3.0 |
|
284 | + * @return void (JSON) |
|
285 | + * @throws EE_Error |
|
286 | + * @throws InvalidArgumentException |
|
287 | + * @throws InvalidDataTypeException |
|
288 | + * @throws InvalidInterfaceException |
|
289 | + */ |
|
290 | + public function get_newsletter_form_content() |
|
291 | + { |
|
292 | + // do a nonce check cause we're not coming in from an normal route here. |
|
293 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
294 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
295 | + ) : ''; |
|
296 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
297 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
298 | + // let's get the mtp for the incoming MTP_ ID |
|
299 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
300 | + EE_Error::add_error( |
|
301 | + esc_html__( |
|
302 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
303 | + 'event_espresso' |
|
304 | + ), |
|
305 | + __FILE__, |
|
306 | + __FUNCTION__, |
|
307 | + __LINE__ |
|
308 | + ); |
|
309 | + $this->_template_args['success'] = false; |
|
310 | + $this->_template_args['error'] = true; |
|
311 | + $this->_return_json(); |
|
312 | + } |
|
313 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
314 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
315 | + EE_Error::add_error( |
|
316 | + sprintf( |
|
317 | + esc_html__( |
|
318 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
319 | + 'event_espresso' |
|
320 | + ), |
|
321 | + $this->_req_data['GRP_ID'] |
|
322 | + ), |
|
323 | + __FILE__, |
|
324 | + __FUNCTION__, |
|
325 | + __LINE__ |
|
326 | + ); |
|
327 | + $this->_template_args['success'] = false; |
|
328 | + $this->_template_args['error'] = true; |
|
329 | + $this->_return_json(); |
|
330 | + } |
|
331 | + $MTPs = $MTPG->context_templates(); |
|
332 | + $MTPs = $MTPs['attendee']; |
|
333 | + $template_fields = array(); |
|
334 | + /** @var EE_Message_Template $MTP */ |
|
335 | + foreach ($MTPs as $MTP) { |
|
336 | + $field = $MTP->get('MTP_template_field'); |
|
337 | + if ($field === 'content') { |
|
338 | + $content = $MTP->get('MTP_content'); |
|
339 | + if (! empty($content['newsletter_content'])) { |
|
340 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
341 | + } |
|
342 | + continue; |
|
343 | + } |
|
344 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
345 | + } |
|
346 | + $this->_template_args['success'] = true; |
|
347 | + $this->_template_args['error'] = false; |
|
348 | + $this->_template_args['data'] = array( |
|
349 | + 'batch_message_from' => isset($template_fields['from']) |
|
350 | + ? $template_fields['from'] |
|
351 | + : '', |
|
352 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
353 | + ? $template_fields['subject'] |
|
354 | + : '', |
|
355 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
356 | + ? $template_fields['newsletter_content'] |
|
357 | + : '', |
|
358 | + ); |
|
359 | + $this->_return_json(); |
|
360 | + } |
|
361 | 361 | |
362 | 362 | |
363 | - /** |
|
364 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
365 | - * |
|
366 | - * @since 4.3.0 |
|
367 | - * @param EE_Admin_List_Table $list_table |
|
368 | - * @return void |
|
369 | - * @throws InvalidArgumentException |
|
370 | - * @throws InvalidDataTypeException |
|
371 | - * @throws InvalidInterfaceException |
|
372 | - */ |
|
373 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
374 | - { |
|
375 | - if ( |
|
376 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
377 | - 'ee_send_message', |
|
378 | - 'espresso_registrations_newsletter_selected_send' |
|
379 | - ) |
|
380 | - ) { |
|
381 | - return; |
|
382 | - } |
|
383 | - $routes_to_add_to = array( |
|
384 | - 'contact_list', |
|
385 | - 'event_registrations', |
|
386 | - 'default', |
|
387 | - ); |
|
388 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
389 | - if ( |
|
390 | - ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
391 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
392 | - ) { |
|
393 | - echo ''; |
|
394 | - } else { |
|
395 | - $button_text = sprintf( |
|
396 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
397 | - '<span class="send-selected-newsletter-count">0</span>' |
|
398 | - ); |
|
399 | - echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
400 | - . '<span class="dashicons dashicons-email "></span>' |
|
401 | - . $button_text |
|
402 | - . '</button>'; |
|
403 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
404 | - } |
|
405 | - } |
|
406 | - } |
|
363 | + /** |
|
364 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
365 | + * |
|
366 | + * @since 4.3.0 |
|
367 | + * @param EE_Admin_List_Table $list_table |
|
368 | + * @return void |
|
369 | + * @throws InvalidArgumentException |
|
370 | + * @throws InvalidDataTypeException |
|
371 | + * @throws InvalidInterfaceException |
|
372 | + */ |
|
373 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
374 | + { |
|
375 | + if ( |
|
376 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
377 | + 'ee_send_message', |
|
378 | + 'espresso_registrations_newsletter_selected_send' |
|
379 | + ) |
|
380 | + ) { |
|
381 | + return; |
|
382 | + } |
|
383 | + $routes_to_add_to = array( |
|
384 | + 'contact_list', |
|
385 | + 'event_registrations', |
|
386 | + 'default', |
|
387 | + ); |
|
388 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
389 | + if ( |
|
390 | + ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
391 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
392 | + ) { |
|
393 | + echo ''; |
|
394 | + } else { |
|
395 | + $button_text = sprintf( |
|
396 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
397 | + '<span class="send-selected-newsletter-count">0</span>' |
|
398 | + ); |
|
399 | + echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
400 | + . '<span class="dashicons dashicons-email "></span>' |
|
401 | + . $button_text |
|
402 | + . '</button>'; |
|
403 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
404 | + } |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | 408 | |
409 | - /** |
|
410 | - * @throws DomainException |
|
411 | - * @throws EE_Error |
|
412 | - * @throws InvalidArgumentException |
|
413 | - * @throws InvalidDataTypeException |
|
414 | - * @throws InvalidInterfaceException |
|
415 | - */ |
|
416 | - public function newsletter_send_form_skeleton() |
|
417 | - { |
|
418 | - $list_table = $this->_list_table_object; |
|
419 | - $codes = array(); |
|
420 | - // need to templates for the newsletter message type for the template selector. |
|
421 | - $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
422 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
423 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
424 | - ); |
|
425 | - foreach ($mtps as $mtp) { |
|
426 | - $name = $mtp->name(); |
|
427 | - $values[] = array( |
|
428 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
429 | - 'id' => $mtp->ID(), |
|
430 | - ); |
|
431 | - } |
|
432 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
433 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
434 | - 'newsletter', |
|
435 | - 'email', |
|
436 | - array(), |
|
437 | - 'attendee', |
|
438 | - false |
|
439 | - ); |
|
440 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
441 | - $available_shortcodes = array(); |
|
442 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
443 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
444 | - ? 'content' |
|
445 | - : $field; |
|
446 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
447 | - $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
448 | - . $shortcode |
|
449 | - . '" data-linked-input-id="' . $field_id . '">' |
|
450 | - . $shortcode |
|
451 | - . '</span>'; |
|
452 | - } |
|
453 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
454 | - } |
|
455 | - $shortcodes = $codes; |
|
456 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
457 | - $form_template_args = array( |
|
458 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
459 | - 'form_route' => 'newsletter_selected_send', |
|
460 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
461 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
462 | - 'redirect_back_to' => $this->_req_action, |
|
463 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
464 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
465 | - 'shortcodes' => $shortcodes, |
|
466 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
467 | - ); |
|
468 | - EEH_Template::display_template($form_template, $form_template_args); |
|
469 | - } |
|
409 | + /** |
|
410 | + * @throws DomainException |
|
411 | + * @throws EE_Error |
|
412 | + * @throws InvalidArgumentException |
|
413 | + * @throws InvalidDataTypeException |
|
414 | + * @throws InvalidInterfaceException |
|
415 | + */ |
|
416 | + public function newsletter_send_form_skeleton() |
|
417 | + { |
|
418 | + $list_table = $this->_list_table_object; |
|
419 | + $codes = array(); |
|
420 | + // need to templates for the newsletter message type for the template selector. |
|
421 | + $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
422 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
423 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
424 | + ); |
|
425 | + foreach ($mtps as $mtp) { |
|
426 | + $name = $mtp->name(); |
|
427 | + $values[] = array( |
|
428 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
429 | + 'id' => $mtp->ID(), |
|
430 | + ); |
|
431 | + } |
|
432 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
433 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
434 | + 'newsletter', |
|
435 | + 'email', |
|
436 | + array(), |
|
437 | + 'attendee', |
|
438 | + false |
|
439 | + ); |
|
440 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
441 | + $available_shortcodes = array(); |
|
442 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
443 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
444 | + ? 'content' |
|
445 | + : $field; |
|
446 | + $field_id = 'batch-message-' . strtolower($field_id); |
|
447 | + $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
448 | + . $shortcode |
|
449 | + . '" data-linked-input-id="' . $field_id . '">' |
|
450 | + . $shortcode |
|
451 | + . '</span>'; |
|
452 | + } |
|
453 | + $codes[ $field ] = implode(', ', $available_shortcodes); |
|
454 | + } |
|
455 | + $shortcodes = $codes; |
|
456 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
457 | + $form_template_args = array( |
|
458 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
459 | + 'form_route' => 'newsletter_selected_send', |
|
460 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
461 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
462 | + 'redirect_back_to' => $this->_req_action, |
|
463 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
464 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
465 | + 'shortcodes' => $shortcodes, |
|
466 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
467 | + ); |
|
468 | + EEH_Template::display_template($form_template, $form_template_args); |
|
469 | + } |
|
470 | 470 | |
471 | 471 | |
472 | - /** |
|
473 | - * Handles sending selected registrations/contacts a newsletter. |
|
474 | - * |
|
475 | - * @since 4.3.0 |
|
476 | - * @return void |
|
477 | - * @throws EE_Error |
|
478 | - * @throws InvalidArgumentException |
|
479 | - * @throws InvalidDataTypeException |
|
480 | - * @throws InvalidInterfaceException |
|
481 | - */ |
|
482 | - protected function _newsletter_selected_send() |
|
483 | - { |
|
484 | - $success = true; |
|
485 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
486 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
487 | - EE_Error::add_error( |
|
488 | - esc_html__( |
|
489 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
490 | - 'event_espresso' |
|
491 | - ), |
|
492 | - __FILE__, |
|
493 | - __FUNCTION__, |
|
494 | - __LINE__ |
|
495 | - ); |
|
496 | - $success = false; |
|
497 | - } |
|
498 | - if ($success) { |
|
499 | - // update Message template in case there are any changes |
|
500 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
501 | - $this->_req_data['newsletter_mtp_selected'] |
|
502 | - ); |
|
503 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
504 | - ? $Message_Template_Group->context_templates() |
|
505 | - : array(); |
|
506 | - if (empty($Message_Templates)) { |
|
507 | - EE_Error::add_error( |
|
508 | - esc_html__( |
|
509 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
510 | - 'event_espresso' |
|
511 | - ), |
|
512 | - __FILE__, |
|
513 | - __FUNCTION__, |
|
514 | - __LINE__ |
|
515 | - ); |
|
516 | - } |
|
517 | - // let's just update the specific fields |
|
518 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
519 | - if ($Message_Template instanceof EE_Message_Template) { |
|
520 | - $field = $Message_Template->get('MTP_template_field'); |
|
521 | - $content = $Message_Template->get('MTP_content'); |
|
522 | - $new_content = $content; |
|
523 | - switch ($field) { |
|
524 | - case 'from': |
|
525 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
526 | - ? $this->_req_data['batch_message']['from'] |
|
527 | - : $content; |
|
528 | - break; |
|
529 | - case 'subject': |
|
530 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
531 | - ? $this->_req_data['batch_message']['subject'] |
|
532 | - : $content; |
|
533 | - break; |
|
534 | - case 'content': |
|
535 | - $new_content = $content; |
|
536 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
537 | - ? $this->_req_data['batch_message']['content'] |
|
538 | - : $content['newsletter_content']; |
|
539 | - break; |
|
540 | - default: |
|
541 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
542 | - continue 2; |
|
543 | - } |
|
544 | - $Message_Template->set('MTP_content', $new_content); |
|
545 | - $Message_Template->save(); |
|
546 | - } |
|
547 | - } |
|
548 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
549 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
550 | - ? $this->_req_data['batch_message']['id_type'] |
|
551 | - : 'registration'; |
|
552 | - // id_type will affect how we assemble the ids. |
|
553 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
554 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
555 | - : array(); |
|
556 | - $registrations_used_for_contact_data = array(); |
|
557 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
558 | - switch ($id_type) { |
|
559 | - case 'registration': |
|
560 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
561 | - array( |
|
562 | - array( |
|
563 | - 'REG_ID' => array('IN', $ids), |
|
564 | - ), |
|
565 | - ) |
|
566 | - ); |
|
567 | - break; |
|
568 | - case 'contact': |
|
569 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
570 | - ->get_latest_registration_for_each_of_given_contacts( |
|
571 | - $ids |
|
572 | - ); |
|
573 | - break; |
|
574 | - } |
|
575 | - do_action_ref_array( |
|
576 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
577 | - array( |
|
578 | - $registrations_used_for_contact_data, |
|
579 | - $Message_Template_Group->ID(), |
|
580 | - ) |
|
581 | - ); |
|
582 | - // kept for backward compat, internally we no longer use this action. |
|
583 | - // @deprecated 4.8.36.rc.002 |
|
584 | - $contacts = $id_type === 'registration' |
|
585 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
586 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
587 | - do_action_ref_array( |
|
588 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
589 | - array( |
|
590 | - $contacts, |
|
591 | - $Message_Template_Group->ID(), |
|
592 | - ) |
|
593 | - ); |
|
594 | - } |
|
595 | - $query_args = array( |
|
596 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
597 | - ? $this->_req_data['redirect_back_to'] |
|
598 | - : 'default', |
|
599 | - ); |
|
600 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
601 | - } |
|
472 | + /** |
|
473 | + * Handles sending selected registrations/contacts a newsletter. |
|
474 | + * |
|
475 | + * @since 4.3.0 |
|
476 | + * @return void |
|
477 | + * @throws EE_Error |
|
478 | + * @throws InvalidArgumentException |
|
479 | + * @throws InvalidDataTypeException |
|
480 | + * @throws InvalidInterfaceException |
|
481 | + */ |
|
482 | + protected function _newsletter_selected_send() |
|
483 | + { |
|
484 | + $success = true; |
|
485 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
486 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
487 | + EE_Error::add_error( |
|
488 | + esc_html__( |
|
489 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
490 | + 'event_espresso' |
|
491 | + ), |
|
492 | + __FILE__, |
|
493 | + __FUNCTION__, |
|
494 | + __LINE__ |
|
495 | + ); |
|
496 | + $success = false; |
|
497 | + } |
|
498 | + if ($success) { |
|
499 | + // update Message template in case there are any changes |
|
500 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
501 | + $this->_req_data['newsletter_mtp_selected'] |
|
502 | + ); |
|
503 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
504 | + ? $Message_Template_Group->context_templates() |
|
505 | + : array(); |
|
506 | + if (empty($Message_Templates)) { |
|
507 | + EE_Error::add_error( |
|
508 | + esc_html__( |
|
509 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
510 | + 'event_espresso' |
|
511 | + ), |
|
512 | + __FILE__, |
|
513 | + __FUNCTION__, |
|
514 | + __LINE__ |
|
515 | + ); |
|
516 | + } |
|
517 | + // let's just update the specific fields |
|
518 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
519 | + if ($Message_Template instanceof EE_Message_Template) { |
|
520 | + $field = $Message_Template->get('MTP_template_field'); |
|
521 | + $content = $Message_Template->get('MTP_content'); |
|
522 | + $new_content = $content; |
|
523 | + switch ($field) { |
|
524 | + case 'from': |
|
525 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
526 | + ? $this->_req_data['batch_message']['from'] |
|
527 | + : $content; |
|
528 | + break; |
|
529 | + case 'subject': |
|
530 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
531 | + ? $this->_req_data['batch_message']['subject'] |
|
532 | + : $content; |
|
533 | + break; |
|
534 | + case 'content': |
|
535 | + $new_content = $content; |
|
536 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
537 | + ? $this->_req_data['batch_message']['content'] |
|
538 | + : $content['newsletter_content']; |
|
539 | + break; |
|
540 | + default: |
|
541 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
542 | + continue 2; |
|
543 | + } |
|
544 | + $Message_Template->set('MTP_content', $new_content); |
|
545 | + $Message_Template->save(); |
|
546 | + } |
|
547 | + } |
|
548 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
549 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
550 | + ? $this->_req_data['batch_message']['id_type'] |
|
551 | + : 'registration'; |
|
552 | + // id_type will affect how we assemble the ids. |
|
553 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
554 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
555 | + : array(); |
|
556 | + $registrations_used_for_contact_data = array(); |
|
557 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
558 | + switch ($id_type) { |
|
559 | + case 'registration': |
|
560 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
561 | + array( |
|
562 | + array( |
|
563 | + 'REG_ID' => array('IN', $ids), |
|
564 | + ), |
|
565 | + ) |
|
566 | + ); |
|
567 | + break; |
|
568 | + case 'contact': |
|
569 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
570 | + ->get_latest_registration_for_each_of_given_contacts( |
|
571 | + $ids |
|
572 | + ); |
|
573 | + break; |
|
574 | + } |
|
575 | + do_action_ref_array( |
|
576 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
577 | + array( |
|
578 | + $registrations_used_for_contact_data, |
|
579 | + $Message_Template_Group->ID(), |
|
580 | + ) |
|
581 | + ); |
|
582 | + // kept for backward compat, internally we no longer use this action. |
|
583 | + // @deprecated 4.8.36.rc.002 |
|
584 | + $contacts = $id_type === 'registration' |
|
585 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
586 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
587 | + do_action_ref_array( |
|
588 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
589 | + array( |
|
590 | + $contacts, |
|
591 | + $Message_Template_Group->ID(), |
|
592 | + ) |
|
593 | + ); |
|
594 | + } |
|
595 | + $query_args = array( |
|
596 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
597 | + ? $this->_req_data['redirect_back_to'] |
|
598 | + : 'default', |
|
599 | + ); |
|
600 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
601 | + } |
|
602 | 602 | |
603 | 603 | |
604 | - /** |
|
605 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
606 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
607 | - */ |
|
608 | - protected function _registration_reports_js_setup() |
|
609 | - { |
|
610 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
611 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
612 | - } |
|
604 | + /** |
|
605 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
606 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
607 | + */ |
|
608 | + protected function _registration_reports_js_setup() |
|
609 | + { |
|
610 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
611 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
612 | + } |
|
613 | 613 | |
614 | 614 | |
615 | - /** |
|
616 | - * generates Business Reports regarding Registrations |
|
617 | - * |
|
618 | - * @access protected |
|
619 | - * @return void |
|
620 | - * @throws DomainException |
|
621 | - */ |
|
622 | - protected function _registration_reports() |
|
623 | - { |
|
624 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
625 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
626 | - $template_path, |
|
627 | - $this->_reports_template_data, |
|
628 | - true |
|
629 | - ); |
|
630 | - // the final template wrapper |
|
631 | - $this->display_admin_page_with_no_sidebar(); |
|
632 | - } |
|
615 | + /** |
|
616 | + * generates Business Reports regarding Registrations |
|
617 | + * |
|
618 | + * @access protected |
|
619 | + * @return void |
|
620 | + * @throws DomainException |
|
621 | + */ |
|
622 | + protected function _registration_reports() |
|
623 | + { |
|
624 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
625 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
626 | + $template_path, |
|
627 | + $this->_reports_template_data, |
|
628 | + true |
|
629 | + ); |
|
630 | + // the final template wrapper |
|
631 | + $this->display_admin_page_with_no_sidebar(); |
|
632 | + } |
|
633 | 633 | |
634 | 634 | |
635 | - /** |
|
636 | - * Generates Business Report showing total registrations per day. |
|
637 | - * |
|
638 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
639 | - * @return string |
|
640 | - * @throws EE_Error |
|
641 | - * @throws InvalidArgumentException |
|
642 | - * @throws InvalidDataTypeException |
|
643 | - * @throws InvalidInterfaceException |
|
644 | - */ |
|
645 | - private function _registrations_per_day_report($period = '-1 month') |
|
646 | - { |
|
647 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
648 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
649 | - $results = (array) $results; |
|
650 | - $regs = array(); |
|
651 | - $subtitle = ''; |
|
652 | - if ($results) { |
|
653 | - $column_titles = array(); |
|
654 | - $tracker = 0; |
|
655 | - foreach ($results as $result) { |
|
656 | - $report_column_values = array(); |
|
657 | - foreach ($result as $property_name => $property_value) { |
|
658 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
659 | - : (int) $property_value; |
|
660 | - $report_column_values[] = $property_value; |
|
661 | - if ($tracker === 0) { |
|
662 | - if ($property_name === 'Registration_REG_date') { |
|
663 | - $column_titles[] = esc_html__( |
|
664 | - 'Date (only days with registrations are shown)', |
|
665 | - 'event_espresso' |
|
666 | - ); |
|
667 | - } else { |
|
668 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
669 | - } |
|
670 | - } |
|
671 | - } |
|
672 | - $tracker++; |
|
673 | - $regs[] = $report_column_values; |
|
674 | - } |
|
675 | - // make sure the column_titles is pushed to the beginning of the array |
|
676 | - array_unshift($regs, $column_titles); |
|
677 | - // setup the date range. |
|
678 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
679 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
680 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
681 | - $subtitle = sprintf( |
|
682 | - wp_strip_all_tags( |
|
683 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
684 | - ), |
|
685 | - $beginning_date->format('Y-m-d'), |
|
686 | - $ending_date->format('Y-m-d') |
|
687 | - ); |
|
688 | - } |
|
689 | - $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
690 | - $report_params = array( |
|
691 | - 'title' => $report_title, |
|
692 | - 'subtitle' => $subtitle, |
|
693 | - 'id' => $report_ID, |
|
694 | - 'regs' => $regs, |
|
695 | - 'noResults' => empty($regs), |
|
696 | - 'noRegsMsg' => sprintf( |
|
697 | - wp_strip_all_tags( |
|
698 | - __( |
|
699 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
700 | - 'event_espresso' |
|
701 | - ) |
|
702 | - ), |
|
703 | - '<h2>' . $report_title . '</h2><p>', |
|
704 | - '</p>' |
|
705 | - ), |
|
706 | - ); |
|
707 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
708 | - return $report_ID; |
|
709 | - } |
|
635 | + /** |
|
636 | + * Generates Business Report showing total registrations per day. |
|
637 | + * |
|
638 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
639 | + * @return string |
|
640 | + * @throws EE_Error |
|
641 | + * @throws InvalidArgumentException |
|
642 | + * @throws InvalidDataTypeException |
|
643 | + * @throws InvalidInterfaceException |
|
644 | + */ |
|
645 | + private function _registrations_per_day_report($period = '-1 month') |
|
646 | + { |
|
647 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
648 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
649 | + $results = (array) $results; |
|
650 | + $regs = array(); |
|
651 | + $subtitle = ''; |
|
652 | + if ($results) { |
|
653 | + $column_titles = array(); |
|
654 | + $tracker = 0; |
|
655 | + foreach ($results as $result) { |
|
656 | + $report_column_values = array(); |
|
657 | + foreach ($result as $property_name => $property_value) { |
|
658 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
659 | + : (int) $property_value; |
|
660 | + $report_column_values[] = $property_value; |
|
661 | + if ($tracker === 0) { |
|
662 | + if ($property_name === 'Registration_REG_date') { |
|
663 | + $column_titles[] = esc_html__( |
|
664 | + 'Date (only days with registrations are shown)', |
|
665 | + 'event_espresso' |
|
666 | + ); |
|
667 | + } else { |
|
668 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
669 | + } |
|
670 | + } |
|
671 | + } |
|
672 | + $tracker++; |
|
673 | + $regs[] = $report_column_values; |
|
674 | + } |
|
675 | + // make sure the column_titles is pushed to the beginning of the array |
|
676 | + array_unshift($regs, $column_titles); |
|
677 | + // setup the date range. |
|
678 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
679 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
680 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
681 | + $subtitle = sprintf( |
|
682 | + wp_strip_all_tags( |
|
683 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
684 | + ), |
|
685 | + $beginning_date->format('Y-m-d'), |
|
686 | + $ending_date->format('Y-m-d') |
|
687 | + ); |
|
688 | + } |
|
689 | + $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
690 | + $report_params = array( |
|
691 | + 'title' => $report_title, |
|
692 | + 'subtitle' => $subtitle, |
|
693 | + 'id' => $report_ID, |
|
694 | + 'regs' => $regs, |
|
695 | + 'noResults' => empty($regs), |
|
696 | + 'noRegsMsg' => sprintf( |
|
697 | + wp_strip_all_tags( |
|
698 | + __( |
|
699 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
700 | + 'event_espresso' |
|
701 | + ) |
|
702 | + ), |
|
703 | + '<h2>' . $report_title . '</h2><p>', |
|
704 | + '</p>' |
|
705 | + ), |
|
706 | + ); |
|
707 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
708 | + return $report_ID; |
|
709 | + } |
|
710 | 710 | |
711 | 711 | |
712 | - /** |
|
713 | - * Generates Business Report showing total registrations per event. |
|
714 | - * |
|
715 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
716 | - * @return string |
|
717 | - * @throws EE_Error |
|
718 | - * @throws InvalidArgumentException |
|
719 | - * @throws InvalidDataTypeException |
|
720 | - * @throws InvalidInterfaceException |
|
721 | - */ |
|
722 | - private function _registrations_per_event_report($period = '-1 month') |
|
723 | - { |
|
724 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
725 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
726 | - $results = (array) $results; |
|
727 | - $regs = array(); |
|
728 | - $subtitle = ''; |
|
729 | - if ($results) { |
|
730 | - $column_titles = array(); |
|
731 | - $tracker = 0; |
|
732 | - foreach ($results as $result) { |
|
733 | - $report_column_values = array(); |
|
734 | - foreach ($result as $property_name => $property_value) { |
|
735 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
736 | - $property_value, |
|
737 | - 4, |
|
738 | - '...' |
|
739 | - ) : (int) $property_value; |
|
740 | - $report_column_values[] = $property_value; |
|
741 | - if ($tracker === 0) { |
|
742 | - if ($property_name === 'Registration_Event') { |
|
743 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
744 | - } else { |
|
745 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
746 | - } |
|
747 | - } |
|
748 | - } |
|
749 | - $tracker++; |
|
750 | - $regs[] = $report_column_values; |
|
751 | - } |
|
752 | - // make sure the column_titles is pushed to the beginning of the array |
|
753 | - array_unshift($regs, $column_titles); |
|
754 | - // setup the date range. |
|
755 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
756 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
757 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
758 | - $subtitle = sprintf( |
|
759 | - wp_strip_all_tags( |
|
760 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
761 | - ), |
|
762 | - $beginning_date->format('Y-m-d'), |
|
763 | - $ending_date->format('Y-m-d') |
|
764 | - ); |
|
765 | - } |
|
766 | - $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
767 | - $report_params = array( |
|
768 | - 'title' => $report_title, |
|
769 | - 'subtitle' => $subtitle, |
|
770 | - 'id' => $report_ID, |
|
771 | - 'regs' => $regs, |
|
772 | - 'noResults' => empty($regs), |
|
773 | - 'noRegsMsg' => sprintf( |
|
774 | - wp_strip_all_tags( |
|
775 | - __( |
|
776 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
777 | - 'event_espresso' |
|
778 | - ) |
|
779 | - ), |
|
780 | - '<h2>' . $report_title . '</h2><p>', |
|
781 | - '</p>' |
|
782 | - ), |
|
783 | - ); |
|
784 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
785 | - return $report_ID; |
|
786 | - } |
|
712 | + /** |
|
713 | + * Generates Business Report showing total registrations per event. |
|
714 | + * |
|
715 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
716 | + * @return string |
|
717 | + * @throws EE_Error |
|
718 | + * @throws InvalidArgumentException |
|
719 | + * @throws InvalidDataTypeException |
|
720 | + * @throws InvalidInterfaceException |
|
721 | + */ |
|
722 | + private function _registrations_per_event_report($period = '-1 month') |
|
723 | + { |
|
724 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
725 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
726 | + $results = (array) $results; |
|
727 | + $regs = array(); |
|
728 | + $subtitle = ''; |
|
729 | + if ($results) { |
|
730 | + $column_titles = array(); |
|
731 | + $tracker = 0; |
|
732 | + foreach ($results as $result) { |
|
733 | + $report_column_values = array(); |
|
734 | + foreach ($result as $property_name => $property_value) { |
|
735 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
736 | + $property_value, |
|
737 | + 4, |
|
738 | + '...' |
|
739 | + ) : (int) $property_value; |
|
740 | + $report_column_values[] = $property_value; |
|
741 | + if ($tracker === 0) { |
|
742 | + if ($property_name === 'Registration_Event') { |
|
743 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
744 | + } else { |
|
745 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
746 | + } |
|
747 | + } |
|
748 | + } |
|
749 | + $tracker++; |
|
750 | + $regs[] = $report_column_values; |
|
751 | + } |
|
752 | + // make sure the column_titles is pushed to the beginning of the array |
|
753 | + array_unshift($regs, $column_titles); |
|
754 | + // setup the date range. |
|
755 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
756 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
757 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
758 | + $subtitle = sprintf( |
|
759 | + wp_strip_all_tags( |
|
760 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
761 | + ), |
|
762 | + $beginning_date->format('Y-m-d'), |
|
763 | + $ending_date->format('Y-m-d') |
|
764 | + ); |
|
765 | + } |
|
766 | + $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
767 | + $report_params = array( |
|
768 | + 'title' => $report_title, |
|
769 | + 'subtitle' => $subtitle, |
|
770 | + 'id' => $report_ID, |
|
771 | + 'regs' => $regs, |
|
772 | + 'noResults' => empty($regs), |
|
773 | + 'noRegsMsg' => sprintf( |
|
774 | + wp_strip_all_tags( |
|
775 | + __( |
|
776 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
777 | + 'event_espresso' |
|
778 | + ) |
|
779 | + ), |
|
780 | + '<h2>' . $report_title . '</h2><p>', |
|
781 | + '</p>' |
|
782 | + ), |
|
783 | + ); |
|
784 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
785 | + return $report_ID; |
|
786 | + } |
|
787 | 787 | |
788 | 788 | |
789 | - /** |
|
790 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
791 | - * |
|
792 | - * @access protected |
|
793 | - * @return void |
|
794 | - * @throws EE_Error |
|
795 | - * @throws InvalidArgumentException |
|
796 | - * @throws InvalidDataTypeException |
|
797 | - * @throws InvalidInterfaceException |
|
798 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
799 | - */ |
|
800 | - protected function _registration_checkin_list_table() |
|
801 | - { |
|
802 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
803 | - $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
804 | - /** @var EE_Registration $registration */ |
|
805 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
806 | - if (! $registration instanceof EE_Registration) { |
|
807 | - throw new EE_Error( |
|
808 | - sprintf( |
|
809 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
810 | - $reg_id |
|
811 | - ) |
|
812 | - ); |
|
813 | - } |
|
814 | - $attendee = $registration->attendee(); |
|
815 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
816 | - 'new_registration', |
|
817 | - 'add-registrant', |
|
818 | - array('event_id' => $registration->event_ID()), |
|
819 | - 'add-new-h2' |
|
820 | - ); |
|
821 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
822 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
823 | - $legend_items = array( |
|
824 | - 'checkin' => array( |
|
825 | - 'class' => $checked_in->cssClasses(), |
|
826 | - 'desc' => $checked_in->legendLabel(), |
|
827 | - ), |
|
828 | - 'checkout' => array( |
|
829 | - 'class' => $checked_out->cssClasses(), |
|
830 | - 'desc' => $checked_out->legendLabel(), |
|
831 | - ), |
|
832 | - ); |
|
833 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
834 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
835 | - /** @var EE_Datetime $datetime */ |
|
836 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
837 | - $datetime_label = ''; |
|
838 | - if ($datetime instanceof EE_Datetime) { |
|
839 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
840 | - $datetime_label .= ! empty($datetime_label) |
|
841 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
842 | - : $datetime->get_dtt_display_name(); |
|
843 | - } |
|
844 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
845 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
846 | - array( |
|
847 | - 'action' => 'event_registrations', |
|
848 | - 'event_id' => $registration->event_ID(), |
|
849 | - 'DTT_ID' => $dtt_id, |
|
850 | - ), |
|
851 | - $this->_admin_base_url |
|
852 | - ) |
|
853 | - : ''; |
|
854 | - $datetime_link = ! empty($datetime_link) |
|
855 | - ? '<a href="' . $datetime_link . '">' |
|
856 | - . '<span id="checkin-dtt">' |
|
857 | - . $datetime_label |
|
858 | - . '</span></a>' |
|
859 | - : $datetime_label; |
|
860 | - $attendee_name = $attendee instanceof EE_Attendee |
|
861 | - ? $attendee->full_name() |
|
862 | - : ''; |
|
863 | - $attendee_link = $attendee instanceof EE_Attendee |
|
864 | - ? $attendee->get_admin_details_link() |
|
865 | - : ''; |
|
866 | - $attendee_link = ! empty($attendee_link) |
|
867 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
868 | - . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
869 | - . '<span id="checkin-attendee-name">' |
|
870 | - . $attendee_name |
|
871 | - . '</span></a>' |
|
872 | - : ''; |
|
873 | - $event_link = $registration->event() instanceof EE_Event |
|
874 | - ? $registration->event()->get_admin_details_link() |
|
875 | - : ''; |
|
876 | - $event_link = ! empty($event_link) |
|
877 | - ? '<a href="' . $event_link . '"' |
|
878 | - . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
879 | - . '<span id="checkin-event-name">' |
|
880 | - . $registration->event_name() |
|
881 | - . '</span>' |
|
882 | - . '</a>' |
|
883 | - : ''; |
|
884 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
885 | - ? '<h2>' . sprintf( |
|
886 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
887 | - $attendee_link, |
|
888 | - $datetime_link, |
|
889 | - $event_link |
|
890 | - ) . '</h2>' |
|
891 | - : ''; |
|
892 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
893 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
894 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
895 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
896 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
897 | - } |
|
789 | + /** |
|
790 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
791 | + * |
|
792 | + * @access protected |
|
793 | + * @return void |
|
794 | + * @throws EE_Error |
|
795 | + * @throws InvalidArgumentException |
|
796 | + * @throws InvalidDataTypeException |
|
797 | + * @throws InvalidInterfaceException |
|
798 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
799 | + */ |
|
800 | + protected function _registration_checkin_list_table() |
|
801 | + { |
|
802 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
803 | + $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
804 | + /** @var EE_Registration $registration */ |
|
805 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
806 | + if (! $registration instanceof EE_Registration) { |
|
807 | + throw new EE_Error( |
|
808 | + sprintf( |
|
809 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
810 | + $reg_id |
|
811 | + ) |
|
812 | + ); |
|
813 | + } |
|
814 | + $attendee = $registration->attendee(); |
|
815 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
816 | + 'new_registration', |
|
817 | + 'add-registrant', |
|
818 | + array('event_id' => $registration->event_ID()), |
|
819 | + 'add-new-h2' |
|
820 | + ); |
|
821 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
822 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
823 | + $legend_items = array( |
|
824 | + 'checkin' => array( |
|
825 | + 'class' => $checked_in->cssClasses(), |
|
826 | + 'desc' => $checked_in->legendLabel(), |
|
827 | + ), |
|
828 | + 'checkout' => array( |
|
829 | + 'class' => $checked_out->cssClasses(), |
|
830 | + 'desc' => $checked_out->legendLabel(), |
|
831 | + ), |
|
832 | + ); |
|
833 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
834 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
835 | + /** @var EE_Datetime $datetime */ |
|
836 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
837 | + $datetime_label = ''; |
|
838 | + if ($datetime instanceof EE_Datetime) { |
|
839 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
840 | + $datetime_label .= ! empty($datetime_label) |
|
841 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
842 | + : $datetime->get_dtt_display_name(); |
|
843 | + } |
|
844 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
845 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
846 | + array( |
|
847 | + 'action' => 'event_registrations', |
|
848 | + 'event_id' => $registration->event_ID(), |
|
849 | + 'DTT_ID' => $dtt_id, |
|
850 | + ), |
|
851 | + $this->_admin_base_url |
|
852 | + ) |
|
853 | + : ''; |
|
854 | + $datetime_link = ! empty($datetime_link) |
|
855 | + ? '<a href="' . $datetime_link . '">' |
|
856 | + . '<span id="checkin-dtt">' |
|
857 | + . $datetime_label |
|
858 | + . '</span></a>' |
|
859 | + : $datetime_label; |
|
860 | + $attendee_name = $attendee instanceof EE_Attendee |
|
861 | + ? $attendee->full_name() |
|
862 | + : ''; |
|
863 | + $attendee_link = $attendee instanceof EE_Attendee |
|
864 | + ? $attendee->get_admin_details_link() |
|
865 | + : ''; |
|
866 | + $attendee_link = ! empty($attendee_link) |
|
867 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
868 | + . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
869 | + . '<span id="checkin-attendee-name">' |
|
870 | + . $attendee_name |
|
871 | + . '</span></a>' |
|
872 | + : ''; |
|
873 | + $event_link = $registration->event() instanceof EE_Event |
|
874 | + ? $registration->event()->get_admin_details_link() |
|
875 | + : ''; |
|
876 | + $event_link = ! empty($event_link) |
|
877 | + ? '<a href="' . $event_link . '"' |
|
878 | + . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
879 | + . '<span id="checkin-event-name">' |
|
880 | + . $registration->event_name() |
|
881 | + . '</span>' |
|
882 | + . '</a>' |
|
883 | + : ''; |
|
884 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
885 | + ? '<h2>' . sprintf( |
|
886 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
887 | + $attendee_link, |
|
888 | + $datetime_link, |
|
889 | + $event_link |
|
890 | + ) . '</h2>' |
|
891 | + : ''; |
|
892 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
893 | + ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
894 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
895 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
896 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
897 | + } |
|
898 | 898 | |
899 | 899 | |
900 | - /** |
|
901 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
902 | - * |
|
903 | - * @return void (JSON) |
|
904 | - * @throws EE_Error |
|
905 | - * @throws InvalidArgumentException |
|
906 | - * @throws InvalidDataTypeException |
|
907 | - * @throws InvalidInterfaceException |
|
908 | - */ |
|
909 | - public function toggle_checkin_status() |
|
910 | - { |
|
911 | - // first make sure we have the necessary data |
|
912 | - if (! isset($this->_req_data['_regid'])) { |
|
913 | - EE_Error::add_error( |
|
914 | - esc_html__( |
|
915 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
916 | - 'event_espresso' |
|
917 | - ), |
|
918 | - __FILE__, |
|
919 | - __FUNCTION__, |
|
920 | - __LINE__ |
|
921 | - ); |
|
922 | - $this->_template_args['success'] = false; |
|
923 | - $this->_template_args['error'] = true; |
|
924 | - $this->_return_json(); |
|
925 | - }; |
|
926 | - // do a nonce check cause we're not coming in from an normal route here. |
|
927 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
928 | - : ''; |
|
929 | - $nonce_ref = 'checkin_nonce'; |
|
930 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
931 | - // beautiful! Made it this far so let's get the status. |
|
932 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
933 | - // setup new class to return via ajax |
|
934 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
935 | - $this->_template_args['success'] = true; |
|
936 | - $this->_return_json(); |
|
937 | - } |
|
900 | + /** |
|
901 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
902 | + * |
|
903 | + * @return void (JSON) |
|
904 | + * @throws EE_Error |
|
905 | + * @throws InvalidArgumentException |
|
906 | + * @throws InvalidDataTypeException |
|
907 | + * @throws InvalidInterfaceException |
|
908 | + */ |
|
909 | + public function toggle_checkin_status() |
|
910 | + { |
|
911 | + // first make sure we have the necessary data |
|
912 | + if (! isset($this->_req_data['_regid'])) { |
|
913 | + EE_Error::add_error( |
|
914 | + esc_html__( |
|
915 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
916 | + 'event_espresso' |
|
917 | + ), |
|
918 | + __FILE__, |
|
919 | + __FUNCTION__, |
|
920 | + __LINE__ |
|
921 | + ); |
|
922 | + $this->_template_args['success'] = false; |
|
923 | + $this->_template_args['error'] = true; |
|
924 | + $this->_return_json(); |
|
925 | + }; |
|
926 | + // do a nonce check cause we're not coming in from an normal route here. |
|
927 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
928 | + : ''; |
|
929 | + $nonce_ref = 'checkin_nonce'; |
|
930 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
931 | + // beautiful! Made it this far so let's get the status. |
|
932 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
933 | + // setup new class to return via ajax |
|
934 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
935 | + $this->_template_args['success'] = true; |
|
936 | + $this->_return_json(); |
|
937 | + } |
|
938 | 938 | |
939 | 939 | |
940 | - /** |
|
941 | - * handles toggling the checkin status for the registration, |
|
942 | - * |
|
943 | - * @access protected |
|
944 | - * @return int|void |
|
945 | - * @throws EE_Error |
|
946 | - * @throws InvalidArgumentException |
|
947 | - * @throws InvalidDataTypeException |
|
948 | - * @throws InvalidInterfaceException |
|
949 | - */ |
|
950 | - protected function _toggle_checkin_status() |
|
951 | - { |
|
952 | - // first let's get the query args out of the way for the redirect |
|
953 | - $query_args = array( |
|
954 | - 'action' => 'event_registrations', |
|
955 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
956 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
957 | - ); |
|
958 | - $new_status = false; |
|
959 | - // bulk action check in toggle |
|
960 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
961 | - // cycle thru checkboxes |
|
962 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
963 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
964 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
965 | - } |
|
966 | - } elseif (isset($this->_req_data['_regid'])) { |
|
967 | - // coming from ajax request |
|
968 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
969 | - $query_args['DTT_ID'] = $DTT_ID; |
|
970 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
971 | - } else { |
|
972 | - EE_Error::add_error( |
|
973 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
974 | - __FILE__, |
|
975 | - __FUNCTION__, |
|
976 | - __LINE__ |
|
977 | - ); |
|
978 | - } |
|
979 | - if (defined('DOING_AJAX')) { |
|
980 | - return $new_status; |
|
981 | - } |
|
982 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
983 | - } |
|
940 | + /** |
|
941 | + * handles toggling the checkin status for the registration, |
|
942 | + * |
|
943 | + * @access protected |
|
944 | + * @return int|void |
|
945 | + * @throws EE_Error |
|
946 | + * @throws InvalidArgumentException |
|
947 | + * @throws InvalidDataTypeException |
|
948 | + * @throws InvalidInterfaceException |
|
949 | + */ |
|
950 | + protected function _toggle_checkin_status() |
|
951 | + { |
|
952 | + // first let's get the query args out of the way for the redirect |
|
953 | + $query_args = array( |
|
954 | + 'action' => 'event_registrations', |
|
955 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
956 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
957 | + ); |
|
958 | + $new_status = false; |
|
959 | + // bulk action check in toggle |
|
960 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
961 | + // cycle thru checkboxes |
|
962 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
963 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
964 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
965 | + } |
|
966 | + } elseif (isset($this->_req_data['_regid'])) { |
|
967 | + // coming from ajax request |
|
968 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
969 | + $query_args['DTT_ID'] = $DTT_ID; |
|
970 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
971 | + } else { |
|
972 | + EE_Error::add_error( |
|
973 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
974 | + __FILE__, |
|
975 | + __FUNCTION__, |
|
976 | + __LINE__ |
|
977 | + ); |
|
978 | + } |
|
979 | + if (defined('DOING_AJAX')) { |
|
980 | + return $new_status; |
|
981 | + } |
|
982 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
983 | + } |
|
984 | 984 | |
985 | 985 | |
986 | - /** |
|
987 | - * This is toggles a single Check-in for the given registration and datetime. |
|
988 | - * |
|
989 | - * @param int $REG_ID The registration we're toggling |
|
990 | - * @param int $DTT_ID The datetime we're toggling |
|
991 | - * @return int The new status toggled to. |
|
992 | - * @throws EE_Error |
|
993 | - * @throws InvalidArgumentException |
|
994 | - * @throws InvalidDataTypeException |
|
995 | - * @throws InvalidInterfaceException |
|
996 | - */ |
|
997 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
998 | - { |
|
999 | - /** @var EE_Registration $REG */ |
|
1000 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1001 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
1002 | - if ($new_status !== false) { |
|
1003 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1004 | - } else { |
|
1005 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1006 | - $new_status = false; |
|
1007 | - } |
|
1008 | - return $new_status; |
|
1009 | - } |
|
986 | + /** |
|
987 | + * This is toggles a single Check-in for the given registration and datetime. |
|
988 | + * |
|
989 | + * @param int $REG_ID The registration we're toggling |
|
990 | + * @param int $DTT_ID The datetime we're toggling |
|
991 | + * @return int The new status toggled to. |
|
992 | + * @throws EE_Error |
|
993 | + * @throws InvalidArgumentException |
|
994 | + * @throws InvalidDataTypeException |
|
995 | + * @throws InvalidInterfaceException |
|
996 | + */ |
|
997 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
998 | + { |
|
999 | + /** @var EE_Registration $REG */ |
|
1000 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1001 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
1002 | + if ($new_status !== false) { |
|
1003 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
1004 | + } else { |
|
1005 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
1006 | + $new_status = false; |
|
1007 | + } |
|
1008 | + return $new_status; |
|
1009 | + } |
|
1010 | 1010 | |
1011 | 1011 | |
1012 | - /** |
|
1013 | - * Takes care of deleting multiple EE_Checkin table rows |
|
1014 | - * |
|
1015 | - * @access protected |
|
1016 | - * @return void |
|
1017 | - * @throws EE_Error |
|
1018 | - * @throws InvalidArgumentException |
|
1019 | - * @throws InvalidDataTypeException |
|
1020 | - * @throws InvalidInterfaceException |
|
1021 | - */ |
|
1022 | - protected function _delete_checkin_rows() |
|
1023 | - { |
|
1024 | - $query_args = array( |
|
1025 | - 'action' => 'registration_checkins', |
|
1026 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1027 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1028 | - ); |
|
1029 | - $errors = 0; |
|
1030 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1031 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1032 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1033 | - $errors++; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } else { |
|
1037 | - EE_Error::add_error( |
|
1038 | - esc_html__( |
|
1039 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1040 | - 'event_espresso' |
|
1041 | - ), |
|
1042 | - __FILE__, |
|
1043 | - __FUNCTION__, |
|
1044 | - __LINE__ |
|
1045 | - ); |
|
1046 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1047 | - } |
|
1048 | - if ($errors > 0) { |
|
1049 | - EE_Error::add_error( |
|
1050 | - sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1051 | - __FILE__, |
|
1052 | - __FUNCTION__, |
|
1053 | - __LINE__ |
|
1054 | - ); |
|
1055 | - } else { |
|
1056 | - EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1057 | - } |
|
1058 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1059 | - } |
|
1012 | + /** |
|
1013 | + * Takes care of deleting multiple EE_Checkin table rows |
|
1014 | + * |
|
1015 | + * @access protected |
|
1016 | + * @return void |
|
1017 | + * @throws EE_Error |
|
1018 | + * @throws InvalidArgumentException |
|
1019 | + * @throws InvalidDataTypeException |
|
1020 | + * @throws InvalidInterfaceException |
|
1021 | + */ |
|
1022 | + protected function _delete_checkin_rows() |
|
1023 | + { |
|
1024 | + $query_args = array( |
|
1025 | + 'action' => 'registration_checkins', |
|
1026 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1027 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1028 | + ); |
|
1029 | + $errors = 0; |
|
1030 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1031 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1032 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1033 | + $errors++; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } else { |
|
1037 | + EE_Error::add_error( |
|
1038 | + esc_html__( |
|
1039 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
1040 | + 'event_espresso' |
|
1041 | + ), |
|
1042 | + __FILE__, |
|
1043 | + __FUNCTION__, |
|
1044 | + __LINE__ |
|
1045 | + ); |
|
1046 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1047 | + } |
|
1048 | + if ($errors > 0) { |
|
1049 | + EE_Error::add_error( |
|
1050 | + sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
1051 | + __FILE__, |
|
1052 | + __FUNCTION__, |
|
1053 | + __LINE__ |
|
1054 | + ); |
|
1055 | + } else { |
|
1056 | + EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
1057 | + } |
|
1058 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1059 | + } |
|
1060 | 1060 | |
1061 | 1061 | |
1062 | - /** |
|
1063 | - * Deletes a single EE_Checkin row |
|
1064 | - * |
|
1065 | - * @return void |
|
1066 | - * @throws EE_Error |
|
1067 | - * @throws InvalidArgumentException |
|
1068 | - * @throws InvalidDataTypeException |
|
1069 | - * @throws InvalidInterfaceException |
|
1070 | - */ |
|
1071 | - protected function _delete_checkin_row() |
|
1072 | - { |
|
1073 | - $query_args = array( |
|
1074 | - 'action' => 'registration_checkins', |
|
1075 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1076 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1077 | - ); |
|
1078 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1079 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1080 | - EE_Error::add_error( |
|
1081 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1082 | - __FILE__, |
|
1083 | - __FUNCTION__, |
|
1084 | - __LINE__ |
|
1085 | - ); |
|
1086 | - } else { |
|
1087 | - EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1088 | - } |
|
1089 | - } else { |
|
1090 | - EE_Error::add_error( |
|
1091 | - esc_html__( |
|
1092 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1093 | - 'event_espresso' |
|
1094 | - ), |
|
1095 | - __FILE__, |
|
1096 | - __FUNCTION__, |
|
1097 | - __LINE__ |
|
1098 | - ); |
|
1099 | - } |
|
1100 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1101 | - } |
|
1062 | + /** |
|
1063 | + * Deletes a single EE_Checkin row |
|
1064 | + * |
|
1065 | + * @return void |
|
1066 | + * @throws EE_Error |
|
1067 | + * @throws InvalidArgumentException |
|
1068 | + * @throws InvalidDataTypeException |
|
1069 | + * @throws InvalidInterfaceException |
|
1070 | + */ |
|
1071 | + protected function _delete_checkin_row() |
|
1072 | + { |
|
1073 | + $query_args = array( |
|
1074 | + 'action' => 'registration_checkins', |
|
1075 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
1076 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
1077 | + ); |
|
1078 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
1079 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1080 | + EE_Error::add_error( |
|
1081 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1082 | + __FILE__, |
|
1083 | + __FUNCTION__, |
|
1084 | + __LINE__ |
|
1085 | + ); |
|
1086 | + } else { |
|
1087 | + EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
1088 | + } |
|
1089 | + } else { |
|
1090 | + EE_Error::add_error( |
|
1091 | + esc_html__( |
|
1092 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1093 | + 'event_espresso' |
|
1094 | + ), |
|
1095 | + __FILE__, |
|
1096 | + __FUNCTION__, |
|
1097 | + __LINE__ |
|
1098 | + ); |
|
1099 | + } |
|
1100 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1101 | + } |
|
1102 | 1102 | |
1103 | 1103 | |
1104 | - /** |
|
1105 | - * generates HTML for the Event Registrations List Table |
|
1106 | - * |
|
1107 | - * @access protected |
|
1108 | - * @return void |
|
1109 | - * @throws EE_Error |
|
1110 | - * @throws InvalidArgumentException |
|
1111 | - * @throws InvalidDataTypeException |
|
1112 | - * @throws InvalidInterfaceException |
|
1113 | - */ |
|
1114 | - protected function _event_registrations_list_table() |
|
1115 | - { |
|
1116 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1117 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1118 | - ? $this->get_action_link_or_button( |
|
1119 | - 'new_registration', |
|
1120 | - 'add-registrant', |
|
1121 | - array('event_id' => $this->_req_data['event_id']), |
|
1122 | - 'add-new-h2', |
|
1123 | - '', |
|
1124 | - false |
|
1125 | - ) |
|
1126 | - : ''; |
|
1127 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1128 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1129 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1130 | - $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid); |
|
1131 | - $legend_items = array( |
|
1132 | - 'star-icon' => array( |
|
1133 | - 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
1134 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1135 | - ), |
|
1136 | - 'checkin' => array( |
|
1137 | - 'class' => $checked_in->cssClasses(), |
|
1138 | - 'desc' => $checked_in->legendLabel(), |
|
1139 | - ), |
|
1140 | - 'checkout' => array( |
|
1141 | - 'class' => $checked_out->cssClasses(), |
|
1142 | - 'desc' => $checked_out->legendLabel(), |
|
1143 | - ), |
|
1144 | - 'nocheckinrecord' => array( |
|
1145 | - 'class' => $checked_never->cssClasses(), |
|
1146 | - 'desc' => $checked_never->legendLabel(), |
|
1147 | - ), |
|
1148 | - 'canNotCheckin' => array( |
|
1149 | - 'class' => $checkin_invalid->cssClasses(), |
|
1150 | - 'desc' => $checkin_invalid->legendLabel(), |
|
1151 | - ), |
|
1152 | - 'approved_status' => array( |
|
1153 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved, |
|
1154 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1155 | - ), |
|
1156 | - 'cancelled_status' => array( |
|
1157 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled, |
|
1158 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1159 | - ), |
|
1160 | - 'declined_status' => array( |
|
1161 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined, |
|
1162 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1163 | - ), |
|
1164 | - 'not_approved' => array( |
|
1165 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved, |
|
1166 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1167 | - ), |
|
1168 | - 'pending_status' => array( |
|
1169 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment, |
|
1170 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1171 | - ), |
|
1172 | - 'wait_list' => array( |
|
1173 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list, |
|
1174 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1175 | - ), |
|
1176 | - ); |
|
1177 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1178 | - $event_id = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
1179 | - /** @var EE_Event $event */ |
|
1180 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1181 | - $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1182 | - ? '<h2> |
|
1104 | + /** |
|
1105 | + * generates HTML for the Event Registrations List Table |
|
1106 | + * |
|
1107 | + * @access protected |
|
1108 | + * @return void |
|
1109 | + * @throws EE_Error |
|
1110 | + * @throws InvalidArgumentException |
|
1111 | + * @throws InvalidDataTypeException |
|
1112 | + * @throws InvalidInterfaceException |
|
1113 | + */ |
|
1114 | + protected function _event_registrations_list_table() |
|
1115 | + { |
|
1116 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1117 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1118 | + ? $this->get_action_link_or_button( |
|
1119 | + 'new_registration', |
|
1120 | + 'add-registrant', |
|
1121 | + array('event_id' => $this->_req_data['event_id']), |
|
1122 | + 'add-new-h2', |
|
1123 | + '', |
|
1124 | + false |
|
1125 | + ) |
|
1126 | + : ''; |
|
1127 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1128 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1129 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1130 | + $checkin_invalid = new CheckinStatusDashicon(EE_Checkin::status_invalid); |
|
1131 | + $legend_items = array( |
|
1132 | + 'star-icon' => array( |
|
1133 | + 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
1134 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1135 | + ), |
|
1136 | + 'checkin' => array( |
|
1137 | + 'class' => $checked_in->cssClasses(), |
|
1138 | + 'desc' => $checked_in->legendLabel(), |
|
1139 | + ), |
|
1140 | + 'checkout' => array( |
|
1141 | + 'class' => $checked_out->cssClasses(), |
|
1142 | + 'desc' => $checked_out->legendLabel(), |
|
1143 | + ), |
|
1144 | + 'nocheckinrecord' => array( |
|
1145 | + 'class' => $checked_never->cssClasses(), |
|
1146 | + 'desc' => $checked_never->legendLabel(), |
|
1147 | + ), |
|
1148 | + 'canNotCheckin' => array( |
|
1149 | + 'class' => $checkin_invalid->cssClasses(), |
|
1150 | + 'desc' => $checkin_invalid->legendLabel(), |
|
1151 | + ), |
|
1152 | + 'approved_status' => array( |
|
1153 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved, |
|
1154 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1155 | + ), |
|
1156 | + 'cancelled_status' => array( |
|
1157 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled, |
|
1158 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1159 | + ), |
|
1160 | + 'declined_status' => array( |
|
1161 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined, |
|
1162 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1163 | + ), |
|
1164 | + 'not_approved' => array( |
|
1165 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved, |
|
1166 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1167 | + ), |
|
1168 | + 'pending_status' => array( |
|
1169 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment, |
|
1170 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1171 | + ), |
|
1172 | + 'wait_list' => array( |
|
1173 | + 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list, |
|
1174 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1175 | + ), |
|
1176 | + ); |
|
1177 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1178 | + $event_id = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
1179 | + /** @var EE_Event $event */ |
|
1180 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1181 | + $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
1182 | + ? '<h2> |
|
1183 | 1183 | ' . sprintf( |
1184 | - esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1185 | - "<span class='ee-event-name'>{$event->name()}</span>" |
|
1186 | - ) |
|
1187 | - : ''; |
|
1188 | - // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1189 | - // the event. |
|
1190 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1191 | - $datetime = null; |
|
1192 | - if ($event instanceof EE_Event) { |
|
1193 | - $datetimes_on_event = $event->datetimes(); |
|
1194 | - if (count($datetimes_on_event) === 1) { |
|
1195 | - $datetime = reset($datetimes_on_event); |
|
1196 | - } |
|
1197 | - } |
|
1198 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1199 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1200 | - $active_status = $datetime->get_active_status(); |
|
1201 | - $datetime_status = |
|
1202 | - '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' . |
|
1203 | - esc_attr($active_status) . '">' |
|
1204 | - . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1205 | - . '</span>'; |
|
1206 | - $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">'; |
|
1207 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>'; |
|
1208 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1209 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1210 | - $this->_template_args['before_list_table'] .= $datetime_status; |
|
1211 | - $this->_template_args['before_list_table'] .= '</span>'; |
|
1212 | - } |
|
1213 | - $this->_template_args['before_list_table'] .= '</h2>'; |
|
1214 | - // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1215 | - // column represents |
|
1216 | - if (! $datetime instanceof EE_Datetime) { |
|
1217 | - $this->_template_args['before_list_table'] .= '<h3 class="description">' |
|
1218 | - . esc_html__( |
|
1219 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1220 | - 'event_espresso' |
|
1221 | - ) |
|
1222 | - . '</h3>'; |
|
1223 | - } |
|
1224 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1225 | - } |
|
1184 | + esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1185 | + "<span class='ee-event-name'>{$event->name()}</span>" |
|
1186 | + ) |
|
1187 | + : ''; |
|
1188 | + // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
1189 | + // the event. |
|
1190 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1191 | + $datetime = null; |
|
1192 | + if ($event instanceof EE_Event) { |
|
1193 | + $datetimes_on_event = $event->datetimes(); |
|
1194 | + if (count($datetimes_on_event) === 1) { |
|
1195 | + $datetime = reset($datetimes_on_event); |
|
1196 | + } |
|
1197 | + } |
|
1198 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1199 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1200 | + $active_status = $datetime->get_active_status(); |
|
1201 | + $datetime_status = |
|
1202 | + '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' . |
|
1203 | + esc_attr($active_status) . '">' |
|
1204 | + . EEH_Template::pretty_status($active_status, false, 'sentence') |
|
1205 | + . '</span>'; |
|
1206 | + $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">'; |
|
1207 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>'; |
|
1208 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1209 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1210 | + $this->_template_args['before_list_table'] .= $datetime_status; |
|
1211 | + $this->_template_args['before_list_table'] .= '</span>'; |
|
1212 | + } |
|
1213 | + $this->_template_args['before_list_table'] .= '</h2>'; |
|
1214 | + // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
1215 | + // column represents |
|
1216 | + if (! $datetime instanceof EE_Datetime) { |
|
1217 | + $this->_template_args['before_list_table'] .= '<h3 class="description">' |
|
1218 | + . esc_html__( |
|
1219 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1220 | + 'event_espresso' |
|
1221 | + ) |
|
1222 | + . '</h3>'; |
|
1223 | + } |
|
1224 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1225 | + } |
|
1226 | 1226 | |
1227 | - /** |
|
1228 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1229 | - * conditions) |
|
1230 | - * |
|
1231 | - * @return void ends the request by a redirect or download |
|
1232 | - */ |
|
1233 | - public function _registrations_checkin_report() |
|
1234 | - { |
|
1235 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1236 | - } |
|
1227 | + /** |
|
1228 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1229 | + * conditions) |
|
1230 | + * |
|
1231 | + * @return void ends the request by a redirect or download |
|
1232 | + */ |
|
1233 | + public function _registrations_checkin_report() |
|
1234 | + { |
|
1235 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1236 | + } |
|
1237 | 1237 | |
1238 | - /** |
|
1239 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1240 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1241 | - * |
|
1242 | - * @param array $request |
|
1243 | - * @param int $per_page |
|
1244 | - * @param bool $count |
|
1245 | - * @return array |
|
1246 | - * @throws EE_Error |
|
1247 | - */ |
|
1248 | - protected function _get_checkin_query_params_from_request( |
|
1249 | - $request, |
|
1250 | - $per_page = 10, |
|
1251 | - $count = false |
|
1252 | - ) { |
|
1253 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1254 | - // unlike the regular registrations list table, |
|
1255 | - $status_ids_array = apply_filters( |
|
1256 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1257 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1258 | - ); |
|
1259 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1260 | - return $query_params; |
|
1261 | - } |
|
1238 | + /** |
|
1239 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1240 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1241 | + * |
|
1242 | + * @param array $request |
|
1243 | + * @param int $per_page |
|
1244 | + * @param bool $count |
|
1245 | + * @return array |
|
1246 | + * @throws EE_Error |
|
1247 | + */ |
|
1248 | + protected function _get_checkin_query_params_from_request( |
|
1249 | + $request, |
|
1250 | + $per_page = 10, |
|
1251 | + $count = false |
|
1252 | + ) { |
|
1253 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1254 | + // unlike the regular registrations list table, |
|
1255 | + $status_ids_array = apply_filters( |
|
1256 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1257 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1258 | + ); |
|
1259 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1260 | + return $query_params; |
|
1261 | + } |
|
1262 | 1262 | |
1263 | 1263 | |
1264 | - /** |
|
1265 | - * Gets registrations for an event |
|
1266 | - * |
|
1267 | - * @param int $per_page |
|
1268 | - * @param bool $count whether to return count or data. |
|
1269 | - * @param bool $trash |
|
1270 | - * @param string $orderby |
|
1271 | - * @return EE_Registration[]|int |
|
1272 | - * @throws EE_Error |
|
1273 | - * @throws InvalidArgumentException |
|
1274 | - * @throws InvalidDataTypeException |
|
1275 | - * @throws InvalidInterfaceException |
|
1276 | - */ |
|
1277 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1278 | - { |
|
1279 | - // set some defaults, these will get overridden if included in the actual request parameters |
|
1280 | - $defaults = [ |
|
1281 | - 'orderby' => $orderby, |
|
1282 | - 'order' => 'ASC', |
|
1283 | - ]; |
|
1284 | - if ($trash) { |
|
1285 | - $defaults['status'] = 'trash'; |
|
1286 | - } |
|
1287 | - $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
1264 | + /** |
|
1265 | + * Gets registrations for an event |
|
1266 | + * |
|
1267 | + * @param int $per_page |
|
1268 | + * @param bool $count whether to return count or data. |
|
1269 | + * @param bool $trash |
|
1270 | + * @param string $orderby |
|
1271 | + * @return EE_Registration[]|int |
|
1272 | + * @throws EE_Error |
|
1273 | + * @throws InvalidArgumentException |
|
1274 | + * @throws InvalidDataTypeException |
|
1275 | + * @throws InvalidInterfaceException |
|
1276 | + */ |
|
1277 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1278 | + { |
|
1279 | + // set some defaults, these will get overridden if included in the actual request parameters |
|
1280 | + $defaults = [ |
|
1281 | + 'orderby' => $orderby, |
|
1282 | + 'order' => 'ASC', |
|
1283 | + ]; |
|
1284 | + if ($trash) { |
|
1285 | + $defaults['status'] = 'trash'; |
|
1286 | + } |
|
1287 | + $query_params = $this->_get_checkin_query_params_from_request($defaults, $per_page, $count); |
|
1288 | 1288 | |
1289 | - /** |
|
1290 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1291 | - * |
|
1292 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1293 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1294 | - * or if you have the development copy of EE you can view this at the path: |
|
1295 | - * /docs/G--Model-System/model-query-params.md |
|
1296 | - */ |
|
1297 | - $query_params['group_by'] = ''; |
|
1289 | + /** |
|
1290 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1291 | + * |
|
1292 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1293 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1294 | + * or if you have the development copy of EE you can view this at the path: |
|
1295 | + * /docs/G--Model-System/model-query-params.md |
|
1296 | + */ |
|
1297 | + $query_params['group_by'] = ''; |
|
1298 | 1298 | |
1299 | - return $count |
|
1300 | - ? EEM_Registration::instance()->count($query_params) |
|
1301 | - /** @type EE_Registration[] */ |
|
1302 | - : EEM_Registration::instance()->get_all($query_params); |
|
1303 | - } |
|
1299 | + return $count |
|
1300 | + ? EEM_Registration::instance()->count($query_params) |
|
1301 | + /** @type EE_Registration[] */ |
|
1302 | + : EEM_Registration::instance()->get_all($query_params); |
|
1303 | + } |
|
1304 | 1304 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | public function __construct($routing = true) |
31 | 31 | { |
32 | 32 | parent::__construct($routing); |
33 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
35 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
36 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
33 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
34 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
35 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
36 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function _extend_page_config() |
45 | 45 | { |
46 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
46 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
47 | 47 | $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
48 | 48 | ? $this->_req_data['_REG_ID'] |
49 | 49 | : 0; |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | // enqueue newsletter js |
183 | 183 | wp_enqueue_script( |
184 | 184 | 'ee-newsletter-trigger', |
185 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
185 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
186 | 186 | array('ee-dialog'), |
187 | 187 | EVENT_ESPRESSO_VERSION, |
188 | 188 | true |
189 | 189 | ); |
190 | 190 | wp_enqueue_style( |
191 | 191 | 'ee-newsletter-trigger-css', |
192 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
192 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
193 | 193 | array(), |
194 | 194 | EVENT_ESPRESSO_VERSION |
195 | 195 | ); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | wp_register_script( |
212 | 212 | 'ee-reg-reports-js', |
213 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
213 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
214 | 214 | array('google-charts'), |
215 | 215 | EVENT_ESPRESSO_VERSION, |
216 | 216 | true |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
297 | 297 | $this->_verify_nonce($nonce, $nonce_ref); |
298 | 298 | // let's get the mtp for the incoming MTP_ ID |
299 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
299 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
300 | 300 | EE_Error::add_error( |
301 | 301 | esc_html__( |
302 | 302 | 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $this->_return_json(); |
312 | 312 | } |
313 | 313 | $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
314 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
314 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
315 | 315 | EE_Error::add_error( |
316 | 316 | sprintf( |
317 | 317 | esc_html__( |
@@ -336,12 +336,12 @@ discard block |
||
336 | 336 | $field = $MTP->get('MTP_template_field'); |
337 | 337 | if ($field === 'content') { |
338 | 338 | $content = $MTP->get('MTP_content'); |
339 | - if (! empty($content['newsletter_content'])) { |
|
339 | + if ( ! empty($content['newsletter_content'])) { |
|
340 | 340 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
341 | 341 | } |
342 | 342 | continue; |
343 | 343 | } |
344 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
344 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
345 | 345 | } |
346 | 346 | $this->_template_args['success'] = true; |
347 | 347 | $this->_template_args['error'] = false; |
@@ -443,17 +443,17 @@ discard block |
||
443 | 443 | $field_id = $field === '[NEWSLETTER_CONTENT]' |
444 | 444 | ? 'content' |
445 | 445 | : $field; |
446 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
446 | + $field_id = 'batch-message-'.strtolower($field_id); |
|
447 | 447 | $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
448 | 448 | . $shortcode |
449 | - . '" data-linked-input-id="' . $field_id . '">' |
|
449 | + . '" data-linked-input-id="'.$field_id.'">' |
|
450 | 450 | . $shortcode |
451 | 451 | . '</span>'; |
452 | 452 | } |
453 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
453 | + $codes[$field] = implode(', ', $available_shortcodes); |
|
454 | 454 | } |
455 | 455 | $shortcodes = $codes; |
456 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
456 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
457 | 457 | $form_template_args = array( |
458 | 458 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
459 | 459 | 'form_route' => 'newsletter_selected_send', |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | */ |
622 | 622 | protected function _registration_reports() |
623 | 623 | { |
624 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
624 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
625 | 625 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
626 | 626 | $template_path, |
627 | 627 | $this->_reports_template_data, |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | array_unshift($regs, $column_titles); |
677 | 677 | // setup the date range. |
678 | 678 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
679 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
679 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
680 | 680 | $ending_date = new DateTime("now", $DateTimeZone); |
681 | 681 | $subtitle = sprintf( |
682 | 682 | wp_strip_all_tags( |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'event_espresso' |
701 | 701 | ) |
702 | 702 | ), |
703 | - '<h2>' . $report_title . '</h2><p>', |
|
703 | + '<h2>'.$report_title.'</h2><p>', |
|
704 | 704 | '</p>' |
705 | 705 | ), |
706 | 706 | ); |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | array_unshift($regs, $column_titles); |
754 | 754 | // setup the date range. |
755 | 755 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
756 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
756 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
757 | 757 | $ending_date = new DateTime("now", $DateTimeZone); |
758 | 758 | $subtitle = sprintf( |
759 | 759 | wp_strip_all_tags( |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | 'event_espresso' |
778 | 778 | ) |
779 | 779 | ), |
780 | - '<h2>' . $report_title . '</h2><p>', |
|
780 | + '<h2>'.$report_title.'</h2><p>', |
|
781 | 781 | '</p>' |
782 | 782 | ), |
783 | 783 | ); |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
804 | 804 | /** @var EE_Registration $registration */ |
805 | 805 | $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
806 | - if (! $registration instanceof EE_Registration) { |
|
806 | + if ( ! $registration instanceof EE_Registration) { |
|
807 | 807 | throw new EE_Error( |
808 | 808 | sprintf( |
809 | 809 | esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | if ($datetime instanceof EE_Datetime) { |
839 | 839 | $datetime_label = $datetime->get_dtt_display_name(true); |
840 | 840 | $datetime_label .= ! empty($datetime_label) |
841 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
841 | + ? ' ('.$datetime->get_dtt_display_name().')' |
|
842 | 842 | : $datetime->get_dtt_display_name(); |
843 | 843 | } |
844 | 844 | $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | ) |
853 | 853 | : ''; |
854 | 854 | $datetime_link = ! empty($datetime_link) |
855 | - ? '<a href="' . $datetime_link . '">' |
|
855 | + ? '<a href="'.$datetime_link.'">' |
|
856 | 856 | . '<span id="checkin-dtt">' |
857 | 857 | . $datetime_label |
858 | 858 | . '</span></a>' |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | ? $attendee->get_admin_details_link() |
865 | 865 | : ''; |
866 | 866 | $attendee_link = ! empty($attendee_link) |
867 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
868 | - . ' aria-label="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
867 | + ? '<a href="'.$attendee->get_admin_details_link().'"' |
|
868 | + . ' aria-label="'.esc_html__('Click for attendee details', 'event_espresso').'">' |
|
869 | 869 | . '<span id="checkin-attendee-name">' |
870 | 870 | . $attendee_name |
871 | 871 | . '</span></a>' |
@@ -874,25 +874,25 @@ discard block |
||
874 | 874 | ? $registration->event()->get_admin_details_link() |
875 | 875 | : ''; |
876 | 876 | $event_link = ! empty($event_link) |
877 | - ? '<a href="' . $event_link . '"' |
|
878 | - . ' aria-label="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
877 | + ? '<a href="'.$event_link.'"' |
|
878 | + . ' aria-label="'.esc_html__('Click here to edit event.', 'event_espresso').'">' |
|
879 | 879 | . '<span id="checkin-event-name">' |
880 | 880 | . $registration->event_name() |
881 | 881 | . '</span>' |
882 | 882 | . '</a>' |
883 | 883 | : ''; |
884 | 884 | $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
885 | - ? '<h2>' . sprintf( |
|
885 | + ? '<h2>'.sprintf( |
|
886 | 886 | esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
887 | 887 | $attendee_link, |
888 | 888 | $datetime_link, |
889 | 889 | $event_link |
890 | - ) . '</h2>' |
|
890 | + ).'</h2>' |
|
891 | 891 | : ''; |
892 | 892 | $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
893 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
893 | + ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : ''; |
|
894 | 894 | $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
895 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
895 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
896 | 896 | $this->display_admin_list_table_page_with_no_sidebar(); |
897 | 897 | } |
898 | 898 | |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | public function toggle_checkin_status() |
910 | 910 | { |
911 | 911 | // first make sure we have the necessary data |
912 | - if (! isset($this->_req_data['_regid'])) { |
|
912 | + if ( ! isset($this->_req_data['_regid'])) { |
|
913 | 913 | EE_Error::add_error( |
914 | 914 | esc_html__( |
915 | 915 | 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | // beautiful! Made it this far so let's get the status. |
932 | 932 | $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
933 | 933 | // setup new class to return via ajax |
934 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
934 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses(); |
|
935 | 935 | $this->_template_args['success'] = true; |
936 | 936 | $this->_return_json(); |
937 | 937 | } |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | ); |
958 | 958 | $new_status = false; |
959 | 959 | // bulk action check in toggle |
960 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
960 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
961 | 961 | // cycle thru checkboxes |
962 | 962 | while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
963 | 963 | $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
1028 | 1028 | ); |
1029 | 1029 | $errors = 0; |
1030 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1030 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1031 | 1031 | while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
1032 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1032 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
1033 | 1033 | $errors++; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
1076 | 1076 | '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
1077 | 1077 | ); |
1078 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
1079 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1078 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
1079 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1080 | 1080 | EE_Error::add_error( |
1081 | 1081 | esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
1082 | 1082 | __FILE__, |
@@ -1150,27 +1150,27 @@ discard block |
||
1150 | 1150 | 'desc' => $checkin_invalid->legendLabel(), |
1151 | 1151 | ), |
1152 | 1152 | 'approved_status' => array( |
1153 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved, |
|
1153 | + 'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_approved, |
|
1154 | 1154 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
1155 | 1155 | ), |
1156 | 1156 | 'cancelled_status' => array( |
1157 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled, |
|
1157 | + 'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_cancelled, |
|
1158 | 1158 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
1159 | 1159 | ), |
1160 | 1160 | 'declined_status' => array( |
1161 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined, |
|
1161 | + 'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_declined, |
|
1162 | 1162 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
1163 | 1163 | ), |
1164 | 1164 | 'not_approved' => array( |
1165 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved, |
|
1165 | + 'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_not_approved, |
|
1166 | 1166 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
1167 | 1167 | ), |
1168 | 1168 | 'pending_status' => array( |
1169 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment, |
|
1169 | + 'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_pending_payment, |
|
1170 | 1170 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
1171 | 1171 | ), |
1172 | 1172 | 'wait_list' => array( |
1173 | - 'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list, |
|
1173 | + 'class' => 'ee-status-legend ee-status-bg--'.EEM_Registration::status_id_wait_list, |
|
1174 | 1174 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
1175 | 1175 | ), |
1176 | 1176 | ); |
@@ -1199,21 +1199,21 @@ discard block |
||
1199 | 1199 | if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
1200 | 1200 | $active_status = $datetime->get_active_status(); |
1201 | 1201 | $datetime_status = |
1202 | - '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' . |
|
1203 | - esc_attr($active_status) . '">' |
|
1202 | + '<span class="ee-status ee-status-bg--'.esc_attr($active_status).' event-active-status-'. |
|
1203 | + esc_attr($active_status).'">' |
|
1204 | 1204 | . EEH_Template::pretty_status($active_status, false, 'sentence') |
1205 | 1205 | . '</span>'; |
1206 | 1206 | $this->_template_args['before_list_table'] .= '<span class="ee-event-datetime-name">'; |
1207 | 1207 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar-alt"></span>'; |
1208 | 1208 | $this->_template_args['before_list_table'] .= $datetime->name(); |
1209 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1209 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
1210 | 1210 | $this->_template_args['before_list_table'] .= $datetime_status; |
1211 | 1211 | $this->_template_args['before_list_table'] .= '</span>'; |
1212 | 1212 | } |
1213 | 1213 | $this->_template_args['before_list_table'] .= '</h2>'; |
1214 | 1214 | // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
1215 | 1215 | // column represents |
1216 | - if (! $datetime instanceof EE_Datetime) { |
|
1216 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1217 | 1217 | $this->_template_args['before_list_table'] .= '<h3 class="description">' |
1218 | 1218 | . esc_html__( |
1219 | 1219 | 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
@@ -15,226 +15,226 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_Registration_CheckIn_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - /** |
|
19 | - * EE_Registration_CheckIn_List_Table constructor. |
|
20 | - * |
|
21 | - * @param EE_Admin_Page $admin_page |
|
22 | - */ |
|
23 | - public function __construct($admin_page) |
|
24 | - { |
|
25 | - parent::__construct($admin_page); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @throws EE_Error |
|
31 | - */ |
|
32 | - protected function _setup_data() |
|
33 | - { |
|
34 | - $this->_data = $this->_get_checkins($this->_per_page); |
|
35 | - $this->_all_data_count = $this->_get_checkins($this->_per_page, true); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Sets up the properties for the list table. |
|
41 | - */ |
|
42 | - protected function _set_properties() |
|
43 | - { |
|
44 | - $this->_wp_list_args = array( |
|
45 | - 'singular' => esc_html__('check-in', 'event_espresso'), |
|
46 | - 'plural' => esc_html__('check-ins', 'event_espresso'), |
|
47 | - 'ajax' => true, |
|
48 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
49 | - ); |
|
50 | - |
|
51 | - $this->_columns = array( |
|
52 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
53 | - 'CHK_in' => esc_html__('Check-In', 'event_espresso'), |
|
54 | - 'CHK_timestamp' => esc_html__('Timestamp', 'event_espresso'), |
|
55 | - ); |
|
56 | - |
|
57 | - $this->_sortable_columns = array( |
|
58 | - 'CHK_timestamp' => array('CHK_timestamp' => true), |
|
59 | - ); |
|
60 | - |
|
61 | - $this->_primary_column = 'CHK_in'; |
|
62 | - |
|
63 | - $this->_hidden_columns = array(); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return array |
|
69 | - */ |
|
70 | - protected function _get_table_filters() |
|
71 | - { |
|
72 | - return []; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Returning an empty string to remove the search box for this view. |
|
78 | - * |
|
79 | - * @param string $text |
|
80 | - * @param string $input_id |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function search_box($text, $input_id) |
|
84 | - { |
|
85 | - return ''; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @throws EE_Error |
|
91 | - */ |
|
92 | - protected function _add_view_counts() |
|
93 | - { |
|
94 | - $this->_views['all']['count'] = $this->_get_checkins(null, true); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @param EE_Checkin $item |
|
100 | - * @return string |
|
101 | - * @throws EE_Error |
|
102 | - * @throws InvalidArgumentException |
|
103 | - * @throws ReflectionException |
|
104 | - * @throws InvalidDataTypeException |
|
105 | - * @throws InvalidInterfaceException |
|
106 | - */ |
|
107 | - public function column_cb($item) |
|
108 | - { |
|
109 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @param EE_Checkin $item |
|
115 | - * @return string |
|
116 | - * @throws EE_Error |
|
117 | - * @throws InvalidArgumentException |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - * @throws ReflectionException |
|
121 | - */ |
|
122 | - public function column_CHK_in(EE_Checkin $item) |
|
123 | - { |
|
124 | - $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
|
125 | - return ' |
|
18 | + /** |
|
19 | + * EE_Registration_CheckIn_List_Table constructor. |
|
20 | + * |
|
21 | + * @param EE_Admin_Page $admin_page |
|
22 | + */ |
|
23 | + public function __construct($admin_page) |
|
24 | + { |
|
25 | + parent::__construct($admin_page); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @throws EE_Error |
|
31 | + */ |
|
32 | + protected function _setup_data() |
|
33 | + { |
|
34 | + $this->_data = $this->_get_checkins($this->_per_page); |
|
35 | + $this->_all_data_count = $this->_get_checkins($this->_per_page, true); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Sets up the properties for the list table. |
|
41 | + */ |
|
42 | + protected function _set_properties() |
|
43 | + { |
|
44 | + $this->_wp_list_args = array( |
|
45 | + 'singular' => esc_html__('check-in', 'event_espresso'), |
|
46 | + 'plural' => esc_html__('check-ins', 'event_espresso'), |
|
47 | + 'ajax' => true, |
|
48 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
49 | + ); |
|
50 | + |
|
51 | + $this->_columns = array( |
|
52 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
53 | + 'CHK_in' => esc_html__('Check-In', 'event_espresso'), |
|
54 | + 'CHK_timestamp' => esc_html__('Timestamp', 'event_espresso'), |
|
55 | + ); |
|
56 | + |
|
57 | + $this->_sortable_columns = array( |
|
58 | + 'CHK_timestamp' => array('CHK_timestamp' => true), |
|
59 | + ); |
|
60 | + |
|
61 | + $this->_primary_column = 'CHK_in'; |
|
62 | + |
|
63 | + $this->_hidden_columns = array(); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return array |
|
69 | + */ |
|
70 | + protected function _get_table_filters() |
|
71 | + { |
|
72 | + return []; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Returning an empty string to remove the search box for this view. |
|
78 | + * |
|
79 | + * @param string $text |
|
80 | + * @param string $input_id |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function search_box($text, $input_id) |
|
84 | + { |
|
85 | + return ''; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @throws EE_Error |
|
91 | + */ |
|
92 | + protected function _add_view_counts() |
|
93 | + { |
|
94 | + $this->_views['all']['count'] = $this->_get_checkins(null, true); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @param EE_Checkin $item |
|
100 | + * @return string |
|
101 | + * @throws EE_Error |
|
102 | + * @throws InvalidArgumentException |
|
103 | + * @throws ReflectionException |
|
104 | + * @throws InvalidDataTypeException |
|
105 | + * @throws InvalidInterfaceException |
|
106 | + */ |
|
107 | + public function column_cb($item) |
|
108 | + { |
|
109 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID()); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @param EE_Checkin $item |
|
115 | + * @return string |
|
116 | + * @throws EE_Error |
|
117 | + * @throws InvalidArgumentException |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + * @throws ReflectionException |
|
121 | + */ |
|
122 | + public function column_CHK_in(EE_Checkin $item) |
|
123 | + { |
|
124 | + $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
|
125 | + return ' |
|
126 | 126 | <span class="ee-entity-id ' . $checkin_status_dashicon->cssClasses() . '"></span> |
127 | 127 | <span class="show-on-mobile-view-only">' . $item->get_datetime('CHK_timestamp') . '</span>'; |
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @param EE_Checkin $item |
|
133 | - * @return string |
|
134 | - * @throws EE_Error |
|
135 | - * @throws InvalidArgumentException |
|
136 | - * @throws InvalidDataTypeException |
|
137 | - * @throws InvalidInterfaceException |
|
138 | - * @throws ReflectionException |
|
139 | - */ |
|
140 | - public function column_CHK_timestamp(EE_Checkin $item) |
|
141 | - { |
|
142 | - $actions = array(); |
|
143 | - $delete_url = EE_Admin_Page::add_query_args_and_nonce( |
|
144 | - array( |
|
145 | - 'action' => 'delete_checkin_row', |
|
146 | - 'DTT_ID' => $this->_req_data['DTT_ID'], |
|
147 | - '_REG_ID' => $this->_req_data['_REG_ID'], |
|
148 | - 'CHK_ID' => $item->ID(), |
|
149 | - ) |
|
150 | - ); |
|
151 | - $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( |
|
152 | - 'ee_delete_checkins', |
|
153 | - 'espresso_registrations_delete_checkin_row' |
|
154 | - ) |
|
155 | - ? '<a href="' . $delete_url . '" aria-label="' |
|
156 | - . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
157 | - . esc_html__('Delete', 'event_espresso') . '</a>' |
|
158 | - : ''; |
|
159 | - |
|
160 | - return sprintf( |
|
161 | - '%1$s %2$s', |
|
162 | - $item->get_datetime('CHK_timestamp', '', 'H:i:s a'), |
|
163 | - $this->row_actions($actions) |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * This retrieves all the Check-ins for the given parameters. |
|
170 | - * experimenting with having the query for the table values within the list table. |
|
171 | - * |
|
172 | - * @param int $per_page How many to retrieve per page |
|
173 | - * @param bool $count Whether to return a count or not |
|
174 | - * @return EE_Checkin[]|int |
|
175 | - * @throws EE_Error |
|
176 | - * @throws InvalidArgumentException |
|
177 | - * @throws InvalidDataTypeException |
|
178 | - * @throws InvalidInterfaceException |
|
179 | - */ |
|
180 | - protected function _get_checkins($per_page = 10, $count = false) |
|
181 | - { |
|
182 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false; |
|
183 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false; |
|
184 | - |
|
185 | - // if user does not have the capability for the checkins for this registration then get out! |
|
186 | - if ( |
|
187 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
188 | - 'ee_read_checkin', |
|
189 | - 'espresso_registrations_registration_checkins', |
|
190 | - $REG_ID |
|
191 | - ) |
|
192 | - ) { |
|
193 | - return $count ? 0 : array(); |
|
194 | - } |
|
195 | - |
|
196 | - // if no reg id then get out cause need a reg id |
|
197 | - if (empty($REG_ID) || empty($DTT_ID)) { |
|
198 | - throw new EE_Error( |
|
199 | - esc_html__( |
|
200 | - 'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', |
|
201 | - 'event_espresso' |
|
202 | - ) |
|
203 | - ); |
|
204 | - } |
|
205 | - |
|
206 | - // set orderby |
|
207 | - // note that with this table we're only providing the option to orderby the timestamp value. |
|
208 | - $orderby = 'CHK_timestamp'; |
|
209 | - |
|
210 | - $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
211 | - |
|
212 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
213 | - ? $this->_req_data['paged'] |
|
214 | - : 1; |
|
215 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
216 | - ? $this->_req_data['perpage'] |
|
217 | - : $per_page; |
|
218 | - $limit = null; |
|
219 | - if (! $count) { |
|
220 | - $offset = ($current_page - 1) * $per_page; |
|
221 | - $limit = array($offset, $per_page); |
|
222 | - } |
|
223 | - |
|
224 | - $_where = array( |
|
225 | - 'REG_ID' => $REG_ID, |
|
226 | - 'DTT_ID' => $DTT_ID, |
|
227 | - ); |
|
228 | - |
|
229 | - $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
230 | - |
|
231 | - // if no per_page value then we just want to return a count of all Check-ins |
|
232 | - if ($count) { |
|
233 | - return EEM_Checkin::instance()->count(array($_where)); |
|
234 | - } |
|
235 | - |
|
236 | - return $count |
|
237 | - ? EEM_Checkin::instance()->count(array($_where)) |
|
238 | - : EEM_Checkin::instance()->get_all($query_params); |
|
239 | - } |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @param EE_Checkin $item |
|
133 | + * @return string |
|
134 | + * @throws EE_Error |
|
135 | + * @throws InvalidArgumentException |
|
136 | + * @throws InvalidDataTypeException |
|
137 | + * @throws InvalidInterfaceException |
|
138 | + * @throws ReflectionException |
|
139 | + */ |
|
140 | + public function column_CHK_timestamp(EE_Checkin $item) |
|
141 | + { |
|
142 | + $actions = array(); |
|
143 | + $delete_url = EE_Admin_Page::add_query_args_and_nonce( |
|
144 | + array( |
|
145 | + 'action' => 'delete_checkin_row', |
|
146 | + 'DTT_ID' => $this->_req_data['DTT_ID'], |
|
147 | + '_REG_ID' => $this->_req_data['_REG_ID'], |
|
148 | + 'CHK_ID' => $item->ID(), |
|
149 | + ) |
|
150 | + ); |
|
151 | + $actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( |
|
152 | + 'ee_delete_checkins', |
|
153 | + 'espresso_registrations_delete_checkin_row' |
|
154 | + ) |
|
155 | + ? '<a href="' . $delete_url . '" aria-label="' |
|
156 | + . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
157 | + . esc_html__('Delete', 'event_espresso') . '</a>' |
|
158 | + : ''; |
|
159 | + |
|
160 | + return sprintf( |
|
161 | + '%1$s %2$s', |
|
162 | + $item->get_datetime('CHK_timestamp', '', 'H:i:s a'), |
|
163 | + $this->row_actions($actions) |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * This retrieves all the Check-ins for the given parameters. |
|
170 | + * experimenting with having the query for the table values within the list table. |
|
171 | + * |
|
172 | + * @param int $per_page How many to retrieve per page |
|
173 | + * @param bool $count Whether to return a count or not |
|
174 | + * @return EE_Checkin[]|int |
|
175 | + * @throws EE_Error |
|
176 | + * @throws InvalidArgumentException |
|
177 | + * @throws InvalidDataTypeException |
|
178 | + * @throws InvalidInterfaceException |
|
179 | + */ |
|
180 | + protected function _get_checkins($per_page = 10, $count = false) |
|
181 | + { |
|
182 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : false; |
|
183 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : false; |
|
184 | + |
|
185 | + // if user does not have the capability for the checkins for this registration then get out! |
|
186 | + if ( |
|
187 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
188 | + 'ee_read_checkin', |
|
189 | + 'espresso_registrations_registration_checkins', |
|
190 | + $REG_ID |
|
191 | + ) |
|
192 | + ) { |
|
193 | + return $count ? 0 : array(); |
|
194 | + } |
|
195 | + |
|
196 | + // if no reg id then get out cause need a reg id |
|
197 | + if (empty($REG_ID) || empty($DTT_ID)) { |
|
198 | + throw new EE_Error( |
|
199 | + esc_html__( |
|
200 | + 'This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', |
|
201 | + 'event_espresso' |
|
202 | + ) |
|
203 | + ); |
|
204 | + } |
|
205 | + |
|
206 | + // set orderby |
|
207 | + // note that with this table we're only providing the option to orderby the timestamp value. |
|
208 | + $orderby = 'CHK_timestamp'; |
|
209 | + |
|
210 | + $order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
211 | + |
|
212 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
213 | + ? $this->_req_data['paged'] |
|
214 | + : 1; |
|
215 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
216 | + ? $this->_req_data['perpage'] |
|
217 | + : $per_page; |
|
218 | + $limit = null; |
|
219 | + if (! $count) { |
|
220 | + $offset = ($current_page - 1) * $per_page; |
|
221 | + $limit = array($offset, $per_page); |
|
222 | + } |
|
223 | + |
|
224 | + $_where = array( |
|
225 | + 'REG_ID' => $REG_ID, |
|
226 | + 'DTT_ID' => $DTT_ID, |
|
227 | + ); |
|
228 | + |
|
229 | + $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit); |
|
230 | + |
|
231 | + // if no per_page value then we just want to return a count of all Check-ins |
|
232 | + if ($count) { |
|
233 | + return EEM_Checkin::instance()->count(array($_where)); |
|
234 | + } |
|
235 | + |
|
236 | + return $count |
|
237 | + ? EEM_Checkin::instance()->count(array($_where)) |
|
238 | + : EEM_Checkin::instance()->get_all($query_params); |
|
239 | + } |
|
240 | 240 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | { |
124 | 124 | $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item); |
125 | 125 | return ' |
126 | - <span class="ee-entity-id ' . $checkin_status_dashicon->cssClasses() . '"></span> |
|
127 | - <span class="show-on-mobile-view-only">' . $item->get_datetime('CHK_timestamp') . '</span>'; |
|
126 | + <span class="ee-entity-id ' . $checkin_status_dashicon->cssClasses().'"></span> |
|
127 | + <span class="show-on-mobile-view-only">' . $item->get_datetime('CHK_timestamp').'</span>'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | 'ee_delete_checkins', |
153 | 153 | 'espresso_registrations_delete_checkin_row' |
154 | 154 | ) |
155 | - ? '<a href="' . $delete_url . '" aria-label="' |
|
156 | - . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' |
|
157 | - . esc_html__('Delete', 'event_espresso') . '</a>' |
|
155 | + ? '<a href="'.$delete_url.'" aria-label="' |
|
156 | + . esc_attr__('Click here to delete this check-in record', 'event_espresso').'">' |
|
157 | + . esc_html__('Delete', 'event_espresso').'</a>' |
|
158 | 158 | : ''; |
159 | 159 | |
160 | 160 | return sprintf( |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | ? $this->_req_data['perpage'] |
217 | 217 | : $per_page; |
218 | 218 | $limit = null; |
219 | - if (! $count) { |
|
219 | + if ( ! $count) { |
|
220 | 220 | $offset = ($current_page - 1) * $per_page; |
221 | 221 | $limit = array($offset, $per_page); |
222 | 222 | } |
@@ -12,116 +12,116 @@ |
||
12 | 12 | */ |
13 | 13 | class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table |
14 | 14 | { |
15 | - /** |
|
16 | - * @param EE_Registration $registration |
|
17 | - * @param bool $prep_content |
|
18 | - * @return string |
|
19 | - * @throws EE_Error |
|
20 | - * @throws ReflectionException |
|
21 | - */ |
|
22 | - public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string |
|
23 | - { |
|
24 | - $actions['check_in'] = ''; |
|
25 | - $date_linked = parent::column__REG_date($registration, false); |
|
26 | - $actions = array(); |
|
15 | + /** |
|
16 | + * @param EE_Registration $registration |
|
17 | + * @param bool $prep_content |
|
18 | + * @return string |
|
19 | + * @throws EE_Error |
|
20 | + * @throws ReflectionException |
|
21 | + */ |
|
22 | + public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string |
|
23 | + { |
|
24 | + $actions['check_in'] = ''; |
|
25 | + $date_linked = parent::column__REG_date($registration, false); |
|
26 | + $actions = array(); |
|
27 | 27 | |
28 | - if ( |
|
29 | - $this->caps_handler->userCanReadRegistrationCheckins() |
|
30 | - && $this->caps_handler->userCanReadRegistrationCheckin($registration) |
|
31 | - ) { |
|
32 | - $check_in_url = EE_Admin_Page::add_query_args_and_nonce( |
|
33 | - [ |
|
34 | - 'action' => 'event_registrations', |
|
35 | - 'event_id' => $registration->event_ID(), |
|
36 | - ], |
|
37 | - REG_ADMIN_URL |
|
38 | - ); |
|
28 | + if ( |
|
29 | + $this->caps_handler->userCanReadRegistrationCheckins() |
|
30 | + && $this->caps_handler->userCanReadRegistrationCheckin($registration) |
|
31 | + ) { |
|
32 | + $check_in_url = EE_Admin_Page::add_query_args_and_nonce( |
|
33 | + [ |
|
34 | + 'action' => 'event_registrations', |
|
35 | + 'event_id' => $registration->event_ID(), |
|
36 | + ], |
|
37 | + REG_ADMIN_URL |
|
38 | + ); |
|
39 | 39 | |
40 | - $actions['check_in'] = ' |
|
40 | + $actions['check_in'] = ' |
|
41 | 41 | <a class="ee-aria-tooltip ee-event-filter-link" |
42 | 42 | href="' . $check_in_url . '" |
43 | 43 | aria-label="' . esc_attr__( |
44 | - 'The Check-In List allows you to easily toggle check-in status for this event', |
|
45 | - 'event_espresso' |
|
46 | - ) . '" |
|
44 | + 'The Check-In List allows you to easily toggle check-in status for this event', |
|
45 | + 'event_espresso' |
|
46 | + ) . '" |
|
47 | 47 | > |
48 | 48 | <span class="dashicons dashicons-groups dashicons--small"></span>' |
49 | - . esc_html__('View Check-ins', 'event_espresso') . ' |
|
49 | + . esc_html__('View Check-ins', 'event_espresso') . ' |
|
50 | 50 | </a>'; |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - $content = sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
53 | + $content = sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
54 | 54 | |
55 | - return $prep_content ? $this->columnContent('_REG_date', $content) : $content; |
|
56 | - } |
|
55 | + return $prep_content ? $this->columnContent('_REG_date', $content) : $content; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @param EE_Registration $registration |
|
61 | - * @return string |
|
62 | - * @throws EE_Error |
|
63 | - * @throws InvalidArgumentException |
|
64 | - * @throws InvalidDataTypeException |
|
65 | - * @throws InvalidInterfaceException |
|
66 | - * @throws ReflectionException |
|
67 | - */ |
|
68 | - public function column_DTT_EVT_start(EE_Registration $registration): string |
|
69 | - { |
|
70 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
71 | - $ticket = $registration->ticket(); |
|
72 | - $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
73 | - $EVT_ID = $registration->event_ID(); |
|
74 | - $datetimes_for_display = array(); |
|
75 | - foreach ($datetimes as $datetime) { |
|
76 | - $datetime_string = '<div class="ee-reg-list-dates-list-date">'; |
|
77 | - if ($this->caps_handler->userCanReadRegistrationCheckin($registration)) { |
|
78 | - $checkins_url = EE_Admin_Page::add_query_args_and_nonce( |
|
79 | - [ |
|
80 | - 'action' => 'event_registrations', |
|
81 | - 'event_id' => $EVT_ID, |
|
82 | - 'DTT_ID' => $datetime->ID(), |
|
83 | - ], |
|
84 | - REG_ADMIN_URL |
|
85 | - ); |
|
86 | - // open "a" tag and "href" |
|
87 | - $datetime_string .= ' |
|
59 | + /** |
|
60 | + * @param EE_Registration $registration |
|
61 | + * @return string |
|
62 | + * @throws EE_Error |
|
63 | + * @throws InvalidArgumentException |
|
64 | + * @throws InvalidDataTypeException |
|
65 | + * @throws InvalidInterfaceException |
|
66 | + * @throws ReflectionException |
|
67 | + */ |
|
68 | + public function column_DTT_EVT_start(EE_Registration $registration): string |
|
69 | + { |
|
70 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
71 | + $ticket = $registration->ticket(); |
|
72 | + $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
73 | + $EVT_ID = $registration->event_ID(); |
|
74 | + $datetimes_for_display = array(); |
|
75 | + foreach ($datetimes as $datetime) { |
|
76 | + $datetime_string = '<div class="ee-reg-list-dates-list-date">'; |
|
77 | + if ($this->caps_handler->userCanReadRegistrationCheckin($registration)) { |
|
78 | + $checkins_url = EE_Admin_Page::add_query_args_and_nonce( |
|
79 | + [ |
|
80 | + 'action' => 'event_registrations', |
|
81 | + 'event_id' => $EVT_ID, |
|
82 | + 'DTT_ID' => $datetime->ID(), |
|
83 | + ], |
|
84 | + REG_ADMIN_URL |
|
85 | + ); |
|
86 | + // open "a" tag and "href" |
|
87 | + $datetime_string .= ' |
|
88 | 88 | <a class="ee-aria-tooltip ee-status-color--' . $datetime->get_active_status() . '" |
89 | 89 | href="' . $checkins_url . '" |
90 | 90 | aria-label="' . esc_attr__('View Checkins for this Event', 'event_espresso') . '" |
91 | 91 | > |
92 | 92 | ' . $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a') . ' |
93 | 93 | </a>'; |
94 | - } else { |
|
95 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
96 | - } |
|
97 | - // add a "View Registrations" link that filters list by event AND datetime |
|
98 | - $filter_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
99 | - ['event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()], |
|
100 | - REG_ADMIN_URL |
|
101 | - ); |
|
102 | - $datetime_string .= $this->row_actions( |
|
103 | - array( |
|
104 | - 'event_datetime_filter' => ' |
|
94 | + } else { |
|
95 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
96 | + } |
|
97 | + // add a "View Registrations" link that filters list by event AND datetime |
|
98 | + $filter_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
99 | + ['event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()], |
|
100 | + REG_ADMIN_URL |
|
101 | + ); |
|
102 | + $datetime_string .= $this->row_actions( |
|
103 | + array( |
|
104 | + 'event_datetime_filter' => ' |
|
105 | 105 | <a class="ee-aria-tooltip ee-event-filter-link" |
106 | 106 | href="' . $filter_list_url . '" |
107 | 107 | aria-label="' . sprintf( |
108 | - esc_attr__( |
|
109 | - 'Filter this list to only show registrations for this datetime %s', |
|
110 | - 'event_espresso' |
|
111 | - ), |
|
112 | - $datetime->name() |
|
113 | - ) . '"> |
|
108 | + esc_attr__( |
|
109 | + 'Filter this list to only show registrations for this datetime %s', |
|
110 | + 'event_espresso' |
|
111 | + ), |
|
112 | + $datetime->name() |
|
113 | + ) . '"> |
|
114 | 114 | <span class="dashicons dashicons-groups dashicons--small"></span> |
115 | 115 | </a>', |
116 | - ) |
|
117 | - ); |
|
118 | - // ' . esc_html__('View Registrations', 'event_espresso') . ' |
|
119 | - $datetime_string .= '</div>'; |
|
120 | - $datetimes_for_display[] = $datetime_string; |
|
121 | - } |
|
122 | - return $this->columnContent( |
|
123 | - 'DTT_EVT_start', |
|
124 | - $this->generateDisplayForDateTimes($datetimes_for_display) |
|
125 | - ); |
|
126 | - } |
|
116 | + ) |
|
117 | + ); |
|
118 | + // ' . esc_html__('View Registrations', 'event_espresso') . ' |
|
119 | + $datetime_string .= '</div>'; |
|
120 | + $datetimes_for_display[] = $datetime_string; |
|
121 | + } |
|
122 | + return $this->columnContent( |
|
123 | + 'DTT_EVT_start', |
|
124 | + $this->generateDisplayForDateTimes($datetimes_for_display) |
|
125 | + ); |
|
126 | + } |
|
127 | 127 | } |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | |
40 | 40 | $actions['check_in'] = ' |
41 | 41 | <a class="ee-aria-tooltip ee-event-filter-link" |
42 | - href="' . $check_in_url . '" |
|
42 | + href="' . $check_in_url.'" |
|
43 | 43 | aria-label="' . esc_attr__( |
44 | 44 | 'The Check-In List allows you to easily toggle check-in status for this event', |
45 | 45 | 'event_espresso' |
46 | - ) . '" |
|
46 | + ).'" |
|
47 | 47 | > |
48 | 48 | <span class="dashicons dashicons-groups dashicons--small"></span>' |
49 | - . esc_html__('View Check-ins', 'event_espresso') . ' |
|
49 | + . esc_html__('View Check-ins', 'event_espresso').' |
|
50 | 50 | </a>'; |
51 | 51 | } |
52 | 52 | |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | ); |
86 | 86 | // open "a" tag and "href" |
87 | 87 | $datetime_string .= ' |
88 | - <a class="ee-aria-tooltip ee-status-color--' . $datetime->get_active_status() . '" |
|
89 | - href="' . $checkins_url . '" |
|
90 | - aria-label="' . esc_attr__('View Checkins for this Event', 'event_espresso') . '" |
|
88 | + <a class="ee-aria-tooltip ee-status-color--' . $datetime->get_active_status().'" |
|
89 | + href="' . $checkins_url.'" |
|
90 | + aria-label="' . esc_attr__('View Checkins for this Event', 'event_espresso').'" |
|
91 | 91 | > |
92 | - ' . $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a') . ' |
|
92 | + ' . $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a').' |
|
93 | 93 | </a>'; |
94 | 94 | } else { |
95 | 95 | $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | array( |
104 | 104 | 'event_datetime_filter' => ' |
105 | 105 | <a class="ee-aria-tooltip ee-event-filter-link" |
106 | - href="' . $filter_list_url . '" |
|
106 | + href="' . $filter_list_url.'" |
|
107 | 107 | aria-label="' . sprintf( |
108 | 108 | esc_attr__( |
109 | 109 | 'Filter this list to only show registrations for this datetime %s', |
110 | 110 | 'event_espresso' |
111 | 111 | ), |
112 | 112 | $datetime->name() |
113 | - ) . '"> |
|
113 | + ).'"> |
|
114 | 114 | <span class="dashicons dashicons-groups dashicons--small"></span> |
115 | 115 | </a>', |
116 | 116 | ) |
@@ -16,692 +16,692 @@ |
||
16 | 16 | */ |
17 | 17 | class EE_Event_Registrations_List_Table extends EE_Admin_List_Table |
18 | 18 | { |
19 | - /** |
|
20 | - * @var RequestInterface |
|
21 | - */ |
|
22 | - protected $request; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var Extend_Registrations_Admin_Page |
|
26 | - */ |
|
27 | - protected $_admin_page; |
|
28 | - |
|
29 | - /** |
|
30 | - * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
31 | - * |
|
32 | - * @var DatetimesForEventCheckIn |
|
33 | - */ |
|
34 | - protected $datetimes_for_event; |
|
35 | - |
|
36 | - /** |
|
37 | - * The DTT_ID if the current view has a specified datetime. |
|
38 | - * |
|
39 | - * @var int |
|
40 | - */ |
|
41 | - protected $datetime_id = 0; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var EE_Datetime |
|
45 | - */ |
|
46 | - protected $datetime; |
|
47 | - |
|
48 | - /** |
|
49 | - * The event ID if one is specified in the request |
|
50 | - * |
|
51 | - * @var int |
|
52 | - */ |
|
53 | - protected $event_id = 0; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EE_Event |
|
57 | - */ |
|
58 | - protected $event; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var DatetimesForEventCheckIn |
|
62 | - */ |
|
63 | - protected $datetimes_for_current_row; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var bool |
|
67 | - */ |
|
68 | - protected $hide_expired; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var bool |
|
72 | - */ |
|
73 | - protected $hide_upcoming; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var array |
|
77 | - * @since 4.10.31.p |
|
78 | - */ |
|
79 | - protected $_status; |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * EE_Event_Registrations_List_Table constructor. |
|
84 | - * |
|
85 | - * @param Registrations_Admin_Page $admin_page |
|
86 | - * @throws EE_Error |
|
87 | - * @throws ReflectionException |
|
88 | - */ |
|
89 | - public function __construct($admin_page) |
|
90 | - { |
|
91 | - $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
92 | - $this->resolveRequestVars(); |
|
93 | - parent::__construct($admin_page); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @throws EE_Error |
|
99 | - * @throws ReflectionException |
|
100 | - * @since $VID:$ |
|
101 | - */ |
|
102 | - private function resolveRequestVars() |
|
103 | - { |
|
104 | - $this->event_id = $this->request->getRequestParam('event_id', 0, 'int'); |
|
105 | - $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id); |
|
106 | - // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
107 | - $datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
108 | - $this->datetime_id = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
109 | - // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
110 | - $this->datetime_id = $this->request->getRequestParam( |
|
111 | - 'DTT_ID', |
|
112 | - $this->datetime_id, |
|
113 | - 'int' |
|
114 | - ); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @throws EE_Error |
|
120 | - */ |
|
121 | - protected function _setup_data() |
|
122 | - { |
|
123 | - $this->_data = $this->_view !== 'trash' |
|
124 | - ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
125 | - : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
126 | - |
|
127 | - $this->_all_data_count = $this->_view !== 'trash' |
|
128 | - ? $this->_admin_page->get_event_attendees($this->_per_page, true) |
|
129 | - : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @throws ReflectionException |
|
135 | - * @throws EE_Error |
|
136 | - */ |
|
137 | - protected function _set_properties() |
|
138 | - { |
|
139 | - $return_url = $this->getReturnUrl(); |
|
140 | - |
|
141 | - $this->_wp_list_args = [ |
|
142 | - 'singular' => esc_html__('registrant', 'event_espresso'), |
|
143 | - 'plural' => esc_html__('registrants', 'event_espresso'), |
|
144 | - 'ajax' => true, |
|
145 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
146 | - ]; |
|
147 | - $columns = []; |
|
148 | - |
|
149 | - $this->_columns = [ |
|
150 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
151 | - 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
152 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
153 | - 'Event' => esc_html__('Event', 'event_espresso'), |
|
154 | - 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
155 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
156 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
157 | - 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
158 | - ]; |
|
159 | - // Add/remove columns when an event has been selected |
|
160 | - if (! empty($this->event_id)) { |
|
161 | - // Render a checkbox column |
|
162 | - $columns['cb'] = '<input type="checkbox" />'; |
|
163 | - $this->_has_checkbox_column = true; |
|
164 | - // Remove the 'Event' column |
|
165 | - unset($this->_columns['Event']); |
|
166 | - $this->setBottomButtons(); |
|
167 | - } |
|
168 | - $this->_columns = array_merge($columns, $this->_columns); |
|
169 | - $this->_primary_column = '_REG_att_checked_in'; |
|
170 | - |
|
171 | - $csv_report = RegistrationsCsvReportParams::getRequestParams( |
|
172 | - $return_url, |
|
173 | - $this->_req_data, |
|
174 | - $this->event_id, |
|
175 | - $this->datetime_id |
|
176 | - ); |
|
177 | - if (! empty($csv_report)) { |
|
178 | - $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
|
179 | - } |
|
180 | - |
|
181 | - $this->_sortable_columns = [ |
|
182 | - /** |
|
183 | - * Allows users to change the default sort if they wish. |
|
184 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
185 | - * |
|
186 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
187 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
188 | - * for a specific list table you can use the provided reference to this object instance. |
|
189 | - */ |
|
190 | - 'ATT_name' => [ |
|
191 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
192 | - true, |
|
193 | - $this, |
|
194 | - ] |
|
195 | - ? ['ATT_lname' => true] |
|
196 | - : ['ATT_fname' => true], |
|
197 | - 'Event' => ['Event.EVT_name' => false], |
|
198 | - ]; |
|
199 | - $this->_hidden_columns = []; |
|
200 | - $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
201 | - if ($this->event instanceof EE_Event) { |
|
202 | - $this->datetimes_for_event = $this->event->datetimes_ordered(); |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * @param EE_Registration $item |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - protected function _get_row_class($item): string |
|
212 | - { |
|
213 | - $class = parent::_get_row_class($item); |
|
214 | - if ($this->_has_checkbox_column) { |
|
215 | - $class .= ' has-checkbox-column'; |
|
216 | - } |
|
217 | - return $class; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @return array |
|
223 | - * @throws EE_Error |
|
224 | - * @throws ReflectionException |
|
225 | - */ |
|
226 | - protected function _get_table_filters(): array |
|
227 | - { |
|
228 | - $filters = []; |
|
229 | - $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool'); |
|
230 | - $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool'); |
|
231 | - $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
232 | - $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
233 | - // get datetimes for ALL active events (note possible capability restrictions) |
|
234 | - $events = $this->datetimes_for_event->getAllDatetimesForAllEvents(); |
|
235 | - $event_options[] = [ |
|
236 | - 'id' => 0, |
|
237 | - 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
238 | - ]; |
|
239 | - foreach ($events as $event) { |
|
240 | - // any registrations for this event? |
|
241 | - if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
242 | - continue; |
|
243 | - } |
|
244 | - $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
245 | - $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
246 | - |
|
247 | - $event_options[] = [ |
|
248 | - 'id' => $event->ID(), |
|
249 | - 'text' => apply_filters( |
|
250 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
251 | - $event->name(), |
|
252 | - $event |
|
253 | - ), |
|
254 | - 'class' => $expired_class . $upcoming_class, |
|
255 | - ]; |
|
256 | - if ($event->ID() === $this->event_id) { |
|
257 | - $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
258 | - $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
259 | - $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
260 | - $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
261 | - } |
|
262 | - } |
|
263 | - |
|
264 | - $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
265 | - $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
266 | - |
|
267 | - $filters[] = ' |
|
19 | + /** |
|
20 | + * @var RequestInterface |
|
21 | + */ |
|
22 | + protected $request; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var Extend_Registrations_Admin_Page |
|
26 | + */ |
|
27 | + protected $_admin_page; |
|
28 | + |
|
29 | + /** |
|
30 | + * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
31 | + * |
|
32 | + * @var DatetimesForEventCheckIn |
|
33 | + */ |
|
34 | + protected $datetimes_for_event; |
|
35 | + |
|
36 | + /** |
|
37 | + * The DTT_ID if the current view has a specified datetime. |
|
38 | + * |
|
39 | + * @var int |
|
40 | + */ |
|
41 | + protected $datetime_id = 0; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var EE_Datetime |
|
45 | + */ |
|
46 | + protected $datetime; |
|
47 | + |
|
48 | + /** |
|
49 | + * The event ID if one is specified in the request |
|
50 | + * |
|
51 | + * @var int |
|
52 | + */ |
|
53 | + protected $event_id = 0; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EE_Event |
|
57 | + */ |
|
58 | + protected $event; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var DatetimesForEventCheckIn |
|
62 | + */ |
|
63 | + protected $datetimes_for_current_row; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var bool |
|
67 | + */ |
|
68 | + protected $hide_expired; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var bool |
|
72 | + */ |
|
73 | + protected $hide_upcoming; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var array |
|
77 | + * @since 4.10.31.p |
|
78 | + */ |
|
79 | + protected $_status; |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * EE_Event_Registrations_List_Table constructor. |
|
84 | + * |
|
85 | + * @param Registrations_Admin_Page $admin_page |
|
86 | + * @throws EE_Error |
|
87 | + * @throws ReflectionException |
|
88 | + */ |
|
89 | + public function __construct($admin_page) |
|
90 | + { |
|
91 | + $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
92 | + $this->resolveRequestVars(); |
|
93 | + parent::__construct($admin_page); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @throws EE_Error |
|
99 | + * @throws ReflectionException |
|
100 | + * @since $VID:$ |
|
101 | + */ |
|
102 | + private function resolveRequestVars() |
|
103 | + { |
|
104 | + $this->event_id = $this->request->getRequestParam('event_id', 0, 'int'); |
|
105 | + $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id); |
|
106 | + // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
107 | + $datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
108 | + $this->datetime_id = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
109 | + // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
110 | + $this->datetime_id = $this->request->getRequestParam( |
|
111 | + 'DTT_ID', |
|
112 | + $this->datetime_id, |
|
113 | + 'int' |
|
114 | + ); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @throws EE_Error |
|
120 | + */ |
|
121 | + protected function _setup_data() |
|
122 | + { |
|
123 | + $this->_data = $this->_view !== 'trash' |
|
124 | + ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
125 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
126 | + |
|
127 | + $this->_all_data_count = $this->_view !== 'trash' |
|
128 | + ? $this->_admin_page->get_event_attendees($this->_per_page, true) |
|
129 | + : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @throws ReflectionException |
|
135 | + * @throws EE_Error |
|
136 | + */ |
|
137 | + protected function _set_properties() |
|
138 | + { |
|
139 | + $return_url = $this->getReturnUrl(); |
|
140 | + |
|
141 | + $this->_wp_list_args = [ |
|
142 | + 'singular' => esc_html__('registrant', 'event_espresso'), |
|
143 | + 'plural' => esc_html__('registrants', 'event_espresso'), |
|
144 | + 'ajax' => true, |
|
145 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
146 | + ]; |
|
147 | + $columns = []; |
|
148 | + |
|
149 | + $this->_columns = [ |
|
150 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
151 | + 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
152 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
153 | + 'Event' => esc_html__('Event', 'event_espresso'), |
|
154 | + 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
155 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
156 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
157 | + 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
158 | + ]; |
|
159 | + // Add/remove columns when an event has been selected |
|
160 | + if (! empty($this->event_id)) { |
|
161 | + // Render a checkbox column |
|
162 | + $columns['cb'] = '<input type="checkbox" />'; |
|
163 | + $this->_has_checkbox_column = true; |
|
164 | + // Remove the 'Event' column |
|
165 | + unset($this->_columns['Event']); |
|
166 | + $this->setBottomButtons(); |
|
167 | + } |
|
168 | + $this->_columns = array_merge($columns, $this->_columns); |
|
169 | + $this->_primary_column = '_REG_att_checked_in'; |
|
170 | + |
|
171 | + $csv_report = RegistrationsCsvReportParams::getRequestParams( |
|
172 | + $return_url, |
|
173 | + $this->_req_data, |
|
174 | + $this->event_id, |
|
175 | + $this->datetime_id |
|
176 | + ); |
|
177 | + if (! empty($csv_report)) { |
|
178 | + $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
|
179 | + } |
|
180 | + |
|
181 | + $this->_sortable_columns = [ |
|
182 | + /** |
|
183 | + * Allows users to change the default sort if they wish. |
|
184 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
185 | + * |
|
186 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
187 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
188 | + * for a specific list table you can use the provided reference to this object instance. |
|
189 | + */ |
|
190 | + 'ATT_name' => [ |
|
191 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
192 | + true, |
|
193 | + $this, |
|
194 | + ] |
|
195 | + ? ['ATT_lname' => true] |
|
196 | + : ['ATT_fname' => true], |
|
197 | + 'Event' => ['Event.EVT_name' => false], |
|
198 | + ]; |
|
199 | + $this->_hidden_columns = []; |
|
200 | + $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
201 | + if ($this->event instanceof EE_Event) { |
|
202 | + $this->datetimes_for_event = $this->event->datetimes_ordered(); |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * @param EE_Registration $item |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + protected function _get_row_class($item): string |
|
212 | + { |
|
213 | + $class = parent::_get_row_class($item); |
|
214 | + if ($this->_has_checkbox_column) { |
|
215 | + $class .= ' has-checkbox-column'; |
|
216 | + } |
|
217 | + return $class; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @return array |
|
223 | + * @throws EE_Error |
|
224 | + * @throws ReflectionException |
|
225 | + */ |
|
226 | + protected function _get_table_filters(): array |
|
227 | + { |
|
228 | + $filters = []; |
|
229 | + $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool'); |
|
230 | + $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool'); |
|
231 | + $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
232 | + $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
233 | + // get datetimes for ALL active events (note possible capability restrictions) |
|
234 | + $events = $this->datetimes_for_event->getAllDatetimesForAllEvents(); |
|
235 | + $event_options[] = [ |
|
236 | + 'id' => 0, |
|
237 | + 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
238 | + ]; |
|
239 | + foreach ($events as $event) { |
|
240 | + // any registrations for this event? |
|
241 | + if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
242 | + continue; |
|
243 | + } |
|
244 | + $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
245 | + $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
246 | + |
|
247 | + $event_options[] = [ |
|
248 | + 'id' => $event->ID(), |
|
249 | + 'text' => apply_filters( |
|
250 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
251 | + $event->name(), |
|
252 | + $event |
|
253 | + ), |
|
254 | + 'class' => $expired_class . $upcoming_class, |
|
255 | + ]; |
|
256 | + if ($event->ID() === $this->event_id) { |
|
257 | + $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
258 | + $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
259 | + $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
260 | + $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
261 | + } |
|
262 | + } |
|
263 | + |
|
264 | + $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
265 | + $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
266 | + |
|
267 | + $filters[] = ' |
|
268 | 268 | <div class="ee-event-filter__wrapper"> |
269 | 269 | <label class="ee-event-filter-main-label">' . esc_html__('Check-in Status for', 'event_espresso') . '</label> |
270 | 270 | <div class="ee-event-filter"> |
271 | 271 | <span class="ee-event-selector"> |
272 | 272 | <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label> |
273 | 273 | ' . EEH_Form_Fields::select_input( |
274 | - 'event_id', |
|
275 | - $event_options, |
|
276 | - $this->event_id, |
|
277 | - '', |
|
278 | - $select_class |
|
279 | - ) . ' |
|
274 | + 'event_id', |
|
275 | + $event_options, |
|
276 | + $this->event_id, |
|
277 | + '', |
|
278 | + $select_class |
|
279 | + ) . ' |
|
280 | 280 | </span>'; |
281 | - // DTT datetimes filter |
|
282 | - $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent($hide_upcoming_checked === 'checked'); |
|
283 | - if (count($datetimes_for_event) > 1) { |
|
284 | - $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
285 | - foreach ($datetimes_for_event as $datetime) { |
|
286 | - if ($datetime instanceof EE_Datetime) { |
|
287 | - $datetime_string = $datetime->name(); |
|
288 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
289 | - $datetime_string .= $datetime->date_and_time_range(); |
|
290 | - $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
291 | - $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
292 | - $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
293 | - // now put it all together |
|
294 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
295 | - } |
|
296 | - } |
|
297 | - $filters[] = ' |
|
281 | + // DTT datetimes filter |
|
282 | + $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent($hide_upcoming_checked === 'checked'); |
|
283 | + if (count($datetimes_for_event) > 1) { |
|
284 | + $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
285 | + foreach ($datetimes_for_event as $datetime) { |
|
286 | + if ($datetime instanceof EE_Datetime) { |
|
287 | + $datetime_string = $datetime->name(); |
|
288 | + $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
289 | + $datetime_string .= $datetime->date_and_time_range(); |
|
290 | + $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
291 | + $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
292 | + $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
293 | + // now put it all together |
|
294 | + $datetimes[ $datetime->ID() ] = $datetime_string; |
|
295 | + } |
|
296 | + } |
|
297 | + $filters[] = ' |
|
298 | 298 | <span class="ee-datetime-selector"> |
299 | 299 | <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
300 | 300 | ' . EEH_Form_Fields::select_input( |
301 | - 'DTT_ID', |
|
302 | - $datetimes, |
|
303 | - $this->datetime_id |
|
304 | - ) . ' |
|
301 | + 'DTT_ID', |
|
302 | + $datetimes, |
|
303 | + $this->datetime_id |
|
304 | + ) . ' |
|
305 | 305 | </span>'; |
306 | - } |
|
307 | - $filters[] = ' |
|
306 | + } |
|
307 | + $filters[] = ' |
|
308 | 308 | <span class="ee-hide-upcoming-check"> |
309 | 309 | <label for="js-ee-hide-upcoming-events"> |
310 | 310 | <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" ' |
311 | - . $hide_upcoming_checked |
|
312 | - . '> |
|
311 | + . $hide_upcoming_checked |
|
312 | + . '> |
|
313 | 313 | ' |
314 | - . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
315 | - . ' |
|
314 | + . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
315 | + . ' |
|
316 | 316 | </label> |
317 | 317 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" aria-label="' |
318 | - . esc_html__( |
|
319 | - 'Will not display events with start dates in the future (ie: have not yet begun)', |
|
320 | - 'event_espresso' |
|
321 | - ) |
|
322 | - . '"></span> |
|
318 | + . esc_html__( |
|
319 | + 'Will not display events with start dates in the future (ie: have not yet begun)', |
|
320 | + 'event_espresso' |
|
321 | + ) |
|
322 | + . '"></span> |
|
323 | 323 | </span> |
324 | 324 | <span class="ee-hide-expired-check"> |
325 | 325 | <label for="js-ee-hide-expired-events"> |
326 | 326 | <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" ' |
327 | - . $hide_expired_checked |
|
328 | - . '> |
|
327 | + . $hide_expired_checked |
|
328 | + . '> |
|
329 | 329 | ' |
330 | - . esc_html__('Hide Expired Events', 'event_espresso') |
|
331 | - . ' |
|
330 | + . esc_html__('Hide Expired Events', 'event_espresso') |
|
331 | + . ' |
|
332 | 332 | </label> |
333 | 333 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" aria-label="' |
334 | - . esc_html__( |
|
335 | - 'Will not display events with end dates in the past (ie: have already finished)', |
|
336 | - 'event_espresso' |
|
337 | - ) |
|
338 | - . '"></span> |
|
334 | + . esc_html__( |
|
335 | + 'Will not display events with end dates in the past (ie: have already finished)', |
|
336 | + 'event_espresso' |
|
337 | + ) |
|
338 | + . '"></span> |
|
339 | 339 | </span> |
340 | 340 | </div> |
341 | 341 | </div>'; |
342 | - return $filters; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @throws EE_Error |
|
348 | - * @throws ReflectionException |
|
349 | - */ |
|
350 | - protected function _add_view_counts() |
|
351 | - { |
|
352 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * @return int |
|
358 | - * @throws EE_Error |
|
359 | - * @throws ReflectionException |
|
360 | - */ |
|
361 | - protected function _get_total_event_attendees(): int |
|
362 | - { |
|
363 | - $query_params = []; |
|
364 | - if ($this->event_id) { |
|
365 | - $query_params[0]['EVT_ID'] = $this->event_id; |
|
366 | - } |
|
367 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
368 | - if ($this->datetime_id) { |
|
369 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
|
370 | - } |
|
371 | - $status_ids_array = apply_filters( |
|
372 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
373 | - [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
|
374 | - ); |
|
375 | - $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
376 | - return EEM_Registration::instance()->count($query_params); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @param EE_Registration $item |
|
382 | - * @return string |
|
383 | - * @throws EE_Error |
|
384 | - * @throws ReflectionException |
|
385 | - */ |
|
386 | - public function column_cb($item): string |
|
387 | - { |
|
388 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - /** |
|
393 | - * column_REG_att_checked_in |
|
394 | - * |
|
395 | - * @param EE_Registration $registration |
|
396 | - * @return string |
|
397 | - * @throws EE_Error |
|
398 | - * @throws InvalidArgumentException |
|
399 | - * @throws InvalidDataTypeException |
|
400 | - * @throws InvalidInterfaceException |
|
401 | - * @throws ReflectionException |
|
402 | - */ |
|
403 | - public function column__REG_att_checked_in(EE_Registration $registration): string |
|
404 | - { |
|
405 | - // we need a local variable for the datetime for each row |
|
406 | - // (so that we don't pollute state for the entire table) |
|
407 | - // so let's try to get it from the registration's event |
|
408 | - $DTT_ID = $this->datetime_id; |
|
409 | - if (! $DTT_ID) { |
|
410 | - $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
|
411 | - if (count($reg_ticket_datetimes) === 1) { |
|
412 | - $reg_ticket_datetime = reset($reg_ticket_datetimes); |
|
413 | - $DTT_ID = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0; |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - if (! $DTT_ID) { |
|
418 | - $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
|
419 | - $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
|
420 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
421 | - } |
|
422 | - |
|
423 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
424 | - $registration, |
|
425 | - $DTT_ID |
|
426 | - ); |
|
427 | - |
|
428 | - $aria_label = $checkin_status_dashicon->ariaLabel(); |
|
429 | - $dashicon_class = $checkin_status_dashicon->cssClasses(); |
|
430 | - $attributes = ' onClick="return false"'; |
|
431 | - $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box'; |
|
432 | - |
|
433 | - if ( |
|
434 | - $DTT_ID |
|
435 | - && EE_Registry::instance()->CAP->current_user_can( |
|
436 | - 'ee_edit_checkin', |
|
437 | - 'espresso_registrations_toggle_checkin_status', |
|
438 | - $registration->ID() |
|
439 | - ) |
|
440 | - ) { |
|
441 | - // overwrite the disabled attribute with data attributes for performing checkin |
|
442 | - $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
443 | - $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
444 | - $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
445 | - $button_class .= ' clickable trigger-checkin'; |
|
446 | - } |
|
447 | - |
|
448 | - $content = ' |
|
342 | + return $filters; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @throws EE_Error |
|
348 | + * @throws ReflectionException |
|
349 | + */ |
|
350 | + protected function _add_view_counts() |
|
351 | + { |
|
352 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * @return int |
|
358 | + * @throws EE_Error |
|
359 | + * @throws ReflectionException |
|
360 | + */ |
|
361 | + protected function _get_total_event_attendees(): int |
|
362 | + { |
|
363 | + $query_params = []; |
|
364 | + if ($this->event_id) { |
|
365 | + $query_params[0]['EVT_ID'] = $this->event_id; |
|
366 | + } |
|
367 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
368 | + if ($this->datetime_id) { |
|
369 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
|
370 | + } |
|
371 | + $status_ids_array = apply_filters( |
|
372 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
373 | + [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
|
374 | + ); |
|
375 | + $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
376 | + return EEM_Registration::instance()->count($query_params); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @param EE_Registration $item |
|
382 | + * @return string |
|
383 | + * @throws EE_Error |
|
384 | + * @throws ReflectionException |
|
385 | + */ |
|
386 | + public function column_cb($item): string |
|
387 | + { |
|
388 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + /** |
|
393 | + * column_REG_att_checked_in |
|
394 | + * |
|
395 | + * @param EE_Registration $registration |
|
396 | + * @return string |
|
397 | + * @throws EE_Error |
|
398 | + * @throws InvalidArgumentException |
|
399 | + * @throws InvalidDataTypeException |
|
400 | + * @throws InvalidInterfaceException |
|
401 | + * @throws ReflectionException |
|
402 | + */ |
|
403 | + public function column__REG_att_checked_in(EE_Registration $registration): string |
|
404 | + { |
|
405 | + // we need a local variable for the datetime for each row |
|
406 | + // (so that we don't pollute state for the entire table) |
|
407 | + // so let's try to get it from the registration's event |
|
408 | + $DTT_ID = $this->datetime_id; |
|
409 | + if (! $DTT_ID) { |
|
410 | + $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
|
411 | + if (count($reg_ticket_datetimes) === 1) { |
|
412 | + $reg_ticket_datetime = reset($reg_ticket_datetimes); |
|
413 | + $DTT_ID = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0; |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + if (! $DTT_ID) { |
|
418 | + $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
|
419 | + $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
|
420 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
421 | + } |
|
422 | + |
|
423 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
424 | + $registration, |
|
425 | + $DTT_ID |
|
426 | + ); |
|
427 | + |
|
428 | + $aria_label = $checkin_status_dashicon->ariaLabel(); |
|
429 | + $dashicon_class = $checkin_status_dashicon->cssClasses(); |
|
430 | + $attributes = ' onClick="return false"'; |
|
431 | + $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box'; |
|
432 | + |
|
433 | + if ( |
|
434 | + $DTT_ID |
|
435 | + && EE_Registry::instance()->CAP->current_user_can( |
|
436 | + 'ee_edit_checkin', |
|
437 | + 'espresso_registrations_toggle_checkin_status', |
|
438 | + $registration->ID() |
|
439 | + ) |
|
440 | + ) { |
|
441 | + // overwrite the disabled attribute with data attributes for performing checkin |
|
442 | + $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
443 | + $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
444 | + $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
445 | + $button_class .= ' clickable trigger-checkin'; |
|
446 | + } |
|
447 | + |
|
448 | + $content = ' |
|
449 | 449 | <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '> |
450 | 450 | <span class="' . $dashicon_class . '" ></span> |
451 | 451 | </button> |
452 | 452 | <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>'; |
453 | - return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * @param EE_Registration $registration |
|
459 | - * @return string |
|
460 | - * @throws EE_Error |
|
461 | - * @throws ReflectionException |
|
462 | - */ |
|
463 | - public function column_ATT_name(EE_Registration $registration): string |
|
464 | - { |
|
465 | - $attendee = $registration->attendee(); |
|
466 | - if (! $attendee instanceof EE_Attendee) { |
|
467 | - return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
468 | - } |
|
469 | - // edit attendee link |
|
470 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
471 | - ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
472 | - REG_ADMIN_URL |
|
473 | - ); |
|
474 | - $name_link = ' |
|
453 | + return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * @param EE_Registration $registration |
|
459 | + * @return string |
|
460 | + * @throws EE_Error |
|
461 | + * @throws ReflectionException |
|
462 | + */ |
|
463 | + public function column_ATT_name(EE_Registration $registration): string |
|
464 | + { |
|
465 | + $attendee = $registration->attendee(); |
|
466 | + if (! $attendee instanceof EE_Attendee) { |
|
467 | + return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
468 | + } |
|
469 | + // edit attendee link |
|
470 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
471 | + ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
472 | + REG_ADMIN_URL |
|
473 | + ); |
|
474 | + $name_link = ' |
|
475 | 475 | <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
476 | 476 | aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
477 | 477 | </span>'; |
478 | - $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
479 | - 'ee_edit_contacts', |
|
480 | - 'espresso_registrations_edit_attendee' |
|
481 | - ) |
|
482 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
483 | - 'View Registration Details', |
|
484 | - 'event_espresso' |
|
485 | - ) . '">' |
|
486 | - . $registration->attendee()->full_name() |
|
487 | - . '</a>' |
|
488 | - : $registration->attendee()->full_name(); |
|
489 | - $name_link .= $registration->count() === 1 |
|
490 | - ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
491 | - : ''; |
|
492 | - // add group details |
|
493 | - $name_link .= ' ' . sprintf( |
|
494 | - esc_html__('(%s of %s)', 'event_espresso'), |
|
495 | - $registration->count(), |
|
496 | - $registration->group_size() |
|
497 | - ); |
|
498 | - // add regcode |
|
499 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
500 | - ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
501 | - REG_ADMIN_URL |
|
502 | - ); |
|
503 | - $name_link .= '<br>'; |
|
504 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
505 | - 'ee_read_registration', |
|
506 | - 'view_registration', |
|
507 | - $registration->ID() |
|
508 | - ) |
|
509 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
510 | - 'View Registration Details', |
|
511 | - 'event_espresso' |
|
512 | - ) . '">' |
|
513 | - . $registration->reg_code() |
|
514 | - . '</a>' |
|
515 | - : $registration->reg_code(); |
|
516 | - |
|
517 | - $actions = []; |
|
518 | - if ( |
|
519 | - $this->datetime_id |
|
520 | - && EE_Registry::instance()->CAP->current_user_can( |
|
521 | - 'ee_read_checkins', |
|
522 | - 'espresso_registrations_registration_checkins' |
|
523 | - ) |
|
524 | - ) { |
|
525 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
526 | - ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id], |
|
527 | - REG_ADMIN_URL |
|
528 | - ); |
|
529 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
530 | - /** @var EE_Checkin[] $checkins */ |
|
531 | - $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
|
532 | - if (! empty($checkins)) { |
|
533 | - // get the last timestamp |
|
534 | - $last_checkin = end($checkins); |
|
535 | - // get timestamp string |
|
536 | - $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
|
537 | - $actions['checkin'] = ' |
|
478 | + $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
479 | + 'ee_edit_contacts', |
|
480 | + 'espresso_registrations_edit_attendee' |
|
481 | + ) |
|
482 | + ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
483 | + 'View Registration Details', |
|
484 | + 'event_espresso' |
|
485 | + ) . '">' |
|
486 | + . $registration->attendee()->full_name() |
|
487 | + . '</a>' |
|
488 | + : $registration->attendee()->full_name(); |
|
489 | + $name_link .= $registration->count() === 1 |
|
490 | + ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
491 | + : ''; |
|
492 | + // add group details |
|
493 | + $name_link .= ' ' . sprintf( |
|
494 | + esc_html__('(%s of %s)', 'event_espresso'), |
|
495 | + $registration->count(), |
|
496 | + $registration->group_size() |
|
497 | + ); |
|
498 | + // add regcode |
|
499 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
500 | + ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
501 | + REG_ADMIN_URL |
|
502 | + ); |
|
503 | + $name_link .= '<br>'; |
|
504 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
505 | + 'ee_read_registration', |
|
506 | + 'view_registration', |
|
507 | + $registration->ID() |
|
508 | + ) |
|
509 | + ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
510 | + 'View Registration Details', |
|
511 | + 'event_espresso' |
|
512 | + ) . '">' |
|
513 | + . $registration->reg_code() |
|
514 | + . '</a>' |
|
515 | + : $registration->reg_code(); |
|
516 | + |
|
517 | + $actions = []; |
|
518 | + if ( |
|
519 | + $this->datetime_id |
|
520 | + && EE_Registry::instance()->CAP->current_user_can( |
|
521 | + 'ee_read_checkins', |
|
522 | + 'espresso_registrations_registration_checkins' |
|
523 | + ) |
|
524 | + ) { |
|
525 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
526 | + ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id], |
|
527 | + REG_ADMIN_URL |
|
528 | + ); |
|
529 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
530 | + /** @var EE_Checkin[] $checkins */ |
|
531 | + $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
|
532 | + if (! empty($checkins)) { |
|
533 | + // get the last timestamp |
|
534 | + $last_checkin = end($checkins); |
|
535 | + // get timestamp string |
|
536 | + $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
|
537 | + $actions['checkin'] = ' |
|
538 | 538 | <a class="ee-aria-tooltip" |
539 | 539 | href="' . $checkin_list_url . '" |
540 | 540 | aria-label="' . esc_attr__( |
541 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
542 | - 'event_espresso' |
|
543 | - ) . '" |
|
541 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
542 | + 'event_espresso' |
|
543 | + ) . '" |
|
544 | 544 | > |
545 | 545 | ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . ' |
546 | 546 | </a>'; |
547 | - } |
|
548 | - } |
|
549 | - $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
550 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
551 | - : $name_link; |
|
552 | - return $this->columnContent('ATT_name', $content); |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * @param EE_Registration $registration |
|
558 | - * @return string |
|
559 | - * @throws EE_Error |
|
560 | - * @throws EE_Error |
|
561 | - * @throws ReflectionException |
|
562 | - */ |
|
563 | - public function column_ATT_email(EE_Registration $registration): string |
|
564 | - { |
|
565 | - $attendee = $registration->attendee(); |
|
566 | - $content = $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
567 | - return $this->columnContent('ATT_email', $content); |
|
568 | - } |
|
569 | - |
|
570 | - |
|
571 | - /** |
|
572 | - * @param EE_Registration $registration |
|
573 | - * @return string |
|
574 | - * @throws EE_Error |
|
575 | - * @throws ReflectionException |
|
576 | - */ |
|
577 | - public function column_Event(EE_Registration $registration): string |
|
578 | - { |
|
579 | - try { |
|
580 | - $event = $this->event instanceof EE_Event ? $this->event : $registration->event(); |
|
581 | - $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
582 | - ['action' => 'event_registrations', 'event_id' => $event->ID()], |
|
583 | - REG_ADMIN_URL |
|
584 | - ); |
|
585 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
586 | - 'ee_read_checkins', |
|
587 | - 'espresso_registrations_registration_checkins' |
|
588 | - ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
589 | - . esc_attr__( |
|
590 | - 'View Checkins for this Event', |
|
591 | - 'event_espresso' |
|
592 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
593 | - } catch (EntityNotFoundException $e) { |
|
594 | - $content = esc_html__('Unknown', 'event_espresso'); |
|
595 | - } |
|
596 | - return $this->columnContent('Event', $content); |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - /** |
|
601 | - * @param EE_Registration $registration |
|
602 | - * @return string |
|
603 | - * @throws EE_Error |
|
604 | - * @throws ReflectionException |
|
605 | - */ |
|
606 | - public function column_PRC_name(EE_Registration $registration): string |
|
607 | - { |
|
608 | - $content = $registration->ticket() instanceof EE_Ticket |
|
609 | - ? $registration->ticket()->name() |
|
610 | - : esc_html__( |
|
611 | - "Unknown", |
|
612 | - "event_espresso" |
|
613 | - ); |
|
614 | - return $this->columnContent('PRC_name', $content); |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * column_REG_final_price |
|
620 | - * |
|
621 | - * @param EE_Registration $registration |
|
622 | - * @return string |
|
623 | - * @throws EE_Error |
|
624 | - */ |
|
625 | - public function column__REG_final_price(EE_Registration $registration): string |
|
626 | - { |
|
627 | - return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end'); |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - /** |
|
632 | - * column_TXN_paid |
|
633 | - * |
|
634 | - * @param EE_Registration $registration |
|
635 | - * @return string |
|
636 | - * @throws EE_Error |
|
637 | - * @throws ReflectionException |
|
638 | - */ |
|
639 | - public function column_TXN_paid(EE_Registration $registration): string |
|
640 | - { |
|
641 | - $content = ''; |
|
642 | - if ($registration->count() === 1) { |
|
643 | - if ($registration->transaction()->paid() >= $registration->transaction()->total()) { |
|
644 | - return '<div class="dashicons dashicons-yes green-icon"></div>'; |
|
645 | - } else { |
|
646 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
647 | - ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
|
648 | - TXN_ADMIN_URL |
|
649 | - ); |
|
650 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
651 | - 'ee_read_transaction', |
|
652 | - 'espresso_transactions_view_transaction' |
|
653 | - ) ? ' |
|
547 | + } |
|
548 | + } |
|
549 | + $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
550 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
551 | + : $name_link; |
|
552 | + return $this->columnContent('ATT_name', $content); |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * @param EE_Registration $registration |
|
558 | + * @return string |
|
559 | + * @throws EE_Error |
|
560 | + * @throws EE_Error |
|
561 | + * @throws ReflectionException |
|
562 | + */ |
|
563 | + public function column_ATT_email(EE_Registration $registration): string |
|
564 | + { |
|
565 | + $attendee = $registration->attendee(); |
|
566 | + $content = $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
567 | + return $this->columnContent('ATT_email', $content); |
|
568 | + } |
|
569 | + |
|
570 | + |
|
571 | + /** |
|
572 | + * @param EE_Registration $registration |
|
573 | + * @return string |
|
574 | + * @throws EE_Error |
|
575 | + * @throws ReflectionException |
|
576 | + */ |
|
577 | + public function column_Event(EE_Registration $registration): string |
|
578 | + { |
|
579 | + try { |
|
580 | + $event = $this->event instanceof EE_Event ? $this->event : $registration->event(); |
|
581 | + $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
582 | + ['action' => 'event_registrations', 'event_id' => $event->ID()], |
|
583 | + REG_ADMIN_URL |
|
584 | + ); |
|
585 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
586 | + 'ee_read_checkins', |
|
587 | + 'espresso_registrations_registration_checkins' |
|
588 | + ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
589 | + . esc_attr__( |
|
590 | + 'View Checkins for this Event', |
|
591 | + 'event_espresso' |
|
592 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
593 | + } catch (EntityNotFoundException $e) { |
|
594 | + $content = esc_html__('Unknown', 'event_espresso'); |
|
595 | + } |
|
596 | + return $this->columnContent('Event', $content); |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + /** |
|
601 | + * @param EE_Registration $registration |
|
602 | + * @return string |
|
603 | + * @throws EE_Error |
|
604 | + * @throws ReflectionException |
|
605 | + */ |
|
606 | + public function column_PRC_name(EE_Registration $registration): string |
|
607 | + { |
|
608 | + $content = $registration->ticket() instanceof EE_Ticket |
|
609 | + ? $registration->ticket()->name() |
|
610 | + : esc_html__( |
|
611 | + "Unknown", |
|
612 | + "event_espresso" |
|
613 | + ); |
|
614 | + return $this->columnContent('PRC_name', $content); |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * column_REG_final_price |
|
620 | + * |
|
621 | + * @param EE_Registration $registration |
|
622 | + * @return string |
|
623 | + * @throws EE_Error |
|
624 | + */ |
|
625 | + public function column__REG_final_price(EE_Registration $registration): string |
|
626 | + { |
|
627 | + return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end'); |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + /** |
|
632 | + * column_TXN_paid |
|
633 | + * |
|
634 | + * @param EE_Registration $registration |
|
635 | + * @return string |
|
636 | + * @throws EE_Error |
|
637 | + * @throws ReflectionException |
|
638 | + */ |
|
639 | + public function column_TXN_paid(EE_Registration $registration): string |
|
640 | + { |
|
641 | + $content = ''; |
|
642 | + if ($registration->count() === 1) { |
|
643 | + if ($registration->transaction()->paid() >= $registration->transaction()->total()) { |
|
644 | + return '<div class="dashicons dashicons-yes green-icon"></div>'; |
|
645 | + } else { |
|
646 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
647 | + ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
|
648 | + TXN_ADMIN_URL |
|
649 | + ); |
|
650 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
651 | + 'ee_read_transaction', |
|
652 | + 'espresso_transactions_view_transaction' |
|
653 | + ) ? ' |
|
654 | 654 | <a class="ee-aria-tooltip ee-status-color--' |
655 | - . $registration->transaction()->status_ID() |
|
656 | - . '" href="' |
|
657 | - . $view_txn_lnk_url |
|
658 | - . '" aria-label="' |
|
659 | - . esc_attr__('View Transaction', 'event_espresso') |
|
660 | - . '"> |
|
655 | + . $registration->transaction()->status_ID() |
|
656 | + . '" href="' |
|
657 | + . $view_txn_lnk_url |
|
658 | + . '" aria-label="' |
|
659 | + . esc_attr__('View Transaction', 'event_espresso') |
|
660 | + . '"> |
|
661 | 661 | ' |
662 | - . $registration->transaction()->pretty_paid() |
|
663 | - . ' |
|
662 | + . $registration->transaction()->pretty_paid() |
|
663 | + . ' |
|
664 | 664 | </a> |
665 | 665 | ' : $registration->transaction()->pretty_paid(); |
666 | - } |
|
667 | - } |
|
668 | - return $this->columnContent('TXN_paid', $content, 'end'); |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * column_TXN_total |
|
674 | - * |
|
675 | - * @param EE_Registration $registration |
|
676 | - * @return string |
|
677 | - * @throws EE_Error |
|
678 | - * @throws ReflectionException |
|
679 | - */ |
|
680 | - public function column_TXN_total(EE_Registration $registration): string |
|
681 | - { |
|
682 | - $content = ''; |
|
683 | - $txn = $registration->transaction(); |
|
684 | - $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL); |
|
685 | - if ($registration->get('REG_count') === 1) { |
|
686 | - $line_total_obj = $txn->total_line_item(); |
|
687 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
688 | - ? $line_total_obj->get_pretty('LIN_total') |
|
689 | - : esc_html__( |
|
690 | - 'View Transaction', |
|
691 | - 'event_espresso' |
|
692 | - ); |
|
693 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
694 | - 'ee_read_transaction', |
|
695 | - 'espresso_transactions_view_transaction' |
|
696 | - ) ? '<a class="ee-aria-tooltip" href="' |
|
697 | - . $view_txn_url |
|
698 | - . '" aria-label="' |
|
699 | - . esc_attr__('View Transaction', 'event_espresso') |
|
700 | - . '">' |
|
701 | - . $txn_total |
|
702 | - . '</a>' |
|
703 | - : $txn_total; |
|
704 | - } |
|
705 | - return $this->columnContent('TXN_total', $content, 'end'); |
|
706 | - } |
|
666 | + } |
|
667 | + } |
|
668 | + return $this->columnContent('TXN_paid', $content, 'end'); |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * column_TXN_total |
|
674 | + * |
|
675 | + * @param EE_Registration $registration |
|
676 | + * @return string |
|
677 | + * @throws EE_Error |
|
678 | + * @throws ReflectionException |
|
679 | + */ |
|
680 | + public function column_TXN_total(EE_Registration $registration): string |
|
681 | + { |
|
682 | + $content = ''; |
|
683 | + $txn = $registration->transaction(); |
|
684 | + $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL); |
|
685 | + if ($registration->get('REG_count') === 1) { |
|
686 | + $line_total_obj = $txn->total_line_item(); |
|
687 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
688 | + ? $line_total_obj->get_pretty('LIN_total') |
|
689 | + : esc_html__( |
|
690 | + 'View Transaction', |
|
691 | + 'event_espresso' |
|
692 | + ); |
|
693 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
694 | + 'ee_read_transaction', |
|
695 | + 'espresso_transactions_view_transaction' |
|
696 | + ) ? '<a class="ee-aria-tooltip" href="' |
|
697 | + . $view_txn_url |
|
698 | + . '" aria-label="' |
|
699 | + . esc_attr__('View Transaction', 'event_espresso') |
|
700 | + . '">' |
|
701 | + . $txn_total |
|
702 | + . '</a>' |
|
703 | + : $txn_total; |
|
704 | + } |
|
705 | + return $this->columnContent('TXN_total', $content, 'end'); |
|
706 | + } |
|
707 | 707 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'ajax' => true, |
145 | 145 | 'screen' => $this->_admin_page->get_current_screen()->id, |
146 | 146 | ]; |
147 | - $columns = []; |
|
147 | + $columns = []; |
|
148 | 148 | |
149 | 149 | $this->_columns = [ |
150 | 150 | '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | 'TXN_total' => esc_html__('Total', 'event_espresso'), |
158 | 158 | ]; |
159 | 159 | // Add/remove columns when an event has been selected |
160 | - if (! empty($this->event_id)) { |
|
160 | + if ( ! empty($this->event_id)) { |
|
161 | 161 | // Render a checkbox column |
162 | 162 | $columns['cb'] = '<input type="checkbox" />'; |
163 | 163 | $this->_has_checkbox_column = true; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $this->event_id, |
175 | 175 | $this->datetime_id |
176 | 176 | ); |
177 | - if (! empty($csv_report)) { |
|
177 | + if ( ! empty($csv_report)) { |
|
178 | 178 | $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
179 | 179 | } |
180 | 180 | |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | : ['ATT_fname' => true], |
197 | 197 | 'Event' => ['Event.EVT_name' => false], |
198 | 198 | ]; |
199 | - $this->_hidden_columns = []; |
|
200 | - $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
199 | + $this->_hidden_columns = []; |
|
200 | + $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
201 | 201 | if ($this->event instanceof EE_Event) { |
202 | 202 | $this->datetimes_for_event = $this->event->datetimes_ordered(); |
203 | 203 | } |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
232 | 232 | $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
233 | 233 | // get datetimes for ALL active events (note possible capability restrictions) |
234 | - $events = $this->datetimes_for_event->getAllDatetimesForAllEvents(); |
|
234 | + $events = $this->datetimes_for_event->getAllDatetimesForAllEvents(); |
|
235 | 235 | $event_options[] = [ |
236 | 236 | 'id' => 0, |
237 | 237 | 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
238 | 238 | ]; |
239 | 239 | foreach ($events as $event) { |
240 | 240 | // any registrations for this event? |
241 | - if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
241 | + if ( ! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $event->name(), |
252 | 252 | $event |
253 | 253 | ), |
254 | - 'class' => $expired_class . $upcoming_class, |
|
254 | + 'class' => $expired_class.$upcoming_class, |
|
255 | 255 | ]; |
256 | 256 | if ($event->ID() === $this->event_id) { |
257 | 257 | $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
@@ -266,17 +266,17 @@ discard block |
||
266 | 266 | |
267 | 267 | $filters[] = ' |
268 | 268 | <div class="ee-event-filter__wrapper"> |
269 | - <label class="ee-event-filter-main-label">' . esc_html__('Check-in Status for', 'event_espresso') . '</label> |
|
269 | + <label class="ee-event-filter-main-label">' . esc_html__('Check-in Status for', 'event_espresso').'</label> |
|
270 | 270 | <div class="ee-event-filter"> |
271 | 271 | <span class="ee-event-selector"> |
272 | - <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label> |
|
272 | + <label for="event_id">' . esc_html__('Event', 'event_espresso').'</label> |
|
273 | 273 | ' . EEH_Form_Fields::select_input( |
274 | 274 | 'event_id', |
275 | 275 | $event_options, |
276 | 276 | $this->event_id, |
277 | 277 | '', |
278 | 278 | $select_class |
279 | - ) . ' |
|
279 | + ).' |
|
280 | 280 | </span>'; |
281 | 281 | // DTT datetimes filter |
282 | 282 | $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent($hide_upcoming_checked === 'checked'); |
@@ -285,23 +285,23 @@ discard block |
||
285 | 285 | foreach ($datetimes_for_event as $datetime) { |
286 | 286 | if ($datetime instanceof EE_Datetime) { |
287 | 287 | $datetime_string = $datetime->name(); |
288 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
288 | + $datetime_string = ! empty($datetime_string) ? $datetime_string.': ' : ''; |
|
289 | 289 | $datetime_string .= $datetime->date_and_time_range(); |
290 | 290 | $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
291 | 291 | $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
292 | 292 | $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
293 | 293 | // now put it all together |
294 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
294 | + $datetimes[$datetime->ID()] = $datetime_string; |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | $filters[] = ' |
298 | 298 | <span class="ee-datetime-selector"> |
299 | - <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
|
299 | + <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso').'</label> |
|
300 | 300 | ' . EEH_Form_Fields::select_input( |
301 | 301 | 'DTT_ID', |
302 | 302 | $datetimes, |
303 | 303 | $this->datetime_id |
304 | - ) . ' |
|
304 | + ).' |
|
305 | 305 | </span>'; |
306 | 306 | } |
307 | 307 | $filters[] = ' |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | */ |
361 | 361 | protected function _get_total_event_attendees(): int |
362 | 362 | { |
363 | - $query_params = []; |
|
363 | + $query_params = []; |
|
364 | 364 | if ($this->event_id) { |
365 | 365 | $query_params[0]['EVT_ID'] = $this->event_id; |
366 | 366 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | if ($this->datetime_id) { |
369 | 369 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
370 | 370 | } |
371 | - $status_ids_array = apply_filters( |
|
371 | + $status_ids_array = apply_filters( |
|
372 | 372 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
373 | 373 | [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
374 | 374 | ); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | // (so that we don't pollute state for the entire table) |
407 | 407 | // so let's try to get it from the registration's event |
408 | 408 | $DTT_ID = $this->datetime_id; |
409 | - if (! $DTT_ID) { |
|
409 | + if ( ! $DTT_ID) { |
|
410 | 410 | $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
411 | 411 | if (count($reg_ticket_datetimes) === 1) { |
412 | 412 | $reg_ticket_datetime = reset($reg_ticket_datetimes); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
417 | - if (! $DTT_ID) { |
|
417 | + if ( ! $DTT_ID) { |
|
418 | 418 | $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
419 | 419 | $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
420 | 420 | $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
@@ -439,17 +439,17 @@ discard block |
||
439 | 439 | ) |
440 | 440 | ) { |
441 | 441 | // overwrite the disabled attribute with data attributes for performing checkin |
442 | - $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
443 | - $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
444 | - $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
442 | + $attributes = 'data-_regid="'.$registration->ID().'"'; |
|
443 | + $attributes .= ' data-dttid="'.$DTT_ID.'"'; |
|
444 | + $attributes .= ' data-nonce="'.wp_create_nonce('checkin_nonce').'"'; |
|
445 | 445 | $button_class .= ' clickable trigger-checkin'; |
446 | 446 | } |
447 | 447 | |
448 | 448 | $content = ' |
449 | - <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '> |
|
450 | - <span class="' . $dashicon_class . '" ></span> |
|
449 | + <button aria-label="' . $aria_label.'" class="'.$button_class.'" '.$attributes.'> |
|
450 | + <span class="' . $dashicon_class.'" ></span> |
|
451 | 451 | </button> |
452 | - <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>'; |
|
452 | + <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration).'</span>'; |
|
453 | 453 | return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
454 | 454 | } |
455 | 455 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | public function column_ATT_name(EE_Registration $registration): string |
464 | 464 | { |
465 | 465 | $attendee = $registration->attendee(); |
466 | - if (! $attendee instanceof EE_Attendee) { |
|
466 | + if ( ! $attendee instanceof EE_Attendee) { |
|
467 | 467 | return esc_html__('No contact record for this registration.', 'event_espresso'); |
468 | 468 | } |
469 | 469 | // edit attendee link |
@@ -471,32 +471,32 @@ discard block |
||
471 | 471 | ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
472 | 472 | REG_ADMIN_URL |
473 | 473 | ); |
474 | - $name_link = ' |
|
475 | - <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
|
476 | - aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
|
474 | + $name_link = ' |
|
475 | + <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()).' ee-aria-tooltip" |
|
476 | + aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'"> |
|
477 | 477 | </span>'; |
478 | - $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
478 | + $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
479 | 479 | 'ee_edit_contacts', |
480 | 480 | 'espresso_registrations_edit_attendee' |
481 | 481 | ) |
482 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
482 | + ? '<a class="ee-aria-tooltip" href="'.$edit_lnk_url.'" aria-label="'.esc_attr__( |
|
483 | 483 | 'View Registration Details', |
484 | 484 | 'event_espresso' |
485 | - ) . '">' |
|
485 | + ).'">' |
|
486 | 486 | . $registration->attendee()->full_name() |
487 | 487 | . '</a>' |
488 | 488 | : $registration->attendee()->full_name(); |
489 | - $name_link .= $registration->count() === 1 |
|
489 | + $name_link .= $registration->count() === 1 |
|
490 | 490 | ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
491 | 491 | : ''; |
492 | 492 | // add group details |
493 | - $name_link .= ' ' . sprintf( |
|
493 | + $name_link .= ' '.sprintf( |
|
494 | 494 | esc_html__('(%s of %s)', 'event_espresso'), |
495 | 495 | $registration->count(), |
496 | 496 | $registration->group_size() |
497 | 497 | ); |
498 | 498 | // add regcode |
499 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
499 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
500 | 500 | ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
501 | 501 | REG_ADMIN_URL |
502 | 502 | ); |
@@ -506,15 +506,15 @@ discard block |
||
506 | 506 | 'view_registration', |
507 | 507 | $registration->ID() |
508 | 508 | ) |
509 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
509 | + ? '<a class="ee-aria-tooltip" href="'.$link.'" aria-label="'.esc_attr__( |
|
510 | 510 | 'View Registration Details', |
511 | 511 | 'event_espresso' |
512 | - ) . '">' |
|
512 | + ).'">' |
|
513 | 513 | . $registration->reg_code() |
514 | 514 | . '</a>' |
515 | 515 | : $registration->reg_code(); |
516 | 516 | |
517 | - $actions = []; |
|
517 | + $actions = []; |
|
518 | 518 | if ( |
519 | 519 | $this->datetime_id |
520 | 520 | && EE_Registry::instance()->CAP->current_user_can( |
@@ -529,24 +529,24 @@ discard block |
||
529 | 529 | // get the timestamps for this registration's checkins, related to the selected datetime |
530 | 530 | /** @var EE_Checkin[] $checkins */ |
531 | 531 | $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
532 | - if (! empty($checkins)) { |
|
532 | + if ( ! empty($checkins)) { |
|
533 | 533 | // get the last timestamp |
534 | 534 | $last_checkin = end($checkins); |
535 | 535 | // get timestamp string |
536 | 536 | $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
537 | 537 | $actions['checkin'] = ' |
538 | 538 | <a class="ee-aria-tooltip" |
539 | - href="' . $checkin_list_url . '" |
|
539 | + href="' . $checkin_list_url.'" |
|
540 | 540 | aria-label="' . esc_attr__( |
541 | 541 | 'View this registrant\'s check-ins/checkouts for the datetime', |
542 | 542 | 'event_espresso' |
543 | - ) . '" |
|
543 | + ).'" |
|
544 | 544 | > |
545 | - ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . ' |
|
545 | + ' . $last_checkin->getCheckInText().': '.$timestamp_string.' |
|
546 | 546 | </a>'; |
547 | 547 | } |
548 | 548 | } |
549 | - $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
549 | + $content = ( ! empty($this->datetime_id) && ! empty($checkins)) |
|
550 | 550 | ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
551 | 551 | : $name_link; |
552 | 552 | return $this->columnContent('ATT_name', $content); |
@@ -582,14 +582,14 @@ discard block |
||
582 | 582 | ['action' => 'event_registrations', 'event_id' => $event->ID()], |
583 | 583 | REG_ADMIN_URL |
584 | 584 | ); |
585 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
585 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
586 | 586 | 'ee_read_checkins', |
587 | 587 | 'espresso_registrations_registration_checkins' |
588 | - ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
588 | + ) ? '<a class="ee-aria-tooltip" href="'.$checkin_link_url.'" aria-label="' |
|
589 | 589 | . esc_attr__( |
590 | 590 | 'View Checkins for this Event', |
591 | 591 | 'event_espresso' |
592 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
592 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
593 | 593 | } catch (EntityNotFoundException $e) { |
594 | 594 | $content = esc_html__('Unknown', 'event_espresso'); |
595 | 595 | } |
@@ -15,102 +15,102 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class espresso_events_Registration_Form_Hooks extends EE_Admin_Hooks |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EE_Event|null |
|
20 | - */ |
|
21 | - protected $_event; |
|
22 | - |
|
23 | - |
|
24 | - protected function _set_hooks_properties() |
|
25 | - { |
|
26 | - $this->_name = 'registration_form'; |
|
27 | - if ( |
|
28 | - $this->_adminpage_obj->adminConfig()->useAdvancedEditor() |
|
29 | - && $this->_adminpage_obj->feature()->allowed('use_reg_form_builder') |
|
30 | - ) { |
|
31 | - $this->_metaboxes = []; |
|
32 | - $this->_scripts_styles = []; |
|
33 | - return; |
|
34 | - } |
|
35 | - $this->_metaboxes = [ |
|
36 | - 0 => [ |
|
37 | - 'page_route' => ['edit', 'create_new'], |
|
38 | - 'func' => 'primary_questions', |
|
39 | - 'label' => esc_html__('Questions for Primary Registrant', 'event_espresso'), |
|
40 | - 'priority' => 'default', |
|
41 | - 'context' => 'side', |
|
42 | - ], |
|
43 | - ]; |
|
44 | - |
|
45 | - // hook into the handler for saving question groups |
|
46 | - add_filter( |
|
47 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
48 | - [$this, 'modify_callbacks'], |
|
49 | - 10 |
|
50 | - ); |
|
51 | - |
|
52 | - // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already |
|
53 | - // restricted by page) |
|
54 | - add_action('AHEE_EE_Admin_Page_CPT__restore_revision', [$this, 'restore_revision'], 10, 2); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
|
60 | - * |
|
61 | - * @param $callbacks |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function modify_callbacks($callbacks) |
|
65 | - { |
|
66 | - // now let's add the question group callback |
|
67 | - $callbacks['primary_question_group_update'] = [$this, 'primary_question_group_update']; |
|
68 | - return $callbacks; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * Hooked into revision restores. |
|
74 | - * |
|
75 | - * @param $post_id |
|
76 | - * @param $revision_id |
|
77 | - * @return EE_Base_Class |
|
78 | - * @throws EE_Error |
|
79 | - * @throws InvalidArgumentException |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - * @throws InvalidInterfaceException |
|
82 | - */ |
|
83 | - public function restore_revision($post_id, $revision_id) |
|
84 | - { |
|
85 | - $post_evt = EEM_Event::instance()->get_one_by_ID($post_id); |
|
86 | - // restore revision for primary questions |
|
87 | - if ($post_evt instanceof EE_Event) { |
|
88 | - $post_evt->restore_revision( |
|
89 | - $revision_id, |
|
90 | - ['Question_Group'], |
|
91 | - ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]] |
|
92 | - ); |
|
93 | - } |
|
94 | - return $post_evt; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * Content of metabox. |
|
100 | - * |
|
101 | - * @param $post_id |
|
102 | - * @param $post |
|
103 | - * @throws EE_Error |
|
104 | - * @throws InvalidArgumentException |
|
105 | - * @throws InvalidDataTypeException |
|
106 | - * @throws InvalidInterfaceException |
|
107 | - * @throws ReflectionException |
|
108 | - */ |
|
109 | - public function primary_questions($post_id, $post) |
|
110 | - { |
|
111 | - $this->_event = $this->_adminpage_obj->get_event_object(); |
|
112 | - $event_id = $this->_event->ID(); |
|
113 | - ?> |
|
18 | + /** |
|
19 | + * @var EE_Event|null |
|
20 | + */ |
|
21 | + protected $_event; |
|
22 | + |
|
23 | + |
|
24 | + protected function _set_hooks_properties() |
|
25 | + { |
|
26 | + $this->_name = 'registration_form'; |
|
27 | + if ( |
|
28 | + $this->_adminpage_obj->adminConfig()->useAdvancedEditor() |
|
29 | + && $this->_adminpage_obj->feature()->allowed('use_reg_form_builder') |
|
30 | + ) { |
|
31 | + $this->_metaboxes = []; |
|
32 | + $this->_scripts_styles = []; |
|
33 | + return; |
|
34 | + } |
|
35 | + $this->_metaboxes = [ |
|
36 | + 0 => [ |
|
37 | + 'page_route' => ['edit', 'create_new'], |
|
38 | + 'func' => 'primary_questions', |
|
39 | + 'label' => esc_html__('Questions for Primary Registrant', 'event_espresso'), |
|
40 | + 'priority' => 'default', |
|
41 | + 'context' => 'side', |
|
42 | + ], |
|
43 | + ]; |
|
44 | + |
|
45 | + // hook into the handler for saving question groups |
|
46 | + add_filter( |
|
47 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
48 | + [$this, 'modify_callbacks'], |
|
49 | + 10 |
|
50 | + ); |
|
51 | + |
|
52 | + // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already |
|
53 | + // restricted by page) |
|
54 | + add_action('AHEE_EE_Admin_Page_CPT__restore_revision', [$this, 'restore_revision'], 10, 2); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
|
60 | + * |
|
61 | + * @param $callbacks |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function modify_callbacks($callbacks) |
|
65 | + { |
|
66 | + // now let's add the question group callback |
|
67 | + $callbacks['primary_question_group_update'] = [$this, 'primary_question_group_update']; |
|
68 | + return $callbacks; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * Hooked into revision restores. |
|
74 | + * |
|
75 | + * @param $post_id |
|
76 | + * @param $revision_id |
|
77 | + * @return EE_Base_Class |
|
78 | + * @throws EE_Error |
|
79 | + * @throws InvalidArgumentException |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + * @throws InvalidInterfaceException |
|
82 | + */ |
|
83 | + public function restore_revision($post_id, $revision_id) |
|
84 | + { |
|
85 | + $post_evt = EEM_Event::instance()->get_one_by_ID($post_id); |
|
86 | + // restore revision for primary questions |
|
87 | + if ($post_evt instanceof EE_Event) { |
|
88 | + $post_evt->restore_revision( |
|
89 | + $revision_id, |
|
90 | + ['Question_Group'], |
|
91 | + ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]] |
|
92 | + ); |
|
93 | + } |
|
94 | + return $post_evt; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * Content of metabox. |
|
100 | + * |
|
101 | + * @param $post_id |
|
102 | + * @param $post |
|
103 | + * @throws EE_Error |
|
104 | + * @throws InvalidArgumentException |
|
105 | + * @throws InvalidDataTypeException |
|
106 | + * @throws InvalidInterfaceException |
|
107 | + * @throws ReflectionException |
|
108 | + */ |
|
109 | + public function primary_questions($post_id, $post) |
|
110 | + { |
|
111 | + $this->_event = $this->_adminpage_obj->get_event_object(); |
|
112 | + $event_id = $this->_event->ID(); |
|
113 | + ?> |
|
114 | 114 | <div class="inside"> |
115 | 115 | <p> |
116 | 116 | <strong> |
@@ -118,64 +118,64 @@ discard block |
||
118 | 118 | </strong> |
119 | 119 | <br /> |
120 | 120 | <?php |
121 | - printf( |
|
122 | - esc_html__( |
|
123 | - 'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events', |
|
124 | - 'event_espresso' |
|
125 | - ), |
|
126 | - '<a href="admin.php?page=espresso_registration_form" target="_blank">', |
|
127 | - '</a>' |
|
128 | - ) |
|
129 | - ?> |
|
121 | + printf( |
|
122 | + esc_html__( |
|
123 | + 'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events', |
|
124 | + 'event_espresso' |
|
125 | + ), |
|
126 | + '<a href="admin.php?page=espresso_registration_form" target="_blank">', |
|
127 | + '</a>' |
|
128 | + ) |
|
129 | + ?> |
|
130 | 130 | </p> |
131 | 131 | <?php |
132 | 132 | |
133 | - $qsg_where['QSG_deleted'] = false; |
|
134 | - $query_params = apply_filters( |
|
135 | - 'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters', |
|
136 | - [$qsg_where, 'order_by' => ['QSG_order' => 'ASC']] |
|
137 | - ); |
|
138 | - $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
139 | - $EQGs = ! empty($event_id) |
|
140 | - ? $this->_event->get_many_related( |
|
141 | - 'Question_Group', |
|
142 | - [['Event_Question_Group.EQG_primary' => true]] |
|
143 | - ) |
|
144 | - : []; |
|
145 | - $EQGids = array_keys($EQGs); |
|
146 | - |
|
147 | - if (! empty($QSGs)) { |
|
148 | - $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
149 | - foreach ($QSGs as $QSG) { |
|
150 | - $QSG_ID = absint($QSG->ID()); |
|
151 | - $checked = in_array($QSG_ID, $EQGids, true) || $QSG->get('QSG_system') === 1 |
|
152 | - ? ' checked' |
|
153 | - : ''; |
|
154 | - $visibility = $QSG->get('QSG_system') === 1 |
|
155 | - ? ' style="visibility:hidden"' |
|
156 | - : ''; |
|
157 | - $edit_query_args = $this->_adminpage_obj->is_caf() |
|
158 | - ? [ |
|
159 | - 'action' => 'edit_question_group', |
|
160 | - 'QSG_ID' => $QSG_ID, |
|
161 | - ] |
|
162 | - : ['action' => 'question_groups']; |
|
163 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
164 | - $edit_query_args, |
|
165 | - EE_FORMS_ADMIN_URL |
|
166 | - ); |
|
167 | - $edit_link_title = sprintf( |
|
168 | - esc_attr__('Edit %s Group', 'event_espresso'), |
|
169 | - $QSG->get('QSG_name') |
|
170 | - ); |
|
171 | - |
|
172 | - $html .= ' |
|
133 | + $qsg_where['QSG_deleted'] = false; |
|
134 | + $query_params = apply_filters( |
|
135 | + 'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters', |
|
136 | + [$qsg_where, 'order_by' => ['QSG_order' => 'ASC']] |
|
137 | + ); |
|
138 | + $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
139 | + $EQGs = ! empty($event_id) |
|
140 | + ? $this->_event->get_many_related( |
|
141 | + 'Question_Group', |
|
142 | + [['Event_Question_Group.EQG_primary' => true]] |
|
143 | + ) |
|
144 | + : []; |
|
145 | + $EQGids = array_keys($EQGs); |
|
146 | + |
|
147 | + if (! empty($QSGs)) { |
|
148 | + $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
149 | + foreach ($QSGs as $QSG) { |
|
150 | + $QSG_ID = absint($QSG->ID()); |
|
151 | + $checked = in_array($QSG_ID, $EQGids, true) || $QSG->get('QSG_system') === 1 |
|
152 | + ? ' checked' |
|
153 | + : ''; |
|
154 | + $visibility = $QSG->get('QSG_system') === 1 |
|
155 | + ? ' style="visibility:hidden"' |
|
156 | + : ''; |
|
157 | + $edit_query_args = $this->_adminpage_obj->is_caf() |
|
158 | + ? [ |
|
159 | + 'action' => 'edit_question_group', |
|
160 | + 'QSG_ID' => $QSG_ID, |
|
161 | + ] |
|
162 | + : ['action' => 'question_groups']; |
|
163 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
164 | + $edit_query_args, |
|
165 | + EE_FORMS_ADMIN_URL |
|
166 | + ); |
|
167 | + $edit_link_title = sprintf( |
|
168 | + esc_attr__('Edit %s Group', 'event_espresso'), |
|
169 | + $QSG->get('QSG_name') |
|
170 | + ); |
|
171 | + |
|
172 | + $html .= ' |
|
173 | 173 | <p id="event-question-group-' . $QSG_ID . '"> |
174 | 174 | <input value="' . $QSG_ID . '" |
175 | 175 | type="checkbox" |
176 | 176 | name="question_groups[' . $QSG_ID . ']" ' |
177 | - . $visibility |
|
178 | - . $checked . ' |
|
177 | + . $visibility |
|
178 | + . $checked . ' |
|
179 | 179 | /> |
180 | 180 | <a href="' . esc_url_raw($edit_link) . '" |
181 | 181 | aria-label="' . esc_attr($edit_link_title) . '" |
@@ -184,62 +184,62 @@ discard block |
||
184 | 184 | ' . $QSG->get('QSG_name') . ' |
185 | 185 | </a> |
186 | 186 | </p>'; |
187 | - } |
|
188 | - $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
189 | - echo wp_kses($html, AllowedTags::getWithFormTags()); |
|
190 | - } else { |
|
191 | - esc_html_e( |
|
192 | - 'There seems to be a problem with your questions. Please contact [email protected]', |
|
193 | - 'event_espresso' |
|
194 | - ); |
|
195 | - } |
|
196 | - do_action('AHEE_event_editor_questions_notice'); |
|
197 | - ?> |
|
187 | + } |
|
188 | + $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
189 | + echo wp_kses($html, AllowedTags::getWithFormTags()); |
|
190 | + } else { |
|
191 | + esc_html_e( |
|
192 | + 'There seems to be a problem with your questions. Please contact [email protected]', |
|
193 | + 'event_espresso' |
|
194 | + ); |
|
195 | + } |
|
196 | + do_action('AHEE_event_editor_questions_notice'); |
|
197 | + ?> |
|
198 | 198 | </div> |
199 | 199 | <?php |
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * @param EE_Event $event |
|
205 | - * @param array $data |
|
206 | - * @return bool |
|
207 | - * @throws EE_Error |
|
208 | - * @throws ReflectionException |
|
209 | - */ |
|
210 | - public function primary_question_group_update($event, $data) |
|
211 | - { |
|
212 | - $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : []; |
|
213 | - $added_qgs = array_keys($question_groups); |
|
214 | - $success = true; |
|
215 | - |
|
216 | - // let's get all current question groups associated with this event. |
|
217 | - $current_qgs = $event->get_many_related( |
|
218 | - 'Question_Group', |
|
219 | - [['Event_Question_Group.EQG_primary' => true]] |
|
220 | - ); |
|
221 | - $current_qgs = array_keys($current_qgs); // we just want the ids |
|
222 | - |
|
223 | - // now let's get the groups selected in the editor and update (IF we have data) |
|
224 | - if (! empty($question_groups)) { |
|
225 | - foreach ($question_groups as $QSG_ID => $val) { |
|
226 | - // add to event |
|
227 | - if ($val) { |
|
228 | - $qg = $event->_add_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]); |
|
229 | - } |
|
230 | - // trip success to false if result is empty |
|
231 | - $success = ! empty($qg) ? $success : false; |
|
232 | - } |
|
233 | - } |
|
234 | - |
|
235 | - // wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
236 | - $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
237 | - |
|
238 | - foreach ($removed_qgs as $QSG_ID) { |
|
239 | - $qg = $event->_remove_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]); |
|
240 | - // trip success to false if result is empty |
|
241 | - $success = ! empty($qg) ? $success : false; |
|
242 | - } |
|
243 | - return $success; |
|
244 | - } |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * @param EE_Event $event |
|
205 | + * @param array $data |
|
206 | + * @return bool |
|
207 | + * @throws EE_Error |
|
208 | + * @throws ReflectionException |
|
209 | + */ |
|
210 | + public function primary_question_group_update($event, $data) |
|
211 | + { |
|
212 | + $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : []; |
|
213 | + $added_qgs = array_keys($question_groups); |
|
214 | + $success = true; |
|
215 | + |
|
216 | + // let's get all current question groups associated with this event. |
|
217 | + $current_qgs = $event->get_many_related( |
|
218 | + 'Question_Group', |
|
219 | + [['Event_Question_Group.EQG_primary' => true]] |
|
220 | + ); |
|
221 | + $current_qgs = array_keys($current_qgs); // we just want the ids |
|
222 | + |
|
223 | + // now let's get the groups selected in the editor and update (IF we have data) |
|
224 | + if (! empty($question_groups)) { |
|
225 | + foreach ($question_groups as $QSG_ID => $val) { |
|
226 | + // add to event |
|
227 | + if ($val) { |
|
228 | + $qg = $event->_add_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]); |
|
229 | + } |
|
230 | + // trip success to false if result is empty |
|
231 | + $success = ! empty($qg) ? $success : false; |
|
232 | + } |
|
233 | + } |
|
234 | + |
|
235 | + // wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
236 | + $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
237 | + |
|
238 | + foreach ($removed_qgs as $QSG_ID) { |
|
239 | + $qg = $event->_remove_relation_to($QSG_ID, 'Question_Group', ['EQG_primary' => true]); |
|
240 | + // trip success to false if result is empty |
|
241 | + $success = ! empty($qg) ? $success : false; |
|
242 | + } |
|
243 | + return $success; |
|
244 | + } |
|
245 | 245 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | [['Event_Question_Group.EQG_primary' => true]] |
143 | 143 | ) |
144 | 144 | : []; |
145 | - $EQGids = array_keys($EQGs); |
|
145 | + $EQGids = array_keys($EQGs); |
|
146 | 146 | |
147 | - if (! empty($QSGs)) { |
|
147 | + if ( ! empty($QSGs)) { |
|
148 | 148 | $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
149 | 149 | foreach ($QSGs as $QSG) { |
150 | 150 | $QSG_ID = absint($QSG->ID()); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'QSG_ID' => $QSG_ID, |
161 | 161 | ] |
162 | 162 | : ['action' => 'question_groups']; |
163 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
163 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
164 | 164 | $edit_query_args, |
165 | 165 | EE_FORMS_ADMIN_URL |
166 | 166 | ); |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | ); |
171 | 171 | |
172 | 172 | $html .= ' |
173 | - <p id="event-question-group-' . $QSG_ID . '"> |
|
174 | - <input value="' . $QSG_ID . '" |
|
173 | + <p id="event-question-group-' . $QSG_ID.'"> |
|
174 | + <input value="' . $QSG_ID.'" |
|
175 | 175 | type="checkbox" |
176 | - name="question_groups[' . $QSG_ID . ']" ' |
|
176 | + name="question_groups[' . $QSG_ID.']" ' |
|
177 | 177 | . $visibility |
178 | - . $checked . ' |
|
178 | + . $checked.' |
|
179 | 179 | /> |
180 | - <a href="' . esc_url_raw($edit_link) . '" |
|
181 | - aria-label="' . esc_attr($edit_link_title) . '" |
|
180 | + <a href="' . esc_url_raw($edit_link).'" |
|
181 | + aria-label="' . esc_attr($edit_link_title).'" |
|
182 | 182 | target="_blank" |
183 | 183 | > |
184 | - ' . $QSG->get('QSG_name') . ' |
|
184 | + ' . $QSG->get('QSG_name').' |
|
185 | 185 | </a> |
186 | 186 | </p>'; |
187 | 187 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $current_qgs = array_keys($current_qgs); // we just want the ids |
222 | 222 | |
223 | 223 | // now let's get the groups selected in the editor and update (IF we have data) |
224 | - if (! empty($question_groups)) { |
|
224 | + if ( ! empty($question_groups)) { |
|
225 | 225 | foreach ($question_groups as $QSG_ID => $val) { |
226 | 226 | // add to event |
227 | 227 | if ($val) { |
@@ -15,223 +15,223 @@ |
||
15 | 15 | */ |
16 | 16 | class Registration_Form_Questions_Admin_List_Table extends EE_Admin_List_Table |
17 | 17 | { |
18 | - /** |
|
19 | - * @var Registration_Form_Admin_Page $_admin_page |
|
20 | - */ |
|
21 | - protected $_admin_page; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var RegFormListTableUserCapabilities |
|
25 | - */ |
|
26 | - protected $caps_handler; |
|
27 | - |
|
28 | - |
|
29 | - public function __construct($admin_page) |
|
30 | - { |
|
31 | - $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP); |
|
32 | - parent::__construct($admin_page); |
|
33 | - |
|
34 | - if (! defined('REG_ADMIN_URL')) { |
|
35 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
36 | - } |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @throws EE_Error |
|
42 | - */ |
|
43 | - protected function _setup_data() |
|
44 | - { |
|
45 | - if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') { |
|
46 | - $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page); |
|
47 | - } else { |
|
48 | - $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page); |
|
49 | - } |
|
50 | - $this->_all_data_count = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - protected function _set_properties() |
|
55 | - { |
|
56 | - $this->_wp_list_args = [ |
|
57 | - 'singular' => esc_html__('question', 'event_espresso'), |
|
58 | - 'plural' => esc_html__('questions', 'event_espresso'), |
|
59 | - 'ajax' => true, // for now, |
|
60 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
61 | - ]; |
|
62 | - |
|
63 | - $this->_columns = [ |
|
64 | - 'cb' => '<input type="checkbox" />', |
|
65 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
66 | - 'display_text' => esc_html__('Question', 'event_espresso'), |
|
67 | - 'admin_label' => esc_html__('Admin Label', 'event_espresso'), |
|
68 | - 'type' => esc_html__('Type', 'event_espresso'), |
|
69 | - 'values' => esc_html__('Values', 'event_espresso'), |
|
70 | - 'required' => esc_html__('Req', 'event_espresso'), |
|
71 | - ]; |
|
72 | - |
|
73 | - $this->_primary_column = 'id'; |
|
74 | - |
|
75 | - $this->_sortable_columns = [ |
|
76 | - 'id' => ['QST_ID' => false], |
|
77 | - 'display_text' => ['QST_display_text' => false], |
|
78 | - ]; |
|
79 | - |
|
80 | - $this->_hidden_columns = []; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - // not needed |
|
85 | - protected function _get_table_filters(): array |
|
86 | - { |
|
87 | - return []; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @throws EE_Error |
|
93 | - */ |
|
94 | - protected function _add_view_counts() |
|
95 | - { |
|
96 | - $this->_views['all']['count'] = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
97 | - if ($this->caps_handler->userCanTrashQuestions()) { |
|
98 | - $this->_views['trash']['count'] = $this->_admin_page->get_trashed_questions(-1, $this->_current_page, true); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @param EE_Question $item |
|
105 | - * @return string |
|
106 | - * @throws EE_Error |
|
107 | - * @throws ReflectionException |
|
108 | - */ |
|
109 | - public function column_cb($item): string |
|
110 | - { |
|
111 | - $system_question = $item->is_system_question(); |
|
112 | - $related_answer_count = $item->count_related('Answer'); |
|
113 | - $has_answers = ! $system_question && $related_answer_count > 0 && $this->_view == 'trash'; |
|
114 | - $notice = $has_answers |
|
115 | - ? esc_html__( |
|
116 | - 'This question has answers attached to it from registrations that have the question. It cannot be permanently deleted.', |
|
117 | - 'event_espresso' |
|
118 | - ) |
|
119 | - : esc_html__('This question is a system question and cannot be trashed', 'event_espresso'); |
|
120 | - |
|
121 | - return $system_question || $has_answers |
|
122 | - ? ' |
|
18 | + /** |
|
19 | + * @var Registration_Form_Admin_Page $_admin_page |
|
20 | + */ |
|
21 | + protected $_admin_page; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var RegFormListTableUserCapabilities |
|
25 | + */ |
|
26 | + protected $caps_handler; |
|
27 | + |
|
28 | + |
|
29 | + public function __construct($admin_page) |
|
30 | + { |
|
31 | + $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP); |
|
32 | + parent::__construct($admin_page); |
|
33 | + |
|
34 | + if (! defined('REG_ADMIN_URL')) { |
|
35 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @throws EE_Error |
|
42 | + */ |
|
43 | + protected function _setup_data() |
|
44 | + { |
|
45 | + if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') { |
|
46 | + $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page); |
|
47 | + } else { |
|
48 | + $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page); |
|
49 | + } |
|
50 | + $this->_all_data_count = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + protected function _set_properties() |
|
55 | + { |
|
56 | + $this->_wp_list_args = [ |
|
57 | + 'singular' => esc_html__('question', 'event_espresso'), |
|
58 | + 'plural' => esc_html__('questions', 'event_espresso'), |
|
59 | + 'ajax' => true, // for now, |
|
60 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
61 | + ]; |
|
62 | + |
|
63 | + $this->_columns = [ |
|
64 | + 'cb' => '<input type="checkbox" />', |
|
65 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
66 | + 'display_text' => esc_html__('Question', 'event_espresso'), |
|
67 | + 'admin_label' => esc_html__('Admin Label', 'event_espresso'), |
|
68 | + 'type' => esc_html__('Type', 'event_espresso'), |
|
69 | + 'values' => esc_html__('Values', 'event_espresso'), |
|
70 | + 'required' => esc_html__('Req', 'event_espresso'), |
|
71 | + ]; |
|
72 | + |
|
73 | + $this->_primary_column = 'id'; |
|
74 | + |
|
75 | + $this->_sortable_columns = [ |
|
76 | + 'id' => ['QST_ID' => false], |
|
77 | + 'display_text' => ['QST_display_text' => false], |
|
78 | + ]; |
|
79 | + |
|
80 | + $this->_hidden_columns = []; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + // not needed |
|
85 | + protected function _get_table_filters(): array |
|
86 | + { |
|
87 | + return []; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @throws EE_Error |
|
93 | + */ |
|
94 | + protected function _add_view_counts() |
|
95 | + { |
|
96 | + $this->_views['all']['count'] = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, true); |
|
97 | + if ($this->caps_handler->userCanTrashQuestions()) { |
|
98 | + $this->_views['trash']['count'] = $this->_admin_page->get_trashed_questions(-1, $this->_current_page, true); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @param EE_Question $item |
|
105 | + * @return string |
|
106 | + * @throws EE_Error |
|
107 | + * @throws ReflectionException |
|
108 | + */ |
|
109 | + public function column_cb($item): string |
|
110 | + { |
|
111 | + $system_question = $item->is_system_question(); |
|
112 | + $related_answer_count = $item->count_related('Answer'); |
|
113 | + $has_answers = ! $system_question && $related_answer_count > 0 && $this->_view == 'trash'; |
|
114 | + $notice = $has_answers |
|
115 | + ? esc_html__( |
|
116 | + 'This question has answers attached to it from registrations that have the question. It cannot be permanently deleted.', |
|
117 | + 'event_espresso' |
|
118 | + ) |
|
119 | + : esc_html__('This question is a system question and cannot be trashed', 'event_espresso'); |
|
120 | + |
|
121 | + return $system_question || $has_answers |
|
122 | + ? ' |
|
123 | 123 | <span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" |
124 | 124 | aria-label="' . $notice . '"></span> |
125 | 125 | ' . sprintf('<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', $item->ID()) |
126 | - : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID()); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @param EE_Question $item |
|
132 | - * @return string |
|
133 | - * @throws EE_Error |
|
134 | - * @throws ReflectionException |
|
135 | - */ |
|
136 | - public function column_id(EE_Question $item): string |
|
137 | - { |
|
138 | - $content = ' |
|
126 | + : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID()); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @param EE_Question $item |
|
132 | + * @return string |
|
133 | + * @throws EE_Error |
|
134 | + * @throws ReflectionException |
|
135 | + */ |
|
136 | + public function column_id(EE_Question $item): string |
|
137 | + { |
|
138 | + $content = ' |
|
139 | 139 | <span class="ee-entity-id">' . $item->ID() . '</span> |
140 | 140 | <span class="show-on-mobile-view-only"> |
141 | 141 | ' . $this->column_display_text($item, false) . ' |
142 | 142 | </span>'; |
143 | - return $this->columnContent('id', $content, 'end'); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @param EE_Question $question |
|
149 | - * @param bool $prep_content |
|
150 | - * @return string |
|
151 | - * @throws EE_Error |
|
152 | - * @throws ReflectionException |
|
153 | - */ |
|
154 | - public function column_display_text(EE_Question $question, bool $prep_content = true): string |
|
155 | - { |
|
156 | - if ($this->caps_handler->userCanEditQuestion($question)) { |
|
157 | - $content = $this->$this->getActionLink( |
|
158 | - $this->getActionUrl($question, self::ACTION_EDIT), |
|
159 | - $prep_content ? $question->display_text() : $question->admin_label(), |
|
160 | - esc_attr__('Edit Question', 'event_espresso'), |
|
161 | - 'row-title' |
|
162 | - ); |
|
163 | - $content .= $this->row_actions( |
|
164 | - [ |
|
165 | - 'edit' => $this->getActionLink( |
|
166 | - $this->getActionUrl($question, self::ACTION_EDIT), |
|
167 | - esc_html__('Edit', 'event_espresso'), |
|
168 | - esc_attr__('Edit Question', 'event_espresso') |
|
169 | - ), |
|
170 | - ] |
|
171 | - ); |
|
172 | - } else { |
|
173 | - $content = $question->display_text(); |
|
174 | - } |
|
175 | - |
|
176 | - return $prep_content ? $this->columnContent('display_text', $content) : $content; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * @param EE_Question $question |
|
182 | - * @param string $action |
|
183 | - * @return string |
|
184 | - * @throws EE_Error |
|
185 | - * @throws ReflectionException |
|
186 | - * @since $VID:$ |
|
187 | - */ |
|
188 | - protected function getActionUrl(EE_Question $question, string $action): string |
|
189 | - { |
|
190 | - if (! in_array($action, self::$actions)) { |
|
191 | - throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
192 | - } |
|
193 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
194 | - [ |
|
195 | - 'action' => $action === self::ACTION_DELETE ? "{$action}_questions" : "{$action}_question", |
|
196 | - 'QST_ID' => $question->ID(), |
|
197 | - 'noheader' => $action !== self::ACTION_EDIT, |
|
198 | - ], |
|
199 | - EE_FORMS_ADMIN_URL |
|
200 | - ); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - public function column_admin_label(EE_Question $item): string |
|
205 | - { |
|
206 | - return $this->columnContent('admin_label', $item->admin_label()); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - public function column_values(EE_Question $item): string |
|
211 | - { |
|
212 | - $optionNames = []; |
|
213 | - $options = $item->options(); |
|
214 | - if (empty($options)) { |
|
215 | - $content = "N/A"; |
|
216 | - } else { |
|
217 | - foreach ($options as $option) { |
|
218 | - $optionNames[] = $option->value(); |
|
219 | - } |
|
220 | - $content = implode(', ', $optionNames); |
|
221 | - } |
|
222 | - return $this->columnContent('values', $content); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - public function column_type(EE_Question $item): string |
|
227 | - { |
|
228 | - return $this->columnContent('type', $item->type()); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - public function column_required(EE_Question $item): string |
|
233 | - { |
|
234 | - $content = $item->required() ? 'Yes' : ''; |
|
235 | - return $this->columnContent('required', $content); |
|
236 | - } |
|
143 | + return $this->columnContent('id', $content, 'end'); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @param EE_Question $question |
|
149 | + * @param bool $prep_content |
|
150 | + * @return string |
|
151 | + * @throws EE_Error |
|
152 | + * @throws ReflectionException |
|
153 | + */ |
|
154 | + public function column_display_text(EE_Question $question, bool $prep_content = true): string |
|
155 | + { |
|
156 | + if ($this->caps_handler->userCanEditQuestion($question)) { |
|
157 | + $content = $this->$this->getActionLink( |
|
158 | + $this->getActionUrl($question, self::ACTION_EDIT), |
|
159 | + $prep_content ? $question->display_text() : $question->admin_label(), |
|
160 | + esc_attr__('Edit Question', 'event_espresso'), |
|
161 | + 'row-title' |
|
162 | + ); |
|
163 | + $content .= $this->row_actions( |
|
164 | + [ |
|
165 | + 'edit' => $this->getActionLink( |
|
166 | + $this->getActionUrl($question, self::ACTION_EDIT), |
|
167 | + esc_html__('Edit', 'event_espresso'), |
|
168 | + esc_attr__('Edit Question', 'event_espresso') |
|
169 | + ), |
|
170 | + ] |
|
171 | + ); |
|
172 | + } else { |
|
173 | + $content = $question->display_text(); |
|
174 | + } |
|
175 | + |
|
176 | + return $prep_content ? $this->columnContent('display_text', $content) : $content; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * @param EE_Question $question |
|
182 | + * @param string $action |
|
183 | + * @return string |
|
184 | + * @throws EE_Error |
|
185 | + * @throws ReflectionException |
|
186 | + * @since $VID:$ |
|
187 | + */ |
|
188 | + protected function getActionUrl(EE_Question $question, string $action): string |
|
189 | + { |
|
190 | + if (! in_array($action, self::$actions)) { |
|
191 | + throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
|
192 | + } |
|
193 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
194 | + [ |
|
195 | + 'action' => $action === self::ACTION_DELETE ? "{$action}_questions" : "{$action}_question", |
|
196 | + 'QST_ID' => $question->ID(), |
|
197 | + 'noheader' => $action !== self::ACTION_EDIT, |
|
198 | + ], |
|
199 | + EE_FORMS_ADMIN_URL |
|
200 | + ); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + public function column_admin_label(EE_Question $item): string |
|
205 | + { |
|
206 | + return $this->columnContent('admin_label', $item->admin_label()); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + public function column_values(EE_Question $item): string |
|
211 | + { |
|
212 | + $optionNames = []; |
|
213 | + $options = $item->options(); |
|
214 | + if (empty($options)) { |
|
215 | + $content = "N/A"; |
|
216 | + } else { |
|
217 | + foreach ($options as $option) { |
|
218 | + $optionNames[] = $option->value(); |
|
219 | + } |
|
220 | + $content = implode(', ', $optionNames); |
|
221 | + } |
|
222 | + return $this->columnContent('values', $content); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + public function column_type(EE_Question $item): string |
|
227 | + { |
|
228 | + return $this->columnContent('type', $item->type()); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + public function column_required(EE_Question $item): string |
|
233 | + { |
|
234 | + $content = $item->required() ? 'Yes' : ''; |
|
235 | + return $this->columnContent('required', $content); |
|
236 | + } |
|
237 | 237 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $this->caps_handler = new RegFormListTableUserCapabilities(EE_Registry::instance()->CAP); |
32 | 32 | parent::__construct($admin_page); |
33 | 33 | |
34 | - if (! defined('REG_ADMIN_URL')) { |
|
34 | + if ( ! defined('REG_ADMIN_URL')) { |
|
35 | 35 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
36 | 36 | } |
37 | 37 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return $system_question || $has_answers |
122 | 122 | ? ' |
123 | 123 | <span class="dashicons dashicons-lock ee-locked-entity ee-aria-tooltip" |
124 | - aria-label="' . $notice . '"></span> |
|
124 | + aria-label="' . $notice.'"></span> |
|
125 | 125 | ' . sprintf('<input type="hidden" name="hdnchk[%1$d]" value="%1$d" />', $item->ID()) |
126 | 126 | : sprintf('<input type="checkbox" class="QST_ID" name="checkbox[%1$d]" value="%1$d" />', $item->ID()); |
127 | 127 | } |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | public function column_id(EE_Question $item): string |
137 | 137 | { |
138 | 138 | $content = ' |
139 | - <span class="ee-entity-id">' . $item->ID() . '</span> |
|
139 | + <span class="ee-entity-id">' . $item->ID().'</span> |
|
140 | 140 | <span class="show-on-mobile-view-only"> |
141 | - ' . $this->column_display_text($item, false) . ' |
|
141 | + ' . $this->column_display_text($item, false).' |
|
142 | 142 | </span>'; |
143 | 143 | return $this->columnContent('id', $content, 'end'); |
144 | 144 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | protected function getActionUrl(EE_Question $question, string $action): string |
189 | 189 | { |
190 | - if (! in_array($action, self::$actions)) { |
|
190 | + if ( ! in_array($action, self::$actions)) { |
|
191 | 191 | throw new DomainException(esc_html__('Invalid Action', 'event_espresso')); |
192 | 192 | } |
193 | 193 | return EE_Admin_Page::add_query_args_and_nonce( |
@@ -33,11 +33,11 @@ |
||
33 | 33 | <td class="jst-rght"><?php echo wp_kses($attendee['ticket_price'], AllowedTags::getAllowedTags()); ?></td> |
34 | 34 | <td class="jst-left"> |
35 | 35 | <?php |
36 | - $att_link = EE_Admin_Page::add_query_args_and_nonce( |
|
37 | - ['action' => 'view_registration', '_REG_ID' => $registration], |
|
38 | - REG_ADMIN_URL |
|
39 | - ); |
|
40 | - ?> |
|
36 | + $att_link = EE_Admin_Page::add_query_args_and_nonce( |
|
37 | + ['action' => 'view_registration', '_REG_ID' => $registration], |
|
38 | + REG_ADMIN_URL |
|
39 | + ); |
|
40 | + ?> |
|
41 | 41 | <a href="<?php echo esc_url_raw($att_link); ?>" |
42 | 42 | aria-label="<?php esc_attr_e('View details for this registrant', 'event_espresso'); ?>" |
43 | 43 | > |